| | |
| | | using DG.Tweening; |
| | | using JetBrains.Annotations; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using TMPro; |
| | | using TowerDefense.Level; |
| | |
| | | using UnityEngine.EventSystems; |
| | | using UnityEngine.UI; |
| | | using TowerDefense.Nodes; |
| | | using TowerDefense.Affectors; |
| | | using KTGMGemClient; |
| | | |
| | | namespace TowerDefense.UI.HUD |
| | | { |
| | |
| | | // 测试屏幕显示相关的倒计时. |
| | | protected bool bLoaded = false; |
| | | |
| | | private Timer overTimer; |
| | | |
| | | /// <summary> |
| | | /// 总兵线数 |
| | | /// </summary> |
| | |
| | | /// 所有攻击塔位的摧毁信息,是否被摧毁,默认全部没有被摧毁 |
| | | /// </summary> |
| | | private bool[,] TowerDestroyArr; |
| | | |
| | | public event Action GameOverEvent; |
| | | |
| | | public IPlacementArea selfTowerPlaceArea |
| | | { |
| | |
| | | public bool towerInList(Tower t) |
| | | { |
| | | return m_listTower.Contains(t); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置已经上阵的所有塔的攻击状态,是否可以攻击 |
| | | /// </summary> |
| | | /// <param name="canAttack"></param> |
| | | public void SetAttackingTowerState(bool canAttack) |
| | | { |
| | | foreach (Tower tower in m_listTower) |
| | | { |
| | | tower.bInAttackMode = canAttack; |
| | | } |
| | | } |
| | | |
| | | public void delTower(Tower t) |
| | |
| | | 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(1.2f, SafelyCallGameOverEvent); |
| | | } |
| | | } |
| | | |
| | | private void SafelyCallGameOverEvent() |
| | | { |
| | | if (GameOverEvent != null) |
| | | GameOverEvent(); |
| | | overTimer = null; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | CancelPlaceTower(pointerInfo); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 强制放置塔,主要是用于新手 |
| | | /// </summary> |
| | | /// <param name="newTower"></param> |
| | | /// <param name="pos"></param> |
| | | /// <param name="level">塔的等级</param> |
| | | public void PlaceTowerForce(Tower newTower, IntVector2 pos, int level) |
| | | { |
| | | TowerPlacementGhost currentTower = Instantiate(newTower.towerGhostPrefab); |
| | | currentTower.Initialize(newTower); |
| | | Tower controller = currentTower.controller; |
| | | Tower createdTower = Instantiate(controller); |
| | | createdTower.Initialize(m_CurrentArea, pos); |
| | | createdTower.SetLevel(level - 1); |
| | | |
| | | addTower(createdTower); |
| | | Destroy(currentTower.gameObject); |
| | | } |
| | | |
| | | protected bool SkillPlayEndDrag(PointerInfo pointer) |
| | | { |
| | | // 我操,终于可以了!ATTENTION TO OPP: |
| | |
| | | // 播放特效,并处理伤害. |
| | | EndlessWaveLineManager.instance.PlayWaveLineEffect(selEff.waveLineId); |
| | | AgentInsManager.instance.ExecWavelineAttack(selEff.waveLineId, sId, sLevel, false); |
| | | ++GameConfig.EndlessPortUseSkillTowerCount; |
| | | return true; |
| | | } |
| | | } |
| | |
| | | int cost = TowerPrice.instance.currentTowerPrice; |
| | | if (zeroCost) |
| | | cost = 0; |
| | | |
| | | |
| | | if (forceCost != -1) |
| | | cost = forceCost; |
| | | |
| | |
| | | m_CurrentTower.Show(); |
| | | if (successfulPurchase) |
| | | { |
| | | ++GameConfig.EndlessBuyTowerCount; |
| | | // 删除towerToMove,确保塔防数据不再出现多个 |
| | | if (zeroCost && (towerToMove != null)) |
| | | { |
| | |
| | | |
| | | PlaceTower(lvl); |
| | | } |
| | | |
| | | |
| | | return true; |
| | | } |
| | | |
| | |
| | | /// </summary> |
| | | private void Update() |
| | | { |
| | | if (overTimer != null) |
| | | overTimer.Tick(Time.deltaTime); |
| | | |
| | | for (int ti = listTowerTimer.Count - 1; ti >= 0; ti--) |
| | | { |
| | | // 如果执行到,会在DelTower函数内删除对应的listTowerTimer. |