-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSceneChanger.cs
More file actions
140 lines (110 loc) · 3.43 KB
/
SceneChanger.cs
File metadata and controls
140 lines (110 loc) · 3.43 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
// Unless denoted by a commented out link, TK wrote literally everything here
public class SceneChanger : MonoBehaviour
{
public void Start()
{
// this.StartCoroutine(fadeInDisableScreen());
}
// Exit the game from Main Menu
public void MenuQuitGame()
{
Debug.Log("The Game is Exiting.");
Application.Quit();
}
// Load scene by number in build order
public void GoSceneNumber(int num)
{
Debug.Log("Loading Scene Number " + num + ".");
SceneManager.LoadScene(num);
}
// ------------------------------------------------------ //
// FADE IN/OUT STUFF:
// Drag AudioManager object that's IN SCENE to this place in inspector
public AudioManagerScript audioManager;
public Animator blackScreeneAnimator;
public GameObject blackScreen;
public IEnumerator fadeInDisableScreen()
{
yield return new WaitForSeconds(1.1f);
blackScreen.SetActive(false);
}
public void sceneFadeOutKeepMusic(int scene)
{
// enable blackScreen UI object
blackScreen.SetActive(true);
// trigger fade to black animation
blackScreeneAnimator.SetTrigger("BlackFadeOutAnimation");
// start delayed scene switch
this.StartCoroutine(fadeOutSwitchScene(scene));
}
// scene is the scene number we are switching to
public void masterSceneFadeOut(int scene)
{
// enable blackScreen UI object
blackScreen.SetActive(true);
// trigger fade to black animation
blackScreeneAnimator.SetTrigger("BlackFadeOutAnimation");
// fade the music out (time)
audioManager.FadeOutBGM(1.2f);
// start delayed scene switch
this.StartCoroutine(fadeOutSwitchScene(scene));
}
public IEnumerator fadeOutSwitchScene(int scene)
{
yield return new WaitForSeconds(1.3f);
GoSceneNumber(scene);
}
// ------------------------------------------------------ //
// WARNING!!!!!!!!!!!!!!!
// If you rename any of the scenes
// these functions will not work anymore:
public void GoMainMenu()
{
Debug.Log("Loading Main Menu.");
SceneManager.LoadScene("0MainMenu");
}
public void GoGameOver()
{
Debug.Log("Loading Game Over.");
SceneManager.LoadScene("1GameOver");
}
public void GoBeatGame()
{
Debug.Log("Loading Beat Game.");
SceneManager.LoadScene("2BeatGame");
}
public void GoCredits()
{
Debug.Log("Loading Credits.");
SceneManager.LoadScene("3Credits");
}
public void GoGymMenu()
{
Debug.Log("Loading GymMenu.");
SceneManager.LoadScene("4GymMenu");
}
public void GoMatch()
{
Debug.Log("Loading Match.");
SceneManager.LoadScene("5Match");
}
public void GoSparring()
{
Debug.Log("Loading Sparring.");
SceneManager.LoadScene("6Sparring");
}
public void GoRankUp()
{
Debug.Log("Loading Rank Up.");
SceneManager.LoadScene("7RankUp");
}
public void GoSpendEXP()
{
Debug.Log("Loading Spend EXP.");
SceneManager.LoadScene("8SpendEXP");
}
}