From c1d12cdfd23933a0db431a70ff5e145924864782 Mon Sep 17 00:00:00 2001 From: River Jiang <546213258@qq.com> Date: Wed, 21 Oct 2020 15:08:29 +0800 Subject: [PATCH] Merge branch 'master' of http://172.16.1.52:8090/r/GemBattle into master --- Assets/Scripts/TowerDefense/UI/HUD/EndlessGameUI.cs | 31 ++++++++++++++++++++++--------- 1 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Assets/Scripts/TowerDefense/UI/HUD/EndlessGameUI.cs b/Assets/Scripts/TowerDefense/UI/HUD/EndlessGameUI.cs index b03cc39..c3398f0 100644 --- a/Assets/Scripts/TowerDefense/UI/HUD/EndlessGameUI.cs +++ b/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> @@ -1471,7 +1481,7 @@ int cost = TowerPrice.instance.currentTowerPrice; if (zeroCost) cost = 0; - + if (forceCost != -1) cost = forceCost; @@ -1499,7 +1509,7 @@ PlaceTower(lvl); } - + return true; } @@ -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. -- Gitblit v1.9.1