-
Notifications
You must be signed in to change notification settings - Fork 0
/
PublicWorldWelcomeScript.cs
66 lines (56 loc) · 2.01 KB
/
PublicWorldWelcomeScript.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Firebase.Database;
public class PublicWorldWelcomeScript : MonoBehaviour {
// Start is called before the first frame update
public GameObject WelcomePanel;
public string worldName;
//test
public GameObject MatterMostConscript;
public int matterMostGreen = -1;
void Start() {
StartCoroutine(LateStart());
CronscriptyMattermost();
StartCoroutine(WithMatter());
}
IEnumerator LateStart() {
yield return new WaitForSeconds(5);
int worldsVisited = PlayerPrefs.GetInt("firstVisit");
if (worldName == "Moon") {
if (worldsVisited == 1 || worldsVisited == 3) {
WelcomePanel.SetActive(true);
worldsVisited += 3;
PlayerPrefs.SetInt("firstVisit", worldsVisited);
}
} else {
if (worldsVisited == 1 || worldsVisited == 4) {
WelcomePanel.SetActive(true);
worldsVisited += 2; //idk why i came up with this way of differentiating visiting world but avoid stashing more into local cache/playerprefs
PlayerPrefs.SetInt("firstVisit", worldsVisited);
}
}
}
public void ClosePanel() {
WelcomePanel.SetActive(false);
}
public void CronscriptyMattermost() {
DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;
reference.Child("withMatter").GetValueAsync().ContinueWith(task => {
DataSnapshot snapshot = task.Result;
string val = snapshot.Value.ToString();
Debug.Log("zzzval " + val);
matterMostGreen = (val == "yes") ? 1 : 0;
});
}
IEnumerator WithMatter() {
while (matterMostGreen == -1) {
yield return null;
}
if (matterMostGreen == 1) {
MatterMostConscript.SetActive(true);
} else {
MatterMostConscript.SetActive(false);
}
}
}