2025-08-27 19:56:49 +08:00
|
|
|
using System;
|
2025-09-02 11:08:15 +08:00
|
|
|
using Base;
|
|
|
|
using Map;
|
2025-08-27 19:56:49 +08:00
|
|
|
using TMPro;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace UI
|
|
|
|
{
|
|
|
|
public class PlayerStateUI:MonoBehaviour,Base.ITick
|
|
|
|
{
|
|
|
|
[SerializeField] private BarUI focusedEntityHP;
|
|
|
|
[SerializeField] private BarUI lastEntityHP;
|
2025-09-02 11:08:15 +08:00
|
|
|
[SerializeField] private BarUI BaseBuildingHP;
|
|
|
|
[SerializeField] private MiniMap miniMap;
|
|
|
|
[SerializeField] private EquipmentUI equipmentUI;
|
|
|
|
[SerializeField] private CoinCountUI coinCountUI;
|
|
|
|
[SerializeField] private BuffIconListUI focuseEntityBuffIconList;
|
|
|
|
[SerializeField] private BuffIconListUI lastEntityBuffIconList;
|
|
|
|
[SerializeField] private AttackModeUI attackMode;
|
2025-08-27 19:56:49 +08:00
|
|
|
|
|
|
|
public void Tick()
|
|
|
|
{
|
|
|
|
var focusedEntity = Program.Instance.FocusedEntity;
|
|
|
|
if (focusedEntity && focusedEntity.entityDef != null)
|
|
|
|
{
|
|
|
|
focusedEntityHP.Progress =
|
|
|
|
(float)focusedEntity.attributes.health / focusedEntity.entityDef.attributes.health;
|
|
|
|
}
|
|
|
|
}
|
2025-09-02 11:08:15 +08:00
|
|
|
|
|
|
|
public void Show()
|
|
|
|
{
|
|
|
|
focusedEntityHP.gameObject.SetActive(true);
|
|
|
|
lastEntityHP.gameObject.SetActive(true);
|
|
|
|
BaseBuildingHP.gameObject.SetActive(true);
|
|
|
|
miniMap.gameObject.SetActive(true);
|
|
|
|
equipmentUI.gameObject.SetActive(true);
|
|
|
|
coinCountUI.gameObject.SetActive(true);
|
|
|
|
focuseEntityBuffIconList.gameObject.SetActive(true);
|
|
|
|
lastEntityBuffIconList.gameObject.SetActive(true);
|
|
|
|
attackMode.gameObject.SetActive(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Hide()
|
|
|
|
{
|
|
|
|
focusedEntityHP.gameObject.SetActive(false);
|
|
|
|
lastEntityHP.gameObject.SetActive(false);
|
|
|
|
BaseBuildingHP.gameObject.SetActive(false);
|
|
|
|
miniMap.gameObject.SetActive(false);
|
|
|
|
equipmentUI.gameObject.SetActive(false);
|
|
|
|
coinCountUI.gameObject.SetActive(false);
|
|
|
|
focuseEntityBuffIconList.gameObject.SetActive(false);
|
|
|
|
lastEntityBuffIconList.gameObject.SetActive(false);
|
|
|
|
attackMode.gameObject.SetActive(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
UIInputControl.Instance.OnWindowVisibilityChanged += UIChange;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
{
|
|
|
|
UIInputControl.Instance.OnWindowVisibilityChanged -= UIChange;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void UIChange(UIBase ui, bool open)
|
|
|
|
{
|
|
|
|
if (ui.exclusive && open)
|
|
|
|
{
|
|
|
|
Hide();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
}
|
2025-08-27 19:56:49 +08:00
|
|
|
}
|
|
|
|
}
|