154 lines
4.5 KiB
C#
154 lines
4.5 KiB
C#
using BitStrap;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class LevelStatsController : MonoBehaviour
|
|
{
|
|
public Text nameText;
|
|
|
|
public Text descriptionText;
|
|
|
|
public float testTime;
|
|
|
|
public Text hourText;
|
|
|
|
public Button hourInc;
|
|
|
|
public Button hourDec;
|
|
|
|
private LevelsManager levelsManager;
|
|
|
|
private LevelsManager.FisheryDefinition currentFishery;
|
|
|
|
private void OnEnable()
|
|
{
|
|
if ((bool)GlobalSettings.Instance)
|
|
{
|
|
if (levelsManager == null)
|
|
{
|
|
levelsManager = GlobalSettings.Instance.levelsManager;
|
|
currentFishery = levelsManager.GetCurrentFishery();
|
|
}
|
|
Refresh();
|
|
}
|
|
}
|
|
|
|
public void CloseMap()
|
|
{
|
|
GetComponentInParent<MapController>().ShowMapFromButton(false);
|
|
}
|
|
|
|
public void Refresh()
|
|
{
|
|
if (levelsManager == null)
|
|
{
|
|
return;
|
|
}
|
|
nameText.text = Utilities.GetTranslation(currentFishery.name);
|
|
descriptionText.text = string.Empty;
|
|
Text text = descriptionText;
|
|
text.text = text.text + FormatHeader(Utilities.GetTranslation("ENCYCLOPEDIA/TIME_SPENT")) + "\n";
|
|
Text text2 = descriptionText;
|
|
text2.text = text2.text + FormatTime(currentFishery.fisheryStats.timeSpent) + "\n\n";
|
|
Text text3 = descriptionText;
|
|
text3.text = text3.text + FormatHeader(Utilities.GetTranslation("ENCYCLOPEDIA/CAUGHT")) + "\n";
|
|
Text text4 = descriptionText;
|
|
string text5 = text4.text;
|
|
text4.text = string.Concat(text5, currentFishery.fisheryStats.fishCaught, " (", UtilitiesUnits.GetWeightString(currentFishery.fisheryStats.weightSum), ")\n\n");
|
|
Text text6 = descriptionText;
|
|
text6.text = text6.text + FormatHeader(Utilities.GetTranslation("ENCYCLOPEDIA/FIGHTS")) + "\n";
|
|
if ((int)currentFishery.fisheryStats.bitesAmount > 0)
|
|
{
|
|
Text text7 = descriptionText;
|
|
text5 = text7.text;
|
|
text7.text = string.Concat(text5, currentFishery.fisheryStats.bitesAmount, " (", Mathf.RoundToInt((float)(int)currentFishery.fisheryStats.fishCaught / (float)(int)currentFishery.fisheryStats.bitesAmount * 100f), "% ", Utilities.GetTranslation("ENCYCLOPEDIA/WON"), ")\n\n");
|
|
}
|
|
else
|
|
{
|
|
Text text8 = descriptionText;
|
|
text8.text = text8.text + "0 (0% " + Utilities.GetTranslation("ENCYCLOPEDIA/WON") + ")\n\n";
|
|
}
|
|
Text text9 = descriptionText;
|
|
text9.text = text9.text + FormatHeader(Utilities.GetTranslation("ENCYCLOPEDIA/BIGGEST_CAUGHT")) + "\n";
|
|
if ((float)currentFishery.fisheryStats.biggestWeight > 0f)
|
|
{
|
|
FishManager.FishDefinition fishDefinition = GlobalSettings.Instance.fishManager.GetFishDefinition(currentFishery.fisheryStats.biggestFish);
|
|
if (fishDefinition != null)
|
|
{
|
|
Text text10 = descriptionText;
|
|
text10.text = text10.text + Utilities.GetTranslation(fishDefinition.fishPrefab.fishName) + "\n";
|
|
Text text11 = descriptionText;
|
|
text11.text = text11.text + UtilitiesUnits.GetWeightString(currentFishery.fisheryStats.biggestWeight) + "\n";
|
|
Text text12 = descriptionText;
|
|
text12.text = text12.text + UtilitiesUnits.GetLengthString(currentFishery.fisheryStats.biggestLength) + "\n\n";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
descriptionText.text += "-\n\n";
|
|
}
|
|
Text text13 = descriptionText;
|
|
text13.text = text13.text + FormatHeader(Utilities.GetTranslation("LEVELS/FISH_SPECIES")) + "\n";
|
|
for (int i = 0; i < currentFishery.fishSpecies.Count; i++)
|
|
{
|
|
FishManager.FishDefinition fishDefinition2 = GlobalSettings.Instance.fishManager.GetFishDefinition(currentFishery.fishSpecies[i]);
|
|
if (fishDefinition2 != null && (fishDefinition2.isAvailable || GlobalSettings.Instance.turnOnCheats || (fishDefinition2.onlyInBeta && GlobalSettings.Instance.isBeta)))
|
|
{
|
|
descriptionText.text += Utilities.GetTranslation(fishDefinition2.fishPrefab.fishName);
|
|
if (i < currentFishery.fishSpecies.Count - 1)
|
|
{
|
|
descriptionText.text += "\n";
|
|
}
|
|
}
|
|
}
|
|
RefreshHour();
|
|
}
|
|
|
|
public void ChangeHour(bool inc)
|
|
{
|
|
GameController.Instance.ChangeHour(inc);
|
|
RefreshHour();
|
|
}
|
|
|
|
public void RefreshHour()
|
|
{
|
|
if ((bool)hourText)
|
|
{
|
|
hourText.text = GameController.Instance.weatherLevelManager.GetHour() + ":" + GameController.Instance.weatherLevelManager.GetMinutes().ToString("00");
|
|
}
|
|
}
|
|
|
|
public static string FormatHeader(string header)
|
|
{
|
|
return "<i>" + header + "</i>";
|
|
}
|
|
|
|
public static string FormatHeaderGlobal(string header)
|
|
{
|
|
return header;
|
|
}
|
|
|
|
[Button]
|
|
public void FormatTimeTest()
|
|
{
|
|
Debug.Log(FormatTime(testTime));
|
|
}
|
|
|
|
public static string FormatTime(float time)
|
|
{
|
|
string empty = string.Empty;
|
|
int num = 0;
|
|
int num2 = 0;
|
|
time /= 60f;
|
|
num2 = Mathf.RoundToInt(time % 60f);
|
|
time -= (float)num2;
|
|
empty += Mathf.RoundToInt(time / 60f);
|
|
empty += ":";
|
|
if (num2 < 10)
|
|
{
|
|
empty += "0";
|
|
}
|
|
return empty + num2;
|
|
}
|
|
}
|