-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDialACode.cs
More file actions
54 lines (46 loc) · 1.32 KB
/
DialACode.cs
File metadata and controls
54 lines (46 loc) · 1.32 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
using UnityEngine;
using System.Collections;
public class DialACode : MonoBehaviour {
public string codeToFind;
public string codeEntered;
public GameObject GOtoUnlock;
private static DialACode instance;
public static DialACode Instance {
get {
if(instance == null) {
instance = GameObject.FindObjectOfType<DialACode>();
}
return instance;
}
}
public void Init(GameObject go, string code){
GameSettings.PlayerBC.EnableControls(false);
codeEntered = "";
CanvasManager.Instance.SetVisible(GetComponent<CanvasGroup>(), true);
codeToFind = code;
GOtoUnlock = go;
}
public void AddNumberToCodeEntered(string number){
codeEntered += number;
if(codeEntered.Length == codeToFind.Length){
if(TestCode()){
GameSettings.PlayerBC.EnableControls(true);
if(GOtoUnlock.GetComponent<Container>() != null){
GOtoUnlock.GetComponent<Container>().Unlock();
GOtoUnlock.GetComponent<Container>().Open();
}
SoundManager.PlaySound(GameModel.Instance.DACSuccess);
CanvasManager.Instance.SetVisible(GetComponent<CanvasGroup>(), false);
} else {
SoundManager.PlaySound(GameModel.Instance.DACError);
CanvasManager.Instance.SetVisible(GetComponent<CanvasGroup>(), false);
}
}
}
public bool TestCode(){
if(codeToFind == codeEntered)
return true;
else
return false;
}
}