-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameManager.cs
More file actions
90 lines (75 loc) · 1.94 KB
/
Copy pathGameManager.cs
File metadata and controls
90 lines (75 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour
{
public enum Scene
{
Undefined=-1,
Title=0,
IntroCutscene=1,
Tutorial=2,
Camera=3,
Cabin=4
}
public static Scene CurrentScene;
public static bool AllowExitGame = true;
public static bool Paused = false;
public GameObject PauseMenu;
public AudioSource BackgroundMusic;
// Start is called before the first frame update
void Start()
{
CurrentScene = (Scene)SceneManager.GetActiveScene().buildIndex;
}
// Update is called once per frame
void Update()
{
if (AllowExitGame && !CurrentScene.Equals(Scene.Camera) && Input.GetKeyDown(KeyCode.Escape))
{
if (PauseMenu != null)
{
if (!Paused)
{
Pause();
}
else
{
Unpause();
}
}
else
{
ExitGame();
}
}
}
public static void ExitGame()
{
Application.Quit();
}
public static void StartGame()
{
ChangeScene((int)GameManager.Scene.IntroCutscene);
}
public static void ChangeScene(int buildIndex)
{
SceneManager.LoadScene(buildIndex);
CameraZoomEntry.ZoomReady = false;
}
public void Pause()
{
Time.timeScale = 0;
PauseMenu.SetActive(true);
InteractiveObject.UniversalInteractable = false;
BackgroundMusic.Stop();
}
public void Unpause()
{
Time.timeScale = 1;
PauseMenu.SetActive(false);
InteractiveObject.UniversalInteractable = true;
BackgroundMusic.Play();
}
}