Assets/Scripts/TowerDefense/UI/HUD/EndlessGameUI.cs
@@ -4,6 +4,7 @@
using DG.Tweening;
using JetBrains.Annotations;
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using TowerDefense.Level;
@@ -201,6 +202,8 @@
        // 测试屏幕显示相关的倒计时.
        protected bool bLoaded = false;
        private Timer overTimer;
        /// <summary>
        /// 总兵线数
        /// </summary>
@@ -228,6 +231,8 @@
        /// 所有攻击塔位的摧毁信息,是否被摧毁,默认全部没有被摧毁
        /// </summary>
        private bool[,] TowerDestroyArr;
        public event Action GameOverEvent;
        public IPlacementArea selfTowerPlaceArea
        {
@@ -421,12 +426,9 @@
                    break;
                case State.Paused:
                case State.GameOver:
                    // if (oldState == State.Building)
                    // {
                    //     CancelGhostPlacement();
                    // }
                    // Time.timeScale = 0f;
                    Debug.Log("--------------------- game over !!! ---------------------");
                    if (oldState == State.Building)
                        CancelGhostPlacement();
                    Time.timeScale = 1f;
                    break;
                default:
                    throw new ArgumentOutOfRangeException("newState", newState, null);
@@ -681,7 +683,7 @@
                }
                TowerDestroyArr[xidx, i] = true;
                Tower tower = FindTowerWithGridIdx(xidx, i);
                Tower tower = FindTowerWithGridIdx(xidx, 3 - i);
                if (tower)
                {
@@ -730,7 +732,15 @@
                // 红心减少逻辑
                // HealthHeartState.instance.killHeart(false);
                GameOver();
                overTimer = new Timer(1f, SafelyCallGameOverEvent);
            }
        }
        private void SafelyCallGameOverEvent()
        {
            if (GameOverEvent != null)
                GameOverEvent();
            overTimer = null;
        }
        /// <summary>
@@ -2001,6 +2011,9 @@
        /// </summary>
        private void Update()
        {
            if (overTimer != null)
                overTimer.Tick(Time.deltaTime);
            for (int ti = listTowerTimer.Count - 1; ti >= 0; ti--)
            {
                // 如果执行到,会在DelTower函数内删除对应的listTowerTimer.