From ae487b742c792c43b81cce6f060b881e5609d160 Mon Sep 17 00:00:00 2001
From: liuzhiwei <liuzhiwei@qq.com>
Date: Tue, 08 Dec 2020 11:48:26 +0800
Subject: [PATCH] Merge branch 'master' of http://172.16.1.52:8090/r/GemBattle into master

---
 Assets/Scripts/UI/FinalPanel/FinalPanel.cs |  247 ++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 192 insertions(+), 55 deletions(-)

diff --git a/Assets/Scripts/UI/FinalPanel/FinalPanel.cs b/Assets/Scripts/UI/FinalPanel/FinalPanel.cs
index aae1a65..14e3b1e 100644
--- a/Assets/Scripts/UI/FinalPanel/FinalPanel.cs
+++ b/Assets/Scripts/UI/FinalPanel/FinalPanel.cs
@@ -26,6 +26,7 @@
         closeBtn = transform.Find("BackGround").GetComponent<Button>();
         closeBtn.onClick.AddListener(() =>
         {
+            goonText.DOKill();
             gameObject.SetActive(false);
             GameConfig.NextSceneName = endlessGameScene;
             SceneManager.LoadScene(loadingScene);
@@ -38,24 +39,24 @@
     Text scoreText;
     GameObject image_NewRecord;
     bool isNewH = false;
-    int hScore;
+    int hScore;//最高分
+    int tmpRank;//当前排名
+    int tmpRankUp;//排名上升了多少
+    //string hwaveInfo;
+
     CanvasGroup scrollerCanvasGroup;
     CanvasGroup itemCanvasGroup;
 
-    Action playEffectAC = null;
+    ParticleSystem endPs;//最终特效
 
+    string playerPrefs_HScore = "GemBattleHScore";
+    //string playerPrefs_HWaveInfo = "GemBattleHWaveInfo";
+    string playerPrefs_HRank = "GemBattleHRank";
 
-    /// <summary>
-    /// 设置播放胜利特效
-    /// </summary>
-    /// <param name="ac"></param>
-    public void SetPlayEffectAC(Action ac)
-    {
-        playEffectAC = ac;
-    }
+    string playerPrefs_NickName = "GemBattlePlayerNickName";
 
     string _waveInfo;
-    int _myScore;
+    int _myScore;//本次
     FinalHttp finalHttp;
     string playerNickName;
     int _limit;
@@ -66,26 +67,40 @@
     FinalPanelItem itemThird;//第三
     Text txt_Name, txt_Wave;
     TextMeshProUGUI txt_HScore, txt_Index;
+
+    TextMeshProUGUI rankUpbj;
+    GameObject newPlayerImage;//新用户提示
+    GameObject httpCountDownPanel;
+    Text goonText;
+
     /// <summary>
     /// 入口函数
     /// </summary>
-    /// <param name="waveInfo">成绩 25关 3波</param>
+    /// <param name="waveInfo">25关 3波</param>
     /// <param name="myScore">789220</param>
     public void SetData(string waveInfo, int myScore)
     {
         _waveInfo = waveInfo;
         _myScore = myScore;
+        isFirstStart = true;//首次启动下载到数据执行动效
+        _data = new SmallList<FinalPanelItemData>();
+        Debug.Log($"_myScore:{_myScore}  _waveInfo:{_waveInfo}");
 
-        hScore = PlayerPrefs.GetInt("GemBattleHScore");
+        hScore = PlayerPrefs.GetInt(playerPrefs_HScore);
+        tmpRank = PlayerPrefs.GetInt(playerPrefs_HRank);
+        tmpRankUp = 0;
+        //hwaveInfo = PlayerPrefs.GetString(playerPrefs_HWaveInfo);
         scrollerCanvasGroup = transform.Find("Scroller").GetComponent<CanvasGroup>();
         scrollerCanvasGroup.alpha = 0;
         itemCanvasGroup = transform.Find("ItemPanel").GetComponent<CanvasGroup>();
         itemCanvasGroup.alpha = 0;
 
-        if (myScore > hScore)
+        if (myScore > hScore)//得分比记录的高
         {
-            PlayerPrefs.SetInt("GemBattleHScore", myScore);
+            PlayerPrefs.SetInt(playerPrefs_HScore, myScore);
+            //PlayerPrefs.SetString(playerPrefs_HWaveInfo, waveInfo);
             hScore = myScore;
+            //hwaveInfo = waveInfo;
             isNewH = true;
         }
 
@@ -105,7 +120,7 @@
         scoreText.text = "";
         waveText.text = "";
         waveText.gameObject.SetActive(false);
-        scoreText.gameObject.SetActive(false);
+        //scoreText.gameObject.SetActive(false);
 
         image_NewRecord = transform.Find("Image_NewRecord").gameObject;
         image_NewRecord.SetActive(false);
@@ -115,13 +130,24 @@
         _limitUp = 100;
         finalHttp.Init(GetHttpData, _limit);//重置状态,设置回调和拉取的所有数据
 
-        itemFirst = transform.Find("ItemPanel/FinalPanelItemFirst").GetComponent<FinalPanelItem>();
-        itemSecond = transform.Find("ItemPanel/FinalPanelItemSecond").GetComponent<FinalPanelItem>();
-        itemThird = transform.Find("ItemPanel/FinalPanelItemThird").GetComponent<FinalPanelItem>();
+        itemFirst = transform.Find("ItemPanel/ItemMask/FinalPanelItemFirst").GetComponent<FinalPanelItem>();
+        itemSecond = transform.Find("ItemPanel/ItemMask/FinalPanelItemSecond").GetComponent<FinalPanelItem>();
+        itemThird = transform.Find("ItemPanel/ItemMask/FinalPanelItemThird").GetComponent<FinalPanelItem>();
 
+        httpCountDownPanel = transform.Find("HttpCountDownPanel").gameObject;
+        httpCountDownPanel.SetActive(false);
+
+        rankUpbj = transform.Find("Image_HScore/RankUp").GetComponent<TextMeshProUGUI>();
+        newPlayerImage = transform.Find("Image_HScore/NewPlayer").gameObject;
+        rankUpbj.gameObject.SetActive(false);
+
+
+        endPs = transform.Find("Effect_UI_JieSuanShengLi/03").GetComponent<ParticleSystem>();
+
+        goonText = transform.Find("Image_HScore/GoOnText").GetComponent<Text>();
         //PlayerPrefs.DeleteKey("GemBattlePlayerNickName");
 
-        playerNickName = PlayerPrefs.GetString("GemBattlePlayerNickName");
+        playerNickName = PlayerPrefs.GetString(playerPrefs_NickName);
         if (playerNickName == "")
         {
             GameObject go = Instantiate(Resources.Load<GameObject>("UI/Final/InputNamePanel"), transform);
@@ -129,6 +155,7 @@
         }
         else
         {
+            newPlayerImage.SetActive(false);
             StartHttp();
         }
 
@@ -137,35 +164,40 @@
     private void LoadName(string nickName)
     {
         playerNickName = nickName;
-        PlayerPrefs.SetString("GemBattlePlayerNickName", playerNickName);
+        PlayerPrefs.SetString(playerPrefs_NickName, playerNickName);
+
+        if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer)
+        {
+            //为了方便测试
+            GameConfig.Imei = playerNickName;
+            Debug.Log("这里是电脑版,直接设置Imei为昵称" + playerNickName);
+        }
+
         StartHttp();
     }
 
     private void StartHttp()
     {
+        Debug.Log($"_myScore:{_myScore}  _waveInfo:{_waveInfo}");
         finalHttp.SendPost(playerNickName, _myScore, 1, _waveInfo);
     }
 
-    private void GetHttpData(List<HttpGetInfo> allHttpGetInfoLis, int myrank)
+    private void GetHttpData(List<HttpGetInfo> allHttpGetInfoLis, int myrank, HttpGetInfo mydataHttpInfo)
     {
         scroller = transform.Find("Scroller").GetComponent<EnhancedScroller>();
         scroller.Delegate = this;
+        playPSItem = new List<FinalPanelItem>();
+        RefreshHttpData(allHttpGetInfoLis, myrank, mydataHttpInfo);
 
-        RefreshHttpData(allHttpGetInfoLis, myrank);
-
-        txt_Name.text = playerNickName;
-        txt_HScore.text = _myScore.ToString();
-        txt_Wave.text = _waveInfo;
-        if (myrank > 3000)
+        if (allHttpGetInfoLis != null)
         {
-            txt_Index.text = "3000+";
-        }
-        else
-        {
-            txt_Index.text = myrank.ToString();
+            txt_Name.text = mydataHttpInfo.nickname;
+            txt_HScore.text = mydataHttpInfo.score.ToString();
+            txt_Wave.text = mydataHttpInfo.waveInfo;
         }
 
         PlayDoTween();
+        isFirstStart = false;
     }
 
     private void PlayDoTween()
@@ -177,24 +209,24 @@
         agentTweenSeq.Join(tsTiele.DOFade(1, 0.3f));
 
         Image Image1 = transform.Find("Image1").GetComponent<Image>();
-        agentTweenSeq.Append(Image1.transform.DOScale(Vector3.one, 0.2f));//变化图片大小
-        agentTweenSeq.Join(Image1.DOFade(1, 0.2f));
+        float imageTime = 0.3f;
+        agentTweenSeq.Append(Image1.transform.DOScale(Vector3.one, imageTime).SetEase(Ease.InOutBack));//变化图片大小
+        agentTweenSeq.Join(Image1.DOFade(1, imageTime));
         agentTweenSeq.Join(waveText.DOText(_waveInfo, 0.2f));
 
         Image Image2 = transform.Find("Image2").GetComponent<Image>();
-        agentTweenSeq.Append(Image2.transform.DOScale(Vector3.one, 0.2f));//变化图片大小
-        agentTweenSeq.Join(Image2.DOFade(1, 0.2f));
-
-        agentTweenSeq.AppendCallback(StartLoadLargeData);
+        agentTweenSeq.Append(Image2.transform.DOScale(Vector3.one, imageTime).SetEase(Ease.InOutBack));//变化图片大小
+        agentTweenSeq.Join(Image2.DOFade(1, imageTime));
 
         Image Image3 = transform.Find("Image3").GetComponent<Image>();
-        agentTweenSeq.Append(Image3.transform.DOScale(Vector3.one, 0.2f));//变化图片大小
-        agentTweenSeq.Join(Image3.DOFade(1, 0.2f));
+        agentTweenSeq.Append(Image3.transform.DOScale(Vector3.one, imageTime).SetEase(Ease.InOutBack));//变化图片大小
+        agentTweenSeq.Join(Image3.DOFade(1, imageTime));
         agentTweenSeq.Join(DOTween.To(delegate (float value)
         {
             var temp = Math.Floor(value);
             scoreText.text = temp + "";
         }, 0, _myScore, 1.0f));
+        agentTweenSeq.AppendCallback(StartLoadLargeData);
 
         tsLight = transform.Find("ImageLight");
         Image ImageLight = tsLight.GetComponent<Image>();
@@ -225,8 +257,6 @@
     /// </summary>
     protected void StartLoadLargeData()
     {
-        scoreText.gameObject.SetActive(true);
-
         StartCoroutine(PlayerItemDoTween());
     }
 
@@ -236,14 +266,36 @@
     /// <returns></returns>
     IEnumerator PlayerItemDoTween()
     {
-
         yield return new WaitForEndOfFrame();
-        scrollerCanvasGroup.alpha = 1;
+        if (_data.Count > 0)
+        {
+            scrollerCanvasGroup.alpha = 1;
+            Debug.Log("开始展示排行榜");
+        }
         itemCanvasGroup.alpha = 1;
+        float duration = 0.1f;
+        for (int i = 0; i < playPSItem.Count; i++)
+        {
+            playPSItem[i].PlayDoTween(duration);
+            yield return new WaitForSeconds(duration);
+        }
 
-        image_HScore.SetActive(true);
+        if (playPSItem.Count > 0)
+        {
+            image_HScore.SetActive(true);
+            goonFade = true;
+            ShowGoOnText();
+        }
 
         yield break;
+    }
+
+    bool goonFade;
+    private void ShowGoOnText()
+    {
+        goonText.DOFade(goonFade ? 0 : 1, 0.8f).SetEase(Ease.InOutQuad).OnComplete(ShowGoOnText);
+        goonText.transform.DOScale(goonFade ? 0.9f : 1.1f, 0.8f);
+        goonFade = !goonFade;
     }
 
     /// <summary>
@@ -252,15 +304,34 @@
     protected void TextDoTweenFinish()
     {
         waveText.gameObject.SetActive(true);
+        if (_allHttpGetInfoLis == null)
+        {
+            httpCountDownPanel.SetActive(true);
+        }
         if (isNewH)
         {
             image_NewRecord.SetActive(true);
+
+            if (tmpRankUp > 0)
+            {
+                Debug.Log("排名上升了:" + tmpRankUp);
+                if (!rankUpbj.gameObject.activeSelf)
+                {
+                    rankUpbj.gameObject.SetActive(true);
+                    DOTween.To(delegate (float value)
+                        {
+                            var temp = Math.Floor(value);
+                            rankUpbj.text = temp + "";
+                        }, 0, tmpRankUp, 0.5f);
+                }
+            }
+            else
+            {
+                Debug.Log("排名下降了");
+            }
         }
 
-        if (playEffectAC != null)
-        {
-            playEffectAC();
-        }
+        endPs?.Play();
 
         closeBtn.interactable = true;
     }
@@ -312,16 +383,16 @@
     {
         FinalPanelItem cellView = scroller.GetCellView(cellViewPrefab) as FinalPanelItem;
         cellView.SetData(_data[dataIndex]);
-
+        //cellView.CheckRank(tmpRankUp);
         if (dataIndex == _data.Count - 2)
         {
-            Debug.Log("是否可以刷新新列表了");
+            Debug.Log($"是否可以刷新新列表了  _limit:{_limit}    _data.Count:{_data.Count}");
 
             if (_limit >= 3000)
             {
                 Debug.Log("数据下载量最大3000");
             }
-            else if (_limit >= _data.Count)
+            else if (_limit > _data.Count + 3)//从第三名开始无限滚动
             {
                 Debug.Log("当前服务器没有那么多数据");
             }
@@ -330,18 +401,50 @@
                 _limit += _limitUp;
                 Debug.Log("刷新新列表了,下载了  " + _limit + "  个数据:");
                 finalHttp.Init(RefreshHttpData, _limit);//重置状态,设置回调和拉取的所有数据
+                StartHttp();
             }
         }
         return cellView;
     }
 
-    private void RefreshHttpData(List<HttpGetInfo> allHttpGetInfoLis, int myrank)
+    List<HttpGetInfo> _allHttpGetInfoLis;
+    List<FinalPanelItem> playPSItem;//特效list
+    bool isFirstStart;
+    private void RefreshHttpData(List<HttpGetInfo> allHttpGetInfoLis, int myrank, HttpGetInfo mydataHttpInfo)
     {
-        _data = new SmallList<FinalPanelItemData>();
+        _allHttpGetInfoLis = allHttpGetInfoLis;
+        if (allHttpGetInfoLis == null)
+        {
+            //httpCountDownPanel.SetActive(true);
+            return;
+        }
+
         FinalPanelItemData data;
 
         if (allHttpGetInfoLis.Count > 0)
         {
+            //排名发生了变化
+            if (tmpRank != myrank)
+            {
+                tmpRankUp = tmpRank - myrank;
+
+                tmpRank = myrank;
+                PlayerPrefs.SetInt(playerPrefs_HRank, tmpRank);
+            }
+            else
+            {
+
+            }
+
+            if (myrank > 3000)
+            {
+                txt_Index.text = "3000+";
+            }
+            else
+            {
+                txt_Index.text = myrank.ToString();
+            }
+
             if (allHttpGetInfoLis.Count >= 1)
             {
                 data = new FinalPanelItemData();
@@ -349,6 +452,12 @@
                 data.index = 1;
                 itemFirst.gameObject.SetActive(true);
                 itemFirst.SetData(data);
+                if (isFirstStart)
+                {
+                    itemFirst.SetPos();
+                    playPSItem.Add(itemFirst);
+                }
+                //itemFirst.CheckRank(tmpRankUp);
             }
             else
             {
@@ -364,6 +473,12 @@
                 data.index = 2;
                 itemSecond.gameObject.SetActive(true);
                 itemSecond.SetData(data);
+                if (isFirstStart)
+                {
+                    itemSecond.SetPos();
+                    playPSItem.Add(itemSecond);
+                }
+                //itemFirst.CheckRank(tmpRankUp);
             }
             else
             {
@@ -378,6 +493,12 @@
                 data.index = 3;
                 itemThird.gameObject.SetActive(true);
                 itemThird.SetData(data);
+                if (isFirstStart)
+                {
+                    itemThird.SetPos();
+                    playPSItem.Add(itemThird);
+                }
+                //itemFirst.CheckRank(tmpRankUp);
             }
             else
             {
@@ -386,6 +507,7 @@
             }
             if (allHttpGetInfoLis.Count > 3)
             {
+                _data.Clear();
                 for (int i = 3; i < allHttpGetInfoLis.Count; i++)
                 {
                     data = new FinalPanelItemData();
@@ -394,11 +516,26 @@
                     _data.Add(data);
                 }
                 scroller.ReloadData();
+
+                if (isFirstStart)
+                {
+                    Transform container = transform.Find("Scroller/Container");
+                    FinalPanelItem[] items = container.GetComponentsInChildren<FinalPanelItem>();
+                    for (int i = 0; i < items.Length; i++)
+                    {
+                        playPSItem.Add(items[i]);
+                        items[i].SetPos();
+                    }
+                }
+
             }
+
         }
     }
 
 
+
+
     #endregion
 
 }

--
Gitblit v1.9.1