添加 SepCore.Runtime 和 SepCore.Base 程序集
- 暂时将 Entity 全部归进 Runtime 程序集里 - 调整部分 UI 的 UseCase/RawData/Context 之间的关系,让 RawData 更接近业务原始数据,Context 更接近 UI 直接可读的数据 - 调整其他程序集的引用关系
This commit is contained in:
+46
-2
@@ -1,3 +1,8 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using CustomUtility;
|
||||
using Entity.EntityData;
|
||||
using Entity.Weapon;
|
||||
using SepCore.Definition;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -8,11 +13,50 @@ namespace SepCore.UI
|
||||
public int Index;
|
||||
public string IconAssetName;
|
||||
public string Title;
|
||||
public string TypeText;
|
||||
public ItemType ItemType;
|
||||
public ItemRarity Rarity;
|
||||
public string Description;
|
||||
public int Price;
|
||||
public bool IsWeapon;
|
||||
public Vector3 TargetPos;
|
||||
|
||||
public DisplayItemInfoContext()
|
||||
{
|
||||
Index = -1;
|
||||
IconAssetName = string.Empty;
|
||||
Title = string.Empty;
|
||||
ItemType = ItemType.None;
|
||||
Rarity = ItemRarity.White;
|
||||
Description = string.Empty;
|
||||
Price = 0;
|
||||
TargetPos = Vector3.zero;
|
||||
}
|
||||
|
||||
public DisplayItemInfoContext(DisplayItemInfoRawData rawData)
|
||||
{
|
||||
Index = rawData.Index;
|
||||
ItemType = rawData.ItemType;
|
||||
Rarity = rawData.Rarity;
|
||||
Price = rawData.Price;
|
||||
TargetPos = rawData.TargetPos;
|
||||
if (ItemType == ItemType.None)
|
||||
{
|
||||
IconAssetName = string.Empty;
|
||||
Title = string.Empty;
|
||||
}
|
||||
else if (ItemType == ItemType.Weapon)
|
||||
{
|
||||
var data = (WeaponData)rawData.Data;
|
||||
IconAssetName = data.IconAssetName;
|
||||
Title = data.Title;
|
||||
Description = ItemDescUtility.CreateWeaponDescription(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
var data = (PropItem)rawData.Data;
|
||||
IconAssetName = data.IconAssetName;
|
||||
Title = data.Title;
|
||||
Description = ItemDescUtility.CreatePropDescription(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-12
@@ -43,18 +43,7 @@ namespace SepCore.UI
|
||||
return null;
|
||||
}
|
||||
|
||||
return new DisplayItemInfoContext
|
||||
{
|
||||
Index = rawData.Index,
|
||||
IconAssetName = rawData.IconAssetName,
|
||||
Title = rawData.Title,
|
||||
Rarity = rawData.Rarity,
|
||||
TypeText = rawData.TypeText,
|
||||
Description = rawData.Description,
|
||||
Price = rawData.Price,
|
||||
IsWeapon = rawData.IsWeapon,
|
||||
TargetPos = rawData.TargetPos
|
||||
};
|
||||
return new DisplayItemInfoContext(rawData);
|
||||
}
|
||||
|
||||
public override async UniTask<int?> OpenUIAsync(object userData = null, float timeout = 30f)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using SepCore.Event;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
@@ -32,6 +33,7 @@ namespace SepCore.UI
|
||||
[SerializeField] private float _screenEdgePadding = 0f;
|
||||
|
||||
private DisplayItemInfoContext _context;
|
||||
|
||||
private Vector3 _targetPos;
|
||||
|
||||
public void RefreshUI(DisplayItemInfoContext context)
|
||||
@@ -53,13 +55,13 @@ namespace SepCore.UI
|
||||
}
|
||||
|
||||
if (_itemTitle != null) _itemTitle.text = _context.Title ?? string.Empty;
|
||||
if (_itemTypeText != null) _itemTypeText.text = _context.TypeText ?? string.Empty;
|
||||
if (_itemTypeText != null) _itemTypeText.text = BuildTypeText(_context.ItemType) ?? string.Empty;
|
||||
if (_itemDescription != null) _itemDescription.text = _context.Description ?? string.Empty;
|
||||
if (_itemPrice != null) _itemPrice.text = $"{_context.Price} <sprite name=\"coin\" index=0>";
|
||||
|
||||
if (_recycleButton != null)
|
||||
{
|
||||
_recycleButton.gameObject.SetActive(_context.IsWeapon);
|
||||
_recycleButton.gameObject.SetActive(_context.ItemType == ItemType.Weapon);
|
||||
}
|
||||
|
||||
if (_iconArea != null)
|
||||
@@ -193,7 +195,7 @@ namespace SepCore.UI
|
||||
|
||||
public void OnRecycleButtonClick()
|
||||
{
|
||||
if (_context == null || !_context.IsWeapon) return;
|
||||
if (_context == null || _context.ItemType != ItemType.Weapon) return;
|
||||
GameEntry.Event.Fire(this, ShopWeaponRecycleEventArgs.Create(_context.Index, _context.Price));
|
||||
}
|
||||
|
||||
@@ -201,5 +203,16 @@ namespace SepCore.UI
|
||||
{
|
||||
GameEntry.Event.Fire(this, DisplayItemInfoHideEventArgs.Create(true));
|
||||
}
|
||||
|
||||
private string BuildTypeText(ItemType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
ItemType.None => "error",
|
||||
ItemType.Weapon => "武器",
|
||||
ItemType.Prop => "道具",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user