mirror of
http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite.git
synced 2025-11-19 23:37:13 +08:00
Co-authored-by: m0_75251201 <m0_75251201@noreply.gitcode.com> Reviewed-on: http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite/pulls/60
71 lines
2.3 KiB
C#
71 lines
2.3 KiB
C#
using System;
|
|
using Base;
|
|
using Map;
|
|
using UnityEngine;
|
|
|
|
namespace UI
|
|
{
|
|
public class PlayerStateUI : MonoBehaviour, ITick
|
|
{
|
|
[SerializeField] private BarUI focusedEntityHP;
|
|
[SerializeField] private NanorobotsHPUI lastEntityHP;
|
|
[SerializeField] private BarUI BaseBuildingHP;
|
|
[SerializeField] private MiniMap miniMap;
|
|
[SerializeField] private EquipmentUI equipmentUI;
|
|
[SerializeField] private CoinCountUI coinCountUI;
|
|
[SerializeField] private BuffIconListUI focuseEntityBuffIconList;
|
|
[SerializeField] private AttackModeUI attackMode;
|
|
|
|
private void Start()
|
|
{
|
|
UIInputControl.Instance.OnWindowVisibilityChanged += UIChange;
|
|
Clock.AddTick(this);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
UIInputControl.Instance.OnWindowVisibilityChanged -= UIChange;
|
|
Clock.RemoveTick(this);
|
|
}
|
|
|
|
public void Tick()
|
|
{
|
|
var focusedEntity = Program.Instance.FocusedEntity;
|
|
if (focusedEntity && focusedEntity.entityDef != null)
|
|
focusedEntityHP.Progress =
|
|
(float)focusedEntity.AttributesNow.health / focusedEntity.entityDef.attributes.health;
|
|
}
|
|
|
|
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);
|
|
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);
|
|
attackMode.gameObject.SetActive(false);
|
|
}
|
|
|
|
private void UIChange(UIBase ui, bool open)
|
|
{
|
|
if (ui.exclusive && open)
|
|
Hide();
|
|
else
|
|
Show();
|
|
}
|
|
}
|
|
} |