| | |
| | | using TMPro; |
| | | using DG.Tweening; |
| | | using Core.Utilities; |
| | | using System.Collections; |
| | | |
| | | /** |
| | | * 无尽模式玩家基地血量管理器 |
| | |
| | | private Image heartImg; |
| | | |
| | | private Timer timer; |
| | | public ParticleSystem loseHeartPS;//心碎特效 |
| | | private GameObject decreaseHeartObj;//掉血显示 |
| | | |
| | | // Start is called before the first frame update |
| | | private void Start() |
| | |
| | | EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.EndlessHeartAllLose); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 丢失爱心飘字 |
| | | /// </summary> |
| | | /// <param name="count"></param> |
| | | private void FloatLoseHeart(int count) |
| | | { |
| | | GameObject prefab = Resources.Load<GameObject>("UI/DecreaseHeart"); |
| | | GameObject obj = Instantiate(prefab); |
| | | obj.transform.SetParent(GameObject.Find("UICamera/BottomCanvas/Panel/Bottom/CurrencyContainer").transform, false); |
| | | obj.transform.localPosition = new Vector3(91.5f, 48.8f, 0f); |
| | | obj.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); |
| | | TextMeshProUGUI textMeshProUGUI = obj.transform.GetChild(0).GetComponent<TextMeshProUGUI>(); |
| | | textMeshProUGUI.text = $"-{count}"; |
| | | DOTween.To( |
| | | () => obj.transform.localPosition.y, |
| | | (float v) => |
| | | { |
| | | Vector3 pos = obj.transform.localPosition; |
| | | pos.y = v; |
| | | obj.transform.localPosition = pos; |
| | | TextMeshProUGUI textMeshProUGUI; |
| | | if (decreaseHeartObj != null) |
| | | { |
| | | textMeshProUGUI = decreaseHeartObj.transform.GetChild(0).GetComponent<TextMeshProUGUI>(); |
| | | textMeshProUGUI.text = int.Parse(textMeshProUGUI.text) - count + ""; |
| | | } |
| | | else |
| | | { |
| | | GameObject prefab = Resources.Load<GameObject>("UI/DecreaseHeart"); |
| | | GameObject obj = Instantiate(prefab); |
| | | obj.transform.SetParent(GameObject.Find("UICamera/BottomCanvas/Panel/Bottom/CurrencyContainer").transform, false); |
| | | obj.transform.localPosition = new Vector3(91.5f, 48.8f, 0f); |
| | | obj.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); |
| | | |
| | | }, 70.9f, 0.3f); |
| | | Destroy(obj, 0.6f); |
| | | decreaseHeartObj = obj; |
| | | |
| | | textMeshProUGUI = obj.transform.GetChild(0).GetComponent<TextMeshProUGUI>(); |
| | | textMeshProUGUI.text = $"-{count}"; |
| | | DOTween.To( |
| | | () => obj.transform.localPosition.y, |
| | | (float v) => |
| | | { |
| | | Vector3 pos = obj.transform.localPosition; |
| | | pos.y = v; |
| | | obj.transform.localPosition = pos; |
| | | |
| | | }, 70.9f, 0.3f); |
| | | StartCoroutine(DestroyDecreaseHeart()); |
| | | } |
| | | |
| | | //Destroy(obj, 0.6f); |
| | | } |
| | | |
| | | IEnumerator DestroyDecreaseHeart() |
| | | { |
| | | yield return new WaitForSeconds(0.6f); |
| | | Destroy(decreaseHeartObj); |
| | | decreaseHeartObj = null; |
| | | } |
| | | |
| | | private void PlayLoseHeartEffect() |
| | |
| | | if (!isPlayLoseHeartDone) return; |
| | | |
| | | heartImg.enabled = false; |
| | | GameObject obj = Instantiate(loseHeartPrefab); |
| | | obj.transform.SetParent(GameObject.Find("ParticleSystemObject").transform, false); |
| | | obj.transform.localPosition = new Vector3(-27.93f, 0f, -51.52f); |
| | | obj.transform.localScale = new Vector3(0.9f, 0.9f, 0.9f); |
| | | ParticleSystem ps = obj.transform.GetChild(0).GetComponent<ParticleSystem>(); |
| | | ps?.Play(); |
| | | // GameObject obj = Instantiate(loseHeartPrefab); |
| | | // obj.transform.SetParent(GameObject.Find("ParticleSystemObject").transform, false); |
| | | // obj.transform.localPosition = new Vector3(-27.93f, 0f, -51.52f); |
| | | // obj.transform.localScale = new Vector3(0.9f, 0.9f, 0.9f); |
| | | // ParticleSystem ps = obj.transform.GetChild(0).GetComponent<ParticleSystem>(); |
| | | |
| | | loseHeartPS?.Play(); |
| | | timer = new Timer(0.6f, SpawnHeart); |
| | | } |
| | | |