62 lines
1.9 KiB
C#
62 lines
1.9 KiB
C#
using Cysharp.Threading.Tasks;
|
|
using SepCore.CustomUtility;
|
|
using SepCore.DataTable;
|
|
using SepCore.Definition;
|
|
using UnityEngine;
|
|
|
|
namespace SepCore.UI
|
|
{
|
|
public class GoodsItemContext : UIContext
|
|
{
|
|
public string Title;
|
|
public ItemRarity Rarity;
|
|
public Sprite Icon;
|
|
public ItemType ItemType;
|
|
public string Description;
|
|
public int Price;
|
|
|
|
public GoodsItemContext()
|
|
{
|
|
Title = string.Empty;
|
|
Description = string.Empty;
|
|
Rarity = ItemRarity.White;
|
|
Price = 0;
|
|
Icon = null;
|
|
ItemType = ItemType.None;
|
|
}
|
|
|
|
public static async UniTask<GoodsItemContext> CreateAsync(GoodsItemRawData rawData)
|
|
{
|
|
var context = new GoodsItemContext
|
|
{
|
|
Price = rawData.Price,
|
|
Rarity = rawData.Rarity,
|
|
ItemType = rawData.ItemType
|
|
};
|
|
|
|
if (context.ItemType == ItemType.None)
|
|
{
|
|
context.Description = string.Empty;
|
|
context.Icon = null;
|
|
context.Title = string.Empty;
|
|
}
|
|
else if (context.ItemType == ItemType.Weapon)
|
|
{
|
|
var weapon = (DRWeapon)rawData.DataRow;
|
|
context.Title = weapon.Title;
|
|
context.Description = ItemDescUtility.CreateWeaponDescription(weapon);
|
|
context.Icon = await GameEntry.SpriteCache.GetSprite(weapon.IconAssetName);
|
|
}
|
|
else
|
|
{
|
|
var prop = (DRProp)rawData.DataRow;
|
|
context.Title = prop.Title;
|
|
context.Description = ItemDescUtility.CreatePropDescription(prop.Modifiers);
|
|
context.Icon = await GameEntry.SpriteCache.GetSprite(prop.IconAssetName);
|
|
}
|
|
|
|
return context;
|
|
}
|
|
}
|
|
}
|