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);
@@ -68,6 +69,10 @@
    TextMeshProUGUI txt_HScore, txt_Index;
    TextMeshProUGUI rankUpbj;
    GameObject newPlayerImage;//新用户提示
    GameObject httpCountDownPanel;
    Text goonText;
    /// <summary>
    /// 入口函数
    /// </summary>
@@ -77,6 +82,7 @@
    {
        _waveInfo = waveInfo;
        _myScore = myScore;
        isFirstStart = true;//首次启动下载到数据执行动效
        _data = new SmallList<FinalPanelItemData>();
        Debug.Log($"_myScore:{_myScore}  _waveInfo:{_waveInfo}");
@@ -120,24 +126,25 @@
        image_NewRecord.SetActive(false);
        finalHttp = GetComponent<FinalHttp>();
        _limit = 10;
        _limitUp = 10;
        _limit = 100;
        _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;
        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>();
        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(playerPrefs_NickName);
@@ -148,6 +155,7 @@
        }
        else
        {
            newPlayerImage.SetActive(false);
            StartHttp();
        }
@@ -170,79 +178,26 @@
    private void StartHttp()
    {
        //OpenHttpCountDown(true);
        Debug.Log($"_myScore:{_myScore}  _waveInfo:{_waveInfo}");
        finalHttp.SendPost(playerNickName, _myScore, 1, _waveInfo);
    }
    #region 联网倒计时判断
    bool isSending;
    int sendCount;
    GameObject httpCountDownPanel;
    Button countDownReplayBtn;
    Text countDownTxt;
    private void OpenHttpCountDown(bool isOn)
    {
        if (isOn)
        {
            isSending = true;
            sendCount = 0;
            StartCoroutine("HttpCountDown");
        }
        else
        {
            isSending = false;
            StopCoroutine("HttpCountDown");
        }
    }
    IEnumerator HttpCountDown()
    {
        while (isSending)
        {
            yield return new WaitForSeconds(1.0f);
            sendCount++;
            Debug.Log($"等待了{sendCount}秒");
            if (sendCount == 3)
            {
                if (!httpCountDownPanel.activeSelf) httpCountDownPanel.SetActive(true);
                if (countDownReplayBtn.gameObject.activeSelf) countDownReplayBtn.gameObject.SetActive(false);
            }
            else if (sendCount > 10)
            {
                Debug.Log("等了10秒了,连接失败");
                isSending = false;
                countDownTxt.text = "等了10秒了,连接失败";
                if (!countDownReplayBtn.gameObject.activeSelf) countDownReplayBtn.gameObject.SetActive(true);
                countDownReplayBtn.onClick.AddListener(Close);
                break;
            }
        }
    }
    #endregion
    private void Close()
    {
        gameObject.SetActive(false);
        GameConfig.NextSceneName = endlessGameScene;
        SceneManager.LoadScene(loadingScene);
    }
    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);
        if (allHttpGetInfoLis == null) return;
        txt_Name.text = mydataHttpInfo.nickname;
        txt_HScore.text = mydataHttpInfo.score.ToString();
        txt_Wave.text = mydataHttpInfo.waveInfo;
        if (allHttpGetInfoLis != null)
        {
            txt_Name.text = mydataHttpInfo.nickname;
            txt_HScore.text = mydataHttpInfo.score.ToString();
            txt_Wave.text = mydataHttpInfo.waveInfo;
        }
        PlayDoTween();
        isFirstStart = false;
    }
    private void PlayDoTween()
@@ -310,14 +265,35 @@
    /// <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.5f).OnComplete(ShowGoOnText);
        goonFade = !goonFade;
    }
    /// <summary>
@@ -326,6 +302,10 @@
    protected void TextDoTweenFinish()
    {
        waveText.gameObject.SetActive(true);
        if (_allHttpGetInfoLis == null)
        {
            httpCountDownPanel.SetActive(true);
        }
        if (isNewH)
        {
            image_NewRecord.SetActive(true);
@@ -349,11 +329,7 @@
            }
        }
        // transform.Find("Image1").gameObject.SetActive(false);
        // transform.Find("Image2").gameObject.SetActive(false);
        // transform.Find("Image3").gameObject.SetActive(false);
        endPs?.Play();
        closeBtn.interactable = true;
    }
@@ -429,20 +405,17 @@
        return cellView;
    }
    List<HttpGetInfo> _allHttpGetInfoLis;
    List<FinalPanelItem> playPSItem;//特效list
    bool isFirstStart;
    private void RefreshHttpData(List<HttpGetInfo> allHttpGetInfoLis, int myrank, HttpGetInfo mydataHttpInfo)
    {
        _allHttpGetInfoLis = allHttpGetInfoLis;
        if (allHttpGetInfoLis == null)
        {
            httpCountDownPanel.SetActive(true);
            countDownTxt.text = "获取排行榜失败";
            countDownReplayBtn.onClick.AddListener(Close);
            //httpCountDownPanel.SetActive(true);
            return;
        }
        // if (isSending)
        // {
        //     OpenHttpCountDown(false);
        // }
        FinalPanelItemData data;
@@ -477,6 +450,11 @@
                data.index = 1;
                itemFirst.gameObject.SetActive(true);
                itemFirst.SetData(data);
                if (isFirstStart)
                {
                    itemFirst.SetPos();
                    playPSItem.Add(itemFirst);
                }
                //itemFirst.CheckRank(tmpRankUp);
            }
            else
@@ -493,6 +471,11 @@
                data.index = 2;
                itemSecond.gameObject.SetActive(true);
                itemSecond.SetData(data);
                if (isFirstStart)
                {
                    itemSecond.SetPos();
                    playPSItem.Add(itemSecond);
                }
                //itemFirst.CheckRank(tmpRankUp);
            }
            else
@@ -508,6 +491,11 @@
                data.index = 3;
                itemThird.gameObject.SetActive(true);
                itemThird.SetData(data);
                if (isFirstStart)
                {
                    itemThird.SetPos();
                    playPSItem.Add(itemThird);
                }
                //itemFirst.CheckRank(tmpRankUp);
            }
            else
@@ -526,6 +514,18 @@
                    _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();
                    }
                }
            }
        }