From 9ad1afab7d9962af7b8e0f592c0b150887b4f2f6 Mon Sep 17 00:00:00 2001 From: chenxin <chenxin6991@163.com> Date: Fri, 04 Dec 2020 11:31:43 +0800 Subject: [PATCH] Merge branch 'master' of http://172.16.1.52:8090/r/GemBattle into master --- Assets/Scripts/UI/FinalPanel/FinalPanel.cs | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 103 insertions(+), 11 deletions(-) diff --git a/Assets/Scripts/UI/FinalPanel/FinalPanel.cs b/Assets/Scripts/UI/FinalPanel/FinalPanel.cs index aae1a65..a8edd17 100644 --- a/Assets/Scripts/UI/FinalPanel/FinalPanel.cs +++ b/Assets/Scripts/UI/FinalPanel/FinalPanel.cs @@ -39,6 +39,8 @@ GameObject image_NewRecord; bool isNewH = false; int hScore; + //string hwaveInfo; + CanvasGroup scrollerCanvasGroup; CanvasGroup itemCanvasGroup; @@ -54,8 +56,13 @@ playEffectAC = ac; } + string playerPrefs_HScore = "GemBattleHScore"; + //string playerPrefs_HWaveInfo = "GemBattleHWaveInfo"; + + string playerPrefs_NickName = "GemBattlePlayerNickName"; + string _waveInfo; - int _myScore; + int _myScore;//本次 FinalHttp finalHttp; string playerNickName; int _limit; @@ -69,23 +76,28 @@ /// <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; + _data = new SmallList<FinalPanelItemData>(); + Debug.Log($"_myScore:{_myScore} _waveInfo:{_waveInfo}"); - hScore = PlayerPrefs.GetInt("GemBattleHScore"); + hScore = PlayerPrefs.GetInt(playerPrefs_HScore); + //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; } @@ -119,9 +131,14 @@ itemSecond = transform.Find("ItemPanel/FinalPanelItemSecond").GetComponent<FinalPanelItem>(); itemThird = transform.Find("ItemPanel/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); + //PlayerPrefs.DeleteKey("GemBattlePlayerNickName"); - playerNickName = PlayerPrefs.GetString("GemBattlePlayerNickName"); + playerNickName = PlayerPrefs.GetString(playerPrefs_NickName); if (playerNickName == "") { GameObject go = Instantiate(Resources.Load<GameObject>("UI/Final/InputNamePanel"), transform); @@ -137,13 +154,70 @@ private void LoadName(string nickName) { playerNickName = nickName; - PlayerPrefs.SetString("GemBattlePlayerNickName", playerNickName); + PlayerPrefs.SetString(playerPrefs_NickName, playerNickName); StartHttp(); } 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) @@ -153,9 +227,14 @@ RefreshHttpData(allHttpGetInfoLis, myrank); - txt_Name.text = playerNickName; - txt_HScore.text = _myScore.ToString(); - txt_Wave.text = _waveInfo; + 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+"; @@ -330,6 +409,7 @@ _limit += _limitUp; Debug.Log("刷新新列表了,下载了 " + _limit + " 个数据:"); finalHttp.Init(RefreshHttpData, _limit);//重置状态,设置回调和拉取的所有数据 + StartHttp(); } } return cellView; @@ -337,7 +417,19 @@ private void RefreshHttpData(List<HttpGetInfo> allHttpGetInfoLis, int myrank) { - _data = new SmallList<FinalPanelItemData>(); + if (allHttpGetInfoLis == null) + { + httpCountDownPanel.SetActive(true); + countDownTxt.text = "获取排行榜失败"; + countDownReplayBtn.onClick.AddListener(Close); + return; + } + + // if (isSending) + // { + // OpenHttpCountDown(false); + // } + FinalPanelItemData data; if (allHttpGetInfoLis.Count > 0) -- Gitblit v1.9.1