-
Notifications
You must be signed in to change notification settings - Fork 0
/
DrinkLoader.cs
141 lines (94 loc) · 3.2 KB
/
DrinkLoader.cs
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
141
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class DrinkLoader : MonoBehaviour
{
//***Name of Save File drink
public string drinkName;
//*** Key for input test key values
public KeyCode inputTestKey;
//*** Name of Scene to load
public string SceneToLoad;
public bool sceneLoadInitialized;
public string HubSceneName;
public string IntroSceneName;
public int saveFileIndex;
public MeshExploder[] meshExploders;
public MeshRenderer[] meshRenderers;
public GameObject highLightParticle;
//*** PLAYER PREFS KEY
private string FirstIntroKey = "FIRST_INTRO";
private NewSaveDataTest saveDataManager;
public void Update()
{
if (Input.GetKeyDown(inputTestKey) && sceneLoadInitialized == false)
{
sceneLoadInitialized = true;
SetSavefile();
}
if (highLightParticle != null)
{
if (highLightParticle.active)
highLightParticle.SetActive(false);
}
}
public void SetSavefile()
{
//SaveDataManager.instance.SetSaveFileData(saveFileIndex);
SetFirstSceneToLoad();
PlayerFadeController.instance.ActivateFader();
// Debug.Log("Activating powerups !!!!");
for (int i = 0; i < meshExploders.Length; i++)
{
//Debug.Log("Powerup index == " + i.ToString());
meshExploders[i].Explode();
meshRenderers[i].enabled = false;
//meshExploders[i].gameObject.SetActive(false);
}
AudioManager.instance.PlayBottleShatterAudio();
Invoke("BeginAsyncSceneLoad", 3f);
}
public void SetFirstSceneToLoad()
{
//*** If Completed Intro Tour
/*if (PlayerPrefs.HasKey(FirstIntroKey) == true)
{
SceneToLoad = HubSceneName;
}
else //*** Else if fresh save file show beginning intro area
{
SceneToLoad = IntroSceneName;
}*/
saveDataManager = GameObject.FindObjectOfType<NewSaveDataTest>();
if (saveDataManager != null)
{
//*** Has nor entered the combat arena load intro scene
if (saveDataManager.storedData.enteredFirstCombatArena == false)
{
SceneToLoad = IntroSceneName;
}
else //*** Has entered the combat arena before, loading into player bedroom.
{
SceneToLoad = HubSceneName;
}
}
}
public void BeginAsyncSceneLoad()
{
StartCoroutine(LoadAsyncScene());
}
IEnumerator LoadAsyncScene()
{
// The Application loads the Scene in the background as the current Scene runs.
// This is particularly good for creating loading screens.
// You could also load the Scene by using sceneBuildIndex. In this case Scene2 has
// a sceneBuildIndex of 1 as shown in Build Settings.
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(SceneToLoad);
// Wait until the asynchronous scene fully loads
while (!asyncLoad.isDone)
{
yield return null;
}
}
}