From 1c3d649735e61a65087d9c281729912831f95fce Mon Sep 17 00:00:00 2001
From: wangguan <wangguan@kt007.com>
Date: Tue, 24 Nov 2020 10:55:11 +0800
Subject: [PATCH] 修改技能为右侧充能释放

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

diff --git a/Assets/Scripts/TowerDefense/Level/AgentInsManager.cs b/Assets/Scripts/TowerDefense/Level/AgentInsManager.cs
index 32240aa..3630a15 100644
--- a/Assets/Scripts/TowerDefense/Level/AgentInsManager.cs
+++ b/Assets/Scripts/TowerDefense/Level/AgentInsManager.cs
@@ -61,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>
@@ -246,6 +254,34 @@
                 }
             }
         }
+    }
+
+    /// <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
@@ -640,6 +676,8 @@
         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];
@@ -649,29 +687,49 @@
                 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);
+                bool isDeath = eag.isDead;
 
-                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);
+                {
+                    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;
     }
@@ -697,25 +755,128 @@
             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>
+    /// 处理战场上的兵线伤害,以兵线为单位对怪物进行伤害---所有兵线
+    /// </summary>
+    /// <param name="waveline"></param>
+    /// <param name="sid"></param>
+    /// <param name="slevel"></param>
+    /// <param name="opponent"></param>
+    public void ExecAllWavelineAttack(int sid, int slevel, bool opponent)
+    {
+        skilllevelinfo slinfo = JsonDataCenter.GetSkillLevelInfo(sid, slevel + 1);
+        if (slinfo == null) return;
+
+        WaveLineAgentInsMgr wavelineIns;
+        if (opponent)
+        {
+            for (int i = 0; i < oppoAgentWaveLineArray.Length; i++)
+            {
+                wavelineIns = oppoAgentWaveLineArray[i];
+                CalculateWavelineAttack(slinfo, wavelineIns, sid, slevel);
+            }
+        }
+        else
+        {
+            for (int i = 0; i < agentWaveLineArray.Length; i++)
+            {
+                wavelineIns = agentWaveLineArray[i];
+                CalculateWavelineAttack(slinfo, wavelineIns, sid, slevel);
             }
         }
 
+    }
+
+    private void CalculateWavelineAttack(skilllevelinfo slinfo, WaveLineAgentInsMgr wavelineIns, int sid, int slevel)
+    {
+        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];
+
+            if (eag.isDead) continue;
+
+            if (eag.AgentType == SpawnAgentType.BubbleBomb)
+            {
+                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>
@@ -766,7 +927,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)
@@ -774,30 +935,45 @@
         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];
             if (eag == ag) continue;
-            Vector3 fpos = eag.transform.position;
-            tpos.y = 0;
-            fpos.y = 0;
-            if (Vector3.Distance(tpos, fpos) < 8)
+
+            if (eag.AgentType == SpawnAgentType.BubbleBomb)
             {
-                eag.TakeDamage(damage, fpos, null);
-                if (!eag.opponentAgent)
+                EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.EndlessBossSkillBubbleBombGetHit, (eag as BubbleBombAgent).Id);
+            }
+            else
+            {
+                Vector3 fpos = eag.transform.position;
+                tpos.y = 0;
+                fpos.y = 0;
+                if (Vector3.Distance(tpos, fpos) < 8)
                 {
-                    if (GameUI.instanceExists)
-                        GameUI.instance.generateBloodText(fpos, damage, false, false);
-                    else if (EndlessGameUI.instanceExists)
-                        EndlessGameUI.instance.generateBloodText(fpos, damage, false, false);
+                    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)
+                        ++deathCount;
                 }
             }
         }
+
+        return deathCount;
+
         /*        foreach (Agent eag in listAg)
                 {
                     if (eag == ag) continue;
@@ -853,6 +1029,7 @@
         // 每一个被链式攻击的怪物,飘血.
         foreach (Agent ag in listBlood)
         {
+            if (ag.AgentType != SpawnAgentType.Normal) continue;
             int tid = ag.liveID;
             Damager damager = ag.GetComponent<Damager>();
             ag.TakeDamage(chainAttackHurt, ag.position, alignment);

--
Gitblit v1.9.1