| | |
| | | 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 |
| | | { |
| | |
| | | private Sprite rank_di_0, rank_di_1, rank_di_2, rank_di_03; |
| | | [SerializeField] |
| | | private Sprite rank_icon_0, rank_icon_1, rank_icon_2; |
| | | |
| | | |
| | | public string endlessGameScene = "Endless"; |
| | | |
| | |
| | | SceneManager.LoadScene(loadingScene); |
| | | }); |
| | | } |
| | | 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> |
| | | /// 入口函数 |
| | |
| | | /// <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(); |
| | | } |
| | | } |
| | | |
| | | /// <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; |