Files
2026-03-04 10:03:45 +08:00

207 lines
7.8 KiB
C#

using UnityEngine;
using UnityEngine.UI;
public class ProfileCreation : MonoBehaviour
{
public ProfileSlot[] profilesContainer;
public int profileIDtoDellete = -1;
public Button getCloudeButton;
private bool checkloadprofile;
public MainGameScene mainGameScene;
private void Start()
{
Singleton<InputManager>.Instance.StartControllerPopUpWork();
ShowProfileSlots();
}
public void LoadProfiles()
{
if (Singleton<SteamStorage>.Instance.isLoadedProfiles && !checkloadprofile)
{
ResetViewAllProfiles();
ShowProfileSlots();
checkloadprofile = true;
}
}
private void ResetViewAllProfiles()
{
for (int i = 0; i < profilesContainer.Length; i++)
{
profilesContainer[i].profileContainer.gameObject.SetActive(value: false);
}
}
public void ShowProfileSlots()
{
for (int i = 0; i < Singleton<SaveDataManager>.Instance.PlayerData.Count; i++)
{
SaveDataManager.SavePlayerDataClass specifiedPlayerData = Singleton<SaveDataManager>.Instance.GetSpecifiedPlayerData(i);
if (specifiedPlayerData.IsEnabled)
{
profilesContainer[i].profileNameText.text = specifiedPlayerData.PlayerName;
profilesContainer[i].profileLevelText.text = specifiedPlayerData.PlayerLevel.ToString();
profilesContainer[i].profileTotalFishText.text = specifiedPlayerData.TotalFish.ToString();
profilesContainer[i].profileContainer.gameObject.SetActive(value: true);
profilesContainer[i].GetComponent<Image>().enabled = false;
profilesContainer[i].GetComponent<Button>().interactable = false;
profilesContainer[i].chooseBtn.SetActive(value: true);
profilesContainer[i].genderContainer.SetActive(value: false);
switch (specifiedPlayerData.GameMode)
{
case GameManager.PlayerData.CPlayer.GameMode.None:
profilesContainer[i].profileGameModeBtns[0].SetActive(value: false);
profilesContainer[i].profileGameModeBtns[1].SetActive(value: true);
profilesContainer[i].profileGameModeBtns[2].SetActive(value: true);
profilesContainer[i].profileGameModeBtns[3].SetActive(value: true);
profilesContainer[i].profileGameModeBtns[0].GetComponent<HoverText>().SelectItem();
break;
case GameManager.PlayerData.CPlayer.GameMode.Demo:
profilesContainer[i].profileGameModeBtns[0].SetActive(value: true);
profilesContainer[i].profileGameModeBtns[1].SetActive(value: false);
profilesContainer[i].profileGameModeBtns[2].SetActive(value: false);
profilesContainer[i].profileGameModeBtns[3].SetActive(value: false);
profilesContainer[i].profileGameModeBtns[0].GetComponent<HoverText>().SelectItem();
profilesContainer[i].ShowGenderSelection();
if (profilesContainer[i].profileNameText.text != "")
{
profilesContainer[i].chooseBtn.SetActive(value: true);
}
else
{
profilesContainer[i].chooseBtn.SetActive(value: false);
}
break;
case GameManager.PlayerData.CPlayer.GameMode.Normal:
profilesContainer[i].profileGameModeBtns[0].SetActive(value: false);
profilesContainer[i].profileGameModeBtns[1].SetActive(value: true);
profilesContainer[i].profileGameModeBtns[2].SetActive(value: false);
profilesContainer[i].profileGameModeBtns[3].SetActive(value: false);
profilesContainer[i].profileGameModeBtns[1].GetComponent<HoverText>().SelectItem();
profilesContainer[i].ShowGenderSelection();
if (profilesContainer[i].profileNameText.text != "")
{
profilesContainer[i].chooseBtn.SetActive(value: true);
}
else
{
profilesContainer[i].chooseBtn.SetActive(value: false);
}
break;
case GameManager.PlayerData.CPlayer.GameMode.Realistic:
profilesContainer[i].profileGameModeBtns[0].SetActive(value: false);
profilesContainer[i].profileGameModeBtns[1].SetActive(value: false);
profilesContainer[i].profileGameModeBtns[2].SetActive(value: true);
profilesContainer[i].profileGameModeBtns[3].SetActive(value: false);
profilesContainer[i].profileGameModeBtns[2].GetComponent<HoverText>().SelectItem();
profilesContainer[i].ShowGenderSelection();
if (profilesContainer[i].profileNameText.text != "")
{
profilesContainer[i].chooseBtn.SetActive(value: true);
}
else
{
profilesContainer[i].chooseBtn.SetActive(value: false);
}
break;
case GameManager.PlayerData.CPlayer.GameMode.Sandbox:
profilesContainer[i].profileGameModeBtns[0].SetActive(value: false);
profilesContainer[i].profileGameModeBtns[1].SetActive(value: false);
profilesContainer[i].profileGameModeBtns[2].SetActive(value: false);
profilesContainer[i].profileGameModeBtns[3].SetActive(value: true);
profilesContainer[i].profileLevelText.text = "∞";
profilesContainer[i].profileGameModeBtns[3].GetComponent<HoverText>().SelectItem();
profilesContainer[i].ShowGenderSelection();
if (profilesContainer[i].profileNameText.text != "")
{
profilesContainer[i].chooseBtn.SetActive(value: true);
}
else
{
profilesContainer[i].chooseBtn.SetActive(value: false);
}
break;
}
if (profilesContainer[i].profileNameText.text != "" && Singleton<SaveDataManager>.Instance.GetSpecifiedPlayerData(i).GameMode != GameManager.PlayerData.CPlayer.GameMode.None)
{
profilesContainer[i].chooseBtn.SetActive(value: true);
}
else
{
profilesContainer[i].chooseBtn.SetActive(value: false);
}
}
else
{
profilesContainer[i].profileContainer.gameObject.SetActive(value: false);
profilesContainer[i].GetComponent<Image>().enabled = true;
profilesContainer[i].GetComponent<Button>().interactable = true;
profilesContainer[i].chooseBtn.SetActive(value: false);
}
}
}
public void SelectGameMode(int profileID, int index)
{
Singleton<SaveDataManager>.Instance.GetSpecifiedPlayerData(profileID).GameMode = (GameManager.PlayerData.CPlayer.GameMode)(index + 1);
ShowProfileSlots();
profilesContainer[profileID].ShowGenderSelection();
}
public void ChooseProfile(int profileIndex)
{
GameManager.Instance._playerData.currentPlayerProfileIndex = profileIndex;
GameManager.Instance._playerData.LoadAllPlayerData();
Singleton<SaveDataManager>.Instance.ResetPlayerBaskets();
AudioListener.volume = Singleton<SaveDataManager>.Instance.SettingsData.MasterVolume;
mainGameScene.SetProfilesSelection();
Application.targetFrameRate = GameManager.Instance._playerData.Player[GameManager.Instance._playerData.currentPlayerProfileIndex].MaxFps[Singleton<SaveDataManager>.Instance.SettingsData.MaxFpsIndex];
GameManager.Instance._playerData.QuestTimer();
GameManager.Instance._playerData.WeeklyQuestTimer();
GameManager.Instance._playerData.MonthlyQuestTimer();
}
public void CreateProfile(int profileIndex)
{
profilesContainer[profileIndex].profileNameText.interactable = true;
if (!Singleton<SaveDataManager>.Instance.GetSpecifiedPlayerData(profileIndex).IsEnabled)
{
GameManager.Instance._playerData.Player[profileIndex].ResetProfile(profileIndex);
Singleton<SaveDataManager>.Instance.GetSpecifiedPlayerData(profileIndex).IsEnabled = true;
ShowProfileSlots();
}
}
public void DeleteProfile()
{
if (profileIDtoDellete != -1)
{
Singleton<SaveDataManager>.Instance.ResetSpecifiedPlayerData(profileIDtoDellete);
GameManager.Instance._playerData.Player[profileIDtoDellete].ResetProfile(profileIDtoDellete);
profilesContainer[profileIDtoDellete].GetComponent<Button>().interactable = true;
EasySaveSystemManager.WriteSaveLog("Player manually deleted profile: " + profileIDtoDellete);
ShowProfileSlots();
profileIDtoDellete = -1;
}
}
public void GetProfilesFromSteamCloude()
{
if (SteamManager.Initialized && (bool)Singleton<SteamStorage>.Instance)
{
Singleton<SteamStorage>.Instance.GetCloudeSteamSavesButton();
}
}
private void OnEnable()
{
Singleton<SteamStorage>.Instance.CheckIsCloudeSaves();
ShowProfileSlots();
}
}