using DragonLi.Core; using TMPro; using Unity.XR.CoreUtils; using UnityEngine; using UnityEngine.UI; using Valheim; using XUI; using UIBehaviour = UnityEngine.EventSystems.UIBehaviour; public class HUD : UIBehaviour { public static UIGroup Group; public GameObject[] icons; public TextMeshProUGUI countDownText; public Image[] guideImg; public Image prossessBar; /// /// 倒计时剩余多少秒 /// private int countDown = 60; /// /// 倒计时剩余多少秒开始抖动 /// private int shakeTime = 10; public RectTransform slider; public RectTransform rectTransform; public static UIGroup Show() { Group= OverlayUIManager.Ins.Cover("UI/HUD", false); return Group; } protected override void Start() { base.Start(); guideImg[0].gameObject.SetActive(false); guideImg[1].gameObject.SetActive(false); } public void ShoGuide(int id) { foreach (var item in guideImg) { item.gameObject.SetActive(false); } guideImg[id].gameObject.SetActive(true); MonoSingleton.Instance.WaitSecondTodo(() => { foreach (var item in guideImg) { item.gameObject.SetActive(false); } },4f); } void Update() { if (GameManager.Ins.GetCountDownSecond() >= 0) { countDownText.text = GameManager.Ins.GetLessTimeStr(); } else { countDownText.text = "00:00"; } prossessBar.fillAmount = Mathf.Lerp(prossessBar.fillAmount, GameManager.Ins.EnergyValue, 0.5f); slider.anchoredPosition = Vector2.Lerp(slider.anchoredPosition, new Vector2(-((rectTransform.rect.width / 10) * (GameManager.Ins.EnergyValue * 10)), 10f), 0.5f); if (GameManager.Ins.GetCountDownSecond() <= countDown) { icons[0].SetActive(true); icons[1].SetActive(false); } else { icons[1].SetActive(true); icons[0].SetActive(false); } if (GameManager.Ins.GetCountDownSecond() <= shakeTime) { } } }