Scriptum/Assets/Scripts/REFACTORING/Application/UI/Inventory/InventoryUIManager.cs

100 lines
2.4 KiB
C#
Raw Normal View History

2022-11-06 21:34:17 +01:00
using System;
using System.Collections.Generic;
using UnityEngine;
[Serializable]
public class InventoryUIManager : UIWarehouseManager
{
public static new InventoryUIManager Instance { get; protected set; }
2022-12-24 15:14:41 +01:00
public override int SLOTS_NUMBER { get { return 42; } }
2022-11-06 21:34:17 +01:00
public const string ITEM_LOCALIZATION = "UiPanels/";
public const string PANEL_NAME = "InventoryPanel";
2022-12-21 12:19:57 +01:00
public override void Awake()
2022-11-06 21:34:17 +01:00
{
if (Instance == null)
{
Instance = this;
}
else
{
Debug.Log(Instance);
Debug.Log("destroiy inventory UI");
Destroy(gameObject);
}
}
/* public override void UpdateList()
{
// TODO something like rebuild associated panel content
// depending on which class we use it mayu be Inventory / Chest / Shop Panel Controller
DynamicPanel.GetComponent<InventoryPanelController>(); //.Refresh() -- rebuild content
}*/
2022-11-06 21:34:17 +01:00
public override void SetupPanel()
{
base.SetupPanel();
// setup models list
DynamicPanel.GetComponent<InventoryPanelController>().SetUp(Elements);
}
public override void UpdateList()
{
2022-11-27 21:28:55 +01:00
// condition for situation where eg player want to pick up item when inventory / equipment is closed
if(DynamicPanel)
DynamicPanel.GetComponent<InventoryPanelController>().BuildPanelContent(Elements);
2022-11-06 21:34:17 +01:00
}
protected override GameObject GetTemplatePanel()
{
// Resources = default path - Asset/Resources ... .obj
return Resources.Load(ITEM_LOCALIZATION + PANEL_NAME) as GameObject;
}
2022-12-27 15:16:59 +01:00
#region List API
public override void RemoveByPosition(int keyPosition)
{
base.RemoveByPosition(keyPosition);
UpdateList();
}
public override int RemoveByItemId(int itemId)
{
var result = base.RemoveByItemId(itemId);
UpdateList();
return result;
}
public override int RemoveOneByItemName(string itemName)
{
var result = base.RemoveOneByItemName(itemName);
UpdateList();
return result;
}
public override int RemoveByItemName(string itemName)
{
var result = base.RemoveByItemName(itemName);
UpdateList();
return result;
}
public override void RemoveAll()
{
Elements.Clear();
UpdateList();
}
#endregion
2022-11-06 21:34:17 +01:00
}