添加 SepCore.Runtime 和 SepCore.Base 程序集
- 暂时将 Entity 全部归进 Runtime 程序集里 - 调整部分 UI 的 UseCase/RawData/Context 之间的关系,让 RawData 更接近业务原始数据,Context 更接近 UI 直接可读的数据 - 调整其他程序集的引用关系
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using CustomUtility;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -7,19 +9,46 @@ namespace SepCore.UI
|
||||
{
|
||||
public string Title;
|
||||
public ItemRarity Rarity;
|
||||
public string Type;
|
||||
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 GoodsItemContext(GoodsItemRawData rawData)
|
||||
{
|
||||
Title = rawData.Title;
|
||||
Description = rawData.Description;
|
||||
Price = rawData.Price;
|
||||
Rarity = rawData.Rarity;
|
||||
Type = rawData.Type;
|
||||
Icon = rawData.Icon;
|
||||
ItemType = rawData.ItemType;
|
||||
if (ItemType == ItemType.None)
|
||||
{
|
||||
Description = string.Empty;
|
||||
Icon = null;
|
||||
Title = string.Empty;
|
||||
}
|
||||
else if (ItemType == ItemType.Weapon)
|
||||
{
|
||||
var weapon = (DRWeapon)rawData.DataRow;
|
||||
Title = weapon.Title;
|
||||
Description = ItemDescUtility.CreateWeaponDescription(weapon);
|
||||
GameEntry.SpriteCache.GetSprite(weapon.IconAssetName, sprite => Icon = sprite);
|
||||
}
|
||||
else
|
||||
{
|
||||
var prop = (DRProp)rawData.DataRow;
|
||||
Title = prop.Title;
|
||||
Description = ItemDescUtility.CreatePropDescription(prop.Modifiers);
|
||||
GameEntry.SpriteCache.GetSprite(prop.IconAssetName, sprite => Icon = sprite);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+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)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,18 +374,14 @@ namespace SepCore.UI
|
||||
return false;
|
||||
}
|
||||
|
||||
var weaponData = weapon.WeaponData;
|
||||
rawData = new DisplayItemInfoRawData
|
||||
{
|
||||
TargetPos = targetPos,
|
||||
Index = index,
|
||||
IconAssetName = weaponData.IconAssetName,
|
||||
Title = weaponData.Title,
|
||||
Rarity = weaponData.Rarity,
|
||||
TypeText = "武器",
|
||||
Description = ItemDescUtility.CreateWeaponDescription(weaponData),
|
||||
Price = Mathf.FloorToInt(weaponData.Price * Context.WeaponRecycleRate),
|
||||
IsWeapon = true
|
||||
Data = weapon.WeaponData,
|
||||
Rarity = weapon.WeaponData.Rarity,
|
||||
ItemType = ItemType.Weapon,
|
||||
Price = Mathf.FloorToInt(weapon.WeaponData.Price * Context.WeaponRecycleRate),
|
||||
};
|
||||
return true;
|
||||
}
|
||||
@@ -417,13 +413,10 @@ namespace SepCore.UI
|
||||
{
|
||||
TargetPos = targetPos,
|
||||
Index = index,
|
||||
IconAssetName = propItem.IconAssetName,
|
||||
Title = propItem.Title,
|
||||
Data = propItem,
|
||||
Rarity = propItem.Rarity,
|
||||
TypeText = "道具",
|
||||
Description = ItemDescUtility.CreatePropDescription(propItem),
|
||||
Price = 0,
|
||||
IsWeapon = false
|
||||
ItemType = ItemType.Prop,
|
||||
Price = 0
|
||||
};
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -22,7 +23,13 @@ namespace SepCore.UI
|
||||
{
|
||||
_iconArea.OnInit(data.Icon, data.Rarity);
|
||||
_titleText.text = data.Title;
|
||||
_typeText.text = data.Type;
|
||||
_typeText.text = data.ItemType switch
|
||||
{
|
||||
ItemType.None => "error",
|
||||
ItemType.Weapon => "武器",
|
||||
ItemType.Prop => "道具",
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
_descriptionText.text = data.Description;
|
||||
_costText.text = $"{data.Price} <sprite name=\"coin\" index=0>";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user