From 56f409504f41dc514a75f39995d11f86aec07e34 Mon Sep 17 00:00:00 2001 From: chenxin <chenxin6991@163.com> Date: Wed, 25 Nov 2020 10:33:08 +0800 Subject: [PATCH] 玉米瞄准bug修改 --- Assets/Scripts/TowerDefense/Level/AgentInsManager.cs | 65 ++++++++++++++++++++------------ 1 files changed, 40 insertions(+), 25 deletions(-) diff --git a/Assets/Scripts/TowerDefense/Level/AgentInsManager.cs b/Assets/Scripts/TowerDefense/Level/AgentInsManager.cs index 3630a15..efdf5d0 100644 --- a/Assets/Scripts/TowerDefense/Level/AgentInsManager.cs +++ b/Assets/Scripts/TowerDefense/Level/AgentInsManager.cs @@ -11,6 +11,7 @@ using UnityEngine; using UnityEngine.AI; using TowerDefense.Level; +using TowerDefense.Towers; /// <summary> /// 基于兵线的Agent Instance管理器 @@ -883,44 +884,58 @@ /// 每一帧更新,更新之后获取几个刚性数据: /// 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> -- Gitblit v1.9.1