using System.Collections.Generic; using UnityEngine; using System.Collections; using System.ComponentModel; using UnityEditor.SceneManagement; using static PotionHandler; public class PlayerSkillTree { private static PlayerSkillTree _instance; private Dictionary potionHandlers = new Dictionary(); public static PlayerSkillTree Instance { get { if (_instance == null) { _instance = new PlayerSkillTree(); } return _instance; } } public enum Skills { Dash, Reflection1, Reflection2, Shockwave, Spin, Potion, Arrows1, Arrows2 } private List playerSkills; public PlayerSkillTree() { playerSkills = new List(); } public void RegisterPotionHandler(PotionType type, PotionHandler handler) { if (!potionHandlers.ContainsKey(type)) { potionHandlers.Add(type, handler); } else { potionHandlers[type] = handler; } } public void UnlockSkill(Skills skill, PotionHandler.PotionType potionType) { if(skill == Skills.Potion){ if (potionHandlers.TryGetValue(potionType, out PotionHandler handler)) { handler.AddPotion(potionType); } return; } if (playerSkills.Contains(skill)) return; playerSkills.Add(skill); } public bool TryUsePotion(PotionHandler.PotionType potionType) { if (potionHandlers.TryGetValue(potionType, out PotionHandler handler)) { if (handler.IsEmpty(potionType)) return false; return handler.UsePotion(potionType); } return false; } public bool IsSkillUnlocked(Skills skill) { return playerSkills.Contains(skill); } public List GetPlayerSkills() { return playerSkills; } }