From 6a05b92a9add5eaed3042c1144a07e18b15775f5 Mon Sep 17 00:00:00 2001
From: chenxin <chenxin6991@163.com>
Date: Fri, 04 Dec 2020 15:49:25 +0800
Subject: [PATCH] 新增几个boss资源

---
 Assets/Scripts/TowerDefense/Level/AgentInsManager.cs |  162 +++++++++++++++++++++++++++--------------------------
 1 files changed, 83 insertions(+), 79 deletions(-)

diff --git a/Assets/Scripts/TowerDefense/Level/AgentInsManager.cs b/Assets/Scripts/TowerDefense/Level/AgentInsManager.cs
index ce99dd9..6ba57fe 100644
--- a/Assets/Scripts/TowerDefense/Level/AgentInsManager.cs
+++ b/Assets/Scripts/TowerDefense/Level/AgentInsManager.cs
@@ -78,44 +78,68 @@
     /// </summary>
     public List<Agent> listAgent { get { return this.agentInsList; } }
 
-    /// <summary>
-    /// 获取距目标结点最近的Agent.
-    /// </summary>
-    /// <returns></returns>
-    public Agent getMinDisAgent(bool _noPoison = false)
+    // /// <summary>
+    // /// 获取距目标结点最近的Agent.
+    // /// </summary>
+    // /// <returns></returns>
+    // public Agent getMinDisAgent(bool _noPoison = false)
+    // {
+    //     if (agentInsList.Count == 0) return null;
+
+    //     // 排序,然后返回对应的数据
+    //     // 直接使用闭包函数来进行排序:
+    //     agentInsList.Sort((left, right) =>
+    //     {
+    //         if (left.distanceToDest > right.distanceToDest)
+    //         {
+    //             return 1;
+    //         }
+    //         else if (left.distanceToDest == right.distanceToDest)
+    //         {
+    //             return 0;
+    //         }
+    //         else
+    //         {
+    //             return -1;
+    //         }
+    //     });
+
+    //     if (_noPoison)
+    //     {
+    //         for (int ti = 0; ti < agentInsList.Count; ti++)
+    //         {
+    //             if (!agentInsList[ti].bInPoison)
+    //                 return agentInsList[ti];
+    //         }
+
+    //         return null;
+    //     }
+    //     else
+    //         return agentInsList[0];
+    // }
+
+    public Agent GetMinDistanceAgent()
     {
-        if (agentInsList.Count == 0) return null;
+        Agent ret = null;
+        float minDistance = -1f;
 
-        // 排序,然后返回对应的数据
-        // 直接使用闭包函数来进行排序:
-        agentInsList.Sort((left, right) =>
+        WaveLineAgentInsMgr[] waveLineAgentIns = AgentInsManager.instance.GetWaveLineList();
+        WaveLineAgentInsMgr waveLineAgentInsMgr = waveLineAgentIns[waveLineID];
+        List<Agent> agents = waveLineAgentInsMgr.listAgent;
+        Vector3 endPos = EndlessLevelManager.instance.GetHomeBasePosition(waveLineID + 1);
+
+        for (int i = 0; i < agents.Count; ++i)
         {
-            if (left.distanceToDest > right.distanceToDest)
-            {
-                return 1;
-            }
-            else if (left.distanceToDest == right.distanceToDest)
-            {
-                return 0;
-            }
-            else
-            {
-                return -1;
-            }
-        });
+            float distance = Mathf.Abs(agents[i].transform.position.z - endPos.z);
 
-        if (_noPoison)
-        {
-            for (int ti = 0; ti < agentInsList.Count; ti++)
+            if (minDistance < 0 || distance < minDistance)
             {
-                if (!agentInsList[ti].bInPoison)
-                    return agentInsList[ti];
+                minDistance = distance;
+                ret = agents[i];
             }
-
-            return null;
         }
-        else
-            return agentInsList[0];
+
+        return ret;
     }
 
 }
@@ -314,9 +338,11 @@
 
         Agent ag;
         if (oppo)
-            ag = oppoAgentWaveLineArray[lineid].getMinDisAgent(noPoison);
+            // ag = oppoAgentWaveLineArray[lineid].getMinDisAgent(noPoison);
+            ag = oppoAgentWaveLineArray[lineid].GetMinDistanceAgent();
         else
-            ag = agentWaveLineArray[lineid].getMinDisAgent(noPoison);
+            // ag = agentWaveLineArray[lineid].getMinDisAgent(noPoison);
+            ag = agentWaveLineArray[lineid].GetMinDistanceAgent();
 
         // 这一行防止无限的循环下去。
         if (forceGet) return ag;
@@ -553,27 +579,6 @@
         return;
     }
 
-
-
-    protected void releaseAllCenterAgent()
-    {
-        int cnt = this.agentInsList.Count;
-        for (int ti = cnt - 1; ti >= 0; ti--)
-        {
-            if (agentInsList[ti].bBoss)
-                continue;
-            agentInsList[ti].Remove();
-        }
-
-        cnt = this.oppoAgentInsList.Count;
-        for (int ti = cnt - 1; ti >= 0; ti--)
-        {
-            if (oppoAgentInsList[ti].bBoss)
-                continue;
-            oppoAgentInsList[ti].Remove();
-        }
-    }
-
     /// <summary>
     /// 获取WaveManager相关的中心点
     /// </summary>
@@ -583,7 +588,6 @@
         Vector3 cpos = Vector3.zero;
         return cpos;
     }
-
 
     protected void updateOpponentAgent()
     {
@@ -712,10 +716,10 @@
                     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 (GameUI.instanceExists)
+                        //     GameUI.instance.generateBloodText(fpos, damage);
+                        // else if (EndlessGameUI.instanceExists)
+                        //     EndlessGameUI.instance.generateBloodText(fpos, damage);
                     }
 
                     if (!isDeath && eag.isDead)
@@ -783,10 +787,10 @@
                 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 (GameUI.instanceExists)
+                    //     GameUI.instance.generateBloodText(fpos, damage);
+                    // else if (EndlessGameUI.instanceExists)
+                    //     EndlessGameUI.instance.generateBloodText(fpos, damage);
                 }
 
                 eag.PlayFireSkillHit();
@@ -863,10 +867,10 @@
                 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 (GameUI.instanceExists)
+                    //     GameUI.instance.generateBloodText(fpos, damage);
+                    // else if (EndlessGameUI.instanceExists)
+                    //     EndlessGameUI.instance.generateBloodText(fpos, damage);
                 }
 
                 eag.PlayFireSkillHit();
@@ -914,7 +918,7 @@
             {
                 tower = EndlessGameUI.instance.FindTowerWithGridIdx(i, j);
 
-                if (!tower || !tower.gameObject.activeInHierarchy || tower.attributeId != 109) continue;
+                if (!tower || !tower.gameObject.activeInHierarchy || tower.ElfId != 301) continue;
 
                 if (tower.IsWoodCharge)
                 {
@@ -971,10 +975,10 @@
                     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 (GameUI.instanceExists)
+                        //     GameUI.instance.generateBloodText(fpos, damage);
+                        // else if (EndlessGameUI.instanceExists)
+                        //     EndlessGameUI.instance.generateBloodText(fpos, damage);
                     }
                     if (eag.isDead)
                         ++deathCount;
@@ -1044,13 +1048,13 @@
             Damager damager = ag.GetComponent<Damager>();
             ag.TakeDamage(chainAttackHurt, ag.position, alignment);
             // 处理飘字效果:
-            if ((ag.liveID == tid) && (!ag.opponentAgent))
-            {
-                if (GameUI.instanceExists)
-                    GameUI.instance.generateBloodText(ag.position, chainAttackHurt, false, false);
-                else if (EndlessGameUI.instanceExists)
-                    EndlessGameUI.instance.generateBloodText(ag.position, chainAttackHurt, false, false);
-            }
+            // if ((ag.liveID == tid) && (!ag.opponentAgent))
+            // {
+            //     if (GameUI.instanceExists)
+            //         GameUI.instance.generateBloodText(ag.position, chainAttackHurt);
+            //     else if (EndlessGameUI.instanceExists)
+            //         EndlessGameUI.instance.generateBloodText(ag.position, chainAttackHurt);
+            // }
         }
         listBlood.Clear();
 

--
Gitblit v1.9.1