using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; namespace TcgEngine.UI { public class LadderRankLine : MonoBehaviour { [Header("排名")] public Text ranking; [Header("玩家名称")] public Text playerName; [Header("头像")] public Image avatar; [Header("天梯ID")] public Text rankId; // 天梯ID [Header("天梯分数")] public Text rankScore; [Header("天梯星星")] public Text stars; // [Header("胜利场次")] // public Text totalWins; [Header("下划线")] public Image highlight; [Header("查看牌组")] public Button viewCardButton; public UnityAction onClick; public string username; private void Start() { highlight.enabled = false; } public void SetLine(LadderLeaderboardEntry udata, int ranking, Sprite avatar, int rankId, int rankScore, int stars, bool highlight) { this.username = udata.username; this.ranking.text = ranking.ToString(); this.playerName.text = username; this.rankId.text = rankId.ToString(); this.rankScore.text = rankScore.ToString(); this.stars.text = "星×" + stars; this.avatar.sprite = avatar; switch (rankId) { case 1: this.rankId.text = "青铜"; break; case 2: this.rankId.text = "白银"; break; case 3: this.rankId.text = "黄金"; break; case 4: this.rankId.text = "铂金"; break; case 5: this.rankId.text = "钻石"; break; case 6: this.rankId.text = "王者"; break; default: this.rankId.text = "青铜"; break; } if (rankScore == 0) { this.rankScore.gameObject.SetActive(true); this.stars.gameObject.SetActive(false); } else { this.rankScore.gameObject.SetActive(false); this.stars.gameObject.SetActive(true); } this.highlight.enabled = highlight; gameObject.SetActive(true); } public void Hide() { gameObject.SetActive(false); } public string GetUsername() { return username; } public void OnClick() { onClick?.Invoke(username); } } }