using System.Collections; using System.Collections.Generic; using UnityEngine; public class GameplayController : MonoBehaviour { [SerializeField] private LoadScene loadAdditiveScene; //public LoadScene loadAdditiveSceneForGameSystemsAndPlayer; public GameObject GameSystemsAndPlayer; [SerializeField] private GameObject OnLoadDontDestroy; [SerializeField] private GameObject playerRelatedSystem; public bool shouldLoadAdditiveSceneForManagersWhenGameLaunched = true; public bool DontDestroyOnLoadGameplayController = true; [HideInInspector] public bool isInteracting; [HideInInspector] public bool canInteract; public bool demoMode; public bool testingMode; public bool isInDebuggingState; private static GameplayController _instance; public static GameplayController GetInstance() { return _instance; } private void OnEnable() { if (!_instance) { _instance = this; } if (shouldLoadAdditiveSceneForManagersWhenGameLaunched && IsOnState(State.GameLaunched)) { OnLoadDontDestroy.SetActive(true); loadAdditiveScene.LoadAdditiveScene(); MainMenu.GetInstance().gameLaunchedLogosScreen.Play(); } } void Awake() { Logger.Initialize(); } private void Start() { shouldLoadAdditiveSceneForManagersWhenGameLaunched = false; } public enum State { GameLaunched, MainMenu, Gameplay, PauseMenu, InventoryMenu, ImportantTutorialMessage } public bool IsOnState(State checkState) { return currentGameState == checkState; } public void GoToMainMenuState() { currentGameState = State.MainMenu; } public void GoToGameplayState() { currentGameState = State.Gameplay; } public void GoToPauseMenuState() { currentGameState = State.PauseMenu; } public void GoToImportantTutorialMessageState() { currentGameState = State.ImportantTutorialMessage; } public void GoToInventoryMenuState() { currentGameState = State.InventoryMenu; } public State currentGameState = State.MainMenu; public void UpdateGameStates() { switch (currentGameState) { case State.GameLaunched: break; case State.MainMenu: if (InputControlManager.Getinstance().IsUsingJoystick) { HideCursor(); } else { DisplayCursor(); } break; case State.Gameplay: break; case State.PauseMenu: if (InputControlManager.Getinstance().IsUsingJoystick) { HideCursor(); } else { DisplayCursor(); } break; case State.InventoryMenu: break; case State.ImportantTutorialMessage: break; default: break; } } private void Update() { UpdateGameStates(); } public void HideCursor() { // Restore the cursor visibility state when the script is destroyed Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; } public void DisplayCursor() { // Restore the cursor visibility state when the script is destroyed Cursor.visible = true; Cursor.lockState = CursorLockMode.None; } public void InstantiatePlayerRelatedSystem() { Instantiate(playerRelatedSystem); } }