Scriptum/Assets/Scripts/REFACTORING/Application/UI/Chest/ChestContentUIManager.cs
2022-11-24 03:03:30 +01:00

112 lines
2.7 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ChestContentUIManager : UIWarehouseManager
{
public static new ChestContentUIManager Instance { get; protected set; }
public override int SLOTS_NUMBER { get { return 48; } }
public const string ITEM_LOCALIZATION = "UiPanels/";
public const string PANEL_NAME = null;
public void Awake()
{
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
}*/
public void Update()
{
// use empty function to override parent Update
// to prevent using Open Panel and Close Panel!!!
// this UI manager mustn't open panel - only manage passed chest content and return updated data
}
public bool OpenPanel() { return true; }
public bool ClosePanel() { return true; }
protected override GameObject GetTemplatePanel() { throw new System.NotImplementedException(); }
public override void SetupPanel()
{
base.SetupPanel();
// setup models list
DynamicPanel.GetComponent<ChestPanelController>().SetUp(Elements);
}
public override void UpdateList()
{
DynamicPanel.GetComponent<ChestPanelController>().BuildPanelContent(Elements);
}
#region adust parent function
public override void Add(IndexValuePair<int, EquippableItem> itemOnSlot)
{
base.Add(itemOnSlot);
UpdateChestContent();
}
public override void Add(EquippableItem item)
{
base.Add(item);
UpdateChestContent();
}
public override void RemoveByPosition(int keyPosition)
{
base.RemoveByPosition(keyPosition);
UpdateChestContent();
}
public override int RemoveByItemId(int itemId)
{
var result = base.RemoveByItemId(itemId);
UpdateChestContent();
return result;
}
public override int RemoveByItemName(string itemName)
{
var result = base.RemoveByItemName(itemName);
UpdateChestContent();
return result;
}
public override void RemoveAll()
{
Elements.Clear();
UpdateChestContent();
}
#endregion
private void UpdateChestContent()
{
ChestUIManager.Instance.UpdateChestContent(ChestUIManager.Instance.CurrentChestName, Elements);
}
}