From adf4e32c75f0886b330c6ad449f6a2a46b3d3771 Mon Sep 17 00:00:00 2001
From: liuzhiwei <liuzhiwei@qq.com>
Date: Fri, 13 Nov 2020 15:25:48 +0800
Subject: [PATCH] Merge branch 'master' of http://172.16.1.52:8090/r/GemBattle into master

---
 Assets/Scripts/UI/FinalPanel/FinalPanel.cs |  128 +++++++++++++++++++++++++++++++++++++++---
 1 files changed, 117 insertions(+), 11 deletions(-)

diff --git a/Assets/Scripts/UI/FinalPanel/FinalPanel.cs b/Assets/Scripts/UI/FinalPanel/FinalPanel.cs
index 2c88ee8..5601b9f 100644
--- a/Assets/Scripts/UI/FinalPanel/FinalPanel.cs
+++ b/Assets/Scripts/UI/FinalPanel/FinalPanel.cs
@@ -1,10 +1,13 @@
-using UnityEngine.UI;
+using System.Collections;
+using UnityEngine.UI;
 using UnityEngine;
 using EnhancedUI;
 using EnhancedUI.EnhancedScroller;
 using TMPro;
 using UnityEngine.SceneManagement;
 using KTGMGemClient;
+using DG.Tweening;
+using System;
 
 public class FinalPanel : MonoBehaviour, IEnhancedScrollerDelegate
 {
@@ -18,20 +21,39 @@
     [SerializeField]
     private Sprite rank_icon_0, rank_icon_1, rank_icon_2;
 
-
     public string endlessGameScene = "Endless";
 
     public string loadingScene = "LoadingScene";
+    Button closeBtn;
     // Start is called before the first frame update
     void Start()
     {
-
-        transform.Find("BackGround").GetComponent<Button>().onClick.AddListener(() =>
+        closeBtn = transform.Find("BackGround").GetComponent<Button>();
+        closeBtn.onClick.AddListener(() =>
         {
             gameObject.SetActive(false);
             GameConfig.NextSceneName = endlessGameScene;
             SceneManager.LoadScene(loadingScene);
         });
+        closeBtn.interactable = false;
+    }
+    Text waveText;
+    GameObject image_HScore;
+    Text scoreText;
+    GameObject image_NewRecord;
+    bool isNewH = false;
+    int hScore;
+    CanvasGroup scrollerCanvasGroup;
+
+    Action playEffectAC = null;
+
+    /// <summary>
+    /// 设置播放胜利特效
+    /// </summary>
+    /// <param name="ac"></param>
+    public void SetPlayEffectAC(Action ac)
+    {
+        playEffectAC = ac;
     }
 
     /// <summary>
@@ -41,26 +63,110 @@
     /// <param name="myScore">789220</param>
     public void SetData(string waveInfo, int myScore)
     {
-        transform.Find("Text_Wave").GetComponent<Text>().text = waveInfo;
-        int hScore = PlayerPrefs.GetInt("GemBattleHScore");
+        hScore = PlayerPrefs.GetInt("GemBattleHScore");
+        scrollerCanvasGroup = transform.Find("Scroller").GetComponent<CanvasGroup>();
         if (myScore > hScore)
         {
             PlayerPrefs.SetInt("GemBattleHScore", myScore);
             hScore = myScore;
+            isNewH = true;
         }
 
-        transform.Find("Text_Score").GetComponent<Text>().text = myScore.ToString();
-        transform.Find("Text_HScore").GetComponent<TextMeshProUGUI>().text = hScore.ToString();
+        transform.Find("Image_HScore/Text_HScore").GetComponent<TextMeshProUGUI>().text = hScore.ToString();
+        image_HScore = transform.Find("Image_HScore").gameObject;
+        image_HScore.SetActive(false);
 
-        scroller = transform.Find("Scroller").GetComponent<EnhancedScroller>();
+        waveText = transform.Find("Text_Wave").GetComponent<Text>();
+        scoreText = transform.Find("Text_Score").GetComponent<Text>();
+        waveText.gameObject.SetActive(false);
+        scoreText.gameObject.SetActive(false);
 
-        scroller.Delegate = this;
+        image_NewRecord = transform.Find("Image_NewRecord").gameObject;
+        image_NewRecord.SetActive(false);
 
-        LoadLargeData(hScore);
+        Transform ts = transform.Find("Images");
+
+        Sequence agentTweenSeq = DOTween.Sequence();
+
+        agentTweenSeq.Append(ts.DOScale(Vector3.one, 0.2f));//变化图片大小
+
+        agentTweenSeq.Append(ts.DOScale(new Vector3(1.7f, 1.7f, 1.7f), 0.2f));//变化图片大小
+        agentTweenSeq.Append(ts.DOScale(Vector3.one, 0.2f));//变化图片大小
+        agentTweenSeq.Append(ts.DOScale(new Vector3(1.2f, 1.2f, 1.2f), 0.2f));//变化图片大小
+        agentTweenSeq.Append(ts.DOScale(Vector3.one, 0.2f));//变化图片大小
+
+        agentTweenSeq.AppendCallback(StartLoadLargeData);
+        agentTweenSeq.Append(DOTween.To(delegate (float value)
+        {
+            var temp = Math.Floor(value);
+            scoreText.text = temp + "";
+        }, 0, myScore, 3.0f));
+
+        agentTweenSeq.AppendCallback(TextDoTweenFinish);
+        agentTweenSeq.Append(waveText.DOText(waveInfo, 0.2f));
     }
 
+    /// <summary>
+    /// 开始展示排行榜
+    /// </summary>
+    protected void StartLoadLargeData()
+    {
+        scoreText.gameObject.SetActive(true);
+        LoadLargeData(hScore);
+        StartCoroutine(PlayerItemDoTween());
+    }
+
+    /// <summary>
+    /// 播放排行榜动效
+    /// </summary>
+    /// <returns></returns>
+    IEnumerator PlayerItemDoTween()
+    {
+        yield return 1f;
+        FinalPanelItem[] allItems = transform.Find("Scroller/Container").GetComponentsInChildren<FinalPanelItem>();
+        for (int i = 0; i < allItems.Length; i++)
+        {
+            allItems[i].SetPos();
+        }
+        yield return new WaitForEndOfFrame();
+        scrollerCanvasGroup.alpha = 1;
+        for (int i = 0; i < allItems.Length; i++)
+        {
+            allItems[i].PlayDoTween(0.1f);
+            yield return new WaitForSeconds(0.1f);
+        }
+        image_HScore.SetActive(true);
+
+        yield break;
+    }
+
+    /// <summary>
+    /// 文字显示结束,显示波次和是否最高记录
+    /// </summary>
+    protected void TextDoTweenFinish()
+    {
+        waveText.gameObject.SetActive(true);
+        if (isNewH)
+        {
+            image_NewRecord.SetActive(true);
+        }
+
+        if (playEffectAC != null)
+        {
+            playEffectAC();
+        }
+
+        closeBtn.interactable = true;
+    }
+
+    /// <summary>
+    /// 生成假排行榜
+    /// </summary>
+    /// <param name="hScore">自身分数</param>
     private void LoadLargeData(int hScore)
     {
+        scroller = transform.Find("Scroller").GetComponent<EnhancedScroller>();
+        scroller.Delegate = this;
         _data = new SmallList<FinalPanelItemData>();
         FinalPanelItemData data;
         int score = 101;

--
Gitblit v1.9.1