mirror of
http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite.git
synced 2025-11-20 02:57:12 +08:00
62 lines
1.7 KiB
C#
62 lines
1.7 KiB
C#
|
|
using System.Linq;
|
||
|
|
using Base;
|
||
|
|
using Data;
|
||
|
|
using Managers;
|
||
|
|
using TMPro;
|
||
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.UI;
|
||
|
|
|
||
|
|
namespace UI
|
||
|
|
{
|
||
|
|
public class SkillTreeNodeInformationUI:UIBase
|
||
|
|
{
|
||
|
|
public TMP_Text label;
|
||
|
|
public TMP_Text description;
|
||
|
|
public TMP_Text coin;
|
||
|
|
public Button purchaseButton;
|
||
|
|
|
||
|
|
public SkillTreeNodeUI currentLink;
|
||
|
|
public SkillTreeDef SkillTreeDef => currentLink.SkillTreeDefine;
|
||
|
|
|
||
|
|
public bool CanUnlock
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if (SkillTreeDef.cost > Program.Instance.CoinCount)
|
||
|
|
return false;
|
||
|
|
var parent = SkillTreeManager.Instance.GetAllDirectParents(SkillTreeDef);
|
||
|
|
return parent.All(p => SkillTreeManager.Instance.IsSkillTreeUnlocked(p.defName));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void Init(SkillTreeNodeUI nodeUI)
|
||
|
|
{
|
||
|
|
currentLink = nodeUI;
|
||
|
|
|
||
|
|
label.text = SkillTreeDef.label;
|
||
|
|
description.text = SkillTreeDef.description;
|
||
|
|
coin.text = $"{SkillTreeDef.cost}/{Program.Instance.CoinCount}";
|
||
|
|
if (CanUnlock)
|
||
|
|
{
|
||
|
|
coin.color = Color.white;
|
||
|
|
purchaseButton.interactable = true;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
coin.color = Color.red;
|
||
|
|
purchaseButton.interactable = false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public void Purchase()
|
||
|
|
{
|
||
|
|
SkillTreeManager.Instance.UnlockSkillTree(SkillTreeDef.defName);
|
||
|
|
OnHide();
|
||
|
|
currentLink.Refresh();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void OnHide()
|
||
|
|
{
|
||
|
|
UIInputControl.Instance.Hide(this);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|