chenxin
2020-11-25 56f409504f41dc514a75f39995d11f86aec07e34
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();
        // 测试重设最前面的Agent到初始化位置:
        if (Input.GetKeyDown(KeyCode.A))
        {
            // 测试数据,重设Agent到开始位置
            if (agentInsList.Count >= 2)
            {
                /*   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)
                {
                    lightBolt = agentInsList[1].gameObject.AddComponent<LightBoltEffect>();
                }
                lightBolt.Initialize(2, lightBoltFx, lightHitFx, agentInsList[1], agentInsList[0]);
        UpdateWoodAim();
            }
        }
        /*
        // TEST CODE TO DELETE:
        if( Input.GetKeyDown( KeyCode.S ))
    /// <summary>
    /// 更新木属性精灵瞄准
    /// </summary>
    private void UpdateWoodAim()
        {
            this.moveAllAgentToCenter();
        }
        if( Input.GetKeyDown( KeyCode.D))
        if (!EndlessLevelManager.instanceExists) return;
        WaveLineAgentInsMgr[] mgrs = GetWaveLineList();
        for (int i = 0; i < 5; ++i)
        {
            Targetter.bSearchTarget = !Targetter.bSearchTarget;
        }*/
            List<Agent> agents = mgrs[i].listAgent;
            // 是否发现有正在蓄力的木属性精灵
            bool findCharge = false;
            Tower tower = null;
            if (agents.Count == 0) continue;
            for (int j = 2; j <= 3; ++j)
            {
                tower = EndlessGameUI.instance.FindTowerWithGridIdx(i, j);
                if (!tower || !tower.gameObject.activeInHierarchy || tower.attributeId != 109) continue;
                if (tower.IsWoodCharge)
                {
                    findCharge = true;
                    break;
                }
            }
            if (!findCharge)
            {
                for (int j = 0; j < agents.Count; ++j)
                {
                    agents[j].StopWoodAimEffect();
                }
            }
            else
            {
                if (tower.WoodAimAgent != null)
                    tower.WoodAimAgent.PlayWoodAimEffect();
            }
        }
    }
    /// <summary>