mirror of
http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite.git
synced 2025-11-20 05:27:13 +08:00
(client) feat:添加基地界面到游玩界面的过程,添加存档管理,技能树变得可用 (#58)
Co-authored-by: m0_75251201 <m0_75251201@noreply.gitcode.com> Reviewed-on: http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite/pulls/58
This commit is contained in:
62
Client/Assets/Scripts/UI/SkillTreeNodeInformationUI.cs
Normal file
62
Client/Assets/Scripts/UI/SkillTreeNodeInformationUI.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user