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; public GameObject infobox_skill; public GameObject Skill; public Transform SkillParent; [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; InitSkil(); } 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; } void InitSkil() { for (int i = 0; i < Base.GlobalObj.GetComponent().CarryCardId.Count; i++) { for (int j = 0; j < 2; j++) { GameObject obj = Instantiate(Skill,SkillParent); obj.GetComponent().infobox_skill_up = infobox_skill; obj.GetComponent().MySkill = MengyaoInfo.Instance.m_SkillData[i].skills[j]; } } //Base.GlobalObj.GetComponent().CarryCardId.Clear(); } }