88 lines
2.1 KiB
C#
88 lines
2.1 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;
|
|
|
|
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<GameObject> expList = new List<GameObject>();
|
|
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<gameGlobal>().CarryCardId.Count; i++)
|
|
{
|
|
|
|
for (int j = 0; j < 2; j++)
|
|
{
|
|
GameObject obj = Instantiate(Skill,SkillParent);
|
|
obj.GetComponent<Skill_Spend>().infobox_skill_up = infobox_skill;
|
|
obj.GetComponent<Skill_Spend>().MySkill = MengyaoInfo.Instance.m_SkillData[i].skills[j];
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|