| | |
| | | using DG.Tweening; |
| | | using JetBrains.Annotations; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using TMPro; |
| | | using TowerDefense.Level; |
| | |
| | | // 测试屏幕显示相关的倒计时. |
| | | protected bool bLoaded = false; |
| | | |
| | | private Timer overTimer; |
| | | |
| | | /// <summary> |
| | | /// 总兵线数 |
| | | /// </summary> |
| | |
| | | /// 所有攻击塔位的摧毁信息,是否被摧毁,默认全部没有被摧毁 |
| | | /// </summary> |
| | | private bool[,] TowerDestroyArr; |
| | | |
| | | public event Action GameOverEvent; |
| | | |
| | | public IPlacementArea selfTowerPlaceArea |
| | | { |
| | |
| | | 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); |
| | |
| | | } |
| | | |
| | | TowerDestroyArr[xidx, i] = true; |
| | | Tower tower = FindTowerWithGridIdx(xidx, i); |
| | | Tower tower = FindTowerWithGridIdx(xidx, 3 - i); |
| | | |
| | | if (tower) |
| | | { |
| | |
| | | // 红心减少逻辑 |
| | | // HealthHeartState.instance.killHeart(false); |
| | | GameOver(); |
| | | overTimer = new Timer(1f, SafelyCallGameOverEvent); |
| | | } |
| | | } |
| | | |
| | | private void SafelyCallGameOverEvent() |
| | | { |
| | | if (GameOverEvent != null) |
| | | GameOverEvent(); |
| | | overTimer = null; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | private void Update() |
| | | { |
| | | if (overTimer != null) |
| | | overTimer.Tick(Time.deltaTime); |
| | | |
| | | for (int ti = listTowerTimer.Count - 1; ti >= 0; ti--) |
| | | { |
| | | // 如果执行到,会在DelTower函数内删除对应的listTowerTimer. |