127 lines
3.4 KiB
C#
127 lines
3.4 KiB
C#
using BitStrap;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class TournamentScreenWidget : MonoBehaviour
|
|
{
|
|
public Image background;
|
|
|
|
public Color backgroundColor1 = Color.grey;
|
|
|
|
public Color backgroundColor2 = Color.black;
|
|
|
|
public Text rankText;
|
|
|
|
public Text nameText;
|
|
|
|
public Text scoreText;
|
|
|
|
public Text levelText;
|
|
|
|
public Text expText;
|
|
|
|
public Text fishCountText;
|
|
|
|
public Text fishTotalWeightText;
|
|
|
|
public Text biggestSpeciesText;
|
|
|
|
public Text biggestWeightText;
|
|
|
|
[ReadOnly]
|
|
public ulong platformID;
|
|
|
|
public void RefreshEmptyWidget()
|
|
{
|
|
background.color = new Color(0f, 0f, 0f, 0f);
|
|
rankText.text = string.Empty;
|
|
nameText.text = string.Empty;
|
|
scoreText.text = string.Empty;
|
|
levelText.text = string.Empty;
|
|
expText.text = string.Empty;
|
|
fishCountText.text = string.Empty;
|
|
fishTotalWeightText.text = string.Empty;
|
|
biggestSpeciesText.text = string.Empty;
|
|
biggestWeightText.text = string.Empty;
|
|
}
|
|
|
|
public void RefreshMyWidget(int rank)
|
|
{
|
|
GlobalSettings instance = GlobalSettings.Instance;
|
|
background.color = backgroundColor1;
|
|
rankText.text = ((rank != -1) ? rank.ToString() : "-");
|
|
nameText.text = GlobalSettings.Instance.GetPlatformProfileName();
|
|
scoreText.text = instance.playerSettings.playersScore.ToString();
|
|
levelText.text = instance.playerSettings.playersLevel.ToString();
|
|
expText.text = instance.playerSettings.playersExperience.ToString();
|
|
fishCountText.text = instance.fishManager.GetTotalFishCount().ToString();
|
|
fishTotalWeightText.text = UtilitiesUnits.GetWeightString(instance.fishManager.GetTotalFishWeight());
|
|
FishManager.FishDefinition biggestFishDefinition = instance.fishManager.GetBiggestFishDefinition();
|
|
if (biggestFishDefinition == null)
|
|
{
|
|
biggestSpeciesText.text = string.Empty;
|
|
biggestWeightText.text = string.Empty;
|
|
}
|
|
else
|
|
{
|
|
biggestSpeciesText.text = Utilities.GetTranslation(biggestFishDefinition.fishPrefab.fishName);
|
|
biggestWeightText.text = UtilitiesUnits.GetWeightString(biggestFishDefinition.weight);
|
|
}
|
|
}
|
|
|
|
public void RefreshWidget(ulong platformProfileID, string playerName, int[] details, int rankPosition, int score)
|
|
{
|
|
if ((float)rankPosition % 2f == 0f)
|
|
{
|
|
background.color = backgroundColor2;
|
|
}
|
|
else
|
|
{
|
|
background.color = backgroundColor1;
|
|
}
|
|
platformID = platformProfileID;
|
|
if (details[2] > 0)
|
|
{
|
|
rankText.text = rankPosition.ToString();
|
|
}
|
|
else
|
|
{
|
|
rankText.text = "-";
|
|
}
|
|
nameText.text = playerName;
|
|
if (GlobalTournamentManager.Instance.currentTournament.goalType == GlobalTournamentManager.GoalType.AMOUNT)
|
|
{
|
|
scoreText.text = score.ToString();
|
|
}
|
|
else
|
|
{
|
|
scoreText.text = UtilitiesUnits.GetWeightString((float)score * 0.001f);
|
|
}
|
|
levelText.text = details[0].ToString();
|
|
expText.text = details[1].ToString();
|
|
fishCountText.text = details[2].ToString();
|
|
fishTotalWeightText.text = UtilitiesUnits.GetWeightString((float)details[3] * 0.001f);
|
|
FishManager.FishDefinition fishDefinition = null;
|
|
if (details[4] != -1)
|
|
{
|
|
fishDefinition = GlobalSettings.Instance.fishManager.GetFishDefinition((Fish.Species)details[4]);
|
|
}
|
|
if (details[4] == -1 || fishDefinition == null)
|
|
{
|
|
biggestSpeciesText.text = "-";
|
|
}
|
|
else
|
|
{
|
|
biggestSpeciesText.text = Utilities.GetTranslation(fishDefinition.fishPrefab.fishName);
|
|
}
|
|
if (details[5] == -1 || fishDefinition == null)
|
|
{
|
|
biggestWeightText.text = "-";
|
|
}
|
|
else
|
|
{
|
|
biggestWeightText.text = UtilitiesUnits.GetWeightString((float)details[5] * 0.001f);
|
|
}
|
|
}
|
|
}
|