Cute_demon_attacks/meng_yao/Assets/script/A_Fight/SkillBox.cs
2024-12-10 06:57:53 +08:00

63 lines
1.5 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SkillBox : Base
{
public static SkillBox instance;
[Header("战魂(经验)")] public int expNumber;
[Header("战魂(经验)")] public Text expNumberText;
[Header("最大战魂(经验)")] public int maxExpNumber;
[HideInInspector]
public int ExpNumber
{
get => expNumber;
set
{
expNumber = value;
}
}
[Header("战魂(经验)填充")] public GameObject ExpFileObj;
private int ExpFileObjNumber=0;
[Header("战魂(经验)填充父节点")] public GameObject ExpFilePrante;
public List<GameObject> expList = new List<GameObject>();
private void Start()
{
if (instance != null) return;
instance = this;
}
public void UpdataExp(int number)
{
if (number > 0)
{
for (int i = 0; i < number; i++)
{
if (expList.Count < maxExpNumber)
{
GameObject obj = Instantiate(ExpFileObj, ExpFilePrante.transform);
expList.Add(obj);
}
}
}
else if(number < 0)
{
number *= -1;
for (int i = 0; i < number; i++)
{
GameObject obj = expList[expList.Count - 1];
expList.RemoveAt(expList.Count - 1);
Destroy(obj.gameObject);
}
}
expNumberText.text = expList.Count+"/"+maxExpNumber;
}
}