using System; using System.Collections; using System.Collections.Generic; using DG.Tweening; using DragonLi.Core; using LitJson; using Mirror; using TMPro; using UnityEngine; using UnityEngine.UI; public class HUDPanel : MonoBehaviour { /// /// 倒计时文本 /// public TextMeshProUGUI LessTimeText; /// /// 枪械剩余子弹 /// public TextMeshProUGUI gunCountTxt; /// /// 枪械种类 /// public Sprite[] gunIcons; /// /// 枪图片 /// public Image gunImage; /// /// 警告节点 /// public GameObject TimingWarning; /// /// 血条 /// public Image blood2; public GameObject hitEffect; /// /// 复活倒计时 /// public GameObject dieUI; public TextMeshProUGUI enemyDieCountTxt; /// /// 下一波倒计时 /// public GameObject Round; public Sprite[] RoundIcon; public Image icon; public GameObject JoinControlNode; public static void Show() { OverlayUIManager.Ins.Cover("UI/HUDPanel", false); } private void Awake() { GameLocal.Ins.HitUI = hitEffect; GameLocal.Ins.DieUI = dieUI; } public void Start() { // LoginPanel.Show(); EventDispatcher.AddEventListener("NewWaveStart", NewWaveStart); EventDispatcher.AddEventListener("HpChange", HpChange); EventDispatcher.AddEventListener("UserGun", UserGun); EventDispatcher.AddEventListener("WinRound", ShowWinRound); EventDispatcher.AddEventListener("ChangeGunIcon", ChangeGunIcon); LessTimeText.text = "15:00"; } public void HpChange(float currentHp, float maxHp) { blood2.fillAmount = currentHp / maxHp; //DOTween.To(() => blood1.fillAmount, x => blood1.fillAmount = x, currentHp / maxHp, 0.5f);//血量变化 } public void JoinControlStart(int playerIndex) { if (GameLocal.Ins.self.index == playerIndex) { JoinControlNode.SetActive(true); } } public void JoinControlEnd(int playerIndex) { if (GameLocal.Ins.self.index == playerIndex) { JoinControlNode.SetActive(false); } } // Update is called once per frame void Update() { if (GameManager.Ins.isStart) { if (GameManager.Ins.GetLessTimeSeconds() <= 0) { //GameManager.Ins.GameOver(GameState.Failur); LessTimeText.text = "00:00"; } else { LessTimeText.text = GameManager.Ins.GetLessTimeStr(); } } } public void NewWaveStart(int wave) { Round.SetActive(true); StartCoroutine(RoundWaveTime()); } IEnumerator RoundWaveTime() { GameManager.Ins.PlaySound2DRPC("1.1"); int time = 3; while (time>0) { icon.sprite = RoundIcon[time-1]; yield return new WaitForSeconds(1f); time--; } Round.SetActive(false); } public void ChangeGunIcon(int bulletIndex) { gunImage.sprite = gunIcons[GameLocal.Ins.self.NowGunIndex]; gunCountTxt.text = bulletIndex.ToString(); Debug.LogError("枪械:"+bulletIndex); } public void UserGun(int bullet) { Debug.LogError("子弹数量:"+bullet); gunCountTxt.text = bullet.ToString(); } public void ShowWinRound(int index) { } }