LethalCompany/Lethal Company/ExportedProject/Assets/Scripts/Assembly-CSharp/PreInitSceneScript.cs

156 lines
3.6 KiB
C#
Raw Normal View History

2023-12-22 22:51:17 +00:00
using System.Collections;
using Dissonance;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class PreInitSceneScript : MonoBehaviour
{
public AudioSource mainAudio;
public AudioClip hoverSFX;
public AudioClip selectSFX;
private bool choseLaunchOption;
[Header("Other initial launch settings")]
public Slider gammaSlider;
public GameObject continueButton;
public Animator blackTransition;
public GameObject OnlineModeButton;
public GameObject[] LaunchSettingsPanels;
public int currentLaunchSettingPanel;
public TextMeshProUGUI headerText;
2023-12-23 00:05:55 +00:00
private bool clickedDeleteFiles;
public GameObject FileCorruptedPanel;
public GameObject FileCorruptedDialoguePanel;
public GameObject FileCorruptedRestartButton;
public GameObject restartingGameText;
2023-12-23 02:13:19 +00:00
public GameObject launchSettingsPanelsContainer;
2023-12-22 22:51:17 +00:00
private void Awake()
{
DissonanceComms.TestDependencies();
}
private void Start()
{
gammaSlider.value = IngamePlayerSettings.Instance.settings.gammaSetting / 0.05f;
}
public void PressContinueButton()
{
if (currentLaunchSettingPanel < LaunchSettingsPanels.Length)
{
LaunchSettingsPanels[currentLaunchSettingPanel].SetActive(value: false);
currentLaunchSettingPanel++;
LaunchSettingsPanels[currentLaunchSettingPanel].SetActive(value: true);
blackTransition.SetTrigger("Transition");
if (currentLaunchSettingPanel >= LaunchSettingsPanels.Length - 1)
{
continueButton.SetActive(value: false);
headerText.text = "LAUNCH MODE";
}
}
}
public void HoverButton()
{
mainAudio.PlayOneShot(hoverSFX);
}
public void ChooseLaunchOption(bool online)
{
if (!choseLaunchOption)
{
choseLaunchOption = true;
mainAudio.PlayOneShot(selectSFX);
IngamePlayerSettings.Instance.SetPlayerFinishedLaunchOptions();
IngamePlayerSettings.Instance.SaveChangedSettings();
2023-12-23 00:30:32 +00:00
if (!IngamePlayerSettings.Instance.encounteredErrorDuringSave)
{
StartCoroutine(loadSceneDelayed(online));
}
2023-12-22 22:51:17 +00:00
}
}
private IEnumerator loadSceneDelayed(bool online)
{
yield return new WaitForSeconds(0.2f);
if (online)
{
SceneManager.LoadScene("InitScene");
}
else
{
SceneManager.LoadScene("InitSceneLANMode");
}
}
2023-12-23 02:13:19 +00:00
public void SetLaunchPanelsEnabled()
{
launchSettingsPanelsContainer.SetActive(value: true);
}
2023-12-22 22:51:17 +00:00
public void SkipToFinalSetting()
{
LaunchSettingsPanels[currentLaunchSettingPanel].SetActive(value: false);
currentLaunchSettingPanel = LaunchSettingsPanels.Length - 1;
LaunchSettingsPanels[currentLaunchSettingPanel].SetActive(value: true);
continueButton.SetActive(value: false);
headerText.text = "LAUNCH MODE";
EventSystem.current.SetSelectedGameObject(OnlineModeButton);
}
2023-12-23 00:05:55 +00:00
public void EnableFileCorruptedScreen()
{
LaunchSettingsPanels[currentLaunchSettingPanel].SetActive(value: false);
FileCorruptedPanel.SetActive(value: true);
EventSystem.current.SetSelectedGameObject(FileCorruptedRestartButton);
}
public void EraseFileAndRestart()
{
StartCoroutine(restartGameDueToCorruptedFile());
}
private IEnumerator restartGameDueToCorruptedFile()
{
if (ES3.FileExists("LCGeneralSaveData"))
{
ES3.DeleteFile("LCGeneralSaveData");
}
if (ES3.FileExists("LCSaveFile1"))
{
ES3.DeleteFile("LCSaveFile1");
}
if (ES3.FileExists("LCSaveFile2"))
{
ES3.DeleteFile("LCSaveFile2");
}
if (ES3.FileExists("LCSaveFile3"))
{
ES3.DeleteFile("LCSaveFile3");
}
FileCorruptedDialoguePanel.SetActive(value: false);
restartingGameText.SetActive(value: true);
yield return new WaitForSeconds(2f);
Application.Quit();
}
2023-12-22 22:51:17 +00:00
}