From eca45a7dbaed666a174e1d69177e06157ec98beb Mon Sep 17 00:00:00 2001
From: wangguan <wangguan@kt007.com>
Date: Fri, 06 Nov 2020 17:37:52 +0800
Subject: [PATCH] 修改材质球速度,增加一个简单的改变速度的方法

---
 Assets/Scripts/TowerDefense/Level/AgentInsManager.cs |  135 +++++++++++++++++++++++++++++++++------------
 1 files changed, 99 insertions(+), 36 deletions(-)

diff --git a/Assets/Scripts/TowerDefense/Level/AgentInsManager.cs b/Assets/Scripts/TowerDefense/Level/AgentInsManager.cs
index 428ed8d..dfe2c74 100644
--- a/Assets/Scripts/TowerDefense/Level/AgentInsManager.cs
+++ b/Assets/Scripts/TowerDefense/Level/AgentInsManager.cs
@@ -10,6 +10,7 @@
 using TowerDefense.UI.HUD;
 using UnityEngine;
 using UnityEngine.AI;
+using TowerDefense.Level;
 
 /// <summary>
 /// 基于兵线的Agent Instance管理器
@@ -60,7 +61,15 @@
     /// <returns></returns>
     public int getAgentInsNum()
     {
-        return this.agentInsList.Count;
+        int ret = 0;
+
+        for (int i = 0; i < agentInsList.Count; ++i)
+        {
+            if (agentInsList[i].AgentType == SpawnAgentType.Normal)
+                ++ret;
+        }
+
+        return ret;
     }
 
     /// <summary>
@@ -223,6 +232,30 @@
         return agentWaveLineArray;
     }
 
+    /// <summary>
+    /// 设置某条兵线的所有小兵的移动状态
+    /// </summary>
+    /// <param name="waveLineId">兵线id 1~5, 如果是-1则设置所有兵线的状态</param>
+    /// <param name="canMove">是否可以移动</param>
+    /// <param name="isOppo">是否是敌方</param>
+    public void SetWaveLineCanMove(int waveLineId, bool canMove, bool isOppo)
+    {
+        WaveLineAgentInsMgr[] waveLineAgents = isOppo ? getOppoWaveLineList() : GetWaveLineList();
+
+        for (int i = 0; i < waveLineAgents.Length; ++i)
+        {
+            if (i == waveLineId - 1 || waveLineId == -1)
+            {
+                List<Agent> list = waveLineAgents[i].listAgent;
+
+                for (int j = 0; j < list.Count; ++j)
+                {
+                    list[j].CanMove = canMove;
+                }
+            }
+        }
+    }
+
     public List<Agent> agentList
     {
         get { return this.agentInsList; }
@@ -259,12 +292,21 @@
         // 这一行防止无限的循环下去。
         if (forceGet) return ag;
 
-        Agent agLeft = GetMinDisAgent(lineid - 1, oppo, true, noPoison);
-        Agent agRight = GetMinDisAgent(lineid + 1, oppo, true, noPoison);
-
         agentTmpArr[0] = ag;
-        agentTmpArr[1] = agLeft;
-        agentTmpArr[2] = agRight;
+
+        if (!EndlessLevelManager.instanceExists)
+        {
+            Agent agLeft = GetMinDisAgent(lineid - 1, oppo, true, noPoison);
+            Agent agRight = GetMinDisAgent(lineid + 1, oppo, true, noPoison);
+
+            agentTmpArr[1] = agLeft;
+            agentTmpArr[2] = agRight;
+        }
+        else
+        {
+            agentTmpArr[1] = null;
+            agentTmpArr[2] = null;
+        }
 
         float minDis = 100000000f;
         int idx = -1;
@@ -606,35 +648,49 @@
         if (slinfo.atcmod.Count < 2) return;
 
         float radius = slinfo.atcmod[1];
+
         for (int ti = 0; ti < mgrList.Length; ti++)
         {
             WaveLineAgentInsMgr mgr = mgrList[ti];
             for (int idx = 0; idx < mgr.listAgent.Count; idx++)
             {
                 Agent eag = mgr.listAgent[idx];
-                Vector3 fpos = eag.transform.position;
-                fpos.y = 0;
-                float dist = Vector3.Distance(fpos, pos);
-                if (radius < dist)
-                    continue;
 
-                float damage = slinfo.skilleffect[2];
-                damage += (slinfo.skilleffect[1] / 100.0f * eag.configuration.maxHealth);
-                damage = (float)Math.Floor(damage);
-
-                eag.TakeDamage(damage, fpos, null);
-                if (!eag.opponentAgent)
+                if (eag.AgentType == SpawnAgentType.BubbleBomb)
                 {
-                    if (GameUI.instanceExists)
-                        GameUI.instance.generateBloodText(fpos, damage, false, false);
-                    else if (EndlessGameUI.instanceExists)
-                        EndlessGameUI.instance.generateBloodText(fpos, damage, false, false);
+                    buffinfo bufdata = JsonDataCenter.GetBuffFromId(3);
+                    if (bufdata != null)
+                    {
+                        if (bufdata.buff_func[0] == 3)
+                            EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.EndlessBubbleBombBeDizzinessed, (eag as BubbleBombAgent).Id, bufdata.last);
+                    }
                 }
-
-                if (eag.isDead)
-                    continue;
                 else
-                    eag.SetAgentBuffEffect(3);
+                {
+                    Vector3 fpos = eag.transform.position;
+                    fpos.y = 0;
+                    float dist = Vector3.Distance(fpos, pos);
+                    if (radius < dist)
+                        continue;
+
+                    float damage = slinfo.skilleffect[2];
+                    damage += (slinfo.skilleffect[1] / 100.0f * eag.configuration.maxHealth);
+                    damage = (float)Math.Floor(damage);
+
+                    eag.TakeDamage(damage, fpos, null);
+                    if (!eag.opponentAgent)
+                    {
+                        if (GameUI.instanceExists)
+                            GameUI.instance.generateBloodText(fpos, damage, false, false);
+                        else if (EndlessGameUI.instanceExists)
+                            EndlessGameUI.instance.generateBloodText(fpos, damage, false, false);
+                    }
+
+                    if (eag.isDead)
+                        continue;
+                    else
+                        eag.SetAgentBuffEffect(3);
+                }
             }
         }
 
@@ -663,25 +719,32 @@
             wavelineIns = agentWaveLineArray[waveline];
 
         if (wavelineIns == null) return;
+
         List<Agent> listAg = wavelineIns.listAgent;
+
         for (int ti = listAg.Count - 1; ti >= 0; ti--)
         {
             Agent eag = listAg[ti];
-            Vector3 fpos = eag.transform.position;
-            float damage = slinfo.skilleffect[2];
-            damage += (slinfo.skilleffect[1] / 100.0f * eag.configuration.maxHealth);
-            damage = (float)Math.Floor(damage);
 
-            eag.TakeDamage(damage, fpos, null);
-            if (!eag.opponentAgent)
+            if (eag.AgentType == SpawnAgentType.BubbleBomb)
+                EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.EndlessFireSkillKillBubbleBomb, (eag as BubbleBombAgent).Id);
+            else
             {
-                if (GameUI.instanceExists)
-                    GameUI.instance.generateBloodText(fpos, damage, false, false);
-                else if (EndlessGameUI.instanceExists)
-                    EndlessGameUI.instance.generateBloodText(fpos, damage, false, false);
+                Vector3 fpos = eag.transform.position;
+                float damage = slinfo.skilleffect[2];
+                damage += (slinfo.skilleffect[1] / 100.0f * eag.configuration.maxHealth);
+                damage = (float)Math.Floor(damage);
+
+                eag.TakeDamage(damage, fpos, null);
+                if (!eag.opponentAgent)
+                {
+                    if (GameUI.instanceExists)
+                        GameUI.instance.generateBloodText(fpos, damage, false, false);
+                    else if (EndlessGameUI.instanceExists)
+                        EndlessGameUI.instance.generateBloodText(fpos, damage, false, false);
+                }
             }
         }
-
     }
 
     /// <summary>

--
Gitblit v1.9.1