86 lines
2.6 KiB
C#
86 lines
2.6 KiB
C#
using Cysharp.Threading.Tasks;
|
|
using SepCore.CustomUtility;
|
|
using SepCore.Definition;
|
|
using SepCore.Entity;
|
|
using UnityEngine;
|
|
using UnityGameFramework.Runtime;
|
|
|
|
namespace SepCore.UI
|
|
{
|
|
public class GoodsItemContext : UIContext
|
|
{
|
|
public string Name;
|
|
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;
|
|
Icon = null;
|
|
ItemType = ItemType.Weapon;
|
|
}
|
|
|
|
public GoodsItemContext(GoodsItemRawData rawData) : this()
|
|
{
|
|
Price = rawData.Price;
|
|
Rarity = rawData.Rarity;
|
|
ItemType = rawData.ItemType;
|
|
|
|
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
|
|
{
|
|
Log.Error("Unsupported goods item type '{0}'.", ItemType);
|
|
}
|
|
}
|
|
}
|
|
}
|