LethalCompany/Lethal Company/ExportedProject/Assets/Scripts/Assembly-CSharp/PreInitSceneScript.cs
2023-12-22 18:30:10 -05:00

99 lines
2.3 KiB
C#

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;
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();
StartCoroutine(loadSceneDelayed(online));
}
}
private IEnumerator loadSceneDelayed(bool online)
{
yield return new WaitForSeconds(0.2f);
if (online)
{
SceneManager.LoadScene("InitScene");
}
else
{
SceneManager.LoadScene("InitSceneLANMode");
}
}
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);
}
}