重构:统一 UI 模块目录结构规范
- 事件命名规范化:RefreshEventArgs → LevelUpRefreshEventArgs - LevelUp 子组件目录调整:LevelUpRewardItem + LevelUpRewardItemContext 移动到 LevelUp/ - Shop 子组件目录调整:DisplayItem/DisplayListArea/GoodsItem/ShopGoodsItem 及其 Context/RawData 全部移动到 Shop/ - 删除冗余文件:LevelUpRewardItemRawData(从未被使用) - 新增 ObjectPool 目录结构 - 更新 LevelUpController 和 LevelUpForm 中的事件引用
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SepCore.Event;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class DisplayItem : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private IconArea _iconArea;
|
||||
|
||||
[SerializeField] private RectTransform _itemRect;
|
||||
|
||||
private DisplayItemContext _context;
|
||||
|
||||
private int _index = -1;
|
||||
|
||||
public void SetIndex(int index)
|
||||
{
|
||||
_index = index;
|
||||
}
|
||||
|
||||
public async UniTaskVoid OnInit(DisplayItemContext context, int index)
|
||||
{
|
||||
if (context == null) return;
|
||||
|
||||
_context = context;
|
||||
_index = index;
|
||||
|
||||
if (_iconArea != null)
|
||||
{
|
||||
var sprite = await GameEntry.SpriteCache.GetSprite(_context.IconAssetName);
|
||||
_iconArea.OnInit(sprite, context.Rarity);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnReset()
|
||||
{
|
||||
_context = null;
|
||||
_index = -1;
|
||||
|
||||
if (_iconArea != null)
|
||||
{
|
||||
_iconArea.OnReset();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnItemInfoShow()
|
||||
{
|
||||
if (_index < 0) return;
|
||||
if (_itemRect == null) return;
|
||||
|
||||
Rect rect = _itemRect.rect;
|
||||
Vector3 targetPos = _itemRect.TransformPoint(new Vector3(
|
||||
(rect.xMin + rect.xMax) / 2,
|
||||
rect.yMax,
|
||||
0f)
|
||||
);
|
||||
GameEntry.Event.Fire(this, DisplayItemHoverEventArgs.Create(_index, _context.IsWeapon, targetPos));
|
||||
}
|
||||
|
||||
public void OnItemInfoLock()
|
||||
{
|
||||
GameEntry.Event.Fire(this, DisplayItemLockEventArgs.Create());
|
||||
}
|
||||
|
||||
public void OnItemInfoHide()
|
||||
{
|
||||
GameEntry.Event.Fire(this, DisplayItemHideEventArgs.Create());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user