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 expList = new List(); 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; } }