103 lines
2.4 KiB
C#
103 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Animancer;
|
|
using Logic;
|
|
using Logic.Action;
|
|
using Logic.Audio;
|
|
using Logic.CrashSight;
|
|
using Logic.Multilingual;
|
|
using RuntimeData;
|
|
using TH1_Core.Events;
|
|
using TH1_Core.Managers;
|
|
using TH1_Logic.Core;
|
|
using TH1_Logic.Net;
|
|
using TH1_Logic.Steam;
|
|
using TH1_UI.Components;
|
|
using TH1_UI.HintUI;
|
|
using TH1_UI.View.Info;
|
|
using TH1Renderer;
|
|
using TH1Resource;
|
|
using TMPro;
|
|
using UI.HintUI;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
namespace TH1_UI.View.Bottom
|
|
{
|
|
public class UIBottomRankingView : Base.View
|
|
{
|
|
//public Button closeButton;
|
|
public ViDelegateAssisstant.Dele OnBtnCloseClick;
|
|
|
|
public GameObject RowPrefab;
|
|
public Transform RowFather;
|
|
public Button CloseButton;
|
|
private List<UIBottomRankingRowMono> Rows = new List<UIBottomRankingRowMono>();
|
|
|
|
|
|
protected override void OnInit()
|
|
{
|
|
base.OnInit();
|
|
CloseButton.onClick.RemoveAllListeners();
|
|
CloseButton.onClick.AddListener(() => { OnBtnCloseClick.Invoke(); });
|
|
//CheckPanel.InitStart(RefreshStatus);
|
|
|
|
|
|
}
|
|
|
|
|
|
//通常一局只会set一次,每次都是完全清空,然后绑定新的一个对局的按钮
|
|
public void SetContent()
|
|
{
|
|
//Step #1 如果不在游戏中,退出
|
|
if (Main.Instance.GameLogic.GetCurState() == GameState.Menu) return;
|
|
|
|
//Step #2 安排好每个row的游戏对象
|
|
CheckRowMonoCountAndSetActive();
|
|
|
|
//Step #3逐个设置
|
|
|
|
var playerList = new List<PlayerData>(Main.MapData.PlayerMap.PlayerDataList);
|
|
playerList.Sort((a, b) => b.PlayerScore.CompareTo(a.PlayerScore));
|
|
|
|
int i = 0;
|
|
foreach(var player in playerList)
|
|
{
|
|
var row = Rows[i];
|
|
row.SetContent(i,player);
|
|
i++;
|
|
}
|
|
}
|
|
|
|
public void UpdateView()
|
|
{
|
|
SetContent();
|
|
}
|
|
|
|
|
|
public void CloseView()
|
|
{
|
|
//AudioManager.Instance.StopMusic();
|
|
}
|
|
private void CheckRowMonoCountAndSetActive()
|
|
{
|
|
var playerCount = Main.MapData.PlayerMap.PlayerDataList.Count;
|
|
while (Rows.Count < playerCount)
|
|
{
|
|
var newRowObj = Instantiate(RowPrefab,RowFather);
|
|
var newRow = newRowObj.transform.GetComponent<UIBottomRankingRowMono>();
|
|
if(newRow != null)
|
|
Rows.Add(newRow);
|
|
}
|
|
|
|
for (int i = 0; i < Rows.Count; i++)
|
|
Rows[i].gameObject.SetActive(i < playerCount);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|