| | |
| | | using TowerDefense.UI.HUD; |
| | | using Core.Utilities; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using TowerDefense.Agents; |
| | | using TowerDefense.Level; |
| | | using TMPro; |
| | | |
| | | /** |
| | | * 泡泡炸弹 |
| | |
| | | /// </summary> |
| | | protected List<GameObject> bubbleBombPool; |
| | | |
| | | protected int capacity = 10; |
| | | |
| | | private int getCount; |
| | | |
| | | private int recycleCount; |
| | |
| | | config.DestroyTime = bubbleBomb.GetExplodeTime(); |
| | | config.MoveSpeed = SkillData.effect[1]; |
| | | bubbleBombList.Add(config); |
| | | |
| | | bubbleBomb.Blood.SetPos(); |
| | | bubbleBomb.Blood.SetRemainHitCount(config.NeedAttackCount); |
| | | bubbleBomb.Blood.ShowBlood(); |
| | | } |
| | | } |
| | | |
| | |
| | | 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> |
| | |
| | | { |
| | | 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); |
| | |
| | | { |
| | | if (obj != null) |
| | | { |
| | | BubbleBombAgent agent = obj.GetComponent<BubbleBombAgent>(); |
| | | agent.Blood.HideBlood(); |
| | | obj.SetActive(false); |
| | | bubbleBombPool.Add(obj); |
| | | } |
| | |
| | | { |
| | | GameObject obj = bubbleBombPool[0]; |
| | | bubbleBombPool.Remove(obj); |
| | | BubbleBombAgent agent = obj.GetComponent<BubbleBombAgent>(); |
| | | GameObject.Destroy(agent.Blood.gameObject); |
| | | GameObject.Destroy(obj); |
| | | } |
| | | } |
| | |
| | | { |
| | | 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} ---------------------"); |
| | | config.Agent.Blood.SetRemainHitCount(config.NeedAttackCount - config.AttackCount); |
| | | |
| | | if (config.AttackCount >= config.NeedAttackCount) |
| | | AgentDead(config); |
| | |
| | | { |
| | | BubbleBombConfig config = bubbleBombList[i]; |
| | | |
| | | if (config.Agent.bInDeathState) return; |
| | | if (config.IsAttackDeath || config.IsArrived) return; |
| | | |
| | | config.Agent.Blood.HideBlood(); |
| | | AgentDead(config); |
| | | break; |
| | | } |
| | |
| | | { |
| | | BubbleBombConfig config = bubbleBombList[i]; |
| | | |
| | | if (config.Agent.bInDeathState) return; |
| | | if (config.IsAttackDeath || config.IsArrived) return; |
| | | |
| | | config.IsDizzinessed = true; |
| | | config.Agent.CanMove = false; |
| | |
| | | /// <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> |
| | |
| | | /// <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) |
| | |
| | | for (int i = 0; i < bubbleBombList.Count; ++i) |
| | | { |
| | | BubbleBombConfig config = bubbleBombList[i]; |
| | | |
| | | if (config.Agent == null || config.obj == null) continue; |
| | | |
| | | // 泡泡炸弹已经触发了攻击,延时一会过后掉爱心 |
| | | if (config.IsAttack) |
| | |
| | | } |
| | | |
| | | // 更新移动 |
| | | 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; |