2023-12-22 22:51:17 +00:00
|
|
|
using TMPro;
|
|
|
|
using UnityEngine;
|
2023-12-23 02:13:19 +00:00
|
|
|
using UnityEngine.UI;
|
2023-12-22 22:51:17 +00:00
|
|
|
|
|
|
|
public class SaveFileUISlot : MonoBehaviour
|
|
|
|
{
|
2023-12-23 02:13:19 +00:00
|
|
|
public Button fileButton;
|
|
|
|
|
2023-12-22 22:51:17 +00:00
|
|
|
public Animator buttonAnimator;
|
|
|
|
|
|
|
|
public TextMeshProUGUI fileStatsText;
|
|
|
|
|
|
|
|
public int fileNum;
|
|
|
|
|
|
|
|
private string fileString;
|
|
|
|
|
|
|
|
public TextMeshProUGUI fileNotCompatibleAlert;
|
|
|
|
|
2023-12-23 02:13:19 +00:00
|
|
|
public TextMeshProUGUI specialTipText;
|
|
|
|
|
|
|
|
public TextMeshProUGUI fileNameText;
|
|
|
|
|
2023-12-22 22:51:17 +00:00
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
switch (fileNum)
|
|
|
|
{
|
2023-12-23 02:13:19 +00:00
|
|
|
case -1:
|
|
|
|
fileString = "LCChallengeFile";
|
|
|
|
break;
|
2023-12-22 22:51:17 +00:00
|
|
|
case 0:
|
|
|
|
fileString = "LCSaveFile1";
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
fileString = "LCSaveFile2";
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
fileString = "LCSaveFile3";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fileString = "LCSaveFile1";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-23 02:13:19 +00:00
|
|
|
private void SetChallengeFileSettings()
|
|
|
|
{
|
|
|
|
if (Object.FindObjectOfType<MenuManager>().hasChallengeBeenCompleted)
|
|
|
|
{
|
|
|
|
int num = ES3.Load("ProfitEarned", fileString, 0);
|
|
|
|
fileStatsText.enabled = true;
|
|
|
|
fileStatsText.text = $"${num} Collected";
|
|
|
|
GameNetworkManager.Instance.currentSaveFileName = "LCSaveFile1";
|
|
|
|
GameNetworkManager.Instance.saveFileNum = 0;
|
|
|
|
SetButtonColorForAllFileSlots();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fileStatsText.enabled = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-22 22:51:17 +00:00
|
|
|
private void OnEnable()
|
|
|
|
{
|
2023-12-23 02:13:19 +00:00
|
|
|
if (fileNum == -1)
|
|
|
|
{
|
|
|
|
fileNameText.text = GameNetworkManager.Instance.GetNameForWeekNumber();
|
|
|
|
}
|
2023-12-22 22:51:17 +00:00
|
|
|
if (ES3.FileExists(fileString))
|
|
|
|
{
|
2023-12-23 02:13:19 +00:00
|
|
|
if (fileNum == -1)
|
|
|
|
{
|
|
|
|
SetChallengeFileSettings();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int num = ES3.Load("GroupCredits", fileString, 0);
|
|
|
|
int num2 = ES3.Load("Stats_DaysSpent", fileString, 0);
|
|
|
|
fileStatsText.text = $"${num}\nDays: {num2}";
|
|
|
|
}
|
2023-12-22 22:51:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fileStatsText.text = "";
|
|
|
|
}
|
2023-12-23 02:13:19 +00:00
|
|
|
if (fileNum != -1 && !Object.FindObjectOfType<MenuManager>().filesCompatible[fileNum])
|
2023-12-22 22:51:17 +00:00
|
|
|
{
|
|
|
|
fileNotCompatibleAlert.enabled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetButtonColor()
|
|
|
|
{
|
|
|
|
buttonAnimator.SetBool("isPressed", GameNetworkManager.Instance.currentSaveFileName == fileString);
|
2023-12-23 02:13:19 +00:00
|
|
|
if (specialTipText != null && GameNetworkManager.Instance.currentSaveFileName != fileString)
|
|
|
|
{
|
|
|
|
specialTipText.enabled = false;
|
|
|
|
}
|
2023-12-22 22:51:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SetFileToThis()
|
|
|
|
{
|
2023-12-23 02:13:19 +00:00
|
|
|
if (Object.FindObjectOfType<MenuManager>().requestingLeaderboard)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (fileNum == -1 && Object.FindObjectOfType<MenuManager>().hasChallengeBeenCompleted)
|
|
|
|
{
|
|
|
|
Object.FindObjectOfType<MenuManager>().EnableLeaderboardDisplay(enable: true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Object.FindObjectOfType<MenuManager>().EnableLeaderboardDisplay(enable: false);
|
|
|
|
if (fileNum == -1)
|
|
|
|
{
|
|
|
|
specialTipText.text = "This is the weekly challenge moon. You have one day and one attempt to make as much profit as possible.";
|
|
|
|
specialTipText.enabled = true;
|
|
|
|
}
|
|
|
|
}
|
2023-12-22 22:51:17 +00:00
|
|
|
GameNetworkManager.Instance.currentSaveFileName = fileString;
|
|
|
|
GameNetworkManager.Instance.saveFileNum = fileNum;
|
|
|
|
SetButtonColorForAllFileSlots();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetButtonColorForAllFileSlots()
|
|
|
|
{
|
|
|
|
SaveFileUISlot[] array = Object.FindObjectsOfType<SaveFileUISlot>();
|
|
|
|
for (int i = 0; i < array.Length; i++)
|
|
|
|
{
|
|
|
|
array[i].SetButtonColor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|