| | |
| | | using TowerDefense.UI.HUD; |
| | | using UnityEngine; |
| | | using TowerDefense.Agents; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | |
| | | namespace TowerDefense.Towers |
| | | { |
| | |
| | | /// <summary> |
| | | /// The current level of the tower |
| | | /// </summary> |
| | | public int currentLevel { get; protected set; } |
| | | public int currentLevel { get; set; } |
| | | |
| | | protected bool m_bInAttackMode = false; |
| | | |
| | |
| | | public int FreezeBreathProgressOffset { get; set; } |
| | | |
| | | public bool PlayWaveLineFlash { get; set; } = true; |
| | | |
| | | private bool isBondage; |
| | | |
| | | /// <summary> |
| | | /// 是否是泡泡禁锢状态 |
| | | /// </summary> |
| | | /// <value></value> |
| | | public bool IsBondage |
| | | { |
| | | get { return isBondage; } |
| | | set |
| | | { |
| | | isBondage = value; |
| | | CanAttack = !value; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 禁锢时间 |
| | | /// </summary> |
| | | public float BondageTime { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 禁锢警告时间 |
| | | /// </summary> |
| | | /// <value></value> |
| | | public float BondageWarningTime { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 泡泡禁锢期间,点击一次减少的时间 |
| | | /// </summary> |
| | | public float BondageClickDecreaseTime { get; set; } = 1f; |
| | | |
| | | /// <summary> |
| | | /// 是否是木属性蓄力状态 |
| | |
| | | /// 是否是对手塔防 |
| | | /// </summary> |
| | | public bool opponentSide { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 禁锢警告 |
| | | /// </summary> |
| | | protected GameObject bondageWarningObj; |
| | | |
| | | /// <summary> |
| | | /// 禁锢泡泡 |
| | | /// </summary> |
| | | protected GameObject bondageObj; |
| | | |
| | | private GameObject tapObj; |
| | | |
| | | /// <summary> |
| | | /// 精灵被禁锢时点击次数 |
| | | /// </summary> |
| | | public int BondageTapCount { get; private set; } |
| | | |
| | | /// <summary> |
| | | /// 泡泡上升高度 |
| | | /// </summary> |
| | | private float yAdd = 10f; |
| | | |
| | | /// <summary> |
| | | /// 原始y值 |
| | | /// </summary> |
| | | private float originY; |
| | | |
| | | /// <summary> |
| | | /// 是否开始禁锢 |
| | | /// </summary> |
| | | public bool IsStartBondage { get; set; } |
| | | |
| | | private float bombDuration = 0.7f; |
| | | |
| | | private float bombTime; |
| | | |
| | | /// <summary> |
| | | /// 爆炸是否结束 |
| | | /// </summary> |
| | | private bool isBombCompleted; |
| | | |
| | | private void Start() |
| | | { |
| | | originY = transform.position.y; |
| | | promptDic = new Dictionary<string, bool>(); |
| | | } |
| | | |
| | | private void Update() |
| | | { |
| | | HandleBondageBubble(); |
| | | } |
| | | |
| | | private static Dictionary<string, bool> promptDic; |
| | | |
| | | /// <summary> |
| | | /// 处理禁锢泡泡技能 |
| | | /// </summary> |
| | | private void HandleBondageBubble() |
| | | { |
| | | if (IsStartBondage) |
| | | { |
| | | if (isBondage) |
| | | { |
| | | if (transform.position.y < yAdd + originY && bondageObj != null) |
| | | { |
| | | // 上升状态 |
| | | Vector3 pos = transform.position; |
| | | pos.y += 28f * Time.deltaTime; |
| | | transform.position = pos; |
| | | |
| | | pos = bondageObj.transform.position; |
| | | pos.y += 28f * Time.deltaTime; |
| | | bondageObj.transform.position = pos; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (!isBombCompleted) |
| | | { |
| | | bombTime += Time.deltaTime; |
| | | |
| | | if (bombTime > bombDuration) |
| | | { |
| | | // 爆炸结束开始下降 |
| | | isBombCompleted = true; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (transform.position.y > originY) |
| | | { |
| | | // 下降状态 |
| | | Vector3 pos = transform.position; |
| | | pos.y -= 55f * Time.deltaTime; |
| | | transform.position = pos; |
| | | } |
| | | else |
| | | { |
| | | // 下降结束 |
| | | IsStartBondage = false; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!IsBondage) return; |
| | | |
| | | if (BondageWarningTime > 0) |
| | | { |
| | | BondageWarningTime -= Time.deltaTime; |
| | | |
| | | if (BondageWarningTime <= 0) |
| | | { |
| | | DestroyBondageWarningObj(); |
| | | StartBondage(); |
| | | ShowTapPrompt(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | BondageTime -= Time.deltaTime; |
| | | |
| | | if (BondageTime <= 0) |
| | | { |
| | | DestroyBondageWarningObj(); |
| | | HideTapPrompt(); |
| | | IsBondage = false; |
| | | Destroy(bondageObj); |
| | | bondageObj = null; |
| | | BondageBubbleBomb(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void DestroyBondageWarningObj() |
| | | { |
| | | if (bondageWarningObj == null) return; |
| | | |
| | | ParticleSystem ps = bondageWarningObj.transform.GetChild(0).GetComponent<ParticleSystem>(); |
| | | ps.Stop(); |
| | | ps.Clear(); |
| | | Destroy(bondageWarningObj); |
| | | bondageWarningObj = null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 展示连续点击提示 |
| | | /// </summary> |
| | | private void ShowTapPrompt() |
| | | { |
| | | string key = $"{gridPosition.x}"; |
| | | if (promptDic.ContainsKey(key)) return; |
| | | |
| | | promptDic.Add(key, true); |
| | | GameObject prefab = Resources.Load<GameObject>("Prefabs/Endless/BondageBubbleTap"); |
| | | tapObj = Instantiate(prefab); |
| | | tapObj.transform.SetParent(TowerPlacementGridEndless.instance.GridContainer.transform, false); |
| | | Vector3 worldPos = TowerPlacementGridEndless.instance.GetGridWorldPos(gridPosition.x, 3); |
| | | ParticleSystem ps = tapObj.transform.GetChild(0).GetComponent<ParticleSystem>(); |
| | | tapObj.transform.position = worldPos; |
| | | Vector3 pos = tapObj.transform.position; |
| | | pos.x += 5.8f; |
| | | pos.z += 3f; |
| | | pos.y = 20f; |
| | | tapObj.transform.position = pos; |
| | | ps?.Play(); |
| | | } |
| | | |
| | | private void HideTapPrompt() |
| | | { |
| | | if (tapObj != null) |
| | | { |
| | | ParticleSystem ps = tapObj.transform.GetChild(0).GetComponent<ParticleSystem>(); |
| | | ps?.Stop(); |
| | | Destroy(tapObj); |
| | | tapObj = null; |
| | | |
| | | string key = $"{gridPosition.x}"; |
| | | if (promptDic.ContainsKey(key)) |
| | | promptDic.Remove(key); |
| | | } |
| | | } |
| | | |
| | | public void OnPressed() |
| | | { |
| | | if (!IsStartBondage || BondageWarningTime > 0) return; |
| | | |
| | | ++BondageTapCount; |
| | | |
| | | if (BondageTapCount >= 3) |
| | | HideTapPrompt(); |
| | | BondageTime -= BondageClickDecreaseTime; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 禁锢泡泡爆炸 |
| | | /// </summary> |
| | | private void BondageBubbleBomb() |
| | | { |
| | | GameObject prefab = Resources.Load<GameObject>("Prefabs/Endless/BondageBubbleBomb"); |
| | | GameObject obj = Instantiate(prefab); |
| | | obj.transform.SetParent(TowerPlacementGridEndless.instance.GridContainer.transform, false); |
| | | obj.transform.position = transform.position; |
| | | obj.transform.GetChild(0).GetComponent<ParticleSystem>().Play(); |
| | | Destroy(obj, 1.2f); |
| | | AudioSourceManager.Ins.StopBossWaterSkill(); |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 开始泡泡禁锢 |
| | | /// </summary> |
| | | private void StartBondage() |
| | | { |
| | | bombTime = 0; |
| | | BondageTapCount = 0; |
| | | isBombCompleted = false; |
| | | GameObject prefab = Resources.Load<GameObject>("Prefabs/Endless/BondageBubble"); |
| | | bondageObj = Instantiate(prefab); |
| | | bondageObj.transform.SetParent(TowerPlacementGridEndless.instance.GridContainer.transform, false); |
| | | bondageObj.transform.position = transform.position; |
| | | Vector3 pos = bondageObj.transform.position; |
| | | pos.y += gridPosition.y == 3 ? 2f : 1f; |
| | | bondageObj.transform.position = pos; |
| | | bondageObj.transform.GetChild(0).GetComponent<ParticleSystem>().Play(); |
| | | AudioSourceManager.Ins.Play(AudioEnum.BossWaterSkill); |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 禁锢警告 |
| | | /// </summary> |
| | | /// <param name="tower"></param> |
| | | public void BondageWarning() |
| | | { |
| | | GameObject prefab = Resources.Load<GameObject>("Prefabs/Endless/BondageBubbleWarning"); |
| | | bondageWarningObj = Instantiate(prefab); |
| | | bondageWarningObj.transform.SetParent(TowerPlacementGridEndless.instance.GridContainer.transform, false); |
| | | bondageWarningObj.transform.position = TowerPlacementGridEndless.instance.GetGridWorldPos(gridPosition.x, gridPosition.y); |
| | | bondageWarningObj.transform.GetChild(0).GetComponent<ParticleSystem>().Play(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 播放充能状态特效. |
| | |
| | | CurrentTowerLevel.Initialize(this, enemyLayerMask, configuration.alignmentProvider); |
| | | CurrentTowerLevel.SetShowLevel(level + 1); |
| | | |
| | | //if(gridPosition.y>=2) |
| | | { |
| | | //Debug.Log("上阵状态,设置缩放"); |
| | | CurrentTowerLevel.SetScale(level + 1); |
| | | } |
| | | |
| | | // disable affectors |
| | | LevelState levelState = LevelState.Intro; |
| | | if (LevelManager.instanceExists) |