using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; public class ItemEffectsManager : MonoBehaviour { public static ItemEffectsManager Instance { get; private set; } public UseItemEvent itemEvent; public virtual void Awake() { if(Instance == null) { Instance = this; } else { Destroy(gameObject); } } public virtual void UseItemEffect(ItemSlot itemSlot, PanelTypeEnum originPanel) { DetectItemActionGroup(itemSlot, originPanel); // origin panel is passed for script to be able to recognize from witch list remove object etc... // use other actions binded to item - not here becaues here item should be removed from chest xd } public void DetectItemActionGroup(ItemSlot itemSlot, PanelTypeEnum originPanel) { var type = itemSlot?.Item.EquipmentType; switch (type) { case EquipmentTypeEnum.Potion: { (PotionEffectsManager.Instance).UseItemEffect(itemSlot, originPanel); break; } default: { Debug.LogError($"Event for item of type - {type} - is not implemented"); break; } // TODO add case for next type to handle action for other items ;) } } public UIWarehouseManager DetectOriginPanel(PanelTypeEnum originPanel) { // don't handle other types because there effects aren't allowed (and source class type is different xd - complicated) switch(originPanel) { case PanelTypeEnum.Inventory: { return InventoryUIManager.Instance; } case PanelTypeEnum.Equippment: { return EquipmentUIManager.Instance; } default: { Debug.LogError($"Event for item of type - {originPanel} - is not implemented"); break; } } return UIWarehouseManager.Instance; } }