WXGame/Blacksmith/Assets/Script/UI/CombatPanel.cs
2024-12-13 20:38:15 +08:00

70 lines
1.9 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
public class CombatPanel : MonoBehaviour
{
[SerializeField] private Slider _hp;
[SerializeField] private Slider _exp;
[SerializeField] private Text _lv;
[SerializeField] private RogenPanel _rogenPanel;
[SerializeField] private List<CombatItem> _combatItems = new List<CombatItem>();
[SerializeField] private GameObject item;
[SerializeField] private Transform itemParent;
public void StartPanel()
{
_rogenPanel.gameObject.SetActive(false);
if (_combatItems.Count>0)
{
for (int i = 0; i < _combatItems.Count; i++)
{
Destroy(_combatItems[i].gameObject);
}
}
_combatItems = new List<CombatItem>();
}
public void ResetItem()
{
foreach (var state in BattleManager.ins.SkillStates)
{
var bo = _combatItems.Any(c => c.State == state);
if (!bo)
{
var obj = Instantiate(item, itemParent);
obj.SetActive(true);
obj.GetComponent<CombatItem>().SetData(state);
_combatItems.Add(obj.GetComponent<CombatItem>());
}
}
}
public void OpenRogenPanel()
{
_rogenPanel.gameObject.SetActive(true);
_rogenPanel.SetResetIndex(1);
_rogenPanel.InitData();
}
public void CloseRogenPanel()
{
_rogenPanel.gameObject.SetActive(false);
}
public void ResetHp()
{
_hp.value = (BattleManager.ins.HP-(float)BattleManager.ins.Injured) / (float)BattleManager.ins.HP;
}
public void ResetExp()
{
_exp.value = (float)BattleManager.ins.Exp / BattleManager.ins.MaxExp;
_lv.text = BattleManager.ins.ExpLevel.ToString();
}
}