-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChallengeAssigner.cs
177 lines (115 loc) · 4.25 KB
/
ChallengeAssigner.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
using UnityEngine.SceneManagement;
public class ChallengeAssigner : MonoBehaviour
{
public MasterChallengeList challengeList;
public SavedChallengeData.ChallengeType challengegroup1Type;
public SavedChallengeData.ChallengeType challengegroup2Type;
public SavedChallengeData.ChallengeType challengegroup3Type;
public List<SavedChallengeData> challengepool1;
public List<SavedChallengeData> challengepool2;
public List<SavedChallengeData> challengepool3;
public SavedChallengeData activeChallenge1;
public SavedChallengeData activeChallenge2;
public SavedChallengeData activeChallenge3;
public List<ChallengeRenderer> challengeRenderers;
public string sceneToLoad;
public bool beginSceneLoad;
// Start is called before the first frame update
void Start()
{
//SetChallenges();
}
private void Update()
{
if(Input.GetKey(KeyCode.D) && beginSceneLoad == false) {
beginSceneLoad = true;
StartCoroutine(LoadYourAsyncSceneTest());
}
}
public void SetChallenges()
{
Invoke("SetChallenge1", 0f);
Invoke("SetChallenge2", 0.3f);
Invoke("SetChallenge3", 0.3f);
Invoke("GetNewChallenges",2f);
}
public void GetChallenges()
{
GetChallenge1();
GetChallenge2();
GetChallenge3();
}
public void SetChallenge1()
{
var result = from s in challengeList.challegeData
where s.ChallengeComplete == false && s.challengeType == challengegroup1Type
select s;
challengepool1 = result.ToList<SavedChallengeData>();
}
public void GetChallenge1()
{
int oRand = Random.Range(0, challengepool1.Count);
activeChallenge1 = challengepool1[oRand];
}
public void SetChallenge2()
{
var result = from s in challengeList.challegeData
where s.ChallengeComplete == false && s.challengeType == challengegroup2Type
select s;
challengepool2 = result.ToList<SavedChallengeData>();
}
public void GetChallenge2()
{
int oRand = Random.Range(0, challengepool2.Count);
activeChallenge2 = challengepool2[oRand];
}
public void SetChallenge3()
{
var result = from s in challengeList.challegeData
where s.ChallengeComplete == false && s.challengeType == challengegroup3Type
select s;
challengepool3 = result.ToList<SavedChallengeData>();
}
public void GetChallenge3()
{
int oRand = Random.Range(0, challengepool3.Count);
activeChallenge3 = challengepool3[oRand];
}
public void GetNewChallenges()
{
GetChallenge1();
GetChallenge2();
GetChallenge3();
challengeRenderers[0].SetChallenge(activeChallenge1);
challengeRenderers[1].SetChallenge(activeChallenge2);
challengeRenderers[2].SetChallenge(activeChallenge3);
//*** Set random challenge data on layer data controller
SetRandomChallengedata();
}
public void SetRandomChallengedata() {
Debug.Log("Setting player challenge data");
if(PlayerDataController.instance != null) {
Debug.Log("Player Data controller is NOT NULL!!!!");
PlayerDataController.instance.SetActiveChallengeData(activeChallenge1);
PlayerDataController.instance.SetActiveChallengeData(activeChallenge2);
PlayerDataController.instance.SetActiveChallengeData(activeChallenge3);
}
}
IEnumerator LoadYourAsyncSceneTest()
{
// 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;
}
}
}