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

63 lines
1.5 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;
[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-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-09 23:24:46 +08:00
}