优化武器商品描述文本、修复敌人子弹无法击中玩家的bug

This commit is contained in:
2026-09-26 22:55:52 +08:00
parent 051c075183
commit 91b8e177c5
5 changed files with 75 additions and 79 deletions
@@ -3,6 +3,7 @@ using SepCore.CustomUtility;
using SepCore.Definition;
using SepCore.Entity;
using UnityEngine;
using UnityGameFramework.Runtime;
namespace SepCore.UI
{
@@ -12,12 +13,14 @@ namespace SepCore.UI
public Rarity Rarity;
public Sprite Icon;
public ItemType ItemType;
public string TypeName;
public string Description;
public int Price;
public GoodsItemContext()
{
Name = string.Empty;
TypeName = string.Empty;
Description = string.Empty;
Rarity = Rarity.White;
Price = 0;
@@ -33,22 +36,49 @@ namespace SepCore.UI
if (ItemType == ItemType.Weapon)
{
DamageType damageType;
if (rawData.DataRow is WeaponConfig weaponConfig)
{
Name = weaponConfig.WeaponType.ToString();
Description = ItemDescUtility.CreateWeaponDescription(weaponConfig);
damageType = weaponConfig.DamageType;
}
else if (rawData.DataRow is WeaponData weaponData)
{
Name = weaponData.Title;
Description = ItemDescUtility.CreateWeaponDescription(weaponData);
damageType = weaponData.DamageType;
}
else
{
Log.Error("Weapon data row is invalid.");
return;
}
TypeName = damageType switch
{
DamageType.Melee => "近战武器",
DamageType.Ranged => "远程武器",
DamageType.Element => "元素武器",
_ => "武器"
};
}
else if (ItemType == ItemType.Prop)
{
if (rawData.DataRow is PropConfig prop)
{
Name = prop.Name;
Description = ItemDescUtility.CreatePropDescription(prop.StatModifierConfigs);
TypeName = "道具";
}
else
{
Log.Error("Prop data row is invalid.");
}
}
else
{
var prop = (PropConfig)rawData.DataRow;
Name = prop.Name;
Description = ItemDescUtility.CreatePropDescription(prop.StatModifierConfigs);
Log.Error("Unsupported goods item type '{0}'.", ItemType);
}
}
}
@@ -29,13 +29,7 @@ namespace SepCore.UI
_iconArea.OnInit(data.Icon, data.Rarity);
_titleText.text = data.Name;
_typeText.text = data.ItemType switch
{
ItemType.None => "error",
ItemType.Weapon => "武器",
ItemType.Prop => "道具",
_ => throw new ArgumentOutOfRangeException()
};
_typeText.text = data.TypeName;
_descriptionText.text = data.Description;
_costText.text = $"{data.Price} <sprite name=\"coin\" index=0>";
}