Scriptum/Assets/Scripts/REFACTORING/Application/UI/Shop/ShopContentUIManager.cs
kabix09 88ab6bcee7 Add Shop module
Add Shop panel & saving module
2022-12-19 03:34:45 +01:00

113 lines
2.8 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class ShopContentUIManager : UIWarehouseManager
{
public static new ShopContentUIManager Instance { get; protected set; }
public override int SLOTS_NUMBER { get { return 24; } }
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 shop 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<ShopPanelController>().SetUp(Elements);
}
public override void UpdateList()
{
DynamicPanel.GetComponent<ShopPanelController>().BuildPanelContent(Elements);
}
#region adust parent function
public override void Add(IndexValuePair<int, EquippableItem> itemOnSlot)
{
base.Add(itemOnSlot);
UpdateShopContent();
}
public override void Add(EquippableItem item)
{
base.Add(item);
UpdateShopContent();
}
public override void RemoveByPosition(int keyPosition)
{
base.RemoveByPosition(keyPosition);
UpdateShopContent();
}
public override int RemoveByItemId(int itemId)
{
var result = base.RemoveByItemId(itemId);
UpdateShopContent();
return result;
}
public override int RemoveByItemName(string itemName)
{
var result = base.RemoveByItemName(itemName);
UpdateShopContent();
return result;
}
public override void RemoveAll()
{
Elements.Clear();
UpdateShopContent();
}
#endregion
private void UpdateShopContent()
{
ShopUIManager.Instance.UpdateShopContent(SceneManager.GetActiveScene().name, ShopUIManager.Instance.CurrentShopOwnerName, Elements);
}
}