added transition scene with basic tutorial AND PERSISTENT DATA

PLEASE launch game from the main menu scene, otherwise persistent data will not load correctly
This commit is contained in:
slevy14
2023-04-25 13:27:12 -07:00
parent cea079d243
commit c0f9749da5
17 changed files with 1790 additions and 242 deletions

View File

@@ -1,6 +1,8 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class StateController : MonoBehaviour {
@@ -9,14 +11,49 @@ public class StateController : MonoBehaviour {
public GameObject spawnPoint;
[SerializeField] private GameObject deathCanvas;
[Header("Pause Menu")]
public bool isPaused = false;
public GameObject pauseMenuCanvas;
void Awake() {
deathCanvas.SetActive(false);
DontDestroyOnLoad(this.gameObject);
SceneManager.sceneLoaded += OnSceneLoaded;
}
void OnSceneLoaded(Scene scene, LoadSceneMode mode) {
deathCanvas = GameObject.Find("DeathUICanvas");
if (deathCanvas != null) {
Button respawnButton = GameObject.Find("RespawnButton").GetComponent<Button>();
respawnButton.onClick.AddListener(RespawnPlayer);
deathCanvas.SetActive(false);
}
pauseMenuCanvas = GameObject.Find("PauseMenuCanvas");
if (pauseMenuCanvas != null) {
TogglePauseMenu(false);
}
}
void OnPause() {
if (!isPaused) {
Time.timeScale = 0;
TogglePauseMenu(true);
} else {
Time.timeScale = 1;
TogglePauseMenu(false);
}
isPaused = !isPaused;
}
void TogglePauseMenu(bool showPauseMenu) {
pauseMenuCanvas.SetActive(showPauseMenu);
}
public void RespawnPlayer() {
SetDeathCanvasActive(false);
GameObject.Find("Main Camera").GetComponent<CameraMovement>().FindPlayer();
Instantiate(player, spawnPoint.transform.position, spawnPoint.transform.rotation);
Instantiate(player, spawnPoint.transform.position, player.transform.rotation);
}
public void SetDeathCanvasActive(bool activeState) {