From 8e2286bc3f5f237dc628b828ffcfe25ef61b2a97 Mon Sep 17 00:00:00 2001
From: chenxin <chenxin6991@163.com>
Date: Wed, 18 Nov 2020 09:46:18 +0800
Subject: [PATCH] 打安卓包

---
 Assets/Scripts/TowerDefense/Level/AgentInsManager.cs |  197 +++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 159 insertions(+), 38 deletions(-)

diff --git a/Assets/Scripts/TowerDefense/Level/AgentInsManager.cs b/Assets/Scripts/TowerDefense/Level/AgentInsManager.cs
index 428ed8d..065abcc 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,58 @@
         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;
+                }
+            }
+        }
+    }
+
+    /// <summary>
+    /// 根据赛道获得该赛道的所有敌人
+    /// </summary>
+    /// <param name="tunel">赛道id (1~5)</param>
+    /// <param name="isOppo">是否是对手的赛道</param>
+    /// <returns></returns>
+    public List<Agent> GetAgentsByTunel(int tunel, bool isOppo = false)
+    {
+        WaveLineAgentInsMgr[] waveLineAgents = isOppo ? getOppoWaveLineList() : GetWaveLineList();
+        List<Agent> ret = new List<Agent>();
+
+        for (int i = 0; i < waveLineAgents.Length; ++i)
+        {
+            if (i == tunel - 1)
+            {
+                for (int j = 0; j < waveLineAgents[i].listAgent.Count; ++j)
+                {
+                    if (waveLineAgents[i].listAgent[j].AgentType == SpawnAgentType.Normal)
+                        ret.Add(waveLineAgents[i].listAgent[j]);
+                }
+
+                return ret;
+            }
+        }
+
+        return null;
+    }
+
     public List<Agent> agentList
     {
         get { return this.agentInsList; }
@@ -259,12 +320,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,38 +676,59 @@
         if (slinfo.atcmod.Count < 2) return;
 
         float radius = slinfo.atcmod[1];
+        int deathCount = 0;
+
         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;
+                bool isDeath = eag.isDead;
 
-                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 (!isDeath && eag.isDead)
+                        ++deathCount;
+
+                    if (eag.isDead)
+                        continue;
+                    else
+                        eag.SetAgentBuffEffect(3);
+                }
             }
         }
 
+        if (deathCount > 1)
+            EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.EndlessOneTimeKillCount, deathCount);
 
         return;
     }
@@ -663,25 +754,48 @@
             wavelineIns = agentWaveLineArray[waveline];
 
         if (wavelineIns == null) return;
+
         List<Agent> listAg = wavelineIns.listAgent;
+        // 统计被火技能直接烧死的数量
+        int deathCount = 0;
+
         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.isDead) continue;
+
+            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);
+                EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.EndlessFireSkillKillBubbleBomb, (eag as BubbleBombAgent).Id);
+                // 泡泡炸弹是直接就被火技能秒杀的
+                ++deathCount;
             }
-        }
+            else
+            {
+                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);
+                }
+
+                eag.PlayFireSkillHit();
+
+                if (eag.isDead)
+                    ++deathCount;
+            }
+
+        }
+        if (deathCount > 1)
+            EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.EndlessOneTimeKillCount, deathCount);
     }
 
     /// <summary>
@@ -732,7 +846,7 @@
     /// 对当前Agent同一列内一定区域内的怪物进行攻击:
     /// </summary>
     /// <param name="ag"></param>
-    public void StartExplodeAttack(Agent ag, float damage)
+    public int StartExplodeAttack(Agent ag, float damage)
     {
         WaveLineAgentInsMgr tmgr;
         if (!ag.opponentAgent)
@@ -740,11 +854,13 @@
         else
             tmgr = this.oppoAgentWaveLineArray[ag.waveLineID];
 
-        if (tmgr.getAgentInsNum() <= 1) return;
+        if (tmgr.getAgentInsNum() <= 1) return 0;
 
         List<Agent> listAg = tmgr.listAgent;
 
         Vector3 tpos = ag.transform.position;
+        int deathCount = 0;
+
         for (int ti = listAg.Count - 1; ti >= 0; ti--)
         {
             Agent eag = listAg[ti];
@@ -762,8 +878,13 @@
                     else if (EndlessGameUI.instanceExists)
                         EndlessGameUI.instance.generateBloodText(fpos, damage, false, false);
                 }
+                if (eag.isDead)
+                    ++deathCount;
             }
         }
+
+        return deathCount;
+
         /*        foreach (Agent eag in listAg)
                 {
                     if (eag == ag) continue;

--
Gitblit v1.9.1