159 lines
4.3 KiB
C#
159 lines
4.3 KiB
C#
using BitStrap;
|
|
using CurvedUI;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class LeaderboardWidget : MonoBehaviour
|
|
{
|
|
public Image background;
|
|
|
|
public Color backgroundColor1 = Color.grey;
|
|
|
|
public Color backgroundColor2 = Color.black;
|
|
|
|
public Color backgroundColorMy = Color.green;
|
|
|
|
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()
|
|
{
|
|
CheckCurvedUI();
|
|
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, LeaderboardsManager.LeaderboardPlayerStats leaderboardPlayerStats)
|
|
{
|
|
CheckCurvedUI();
|
|
GlobalSettings instance = GlobalSettings.Instance;
|
|
background.color = backgroundColor1;
|
|
if ((int)leaderboardPlayerStats.leaderboardTotalFishCount > 0 && rank != -1)
|
|
{
|
|
rankText.text = rank.ToString();
|
|
}
|
|
else
|
|
{
|
|
rankText.text = "-";
|
|
}
|
|
nameText.text = GlobalSettings.Instance.GetPlatformProfileName();
|
|
scoreText.text = leaderboardPlayerStats.leaderboardScore.ToString();
|
|
levelText.text = leaderboardPlayerStats.leaderboardLevel.ToString();
|
|
expText.text = leaderboardPlayerStats.leaderboardExp.ToString();
|
|
fishCountText.text = leaderboardPlayerStats.leaderboardTotalFishCount.ToString();
|
|
fishTotalWeightText.text = UtilitiesUnits.GetWeightString((float)(int)leaderboardPlayerStats.leaderboardTotalFishWeight * 0.001f);
|
|
FishManager.FishDefinition fishDefinition = null;
|
|
if ((int)leaderboardPlayerStats.leaderboardBiggestFishSpecies != -1)
|
|
{
|
|
fishDefinition = GlobalSettings.Instance.fishManager.GetFishDefinition((Fish.Species)(int)leaderboardPlayerStats.leaderboardBiggestFishSpecies);
|
|
}
|
|
if ((int)leaderboardPlayerStats.leaderboardBiggestFishSpecies == -1 || fishDefinition == null)
|
|
{
|
|
biggestSpeciesText.text = "-";
|
|
}
|
|
else
|
|
{
|
|
biggestSpeciesText.text = Utilities.GetTranslation(fishDefinition.fishPrefab.fishName);
|
|
}
|
|
if ((int)leaderboardPlayerStats.leaderboardBiggestFishWeight <= 0 || fishDefinition == null)
|
|
{
|
|
biggestWeightText.text = "-";
|
|
}
|
|
else
|
|
{
|
|
biggestWeightText.text = UtilitiesUnits.GetWeightString((float)(int)leaderboardPlayerStats.leaderboardBiggestFishWeight * 0.001f);
|
|
}
|
|
}
|
|
|
|
public void RefreshWidget(ulong platformProfileID, string playerName, int[] details, int listPosition)
|
|
{
|
|
CheckCurvedUI();
|
|
if (platformProfileID == GlobalSettings.Instance.GetPlatformProfileID())
|
|
{
|
|
background.color = backgroundColorMy;
|
|
}
|
|
else if ((float)listPosition % 2f == 0f)
|
|
{
|
|
background.color = backgroundColor2;
|
|
}
|
|
else
|
|
{
|
|
background.color = backgroundColor1;
|
|
}
|
|
platformID = platformProfileID;
|
|
if (details[2] > 0)
|
|
{
|
|
rankText.text = listPosition.ToString();
|
|
}
|
|
else
|
|
{
|
|
rankText.text = "-";
|
|
}
|
|
nameText.text = playerName;
|
|
scoreText.text = details[6].ToString();
|
|
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);
|
|
}
|
|
}
|
|
|
|
public void CheckCurvedUI()
|
|
{
|
|
if (!VRManager.Instance.useCurvedUI)
|
|
{
|
|
CurvedUIVertexEffect[] componentsInChildren = GetComponentsInChildren<CurvedUIVertexEffect>();
|
|
for (int i = 0; i < componentsInChildren.Length; i++)
|
|
{
|
|
Object.DestroyImmediate(componentsInChildren[i]);
|
|
}
|
|
}
|
|
}
|
|
}
|