| | |
| | | using KTGMGemClient; |
| | | using UnityEngine.UI; |
| | | using DG.Tweening; |
| | | using KTGMGemClient; |
| | | using System; |
| | | using ActionGameFramework.Health; |
| | | using Core.Utilities; |
| | |
| | | |
| | | 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; } |
| | | |
| | | private void Update() |
| | | { |
| | | HandleBondageBubble(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 处理禁锢泡泡技能 |
| | | /// </summary> |
| | | private void HandleBondageBubble() |
| | | { |
| | | if (!IsBondage) return; |
| | | |
| | | if (BondageWarningTime > 0) |
| | | { |
| | | BondageWarningTime -= Time.deltaTime; |
| | | |
| | | if (BondageWarningTime <= 0) |
| | | { |
| | | Destroy(bondageWarningObj); |
| | | bondageWarningObj = null; |
| | | StartBondage(); |
| | | ShowTapPrompt(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | BondageTime -= Time.deltaTime; |
| | | |
| | | if (BondageTime <= 0) |
| | | { |
| | | IsBondage = false; |
| | | Destroy(bondageObj); |
| | | bondageObj = null; |
| | | BondageBubbleBomb(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 展示连续点击提示 |
| | | /// </summary> |
| | | private void ShowTapPrompt() |
| | | { |
| | | 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); |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | public void OnPressed() |
| | | { |
| | | if (!IsBondage || BondageWarningTime > 0) return; |
| | | |
| | | ++BondageTapCount; |
| | | |
| | | if (BondageTapCount == 1) |
| | | 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 = TowerPlacementGridEndless.instance.GetGridWorldPos(gridPosition.x, gridPosition.y); |
| | | obj.transform.GetChild(0).GetComponent<ParticleSystem>().Play(); |
| | | Destroy(obj, 1.2f); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 开始泡泡禁锢 |
| | | /// </summary> |
| | | private void StartBondage() |
| | | { |
| | | BondageTapCount = 0; |
| | | 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.GetChild(0).GetComponent<ParticleSystem>().Play(); |
| | | } |
| | | |
| | | /// <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> |
| | | /// 播放充能状态特效. |
| | | /// </summary> |
| | | /// <param name="play"></param> |