71 lines
1.8 KiB
C#
71 lines
1.8 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ParticipantItem : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private Text positionText;
|
|
|
|
[SerializeField]
|
|
private Text playerNameText;
|
|
|
|
[SerializeField]
|
|
private Text playerValueText;
|
|
|
|
[SerializeField]
|
|
private Color[] positionNoColor;
|
|
|
|
public TournamentManager.CTournament.TournamentParticipant tournamentParticipant;
|
|
|
|
public TournamentManager.CTournament.TournamentTask tournamentTask;
|
|
|
|
private void Start()
|
|
{
|
|
Refresh();
|
|
}
|
|
|
|
private void Refresh()
|
|
{
|
|
positionText.text = (tournamentParticipant.position + 1).ToString();
|
|
playerNameText.text = tournamentParticipant.playerName;
|
|
switch (tournamentParticipant.position)
|
|
{
|
|
case 0:
|
|
positionText.color = positionNoColor[0];
|
|
break;
|
|
case 1:
|
|
positionText.color = positionNoColor[1];
|
|
break;
|
|
case 2:
|
|
positionText.color = positionNoColor[2];
|
|
break;
|
|
default:
|
|
positionText.color = positionNoColor[3];
|
|
break;
|
|
}
|
|
switch (tournamentTask)
|
|
{
|
|
case TournamentManager.CTournament.TournamentTask.Amount_fish:
|
|
playerValueText.text = tournamentParticipant.value.ToString("F0");
|
|
break;
|
|
case TournamentManager.CTournament.TournamentTask.Amount_fish_weight:
|
|
playerValueText.text = GameManager.Instance.ConvertWeight(tournamentParticipant.value);
|
|
break;
|
|
case TournamentManager.CTournament.TournamentTask.Best_fish_weight:
|
|
if (tournamentParticipant.bestFishId == -1)
|
|
{
|
|
playerValueText.text = "-";
|
|
return;
|
|
}
|
|
playerValueText.text = "<color=green>" + GameManager.GetFishNameFromSpecies((GameManager.FishSpecies)tournamentParticipant.bestFishId) + "</color> " + GameManager.Instance.ConvertWeight(tournamentParticipant.value);
|
|
break;
|
|
}
|
|
base.transform.SetSiblingIndex(tournamentParticipant.position);
|
|
}
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
Refresh();
|
|
}
|
|
}
|