- S4-03 | 先固化 Tag 系统设计与首发范围
- S4-04 | 实现组件实例 Tag 的统一生成入口 - S4-05 | 实现组塔后的 Tag 汇总与展示入口
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using GameFramework.Event;
|
||||
using GeometryTD.CustomUtility;
|
||||
using GeometryTD.Definition;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
@@ -35,18 +35,33 @@ namespace GeometryTD.UI
|
||||
Description = rawData.Description,
|
||||
Price = rawData.Price,
|
||||
TargetPos = rawData.TargetPos,
|
||||
Tags = BuildTags(rawData.Tags)
|
||||
Tags = BuildTags(rawData)
|
||||
};
|
||||
}
|
||||
|
||||
private static List<TagType> BuildTags(TagType[] tags)
|
||||
private static TagItemContext[] BuildTags(ItemDescFormRawData rawData)
|
||||
{
|
||||
if (tags == null || tags.Length <= 0)
|
||||
string[] tagTexts = rawData?.TagTexts;
|
||||
if ((tagTexts == null || tagTexts.Length <= 0) && rawData?.Tags != null)
|
||||
{
|
||||
return new List<TagType>();
|
||||
tagTexts = TagDisplayUtility.BuildTagTexts(rawData.Tags);
|
||||
}
|
||||
|
||||
return new List<TagType>(tags);
|
||||
if (tagTexts == null || tagTexts.Length <= 0)
|
||||
{
|
||||
return System.Array.Empty<TagItemContext>();
|
||||
}
|
||||
|
||||
TagItemContext[] contexts = new TagItemContext[tagTexts.Length];
|
||||
for (int i = 0; i < tagTexts.Length; i++)
|
||||
{
|
||||
contexts[i] = new TagItemContext
|
||||
{
|
||||
TagName = tagTexts[i] ?? string.Empty
|
||||
};
|
||||
}
|
||||
|
||||
return contexts;
|
||||
}
|
||||
|
||||
public int? OpenUI(ItemDescFormRawData rawData)
|
||||
|
||||
@@ -179,44 +179,24 @@ namespace GeometryTD.UI
|
||||
|
||||
private static TagItemContext[] BuildTagContexts(TagType[] tags)
|
||||
{
|
||||
if (tags == null || tags.Length <= 0)
|
||||
string[] tagTexts = TagDisplayUtility.BuildTagTexts(tags);
|
||||
if (tagTexts == null || tagTexts.Length <= 0)
|
||||
{
|
||||
return System.Array.Empty<TagItemContext>();
|
||||
}
|
||||
|
||||
TagItemContext[] contexts = new TagItemContext[tags.Length];
|
||||
for (int i = 0; i < tags.Length; i++)
|
||||
TagItemContext[] contexts = new TagItemContext[tagTexts.Length];
|
||||
for (int i = 0; i < tagTexts.Length; i++)
|
||||
{
|
||||
TagType tagType = tags[i];
|
||||
contexts[i] = new TagItemContext
|
||||
{
|
||||
TagName = ResolveTagName(tagType)
|
||||
TagName = tagTexts[i]
|
||||
};
|
||||
}
|
||||
|
||||
return contexts;
|
||||
}
|
||||
|
||||
private static string ResolveTagName(TagType tagType)
|
||||
{
|
||||
if (tagType == TagType.None)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var tagTable = GameEntry.DataTable.GetDataTable<DRTag>();
|
||||
if (tagTable != null)
|
||||
{
|
||||
DRTag tagRow = tagTable.GetDataRow((int)tagType);
|
||||
if (tagRow != null && !string.IsNullOrWhiteSpace(tagRow.Name))
|
||||
{
|
||||
return tagRow.Name;
|
||||
}
|
||||
}
|
||||
|
||||
return tagType.ToString();
|
||||
}
|
||||
|
||||
private void OnRewardSelected(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!IsEventFromCurrentForm(sender) || !(e is RewardSelectItemSelectedEventArgs args))
|
||||
|
||||
Reference in New Issue
Block a user