From 77058ba582827aea8fbbaaa3b47eb8cb181682de Mon Sep 17 00:00:00 2001 From: "DESKTOP-SAJ6RKV\\Administrator" Date: Thu, 15 May 2025 18:09:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E9=83=A8=E5=88=86=E9=97=AD?= =?UTF-8?q?=E7=8E=AF=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/AssetRaw/UI/UIGameRankForm.prefab | 9 +++- .../HotFix/GameLogic/UI/UIGameRankForm.cs | 54 +++++++++++++++++++ .../HotFix/GameLogic/UI/UIGameRankItem.cs | 40 ++++---------- 3 files changed, 73 insertions(+), 30 deletions(-) diff --git a/UnityProject/Assets/AssetRaw/UI/UIGameRankForm.prefab b/UnityProject/Assets/AssetRaw/UI/UIGameRankForm.prefab index 079af205..cb54f69a 100644 --- a/UnityProject/Assets/AssetRaw/UI/UIGameRankForm.prefab +++ b/UnityProject/Assets/AssetRaw/UI/UIGameRankForm.prefab @@ -602,7 +602,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0.004945713, y: -0.00032158243} + m_AnchoredPosition: {x: 0.00038004026, y: -0.00032158243} m_SizeDelta: {x: 0, y: 1292.4} m_Pivot: {x: 0, y: 1} --- !u!114 &6944785608262845692 @@ -764,6 +764,13 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 3a61ef7d593880141b038ffc2c45e67d, type: 3} m_Name: m_EditorClassIdentifier: + m_HeadIcon: {fileID: 4392786442847295306} + m_RankImg: {fileID: 3886915729302914564} + m_Name: {fileID: 7363701821129859374} + m_Score: {fileID: 6758929203519133182} + m_LoaclScore: {fileID: 6795924212604387844} + m_WinCount: {fileID: 8169080446283399744} + m_RankIndex: {fileID: 7943501947076435089} --- !u!114 &4487970101200929661 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/UI/UIGameRankForm.cs b/UnityProject/Assets/GameScripts/HotFix/GameLogic/UI/UIGameRankForm.cs index db16cc6b..2fe288de 100644 --- a/UnityProject/Assets/GameScripts/HotFix/GameLogic/UI/UIGameRankForm.cs +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/UI/UIGameRankForm.cs @@ -2,6 +2,7 @@ using UnityEngine; using UnityEngine.UI; using TEngine; using TMPro; +using System.Collections.Generic; namespace GameLogic { @@ -42,14 +43,67 @@ namespace GameLogic #region 事件 private void OnClick_RankBtn() { + } private void OnClick_CloseBtn() { + // 返回主界面 } private void OnClick_RestBtn() { + // 重新开始 + GameModule.UI.CloseUI(); } #endregion + + List m_PlayRankDatas; + + protected override void OnCreate() + { + base.OnCreate(); + + m_PlayRankDatas = UserData as List; + + m_loopListView_View.InitListView(m_PlayRankDatas.Count, OnGetItemByIndex); + m_loopListView_View.SetListItemCount(m_PlayRankDatas.Count); + m_loopListView_View.RefreshAllShownItem(); + } + + protected override void Close() + { + base.Close(); + + + Log.Debug("UIGameRankForm Close"); + DataGameSceneManager.Instance.OnRestData(); + } + + + LoopListViewItem OnGetItemByIndex(LoopListView listView, int index) + { + if (index >= m_PlayRankDatas.Count) + { + return null; + } + if (m_PlayRankDatas[index] == null) + { + return null; + } + + UnitPlayerData unitData = DataGameSceneManager.Instance.GetUnitPlayerData(m_PlayRankDatas[index].uid); + + if (unitData == null) + { + return null; + } + + LoopListViewItem item = listView.AllocOrNewListViewItem("RankItem"); + UIGameRankItem itemScript = item.GetComponent(); + + itemScript.OnInit(index, m_PlayRankDatas[index], unitData); + + return item; + } } } diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/UI/UIGameRankItem.cs b/UnityProject/Assets/GameScripts/HotFix/GameLogic/UI/UIGameRankItem.cs index 776759ef..8f69937c 100644 --- a/UnityProject/Assets/GameScripts/HotFix/GameLogic/UI/UIGameRankItem.cs +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/UI/UIGameRankItem.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Collections.Generic; using TEngine; +using TMPro; using UnityEngine; using UnityEngine.UI; @@ -9,21 +10,15 @@ namespace GameLogic public class UIGameRankItem : MonoBehaviour { // Start is called before the first frame update - private RawImage m_HeadIcon; - private Text m_Name; - private Text m_Score; - private Text m_WinCount; - private Text m_RankIndex; - void Awake() - { - m_HeadIcon = transform.Find("Mask/HeadImg").GetComponent(); - m_Name = transform.Find("Name").GetComponent(); - m_Score = transform.Find("Score").GetComponent(); - m_WinCount = transform.Find("WinCount").GetComponent(); - m_RankIndex = transform.Find("Rank").GetComponent(); - } + public RawImage m_HeadIcon; + public Image m_RankImg; + public TextMeshProUGUI m_Name; + public TextMeshProUGUI m_Score; + public TextMeshProUGUI m_LoaclScore; + public TextMeshProUGUI m_WinCount; + public TextMeshProUGUI m_RankIndex; - public void OnInit(int i, PlayRankData playRankData, GameRankType gameRankType, UnitPlayerData unitPlayer) + public void OnInit(int i, PlayRankData playRankData, UnitPlayerData unitPlayer) { m_Name.text = playRankData.name; @@ -38,21 +33,8 @@ namespace GameLogic m_WinCount.text = UITool.ConvertToString(playRankData.winCount).ToString(); } - switch (gameRankType) - { - case GameRankType.当局排行榜: - m_RankIndex.text = (i + 1).ToString(); - m_Score.text = UITool.ConvertToString(unitPlayer.m_Score); - break; - case GameRankType.本周排行榜: - m_RankIndex.text = playRankData.rank.ToString(); // 请求排行榜数据的时候已经划分了 - m_Score.text = UITool.ConvertToString(playRankData.score).ToString(); - break; - case GameRankType.本月排行榜: - m_Score.text = UITool.ConvertToString(playRankData.score).ToString(); - m_RankIndex.text = playRankData.rank.ToString(); - break; - } + m_RankIndex.text = (i + 1).ToString(); + m_Score.text = UITool.ConvertToString(unitPlayer.m_Score); // 设置头像 AsyncImageDownload.Instance.SetAsyncImage(playRankData.avatar, m_HeadIcon);