2023-07-24 16:38:13 +03:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
2023-10-02 19:12:35 +03:00
|
|
|
|
using UnityEngine.UI;
|
2023-07-24 16:38:13 +03:00
|
|
|
|
|
|
|
|
|
public class LeaderboardEntry : MonoBehaviour
|
|
|
|
|
{
|
2023-10-29 11:59:57 +03:00
|
|
|
|
[SerializeField] private TMPro.TextMeshProUGUI _numText;
|
|
|
|
|
[SerializeField] private Text _numText2;
|
|
|
|
|
[SerializeField] private TMPro.TextMeshProUGUI _nameText;
|
|
|
|
|
[SerializeField] private Text _nameText2;
|
|
|
|
|
[SerializeField] private TMPro.TextMeshProUGUI _scoreText;
|
|
|
|
|
[SerializeField] private Text _scoreText2;
|
|
|
|
|
[SerializeField] private Image _lable;
|
|
|
|
|
[SerializeField] private Image _selectBackground;
|
|
|
|
|
[SerializeField] private Sprite _goldLable;
|
2023-07-24 16:38:13 +03:00
|
|
|
|
|
2023-10-11 11:58:06 +03:00
|
|
|
|
public int MaxIndex = 29;
|
|
|
|
|
|
2023-07-24 16:38:13 +03:00
|
|
|
|
[SerializeField]
|
|
|
|
|
private List<GameObject> _medals = new List<GameObject>();
|
|
|
|
|
|
2023-08-22 15:41:12 +03:00
|
|
|
|
public void Init(Player player, int index, bool selected = false)
|
2023-07-24 16:38:13 +03:00
|
|
|
|
{
|
|
|
|
|
if (index < 3)
|
|
|
|
|
{
|
|
|
|
|
_medals[index].SetActive(true);
|
2023-10-12 15:05:48 +03:00
|
|
|
|
_lable.sprite = _goldLable;
|
2023-07-24 16:38:13 +03:00
|
|
|
|
}
|
|
|
|
|
|
2023-10-11 11:58:06 +03:00
|
|
|
|
if (index <= MaxIndex)
|
2023-10-29 11:59:57 +03:00
|
|
|
|
{
|
|
|
|
|
if(_numText != default)
|
|
|
|
|
_numText.SetText($"{index + 1}");
|
|
|
|
|
if(_numText2 != default)
|
|
|
|
|
_numText2.text = $"{index + 1}";
|
|
|
|
|
}
|
2023-10-11 11:58:06 +03:00
|
|
|
|
else
|
2023-10-29 11:59:57 +03:00
|
|
|
|
{
|
|
|
|
|
if(_numText != default)
|
|
|
|
|
_numText.SetText($"-");
|
|
|
|
|
if(_numText2 != default)
|
|
|
|
|
_numText2.text = $"-";
|
|
|
|
|
}
|
2023-10-11 11:58:06 +03:00
|
|
|
|
|
2023-10-29 11:59:57 +03:00
|
|
|
|
if(_scoreText != default)
|
|
|
|
|
_scoreText.SetText($"{player.Score}");
|
|
|
|
|
if(_scoreText2 != default)
|
|
|
|
|
_scoreText2.text = $"{player.Score}";
|
2023-08-22 15:41:12 +03:00
|
|
|
|
|
|
|
|
|
if (selected)
|
|
|
|
|
{
|
2023-10-29 11:59:57 +03:00
|
|
|
|
if(_nameText != default)
|
|
|
|
|
_nameText.SetText("<22><>");
|
|
|
|
|
if(_nameText2 != default)
|
|
|
|
|
_nameText2.text = "<22><>";
|
2023-10-12 15:05:48 +03:00
|
|
|
|
_selectBackground.gameObject.SetActive(true);
|
2023-08-22 15:41:12 +03:00
|
|
|
|
}
|
2023-10-11 11:58:06 +03:00
|
|
|
|
else
|
|
|
|
|
{
|
2023-10-29 11:59:57 +03:00
|
|
|
|
if(_nameText != default)
|
|
|
|
|
_nameText.SetText(player.Name);
|
|
|
|
|
if(_nameText2 != default)
|
|
|
|
|
_nameText2.text = player.Name;
|
2023-10-11 11:58:06 +03:00
|
|
|
|
}
|
2023-07-24 16:38:13 +03:00
|
|
|
|
}
|
|
|
|
|
}
|