2025-07-27 23:48:47 +02:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using System.Collections;
|
2025-08-02 15:35:39 +02:00
|
|
|
using System.ComponentModel;
|
|
|
|
|
using UnityEditor.SceneManagement;
|
2025-07-27 23:48:47 +02:00
|
|
|
|
|
|
|
|
public class PlayerSkillTree
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private static PlayerSkillTree _instance;
|
2025-08-02 15:35:39 +02:00
|
|
|
private Dictionary<PotionHandler.PotionType, PotionHandler> potionHandlers = new Dictionary<PotionHandler.PotionType, PotionHandler>();
|
2025-07-27 23:48:47 +02:00
|
|
|
|
|
|
|
|
public static PlayerSkillTree Instance
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_instance == null)
|
|
|
|
|
{
|
|
|
|
|
_instance = new PlayerSkillTree();
|
|
|
|
|
}
|
|
|
|
|
return _instance;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public enum Skills
|
|
|
|
|
{
|
|
|
|
|
Dash,
|
2025-08-02 02:54:53 +02:00
|
|
|
Reflection1,
|
|
|
|
|
Reflection2,
|
|
|
|
|
Shockwave,
|
|
|
|
|
Spin,
|
|
|
|
|
Potion,
|
|
|
|
|
Arrows1,
|
|
|
|
|
Arrows2
|
2025-07-27 23:48:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<Skills> playerSkills;
|
|
|
|
|
|
|
|
|
|
public PlayerSkillTree()
|
|
|
|
|
{
|
|
|
|
|
playerSkills = new List<Skills>();
|
2025-08-02 15:35:39 +02:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-03 01:18:33 +02:00
|
|
|
public void RegisterPotionHandler(PotionHandler.PotionType type, PotionHandler handler)
|
2025-08-02 15:35:39 +02:00
|
|
|
{
|
|
|
|
|
if (!potionHandlers.ContainsKey(type))
|
|
|
|
|
{
|
|
|
|
|
potionHandlers.Add(type, handler);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
potionHandlers[type] = handler;
|
|
|
|
|
}
|
2025-07-27 23:48:47 +02:00
|
|
|
}
|
|
|
|
|
|
2025-08-02 02:54:53 +02:00
|
|
|
public void UnlockSkill(Skills skill, PotionHandler.PotionType potionType)
|
2025-07-27 23:48:47 +02:00
|
|
|
{
|
2025-08-02 02:54:53 +02:00
|
|
|
|
|
|
|
|
if(skill == Skills.Potion){
|
2025-08-02 15:35:39 +02:00
|
|
|
if (potionHandlers.TryGetValue(potionType, out PotionHandler handler))
|
|
|
|
|
{
|
|
|
|
|
handler.AddPotion(potionType);
|
|
|
|
|
}
|
2025-08-02 02:54:53 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (playerSkills.Contains(skill)) return;
|
|
|
|
|
|
2025-07-27 23:48:47 +02:00
|
|
|
playerSkills.Add(skill);
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-02 02:54:53 +02:00
|
|
|
public bool TryUsePotion(PotionHandler.PotionType potionType)
|
|
|
|
|
{
|
2025-08-02 15:35:39 +02:00
|
|
|
if (potionHandlers.TryGetValue(potionType, out PotionHandler handler))
|
|
|
|
|
{
|
|
|
|
|
if (handler.IsEmpty(potionType)) return false;
|
|
|
|
|
return handler.UsePotion(potionType);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2025-08-02 02:54:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-07-27 23:48:47 +02:00
|
|
|
public bool IsSkillUnlocked(Skills skill)
|
|
|
|
|
{
|
|
|
|
|
return playerSkills.Contains(skill);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Skills> GetPlayerSkills() { return playerSkills; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|