-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoSceneChange.cs
More file actions
48 lines (41 loc) · 1.45 KB
/
Copy pathAutoSceneChange.cs
File metadata and controls
48 lines (41 loc) · 1.45 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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
// Unless denoted by a commented out link, TK wrote literally everything here
// Auto calls Main Menu scene on a delay with fadeout of screen & music
// Only called for GameOver / Win Game
public class AutoSceneChange : MonoBehaviour
{
public SceneChanger sceneChanger;
public Animator blackScreenAnimator;
public float waitSeconds = 4.0f;
public int sceneNum = 0;
// Start is called before the first frame update
void Start()
{
Scene s = SceneManager.GetActiveScene();
if (s.name == "1GameOver")
{
StartCoroutine(WaitSceneChange(waitSeconds, sceneNum));
}
else if (s.name == "2BeatGame")
{
waitSeconds = 9.0f;
sceneNum = 3; // currently points to mainmenu, may change to credits
StartCoroutine(WaitSceneKeepBGM(waitSeconds, sceneNum));
}
}
IEnumerator WaitSceneChange(float sec, int scene)
{
yield return new WaitForSeconds(sec);
Debug.Log("RETURNING TO GAME'S MAIN MENU!");
sceneChanger.masterSceneFadeOut(scene);
}
IEnumerator WaitSceneKeepBGM(float sec, int scene)
{
yield return new WaitForSeconds(sec);
Debug.Log("RETURNING TO GAME'S MAIN MENU!");
sceneChanger.sceneFadeOutKeepMusic(scene);
}
}