PotionGui
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
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 PotionHandler potionHandler;
|
||||
private Dictionary<PotionHandler.PotionType, PotionHandler> potionHandlers = new Dictionary<PotionHandler.PotionType, PotionHandler>();
|
||||
|
||||
public static PlayerSkillTree Instance
|
||||
{
|
||||
@@ -38,14 +41,29 @@ public class PlayerSkillTree
|
||||
public PlayerSkillTree()
|
||||
{
|
||||
playerSkills = new List<Skills>();
|
||||
potionHandler = new PotionHandler();
|
||||
|
||||
}
|
||||
|
||||
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){
|
||||
potionHandler.AddPotion(potionType);
|
||||
if (potionHandlers.TryGetValue(potionType, out PotionHandler handler))
|
||||
{
|
||||
handler.AddPotion(potionType);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -56,8 +74,12 @@ public class PlayerSkillTree
|
||||
|
||||
public bool TryUsePotion(PotionHandler.PotionType potionType)
|
||||
{
|
||||
if(potionHandler.IsEmpty(potionType)) return false;
|
||||
return potionHandler.UsePotion(potionType);
|
||||
if (potionHandlers.TryGetValue(potionType, out PotionHandler handler))
|
||||
{
|
||||
if (handler.IsEmpty(potionType)) return false;
|
||||
return handler.UsePotion(potionType);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user