| | |
| | | using UnityEngine; |
| | | using UnityEngine.AI; |
| | | using TowerDefense.Level; |
| | | using TowerDefense.Towers; |
| | | |
| | | /// <summary> |
| | | /// 基于兵线的Agent Instance管理器 |
| | |
| | | /// 每一帧更新,更新之后获取几个刚性数据: |
| | | /// 1:血量最多的AgentInstance. |
| | | /// 2:最前面的AgentInstance. |
| | | /// 3: |
| | | /// </summary> |
| | | void Update() |
| | | { |
| | | this.updateAgent(); |
| | | this.updateOpponentAgent(); |
| | | UpdateWoodAim(); |
| | | } |
| | | |
| | | // 测试重设最前面的Agent到初始化位置: |
| | | if (Input.GetKeyDown(KeyCode.A)) |
| | | /// <summary> |
| | | /// 更新木属性精灵瞄准 |
| | | /// </summary> |
| | | private void UpdateWoodAim() |
| | | { |
| | | if (!EndlessLevelManager.instanceExists) return; |
| | | |
| | | WaveLineAgentInsMgr[] mgrs = GetWaveLineList(); |
| | | |
| | | for (int i = 0; i < 5; ++i) |
| | | { |
| | | // 测试数据,重设Agent到开始位置 |
| | | if (agentInsList.Count >= 2) |
| | | List<Agent> agents = mgrs[i].listAgent; |
| | | // 是否发现有正在蓄力的木属性精灵 |
| | | bool findCharge = false; |
| | | Tower tower = null; |
| | | |
| | | if (agents.Count == 0) continue; |
| | | |
| | | for (int j = 2; j <= 3; ++j) |
| | | { |
| | | /* var posResetEff = MinDisAgent.GetComponent<AgentResetPosEffect>(); |
| | | if (posResetEff == null) |
| | | { |
| | | posResetEff = MinDisAgent.gameObject.AddComponent<AgentResetPosEffect>(); |
| | | } |
| | | posResetEff.Initialize(4, posResetFx );*/ |
| | | var lightBolt = agentInsList[1].GetComponent<LightBoltEffect>(); |
| | | if (lightBolt == null) |
| | | tower = EndlessGameUI.instance.FindTowerWithGridIdx(i, j); |
| | | |
| | | if (!tower || !tower.gameObject.activeInHierarchy || tower.attributeId != 109) continue; |
| | | |
| | | if (tower.IsWoodCharge) |
| | | { |
| | | lightBolt = agentInsList[1].gameObject.AddComponent<LightBoltEffect>(); |
| | | findCharge = true; |
| | | break; |
| | | } |
| | | lightBolt.Initialize(2, lightBoltFx, lightHitFx, agentInsList[1], agentInsList[0]); |
| | | } |
| | | |
| | | if (!findCharge) |
| | | { |
| | | for (int j = 0; j < agents.Count; ++j) |
| | | { |
| | | agents[j].StopWoodAimEffect(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (tower.WoodAimAgent != null) |
| | | tower.WoodAimAgent.PlayWoodAimEffect(); |
| | | } |
| | | } |
| | | /* |
| | | // TEST CODE TO DELETE: |
| | | if( Input.GetKeyDown( KeyCode.S )) |
| | | { |
| | | this.moveAllAgentToCenter(); |
| | | } |
| | | if( Input.GetKeyDown( KeyCode.D)) |
| | | { |
| | | Targetter.bSearchTarget = !Targetter.bSearchTarget; |
| | | }*/ |
| | | } |
| | | |
| | | /// <summary> |