From adb0dae8a82a7eabb4e686bc0e83c8859bf6445f Mon Sep 17 00:00:00 2001
From: chenxin <chenxin6991@163.com>
Date: Fri, 25 Dec 2020 10:48:53 +0800
Subject: [PATCH] Merge branch 'master' of http://47.95.218.140:8090/r/GemBattle into master

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

diff --git a/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillBubbleBomb.cs b/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillBubbleBomb.cs
index fdf0bc1..66d576c 100644
--- a/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillBubbleBomb.cs
+++ b/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillBubbleBomb.cs
@@ -1,11 +1,8 @@
-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;
+using TMPro;
 
 /**
  * 泡泡炸弹
@@ -14,6 +11,9 @@
  */
 namespace KTGMGemClient
 {
+    /// <summary>
+    /// 泡泡炸弹配置数据
+    /// </summary>
     public class BubbleBombConfig
     {
         public BubbleBombAgent Agent { get; set; }
@@ -83,10 +83,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 +97,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 +113,6 @@
         {
             base.ReleaseSkill();
             Debug.Log("--------------------- 泡泡炸弹释放 ---------------------");
-            // cx test
             SpawnBubbleBomb();
         }
 
@@ -161,6 +153,7 @@
                 bubbleBomb.AgentType = SpawnAgentType.BubbleBomb;
                 bubbleBomb.opponentAgent = false;
                 bubbleBomb.Reset();
+                bubbleBomb.Initialize();
 
                 // 出生位置
                 Vector3 spawnPosition = EndlessLevelManager.instance.GetTunelWorldPosition(tunelIdList[i], (EndlessBossSkillTunelType)SkillData.target[1]);
@@ -177,40 +170,11 @@
                 config.DestroyTime = bubbleBomb.GetExplodeTime();
                 config.MoveSpeed = SkillData.effect[1];
                 bubbleBombList.Add(config);
+
+                bubbleBomb.Blood.SetPos();
+                bubbleBomb.Blood.SetRemainHitCount(config.NeedAttackCount);
+                bubbleBomb.Blood.ShowBlood();
             }
-        }
-
-        /// <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 +212,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>
@@ -278,6 +233,15 @@
             {
                 GameObject prefab = Resources.Load<GameObject>(prefabPath);
                 ret = GameObject.Instantiate(prefab);
+                BubbleBombAgent agent = ret.GetComponent<BubbleBombAgent>();
+
+                prefab = Resources.Load<GameObject>($"Prefabs/BubbleBombBlood");
+                GameObject bubbleBombBlood = GameObject.Instantiate(prefab);
+                GameObject bloodUI = GameObject.Find("MainUI/BloodUI");
+                bubbleBombBlood.transform.SetParent(bloodUI.transform, false);
+
+                agent.Blood = bubbleBombBlood.GetComponent<BubbleBombBlood>();
+                agent.Blood.Target = agent;
             }
 
             ret.SetActive(true);
@@ -293,6 +257,8 @@
         {
             if (obj != null)
             {
+                BubbleBombAgent agent = obj.GetComponent<BubbleBombAgent>();
+                agent.Blood.HideBlood();
                 obj.SetActive(false);
                 bubbleBombPool.Add(obj);
             }
@@ -307,6 +273,8 @@
             {
                 GameObject obj = bubbleBombPool[0];
                 bubbleBombPool.Remove(obj);
+                BubbleBombAgent agent = obj.GetComponent<BubbleBombAgent>();
+                GameObject.Destroy(agent.Blood.gameObject);
                 GameObject.Destroy(obj);
             }
         }
@@ -337,9 +305,10 @@
                 {
                     BubbleBombConfig config = bubbleBombList[i];
                     // 攻击次数够了被打死了 或者 达到基地了
-                    if (config.Agent.bInDeathState) return;
+                    if (config.IsAttackDeath || config.IsArrived) return;
 
                     ++config.AttackCount;
+                    config.Agent.Blood.SetRemainHitCount(config.NeedAttackCount - config.AttackCount);
 
                     if (config.AttackCount >= config.NeedAttackCount)
                         AgentDead(config);
@@ -361,8 +330,9 @@
                 {
                     BubbleBombConfig config = bubbleBombList[i];
 
-                    if (config.Agent.bInDeathState) return;
+                    if (config.IsAttackDeath || config.IsArrived) return;
 
+                    config.Agent.Blood.HideBlood();
                     AgentDead(config);
                     break;
                 }
@@ -382,7 +352,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 +369,11 @@
         /// <param name="config"></param>
         private void AgentDead(BubbleBombConfig config)
         {
+            config.Agent.Blood.HideBlood();
+            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>
@@ -412,11 +382,11 @@
         /// <param name="config"></param>
         private void AgentArrived(BubbleBombConfig config)
         {
+            config.Agent.Blood.HideBlood();
             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 +397,8 @@
             {
                 BubbleBombConfig config = bubbleBombList[i];
 
+                if (config.Agent == null || config.obj == null) continue;
+
                 // 泡泡炸弹已经触发了攻击,延时一会过后掉爱心
                 if (config.IsAttack)
                 {
@@ -434,9 +406,7 @@
 
                     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);
+                        EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.EndlessLoseHeart, 2);
                         config.IsAttack = false;
                     }
                 }
@@ -473,7 +443,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