Files
Fishing2/Assets/Scripts/UI/Bag/BagPanel.cs
2025-10-14 17:58:49 +08:00

73 lines
1.8 KiB
C#

// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
using System.Collections.Generic;
using UnityEngine;
using NBC;
using NBF.Fishing2;
namespace NBF
{
public partial class BagPanel : UIPanel
{
protected override void OnInit()
{
base.OnInit();
}
protected override void OnShow()
{
Game.Input.OnUICanceled += OnUICanceled;
UseBottomMenu();
List<TabItemData> tabItemList = new List<TabItemData>();
var role = App.Main.GetComponent<Role>();
var roleBag = role.GetComponent<RoleBag>();
var dic = roleBag.GetItemsByType();
foreach (var (type, list) in dic)
{
TabItemData tabItem = new TabItemData
{
Key = type.ToString()
};
tabItem.Items.AddRange(list);
tabItemList.Add(tabItem);
}
ItemList.SetPanel(this);
ItemList.SetData(tabItemList, true, true);
}
private void OnUICanceled(string action)
{
if (!IsTop) return;
if (action == InputDef.UI.SubPrev)
{
}
else if (action == InputDef.UI.SubNext)
{
}
else if (action == InputDef.UI.Up)
{
}
else if (action == InputDef.UI.Down)
{
}
}
private void UseBottomMenu()
{
BottomMenu.Use(this);
}
protected override void OnHide()
{
Game.Input.OnUICanceled -= OnUICanceled;
}
protected override void OnDestroy()
{
base.OnDestroy();
}
}
}