174 lines
6.8 KiB
C#
174 lines
6.8 KiB
C#
using System.Collections.Generic;
|
||
using Logic.Action;
|
||
using Logic.Multilingual;
|
||
using Logic.Skill;
|
||
using NUnit.Framework;
|
||
using RuntimeData;
|
||
using TH1_Logic.Action;
|
||
using TH1_Logic.Core;
|
||
using Unity.Burst.CompilerServices;
|
||
using UnityEngine;
|
||
|
||
// using Logic.Tech; // 假设TechType在这里
|
||
// using Logic.Skill; // 假设SkillType在这里
|
||
// using Logic.City; // 假设CityUpgradeId在这里
|
||
|
||
// 建议将所有与HintUI相关的逻辑类都放在这个命名空间下
|
||
namespace UI.HintUI
|
||
{
|
||
/// <summary>
|
||
/// 定义提示所依赖的数据类型
|
||
/// </summary>
|
||
public enum HintDataType
|
||
{
|
||
SkillHintData,
|
||
ActionHintData,
|
||
TechHintData,
|
||
CityUpgradeHintData,
|
||
UnitHintData,
|
||
// 直接显示静态文本
|
||
TextData,
|
||
TextDataGiantUpgrate,
|
||
TechAtomHintData,
|
||
GeoData,
|
||
}
|
||
|
||
/// <summary>
|
||
/// 一个统一的提示数据提供者。
|
||
/// 它包含所有可能用到的数据字段,通过HintDataType枚举来决定使用哪个。
|
||
/// </summary>
|
||
[System.Serializable] // 必须标记为Serializable,这样才能在Inspector中显示
|
||
public class HintDataProvider
|
||
{
|
||
// --- 核心控制字段 ---
|
||
public HintDataType HintDataType;
|
||
|
||
// --- 所有可能的数据字段 ---
|
||
|
||
// 用于 TextData
|
||
[Tooltip("当类型为TextData时,直接显示此文本")]
|
||
public string Text = "默认静态文本...";
|
||
|
||
// 用于 TechHintData
|
||
[Tooltip("当类型为TechHintData时,使用此数据")]
|
||
public TechType TechTypeData;
|
||
|
||
// 用于 SkillHintData
|
||
[Tooltip("当类型为SkillHintData时,使用此数据")]
|
||
public SkillType SkillTypeData;
|
||
public SkillBase SkillParam;
|
||
|
||
// 用于 ActionHintData
|
||
[Tooltip("当类型为ActionHintData时,使用此数据")]
|
||
public CommonActionId ActionIdData;
|
||
public bool locked = false;
|
||
|
||
// 用于 TextData
|
||
[Tooltip("当类型为ActionHintData时,使用此数据")]
|
||
public CommonActionId TextData;
|
||
|
||
[Tooltip("当类型为TechAtomData时,使用此数据")]
|
||
public TechAtom TechAtom;
|
||
|
||
[Tooltip("当类型为GeoData时,使用此数据")]
|
||
public List<uint> GeoIdList;
|
||
|
||
[Tooltip("unitData")]
|
||
public UnitFullType UnitFullType;
|
||
//public UnitType UnitType;
|
||
//public GiantType GiantType;
|
||
//public uint UnitLevel;
|
||
|
||
// 用于 CityUpgradeHintData (注意:我根据推断为您增加了这个字段)
|
||
//[Tooltip("当类型为CityUpgradeHintData时,使用此数据")]
|
||
//public CityUpgradeId CityUpgradeIdData; // 假设存在一个CityUpgradeId类型
|
||
|
||
/// <summary>
|
||
/// 根据HintDataType动态获取最终应显示的提示文本
|
||
/// </summary>
|
||
/// <returns>提示字符串</returns>
|
||
public string GetHintText()
|
||
{
|
||
|
||
string ret = Text;
|
||
string ret2 = "";
|
||
bool IsDecode = false;
|
||
switch (this.HintDataType)
|
||
{
|
||
case HintDataType.SkillHintData:
|
||
// 假设GetSkillDesc存在并且接收SkillTypeData
|
||
Table.Instance.SkillDataAssets.GetSkillNameAndDesc_DECODE(this.SkillTypeData,UnitFullType,SkillParam,out ret2,out ret);
|
||
ret = "<color=orange>" + ret2 +"</color> : " + ret;
|
||
IsDecode = true;
|
||
break;
|
||
case HintDataType.ActionHintData:
|
||
// 仿写:从Action数据表中获取描述
|
||
Table.Instance.ActionDataAssets.GetActionDesc(this.ActionIdData,locked,out ret);
|
||
break;
|
||
case HintDataType.TechHintData:
|
||
// 仿写:从Tech数据表中获取描述
|
||
Table.Instance.TechDataAssets.GetTechDesc(this.TechTypeData,out ret);
|
||
break;
|
||
case HintDataType.CityUpgradeHintData:
|
||
// 仿写:从CityUpgrade数据表中获取描述
|
||
//return Table.Instance.CityUpgradeDataAssets.GetUpgradeDesc(this.CityUpgradeIdData);
|
||
break;
|
||
case HintDataType.UnitHintData:
|
||
Table.Instance.UnitTypeDataAssets.GetUnitDesc(UnitFullType,out ret);
|
||
break;
|
||
case HintDataType.TextDataGiantUpgrate:
|
||
Table.Instance.TextDataAssets.GetGiantUpgradeText_DECODE(UnitFullType.GiantType,out ret);
|
||
ret.Replace("\\n","\n");
|
||
IsDecode = true;
|
||
break;
|
||
case HintDataType.TechAtomHintData:
|
||
IsDecode = true;
|
||
ret = "";
|
||
if (Table.Instance.TechDataAssets.GetTechAtomInfo(this.TechAtom, out var info))
|
||
ret = "<color=orange>" + MultilingualManager.Instance.GetMultilingualTextSafe(info.TechAtomName) +
|
||
"</color><br>" +
|
||
MultilingualManager.Instance.GetMultilingualTextSafe(info.Desc);
|
||
break;
|
||
case HintDataType.TextData:
|
||
if (TextData.PlayerActionType == PlayerActionType.FinishHeroTask)
|
||
{
|
||
ret = Table.Instance.TextDataAssets.HeroForceFinishHint;
|
||
}else
|
||
{
|
||
ret = Text;
|
||
IsDecode = true;
|
||
}
|
||
break;
|
||
case HintDataType.GeoData:
|
||
ret = "";
|
||
foreach (var GeoId in GeoIdList)
|
||
{
|
||
|
||
if (Table.Instance.GeoDataAssets.GetGeoInfo(GeoId, out var v))
|
||
ret += "<color=orange>" + TmpGetBigClassType(v.GeoSmallClass) +" : " + MultilingualManager.Instance.GetMultilingualTextSafe(v.GeoName) + "</color><br>"
|
||
+ "<color=grey>历史资料:</color>"+MultilingualManager.Instance.GetMultilingualTextSafe(v.GeoDesc) + "<br>";
|
||
}
|
||
|
||
IsDecode = true;
|
||
break;
|
||
default:
|
||
// 处理未知的或默认的枚举值,方便调试
|
||
UnityEngine.Debug.LogWarning($"未处理的HintDataType: {this.HintDataType}");
|
||
break;
|
||
}
|
||
|
||
//如果已经是decode的多语言,直接返回
|
||
if (IsDecode || ret == "") return ret;
|
||
//否则要进行多语言解码
|
||
return MultilingualManager.Instance.GetMultilingualTextSafe(ret);
|
||
}
|
||
public string TmpGetBigClassType(GeoSmallClass smallClass)
|
||
{
|
||
return Table.Instance.GeoDataAssets.GetSmallClassName(smallClass);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
}
|