From 6bc45c691891dac88bece3483fb6f3cf2d7a00a4 Mon Sep 17 00:00:00 2001
From: wangguan <wangguan@kt007.com>
Date: Wed, 02 Dec 2020 17:48:06 +0800
Subject: [PATCH] Merge branch 'master' of http://172.16.1.52:8090/r/GemBattle

---
 Assets/Scripts/TowerDefense/UI/TextMoveDoTween.cs |  108 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 105 insertions(+), 3 deletions(-)

diff --git a/Assets/Scripts/TowerDefense/UI/TextMoveDoTween.cs b/Assets/Scripts/TowerDefense/UI/TextMoveDoTween.cs
index 6e997f1..380573b 100644
--- a/Assets/Scripts/TowerDefense/UI/TextMoveDoTween.cs
+++ b/Assets/Scripts/TowerDefense/UI/TextMoveDoTween.cs
@@ -1,16 +1,17 @@
 using Core.Utilities;
 using DG.Tweening;
 using System;
-using System.Collections;
-using System.Collections.Generic;
 using TMPro;
-using TowerDefense.UI.HUD;
 using UnityEngine;
 using UnityEngine.UI;
 
 public class TextMoveDoTween : MonoBehaviour
 {
     public TextMeshProUGUI bloodText;
+
+    public Image SlowDownWord;
+
+    public Image CritWord;
 
     // Start is called before the first frame update
     void Start()
@@ -51,6 +52,107 @@
     }
 
     /// <summary>
+    /// 减速飘字
+    /// </summary>
+    /// <param name="x"></param>
+    /// <param name="y"></param>
+    public void FloatSlowDownWord(float x, float y)
+    {
+        // 先设置Text的位置到一个标准位置
+        Vector3 pos = SlowDownWord.transform.position;
+        pos.x = x;
+        pos.y = y;
+        pos.z = 0;
+        SlowDownWord.transform.position = pos;
+
+        Vector3 sval = SlowDownWord.transform.localScale;
+        sval.x = 1.0f;
+        sval.y = 1.0f;
+        sval.z = 1.0f;
+        SlowDownWord.transform.localScale = sval * scaleOffect;
+
+        WordMove(SlowDownWord);
+    }
+
+    public void FloatCritWord(float x, float y)
+    {
+        // 先设置Text的位置到一个标准位置
+        Vector3 pos = CritWord.transform.position;
+        pos.x = x;
+        pos.y = y;
+        pos.z = 0;
+        CritWord.transform.position = pos;
+
+        Vector3 sval = CritWord.transform.localScale;
+        sval.x = 1.0f;
+        sval.y = 1.0f;
+        sval.z = 1.0f;
+        CritWord.transform.localScale = sval * scaleOffect;
+
+        WordMove(CritWord, true);
+    }
+
+    private void WordMove(Graphic graphic, bool crit = false)
+    {
+        //获得Text的rectTransform,和颜色,并设置颜色微透明
+        RectTransform rect = graphic.rectTransform;
+
+        Color color = graphic.color;
+
+        graphic.color = new Color(color.r, color.g, color.b, 0);
+
+        //设置一个DOTween队列
+        Sequence textMoveSequence = DOTween.Sequence();
+
+        System.Random rd = new System.Random();
+
+
+        //设置Text移动和透明度的变化值\
+        float baseTime = 0.3f;
+        if (crit)
+            baseTime = 0.2f;
+        float scaleUp = 1.8f * scaleOffect;
+        if (crit)
+            scaleUp = 2.2f * scaleOffect;
+        float scaleVec = Screen.height / 2400f;
+        int basey = rd.Next((int)(100 * scaleVec), (int)(180 * scaleVec));
+        if (crit)
+            basey = rd.Next((int)(150 * scaleVec), (int)(210 * scaleVec));
+
+        int basex;
+        if (crit)
+            basex = rd.Next(-30, 30);
+        else
+            basex = rd.Next(35, 55);
+
+        Tweener textMove01 = rect.DOMoveY(rect.position.y + basey, baseTime);
+        Tweener textMovex = rect.DOMoveX(rect.position.x + basex, baseTime);
+        Tweener textMove02 = rect.DOMoveY(rect.position.y + basey + (int)(60 * scaleVec), baseTime);
+        Tweener textColor01 = graphic.DOColor(new Color(color.r, color.g, color.b, 1), baseTime);
+        Tweener textColor02 = graphic.DOColor(new Color(color.r, color.g, color.b, 0), baseTime);
+        Tweener textScale = rect.DOScale(scaleUp, 0.25f);
+
+        //Append 追加一个队列,Join 添加一个队列
+        //中间间隔一秒
+        //Append 再追加一个队列,再Join 添加一个队列
+        textMoveSequence.Append(textMove01);
+        textMoveSequence.Join(textMovex);
+        textMoveSequence.Join(textColor01);
+        // 中断一下.   
+        textMoveSequence.AppendInterval(0.3f + (float)rd.NextDouble() * 0.3f);
+        // 向上变大淡出
+        textMoveSequence.Append(textMove02);
+        textMoveSequence.Join(textColor02);
+        textMoveSequence.Join(textScale);
+        textMoveSequence.AppendCallback(DestroyWord);
+    }
+
+    protected void DestroyWord()
+    {
+        Destroy(gameObject);
+    }
+
+    /// <summary>
     /// 清空当前的DoTweenMove数据并把数据放到Pool中.
     /// </summary>
     protected void Remove()

--
Gitblit v1.9.1