Cute_demon_attacks/meng_yao/Assets/script/A_Fight/SkillBox.cs

86 lines
2.2 KiB
C#
Raw Normal View History

2024-12-09 23:24:46 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2024-12-10 06:57:53 +08:00
using UnityEngine.UI;
2024-12-09 23:24:46 +08:00
2024-12-10 06:57:53 +08:00
public class SkillBox : Base
2024-12-09 23:24:46 +08:00
{
2024-12-10 06:57:53 +08:00
public static SkillBox instance;
[Header("ս<><D5BD>(<28><><EFBFBD><EFBFBD>)")] public int expNumber;
[Header("ս<><D5BD>(<28><><EFBFBD><EFBFBD>)")] public Text expNumberText;
[Header("<22><><EFBFBD><EFBFBD>ս<EFBFBD><D5BD>(<28><><EFBFBD><EFBFBD>)")] public int maxExpNumber;
2024-12-13 05:40:51 +08:00
public GameObject infobox_skill;
public GameObject Skill;
public Transform SkillParent;
2024-12-10 06:57:53 +08:00
[HideInInspector]
public int ExpNumber
{
get => expNumber;
set
{
expNumber = value;
}
}
[Header("ս<><D5BD>(<28><><EFBFBD><EFBFBD>)<29><><EFBFBD><EFBFBD>")] public GameObject ExpFileObj;
private int ExpFileObjNumber=0;
[Header("ս<><D5BD>(<28><><EFBFBD><EFBFBD>)<29><><EFBFBD><EFBFBD>ڵ<EFBFBD>")] public GameObject ExpFilePrante;
public List<GameObject> expList = new List<GameObject>();
private void Start()
2024-12-09 23:24:46 +08:00
{
2024-12-10 06:57:53 +08:00
if (instance != null) return;
instance = this;
2024-12-13 05:40:51 +08:00
InitSkil();
2024-12-09 23:24:46 +08:00
}
2024-12-10 06:57:53 +08:00
public void UpdataExp(int number)
2024-12-09 23:24:46 +08:00
{
2024-12-10 06:57:53 +08:00
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;
2024-12-09 23:24:46 +08:00
}
2024-12-10 06:57:53 +08:00
2024-12-13 05:40:51 +08:00
void InitSkil()
{
for (int i = 0; i < Base.GlobalObj.GetComponent<gameGlobal>().CarryCardId.Count; i++)
{
2024-12-13 07:16:44 +08:00
for (int j = 0; j < 2; j++)
{
2024-12-13 05:40:51 +08:00
GameObject obj = Instantiate(Skill,SkillParent);
obj.GetComponent<Skill_Spend>().infobox_skill_up = infobox_skill;
2024-12-13 07:16:44 +08:00
obj.GetComponent<Skill_Spend>().MySkill = MengyaoInfo.Instance.m_SkillData[i].skills[j];
}
2024-12-13 05:40:51 +08:00
}
2024-12-14 17:34:12 +08:00
//Base.GlobalObj.GetComponent<gameGlobal>().CarryCardId.Clear();
2024-12-13 05:40:51 +08:00
}
2024-12-09 23:24:46 +08:00
}