From c49c0e39e4c11a438014a0b0732ecf0968fceb5e Mon Sep 17 00:00:00 2001
From: chenxin <chenxin6991@163.com>
Date: Fri, 27 Nov 2020 20:58:36 +0800
Subject: [PATCH] 出二级宝石的时间不对的bug

---
 Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillBubbleBomb.cs |   38 +++++++++++---------------------------
 1 files changed, 11 insertions(+), 27 deletions(-)

diff --git a/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillBubbleBomb.cs b/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillBubbleBomb.cs
index 5eb9475..8ac98e2 100644
--- a/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillBubbleBomb.cs
+++ b/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillBubbleBomb.cs
@@ -101,8 +101,6 @@
         /// </summary>
         protected List<GameObject> bubbleBombPool;
 
-        protected int capacity = 10;
-
         private int getCount;
 
         private int recycleCount;
@@ -209,18 +207,9 @@
         public override void Init()
         {
             base.Init();
-            Debug.Log("--------------------- 泡泡炸弹技能初始化 ---------------------");
+            Debug.Log("---- 泡泡炸弹技能初始化 ----");
             bubbleBombList = new List<BubbleBombConfig>();
             bubbleBombPool = new List<GameObject>();
-
-            GameObject prefab = Resources.Load<GameObject>(prefabPath);
-
-            for (int i = 0; i < capacity; ++i)
-            {
-                GameObject obj = GameObject.Instantiate(prefab);
-                obj.SetActive(false);
-                bubbleBombPool.Add(obj);
-            }
         }
 
         /// <summary>
@@ -298,10 +287,10 @@
                 {
                     BubbleBombConfig config = bubbleBombList[i];
                     // 攻击次数够了被打死了 或者 达到基地了
-                    if (config.Agent.bInDeathState) return;
+                    if (config.IsAttackDeath || config.IsArrived) return;
 
                     ++config.AttackCount;
-                    Debug.Log($"--------------------- BubbleBombAgent Id: {id}, AttackCount:{config.AttackCount} ---------------------");
+                    Debug.Log($"---- BubbleBombAgent Id: {id}, AttackCount: {config.AttackCount} ----");
 
                     if (config.AttackCount >= config.NeedAttackCount)
                         AgentDead(config);
@@ -323,7 +312,7 @@
                 {
                     BubbleBombConfig config = bubbleBombList[i];
 
-                    if (config.Agent.bInDeathState) return;
+                    if (config.IsAttackDeath || config.IsArrived) return;
 
                     AgentDead(config);
                     break;
@@ -344,7 +333,7 @@
                 {
                     BubbleBombConfig config = bubbleBombList[i];
 
-                    if (config.Agent.bInDeathState) return;
+                    if (config.IsAttackDeath || config.IsArrived) return;
 
                     config.IsDizzinessed = true;
                     config.Agent.CanMove = false;
@@ -361,11 +350,10 @@
         /// <param name="config"></param>
         private void AgentDead(BubbleBombConfig config)
         {
+            config.IsAttackDeath = true;
+            AgentInsManager.instance.removeAgent(config.Agent);
             config.Agent.StopNormalEffect();
             config.Agent.PlayExplodeEffect();
-            AgentInsManager.instance.removeAgent(config.Agent);
-            config.Agent.bInDeathState = true;
-            config.IsAttackDeath = true;
         }
 
         /// <summary>
@@ -375,10 +363,9 @@
         private void AgentArrived(BubbleBombConfig config)
         {
             config.IsArrived = true;
+            AgentInsManager.instance.removeAgent(config.Agent);
             config.Agent.StopNormalEffect();
             config.Agent.PlayExplodeEffect();
-            AgentInsManager.instance.removeAgent(config.Agent);
-            config.Agent.bInDeathState = true;
         }
 
         public override void Update(float deltaTime)
@@ -388,6 +375,8 @@
             for (int i = 0; i < bubbleBombList.Count; ++i)
             {
                 BubbleBombConfig config = bubbleBombList[i];
+
+                if (config.Agent == null || config.obj == null) continue;
 
                 // 泡泡炸弹已经触发了攻击,延时一会过后掉爱心
                 if (config.IsAttack)
@@ -433,7 +422,7 @@
                 }
 
                 // 更新移动
-                if (config.Agent != null && !config.Agent.bInDeathState && config.Agent.CanMove)
+                if (config.Agent != null && config.Agent.CanMove)
                 {
                     Vector3 pos = config.obj.transform.position;
                     pos.z -= deltaTime * config.MoveSpeed;
@@ -445,11 +434,6 @@
                         config.IsAttack = true;
                         config.AttackTime = 0.65f;
                     }
-                }
-                else
-                {
-                    // cx test
-                    Debug.Log("--------------------- 泡泡炸弹不能移动 ---------------------");
                 }
             }
         }

--
Gitblit v1.9.1