补充参战防御塔进入战斗逻辑
- 将 Inventory 中参战的防御塔数据传递到 CombatSelectForm 中 - 为防御塔的图标展示添加 TowerRepoItem 与 TowerIconArea 适配防御塔的三层 Image
This commit is contained in:
@@ -116,9 +116,8 @@ namespace GeometryTD.UI
|
||||
|
||||
if (inventory.Towers != null)
|
||||
{
|
||||
for (int i = 0; i < inventory.Towers.Count; i++)
|
||||
foreach (TowerItemData tower in inventory.Towers)
|
||||
{
|
||||
var tower = inventory.Towers[i];
|
||||
if (tower == null)
|
||||
{
|
||||
continue;
|
||||
@@ -131,7 +130,7 @@ namespace GeometryTD.UI
|
||||
EnduranceRate01 = ItemDescUtility.ResolveTowerEnduranceRate(tower, muzzleMap, bearingMap, baseMap),
|
||||
ClickActionType = RepoItemClickActionType.OpenDetail,
|
||||
ComponentSlotType = TowerCompSlotType.None,
|
||||
IconAreaContext = BuildIconAreaContext(tower)
|
||||
IconAreaContext = BuildTowerIconContext(tower, muzzleMap, bearingMap, baseMap)
|
||||
});
|
||||
|
||||
AddItemDescSeed(
|
||||
@@ -145,9 +144,8 @@ namespace GeometryTD.UI
|
||||
|
||||
if (inventory.MuzzleComponents != null)
|
||||
{
|
||||
for (int i = 0; i < inventory.MuzzleComponents.Count; i++)
|
||||
foreach (MuzzleCompItemData item in inventory.MuzzleComponents)
|
||||
{
|
||||
var item = inventory.MuzzleComponents[i];
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
@@ -174,7 +172,7 @@ namespace GeometryTD.UI
|
||||
|
||||
if (inventory.BearingComponents != null)
|
||||
{
|
||||
foreach (var item in inventory.BearingComponents)
|
||||
foreach (BearingCompItemData item in inventory.BearingComponents)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
@@ -202,9 +200,8 @@ namespace GeometryTD.UI
|
||||
|
||||
if (inventory.BaseComponents != null)
|
||||
{
|
||||
for (int i = 0; i < inventory.BaseComponents.Count; i++)
|
||||
foreach (BaseCompItemData item in inventory.BaseComponents)
|
||||
{
|
||||
var item = inventory.BaseComponents[i];
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
@@ -232,6 +229,38 @@ namespace GeometryTD.UI
|
||||
return itemContexts.ToArray();
|
||||
}
|
||||
|
||||
private static TowerIconAreaContext BuildTowerIconContext(
|
||||
TowerItemData tower,
|
||||
IReadOnlyDictionary<long, MuzzleCompItemData> muzzleMap,
|
||||
IReadOnlyDictionary<long, BearingCompItemData> bearingMap,
|
||||
IReadOnlyDictionary<long, BaseCompItemData> baseMap)
|
||||
{
|
||||
if (tower == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new TowerIconAreaContext
|
||||
{
|
||||
Rarity = tower.Rarity,
|
||||
MuzzleColor = ResolveComponentColor(tower.MuzzleComponentInstanceId, muzzleMap),
|
||||
BearingColor = ResolveComponentColor(tower.BearingComponentInstanceId, bearingMap),
|
||||
BaseColor = ResolveComponentColor(tower.BaseComponentInstanceId, baseMap)
|
||||
};
|
||||
}
|
||||
|
||||
private static Color ResolveComponentColor<TComp>(long instanceId, IReadOnlyDictionary<long, TComp> componentMap)
|
||||
where TComp : TowerCompItemData
|
||||
{
|
||||
if (instanceId > 0 && componentMap != null && componentMap.TryGetValue(instanceId, out TComp comp) &&
|
||||
comp != null)
|
||||
{
|
||||
return IconColorGenerator.GenerateForComponent(comp);
|
||||
}
|
||||
|
||||
return Color.white;
|
||||
}
|
||||
|
||||
private void AddItemDescSeed(long itemId, string title, string typeText, string description, TagType[] tags)
|
||||
{
|
||||
if (itemId <= 0)
|
||||
@@ -274,9 +303,8 @@ namespace GeometryTD.UI
|
||||
return map;
|
||||
}
|
||||
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
foreach (TComp item in items)
|
||||
{
|
||||
TComp item = items[i];
|
||||
if (item == null || item.InstanceId <= 0)
|
||||
{
|
||||
continue;
|
||||
@@ -288,35 +316,13 @@ namespace GeometryTD.UI
|
||||
return map;
|
||||
}
|
||||
|
||||
private static IconAreaContext BuildIconAreaContext(TowerItemData tower)
|
||||
{
|
||||
if (tower == null)
|
||||
{
|
||||
return new IconAreaContext
|
||||
{
|
||||
ComponentSlotType = TowerCompSlotType.None,
|
||||
Rarity = RarityType.None,
|
||||
Color = Color.white,
|
||||
Icon = null
|
||||
};
|
||||
}
|
||||
|
||||
return new IconAreaContext
|
||||
{
|
||||
ComponentSlotType = TowerCompSlotType.None,
|
||||
Rarity = tower.Rarity,
|
||||
Color = IconColorGenerator.GenerateForTower(tower),
|
||||
Icon = null
|
||||
};
|
||||
}
|
||||
|
||||
private static IconAreaContext BuildIconAreaContext(TowerCompItemData item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return new IconAreaContext
|
||||
{
|
||||
ComponentSlotType = TowerCompSlotType.None,
|
||||
ComponentSlotType = TowerCompSlotType.None,
|
||||
Rarity = RarityType.None,
|
||||
Color = Color.white,
|
||||
Icon = null
|
||||
@@ -332,6 +338,8 @@ namespace GeometryTD.UI
|
||||
};
|
||||
}
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
private void OnCombatFinishReturnButtonClicked(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!IsEventFromCurrentForm(sender) || !(e is CombatFinishReturnEventArgs))
|
||||
@@ -370,6 +378,8 @@ namespace GeometryTD.UI
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private bool IsEventFromCurrentForm(object sender)
|
||||
{
|
||||
if (Form == null)
|
||||
@@ -392,3 +402,7 @@ namespace GeometryTD.UI
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -229,7 +229,13 @@ namespace GeometryTD.UI
|
||||
IsVisible = rawData.IsVisible,
|
||||
IsInteractable = rawData.IsInteractable,
|
||||
ActionType = rawData.ActionType,
|
||||
ActionIndex = rawData.ActionIndex
|
||||
ActionIndex = rawData.ActionIndex,
|
||||
TowerIconAreaContext = new TowerIconAreaContext()
|
||||
{
|
||||
BaseColor = rawData.BaseColor,
|
||||
BearingColor = rawData.BearingColor,
|
||||
MuzzleColor = rawData.MuzzleColor
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -284,4 +290,4 @@ namespace GeometryTD.UI
|
||||
RefreshFromUseCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user