结构大修改,改成朴实无华的结构,不过度架构。能跑就行
This commit is contained in:
@@ -14,7 +14,6 @@ namespace NBF
|
||||
{
|
||||
private List<ItemInfo> _items = new List<ItemInfo>();
|
||||
|
||||
private RoleBag _roleBag;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
@@ -23,8 +22,6 @@ namespace NBF
|
||||
|
||||
protected override void OnShow()
|
||||
{
|
||||
var role = App.Main.GetComponent<Role>();
|
||||
_roleBag = role.GetComponent<RoleBag>();
|
||||
SetList();
|
||||
SetSlotList();
|
||||
}
|
||||
@@ -34,7 +31,7 @@ namespace NBF
|
||||
private void SetList()
|
||||
{
|
||||
_items.Clear();
|
||||
foreach (var roleBagItem in _roleBag.Items)
|
||||
foreach (var roleBagItem in RoleModel.Instance.Items)
|
||||
{
|
||||
if (CanShow(roleBagItem))
|
||||
{
|
||||
@@ -42,7 +39,7 @@ namespace NBF
|
||||
}
|
||||
}
|
||||
|
||||
List<object> items = _roleBag.GetItemListData();
|
||||
List<object> items = RoleModel.Instance.GetItemListData();
|
||||
List.SetListData(items);
|
||||
var children = List.List.GetChildren();
|
||||
foreach (var gObject in children)
|
||||
@@ -74,7 +71,7 @@ namespace NBF
|
||||
{
|
||||
if (SlotList.AddItemFromPool() is BagSlotItem slotItem)
|
||||
{
|
||||
slotItem.SetData(index, _roleBag.GetSlotItem(index));
|
||||
slotItem.SetData(index, RoleModel.Instance.GetSlotItem(index));
|
||||
slotItem.OnChangeSlot = OnChangeSlotItem;
|
||||
}
|
||||
}
|
||||
@@ -83,7 +80,7 @@ namespace NBF
|
||||
|
||||
private void OnChangeSlotItem(int index, long id)
|
||||
{
|
||||
_roleBag.SetSlot(index, id).OnCompleted(OnChangeSlotItemDone);
|
||||
RoleModel.Instance.SetSlot(index, id).OnCompleted(OnChangeSlotItemDone);
|
||||
}
|
||||
|
||||
private void OnChangeSlotItemDone()
|
||||
@@ -104,7 +101,7 @@ namespace NBF
|
||||
private void SelectCallback(long selectId)
|
||||
{
|
||||
if (selectId < 1) return;
|
||||
_roleBag.SetSlot(_lastSelectedItem, selectId).OnCompleted(OnChangeSlotItemDone);
|
||||
RoleModel.Instance.SetSlot(_lastSelectedItem, selectId).OnCompleted(OnChangeSlotItemDone);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user