From 988e7226f6799263fed8e8e2afe04288f357df29 Mon Sep 17 00:00:00 2001
From: chenxin <chenxin6991@163.com>
Date: Fri, 04 Dec 2020 17:43:30 +0800
Subject: [PATCH] Merge branch 'master' of http://172.16.1.52:8090/r/GemBattle into master

---
 Assets/Scripts/UI/FinalPanel/FinalPanel.cs |  119 +++++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 75 insertions(+), 44 deletions(-)

diff --git a/Assets/Scripts/UI/FinalPanel/FinalPanel.cs b/Assets/Scripts/UI/FinalPanel/FinalPanel.cs
index a8edd17..d20c2f3 100644
--- a/Assets/Scripts/UI/FinalPanel/FinalPanel.cs
+++ b/Assets/Scripts/UI/FinalPanel/FinalPanel.cs
@@ -38,26 +38,19 @@
     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;
-
-
-    /// <summary>
-    /// 设置播放胜利特效
-    /// </summary>
-    /// <param name="ac"></param>
-    public void SetPlayEffectAC(Action ac)
-    {
-        playEffectAC = ac;
-    }
+    ParticleSystem endPs;//最终特效
 
     string playerPrefs_HScore = "GemBattleHScore";
     //string playerPrefs_HWaveInfo = "GemBattleHWaveInfo";
+    string playerPrefs_HRank = "GemBattleHRank";
 
     string playerPrefs_NickName = "GemBattlePlayerNickName";
 
@@ -73,6 +66,8 @@
     FinalPanelItem itemThird;//第三
     Text txt_Name, txt_Wave;
     TextMeshProUGUI txt_HScore, txt_Index;
+
+    TextMeshProUGUI rankUpbj;
     /// <summary>
     /// 入口函数
     /// </summary>
@@ -86,6 +81,8 @@
         Debug.Log($"_myScore:{_myScore}  _waveInfo:{_waveInfo}");
 
         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;
@@ -117,14 +114,14 @@
         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);
 
         finalHttp = GetComponent<FinalHttp>();
-        _limit = 100;
-        _limitUp = 100;
+        _limit = 10;
+        _limitUp = 10;
         finalHttp.Init(GetHttpData, _limit);//重置状态,设置回调和拉取的所有数据
 
         itemFirst = transform.Find("ItemPanel/FinalPanelItemFirst").GetComponent<FinalPanelItem>();
@@ -135,6 +132,11 @@
         countDownReplayBtn = transform.Find("HttpCountDownPanel/ReplayBtn").GetComponent<Button>();
         countDownTxt = transform.Find("HttpCountDownPanel/WarningTxt").GetComponent<Text>();
         httpCountDownPanel.SetActive(false);
+
+        rankUpbj = transform.Find("Image_HScore/RankUp").GetComponent<TextMeshProUGUI>();
+        rankUpbj.gameObject.SetActive(false);
+
+        endPs = transform.Find("Effect_UI_JieSuanShengLi/03").GetComponent<ParticleSystem>();
 
         //PlayerPrefs.DeleteKey("GemBattlePlayerNickName");
 
@@ -161,7 +163,6 @@
     private void StartHttp()
     {
         //OpenHttpCountDown(true);
-
         Debug.Log($"_myScore:{_myScore}  _waveInfo:{_waveInfo}");
         finalHttp.SendPost(playerNickName, _myScore, 1, _waveInfo);
     }
@@ -220,29 +221,18 @@
         SceneManager.LoadScene(loadingScene);
     }
 
-    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;
 
-        RefreshHttpData(allHttpGetInfoLis, myrank);
+        RefreshHttpData(allHttpGetInfoLis, myrank, mydataHttpInfo);
 
         if (allHttpGetInfoLis == null) return;
 
-        HttpGetInfo tmpData = allHttpGetInfoLis[myrank - 1];
-
-        txt_Name.text = tmpData.nickname;
-        txt_HScore.text = tmpData.score.ToString();
-        txt_Wave.text = tmpData.waveInfo;
-
-        if (myrank > 3000)
-        {
-            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();
     }
@@ -264,8 +254,6 @@
         agentTweenSeq.Append(Image2.transform.DOScale(Vector3.one, 0.2f));//变化图片大小
         agentTweenSeq.Join(Image2.DOFade(1, 0.2f));
 
-        agentTweenSeq.AppendCallback(StartLoadLargeData);
-
         Image Image3 = transform.Find("Image3").GetComponent<Image>();
         agentTweenSeq.Append(Image3.transform.DOScale(Vector3.one, 0.2f));//变化图片大小
         agentTweenSeq.Join(Image3.DOFade(1, 0.2f));
@@ -274,6 +262,7 @@
             var temp = Math.Floor(value);
             scoreText.text = temp + "";
         }, 0, _myScore, 1.0f));
+        agentTweenSeq.AppendCallback(StartLoadLargeData);
 
         tsLight = transform.Find("ImageLight");
         Image ImageLight = tsLight.GetComponent<Image>();
@@ -304,8 +293,6 @@
     /// </summary>
     protected void StartLoadLargeData()
     {
-        scoreText.gameObject.SetActive(true);
-
         StartCoroutine(PlayerItemDoTween());
     }
 
@@ -334,12 +321,27 @@
         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;
     }
@@ -391,16 +393,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("当前服务器没有那么多数据");
             }
@@ -415,7 +417,7 @@
         return cellView;
     }
 
-    private void RefreshHttpData(List<HttpGetInfo> allHttpGetInfoLis, int myrank)
+    private void RefreshHttpData(List<HttpGetInfo> allHttpGetInfoLis, int myrank, HttpGetInfo mydataHttpInfo)
     {
         if (allHttpGetInfoLis == null)
         {
@@ -434,6 +436,28 @@
 
         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();
@@ -441,6 +465,7 @@
                 data.index = 1;
                 itemFirst.gameObject.SetActive(true);
                 itemFirst.SetData(data);
+                //itemFirst.CheckRank(tmpRankUp);
             }
             else
             {
@@ -456,6 +481,7 @@
                 data.index = 2;
                 itemSecond.gameObject.SetActive(true);
                 itemSecond.SetData(data);
+                //itemFirst.CheckRank(tmpRankUp);
             }
             else
             {
@@ -470,6 +496,7 @@
                 data.index = 3;
                 itemThird.gameObject.SetActive(true);
                 itemThird.SetData(data);
+                //itemFirst.CheckRank(tmpRankUp);
             }
             else
             {
@@ -478,6 +505,7 @@
             }
             if (allHttpGetInfoLis.Count > 3)
             {
+                _data.Clear();
                 for (int i = 3; i < allHttpGetInfoLis.Count; i++)
                 {
                     data = new FinalPanelItemData();
@@ -487,10 +515,13 @@
                 }
                 scroller.ReloadData();
             }
+
         }
     }
 
 
+
+
     #endregion
 
 }

--
Gitblit v1.9.1