-
Notifications
You must be signed in to change notification settings - Fork 0
/
MenuScript.js
104 lines (67 loc) · 1.89 KB
/
MenuScript.js
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
#pragma strict
//
//@script ExecuteInEditMode() //--makes this bit work without having to click play
var showLevels : boolean = false;
private var btnWidth = 200;
private var btnHeight = 40;
private var btnVerticalPos : int;
private var boxWidth = 500;
private var boxHeight : int = 500;
var levelReached :int = 0;
function Start() {
var levelReachedLoad : int = PlayerPrefs.GetInt("levelReached");
Debug.Log("LevelReachedLoad = "+levelReachedLoad);
if(levelReachedLoad > 0)
{
levelReached = levelReachedLoad;
}
Debug.Log("levelReached"+levelReached);
//PlayerPrefs.DeleteAll();
//PlayerPrefs.SetInt("levelReached",0);
}
function OnGUI() {
// if (GUI.Button(Rect(Screen.width-btnWidth,20,btnWidth-20,btnHeight),btnFB,""))
// {
// Debug.Log("Clicked the button");
//
// //--create a popover
//
// //--add a speech box
// GUI.Box(GUIBoxPosition,"");
// }
if(showLevels == true){
// Debug.Log("show levels");
btnVerticalPos = 120;
GUI.Box(Rect (Screen.width/2-(boxWidth/2),btnVerticalPos-20,boxWidth,boxHeight),"");
//
// GUI.enabled = false;
for(var i : int = 1; i <= 9; i++) {
if(i > levelReached){
GUI.enabled = false;
}
if (GUI.Button(Rect(Screen.width/2-(btnWidth/2),btnVerticalPos,btnWidth,btnHeight),"Level "+i))
{
Debug.Log("Clicked the button");
Application.LoadLevel("scene"+i);
//PlayerPrefs.SetInt("levelReached",i);
//var levelReachedLoad : int = PlayerPrefs.GetInt("levelReached");
//Debug.Log("level now = "+levelReachedLoad);
}
btnVerticalPos += (btnHeight + 10);
}
// GUI.enabled = true;
// if (GUI.Button(Rect(Screen.width/2,btnVerticalPos,btnWidth,btnHeight),"Button 2"))
// {
// Debug.Log("Clicked the button");
//
// }
//LevelMenu.active = true;
}
}
function Update()
{
if(Input.GetKeyDown(KeyCode.Escape) == true)
{
Application.Quit();
}
}