| | |
| | | using UnityEngine.UI; |
| | | using DG.Tweening; |
| | | using KTGMGemClient; |
| | | using KTGMGemClient; |
| | | using System; |
| | | using ActionGameFramework.Health; |
| | | using Core.Utilities; |
| | |
| | | using TowerDefense.UI.HUD; |
| | | using UnityEngine; |
| | | using TowerDefense.Agents; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | |
| | | namespace TowerDefense.Towers |
| | | { |
| | |
| | | /// </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) |
| | |
| | | /// </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(GameObject.Find("MainUI/CoinPanel").transform, false); |
| | | Vector3 worldPos = TowerPlacementGridEndless.instance.GetGridWorldPos(gridPosition.x, gridPosition.y); |
| | | Camera camera = GameObject.Find("SceneCamera3D").GetComponent<Camera>(); |
| | | Vector3 screenPos = camera.WorldToScreenPoint(worldPos); |
| | | screenPos.z = 0; |
| | | screenPos.x += 100; |
| | | screenPos.y += 85; |
| | | tapObj.transform.position = screenPos; |
| | | tapObj.transform.localScale = new Vector3(0.6f, 0.6f, 0.6f); |
| | | |
| | | DOTween.To(() => tapObj.transform.localScale, (Vector3 v) => tapObj.transform.localScale = v, new Vector3(1f, 1f, 1f), 0.3f).SetEase(Ease.OutBack); |
| | | 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 = 13f; |
| | | tapObj.transform.position = pos; |
| | | ps?.Play(); |
| | | } |
| | | |
| | | private void HideTapPrompt() |
| | | { |
| | | if (tapObj != null) |
| | | { |
| | | Image img = tapObj.GetComponent<Image>(); |
| | | DOTween.To(() => img.color, (Color v) => img.color = v, new Color(1f, 1f, 1f, 0f), 0.3f).OnComplete(() => |
| | | { |
| | | if (tapObj != null) |
| | | { |
| | | Destroy(tapObj); |
| | | 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 (!IsBondage || BondageWarningTime > 0) return; |
| | | if (!IsStartBondage || BondageWarningTime > 0) return; |
| | | |
| | | ++BondageTapCount; |
| | | |
| | | if (BondageTapCount == 1) |
| | | if (BondageTapCount >= 3) |
| | | HideTapPrompt(); |
| | | BondageTime -= BondageClickDecreaseTime; |
| | | } |
| | |
| | | GameObject prefab = Resources.Load<GameObject>("Prefabs/Endless/BondageBubbleBomb"); |
| | | GameObject obj = Instantiate(prefab); |
| | | obj.transform.SetParent(TowerPlacementGridEndless.instance.GridContainer.transform, false); |
| | | obj.transform.position = TowerPlacementGridEndless.instance.GetGridWorldPos(gridPosition.x, gridPosition.y); |
| | | obj.transform.position = transform.position; |
| | | obj.transform.GetChild(0).GetComponent<ParticleSystem>().Play(); |
| | | Destroy(obj, 1.2f); |
| | | } |
| | |
| | | /// </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 = TowerPlacementGridEndless.instance.GetGridWorldPos(gridPosition.x, gridPosition.y); |
| | | 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(); |
| | | } |
| | | |