Files
vampire-like/Assets/GameMain/Scripts/Presentation/Shop/GoodsItemContext.cs
T
2026-10-03 18:30:31 +08:00

77 lines
2.3 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)
{
if (rawData.DataRow is WeaponConfig weaponConfig)
{
Name = weaponConfig.WeaponName;
Description = ItemDescUtility.CreateWeaponDescription(weaponConfig);
TypeName = ItemDescUtility.FormatWeaponTags(weaponConfig);
}
else if (rawData.DataRow is WeaponData weaponData)
{
Name = weaponData.Title;
Description = ItemDescUtility.CreateWeaponDescription(weaponData);
TypeName = ItemDescUtility.FormatWeaponTags(weaponData);
}
else
{
Log.Error("Weapon data row is invalid.");
return;
}
}
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);
}
}
}
}