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 |   83 ++++++++---------------------------------
 1 files changed, 16 insertions(+), 67 deletions(-)

diff --git a/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillBubbleBomb.cs b/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillBubbleBomb.cs
index fdf0bc1..8ac98e2 100644
--- a/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillBubbleBomb.cs
+++ b/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillBubbleBomb.cs
@@ -1,11 +1,7 @@
-using TowerDefense.UI.HUD;
-using Core.Utilities;
 using System.Collections.Generic;
 using UnityEngine;
 using TowerDefense.Agents;
 using TowerDefense.Level;
-using DG.Tweening;
-using MoreMountains.NiceVibrations;
 
 /**
  * 泡泡炸弹
@@ -14,6 +10,9 @@
  */
 namespace KTGMGemClient
 {
+    /// <summary>
+    /// 泡泡炸弹配置数据
+    /// </summary>
     public class BubbleBombConfig
     {
         public BubbleBombAgent Agent { get; set; }
@@ -83,10 +82,7 @@
 
     public class BossSkillBubbleBomb : EndlessBossSkill
     {
-        public BossSkillBubbleBomb(boss_skill param) : base(param)
-        {
-            random = new System.Random();
-        }
+        public BossSkillBubbleBomb(boss_skill param) : base(param) { }
 
         /// <summary>
         /// 被攻击的次数
@@ -100,14 +96,10 @@
         /// </summary>
         protected List<BubbleBombConfig> bubbleBombList;
 
-        protected System.Random random;
-
         /// <summary>
         /// 泡泡炸弹对象池
         /// </summary>
         protected List<GameObject> bubbleBombPool;
-
-        protected int capacity = 10;
 
         private int getCount;
 
@@ -120,7 +112,6 @@
         {
             base.ReleaseSkill();
             Debug.Log("--------------------- 泡泡炸弹释放 ---------------------");
-            // cx test
             SpawnBubbleBomb();
         }
 
@@ -161,6 +152,7 @@
                 bubbleBomb.AgentType = SpawnAgentType.BubbleBomb;
                 bubbleBomb.opponentAgent = false;
                 bubbleBomb.Reset();
+                bubbleBomb.Initialize();
 
                 // 出生位置
                 Vector3 spawnPosition = EndlessLevelManager.instance.GetTunelWorldPosition(tunelIdList[i], (EndlessBossSkillTunelType)SkillData.target[1]);
@@ -178,39 +170,6 @@
                 config.MoveSpeed = SkillData.effect[1];
                 bubbleBombList.Add(config);
             }
-        }
-
-        /// <summary>
-        /// 获取赛道列表
-        /// </summary>
-        protected List<int> GetTunelList()
-        {
-            List<int> tunelIdList = new List<int>();
-            int count = 0;
-            // 剩余没有用到的赛道
-            List<int> remainList = new List<int>() { 1, 2, 3, 4, 5 };
-
-            for (int i = 0; i < SkillData.tunnel.Count; ++i)
-            {
-                // 统计6这种类型的数量
-                if (SkillData.tunnel[i] == 6)
-                {
-                    ++count;
-                    continue;
-                }
-
-                tunelIdList.Add(SkillData.tunnel[i]);
-                remainList.Remove(SkillData.tunnel[i]);
-            }
-
-            for (int i = 0; i < count; ++i)
-            {
-                int num = random.Next(remainList.Count);
-                tunelIdList.Add(remainList[num]);
-                remainList.Remove(remainList[num]);
-            }
-
-            return tunelIdList;
         }
 
         public override void Reset()
@@ -248,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>
@@ -337,9 +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} ----");
 
                     if (config.AttackCount >= config.NeedAttackCount)
                         AgentDead(config);
@@ -361,7 +312,7 @@
                 {
                     BubbleBombConfig config = bubbleBombList[i];
 
-                    if (config.Agent.bInDeathState) return;
+                    if (config.IsAttackDeath || config.IsArrived) return;
 
                     AgentDead(config);
                     break;
@@ -382,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;
@@ -399,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>
@@ -413,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)
@@ -427,6 +376,8 @@
             {
                 BubbleBombConfig config = bubbleBombList[i];
 
+                if (config.Agent == null || config.obj == null) continue;
+
                 // 泡泡炸弹已经触发了攻击,延时一会过后掉爱心
                 if (config.IsAttack)
                 {
@@ -435,8 +386,6 @@
                     if (config.AttackTime <= 0)
                     {
                         EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.EndlessLoseHeart, 3);
-                        ViewPortAdj.instance.cachedCamera.DOShakePosition(0.25f, 1.5f, 4);
-                        MMVibrationManager.Haptic(HapticTypes.HeavyImpact);
                         config.IsAttack = false;
                     }
                 }
@@ -473,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;

--
Gitblit v1.9.1