111 lines
3.6 KiB
C#
111 lines
3.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Logic;
|
|
using Logic.Multilingual;
|
|
using RuntimeData;
|
|
using TH1_Core.Events;
|
|
using TH1_Core.Managers;
|
|
using TH1_Logic.Core;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.EventSystems; // 需要引入此命名空间以处理指针事件
|
|
|
|
namespace TH1_UI.View.Info
|
|
{
|
|
public class UIBottomRankingRowMono : MonoBehaviour
|
|
{
|
|
public Image Medal;
|
|
public List<Sprite> MedalSprite;
|
|
public Color NormalRankTextColor;
|
|
public List<Color> MedalRankTextColor;
|
|
|
|
public Image BG;
|
|
public Sprite NormalBG;
|
|
public Sprite SelfBG;
|
|
public Button Button;
|
|
public Image AvatarMask;
|
|
public Image Avatar;
|
|
public GameObject Union;
|
|
public TextMeshProUGUI Rank;
|
|
public TextMeshProUGUI ForceName;
|
|
public TextMeshProUGUI City;
|
|
public TextMeshProUGUI Score;
|
|
|
|
public Material GrayScaleMat;
|
|
|
|
private void Awake()
|
|
{
|
|
|
|
}
|
|
|
|
public void SetContent(int rk, PlayerData player)
|
|
{
|
|
if (!Table.Instance.PlayerDataAssets.GetPlayerInfo(player, out var playerInfo)) return;
|
|
var selfPlayer = Main.MapData.PlayerMap.SelfPlayerData;
|
|
|
|
Rank.text = (rk + 1).ToString();
|
|
BG.sprite = player == Main.MapData.PlayerMap.SelfPlayerData ? SelfBG : NormalBG;
|
|
Medal.gameObject.SetActive(rk < 3);
|
|
Rank.color = NormalRankTextColor;
|
|
if (rk is >= 0 and < 3)
|
|
{
|
|
Medal.sprite = MedalSprite[rk];
|
|
Rank.color = MedalRankTextColor[rk];
|
|
}
|
|
|
|
Button.onClick.RemoveAllListeners();
|
|
|
|
var col = AvatarMask.color;
|
|
col.a = 0.01f;
|
|
AvatarMask.color = col;
|
|
|
|
//死亡的对手,未相遇也会呈现真名和avatar
|
|
if (!player.Alive)
|
|
{
|
|
MultilingualManager.Instance.SetUIText(ForceName, playerInfo.ForceName);
|
|
ForceName.color = Color.gray;
|
|
Avatar.sprite = playerInfo.LeaderAvatar;
|
|
Avatar.material = GrayScaleMat;
|
|
col = AvatarMask.color;
|
|
col.a = 0;
|
|
AvatarMask.color = col;
|
|
Union.SetActive(false);
|
|
}
|
|
//未相遇的对手
|
|
else if (!selfPlayer.MeetPlayers.Contains(player.Id))
|
|
{
|
|
ForceName.text = "???";
|
|
ForceName.color = NormalRankTextColor;
|
|
Avatar.sprite = Table.Instance.PlayerDataAssets.CommonPlayerAvatar;
|
|
Avatar.material = null;
|
|
Union.SetActive(false);
|
|
}
|
|
//常规对手
|
|
else
|
|
{
|
|
MultilingualManager.Instance.SetUIText(ForceName, playerInfo.ForceName);
|
|
ForceName.color = NormalRankTextColor;
|
|
Avatar.sprite = playerInfo.LeaderAvatar;
|
|
Avatar.material = null;
|
|
|
|
var tt = player.Id;
|
|
Button.onClick.AddListener(() =>
|
|
{
|
|
|
|
var infoUI = new ShowUIInfoDiplomacy() { Pid = tt };
|
|
EventManager.Publish(infoUI);
|
|
});
|
|
Union.SetActive(player != selfPlayer && Main.MapData.SameUnion(selfPlayer.Id, player.Id));
|
|
|
|
|
|
}
|
|
|
|
City.text = Main.MapData.GetCityCount(player.Id).ToString();
|
|
Score.text = player.PlayerScore.ToString();
|
|
}
|
|
|
|
|
|
|
|
}
|
|
} |