-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainMenuScript.js
860 lines (632 loc) · 22.2 KB
/
MainMenuScript.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
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
#pragma strict
static var devBuild:boolean = true;
// DONT FORGET TO CHANGE IF PUBLISHING
var resetData:boolean;
var togglePay:boolean;
@System.NonSerialized var menuType:String;
var MyGUISkin : GUISkin;
var MyGUISkin2 : GUISkin;
var MyGUISkin3 : GUISkin;
var SubHeadingSkin : GUISkin;
var BackSkin : GUISkin;
var SoundOnSkin : GUISkin;
var SoundOffSkin : GUISkin;
var SoundOn : boolean;
var optionsGuiStyle : GUIStyle;
var contSliderValue : float;
var coolSliderValue : float;
var scoreSliderInt: int;
var aiDifficulty: int;
var instructionScrollPosition : Vector2;
var optionScrollPosition : Vector2;
@System.NonSerialized var cheatCheck: boolean;
@System.NonSerialized var cookiePositions = new ArrayList();
static var MainMenuScene = 0;
static var PvPScene = 1;
static var PvPOnlineScene = 2;
static var PvAIScene = 3;
static var EndlessScene = 4;
static var TutorialScene = 5;
static var LevelSelectionScene = 6;
static var levelsBeforeBB = LevelSelectionScene;
//remember to update MainMenuScript.cs
function OnGUI() {
if (menuType == "" || menuType == null) {
menuType == "main";
}
if(PlayerPrefs.GetInt("mute") == 0){
SoundOn = true;
}
else{
SoundOn = false;
}
resetPowerups();
if(SoundOn){
GUI.skin = SoundOnSkin;
AudioListener.volume = 1;
}
else{
GUI.skin = SoundOffSkin;
AudioListener.volume = 0;
}
if(GUI.Button(new Rect(Screen.width*.02,Screen.height*0.01,Screen.width*0.1,Screen.width*0.1),""))
{
if(SoundOn){
PlayerPrefs.SetInt("mute", 1);
//AudioListener.volume = 0;
}
else{
PlayerPrefs.SetInt("mute", 0);
//AudioListener.volume = 1;
}
}
// GUILayout.BeginArea(new Rect(Screen.width*0.25, Screen.height*0.25, Screen.width*0.5, Screen.height*0.5), "");
GUILayout.BeginArea(new Rect(Screen.width*0.1, Screen.height*0.02, Screen.width*0.8, Screen.height*0.2), "");
GUI.skin = MyGUISkin2;
GUILayout.Space(5);
// GUI.skin.label.fontSize = Screen.height / 10; NO
// GUI.skin.button.fontSize = Screen.height / 20;
// transform.guiText.fontSize = Screen.height / 12; //480 / 40 = 12
var titleText:String;
// if (PlayerPrefs.GetString("debugText") == "") {
titleText = "CurveBall";
// }
// else {
// titleText = PlayerPrefs.GetString("debugText");
// }
GUILayout.Label(titleText);
GUILayout.EndArea();
GUILayout.BeginArea(new Rect(Screen.width*0.1, Screen.height*0.22, Screen.width*0.8, Screen.height*0.73), "");
GUI.skin = MyGUISkin2;
if(menuType == "main") {
if(GUILayout.Button("Smash Bricks")) {
// if(GUI.Button(Rect (0, Screen.height*.1, Screen.height*.75, Screen.height*.1), "Play")) {
audio.PlayOneShot(Resources.Load("audio/Click"));
Application.LoadLevel(levelsBeforeBB);
}
if (TutorialEngine.phoneCheck() || TutorialEngine.editorCheck()) {
if(GUILayout.Button("Multiplayer")) {
audio.PlayOneShot(Resources.Load("audio/Click"));
menuType = "matchmaking";
}
}
if(GUILayout.Button("Endless Bricks")) {
audio.PlayOneShot(Resources.Load("audio/Click"));
// if(GUI.Button(Rect (0, Screen.height*.1, Screen.height*.75, Screen.height*.1), "Play")) {
Application.LoadLevel(EndlessScene);
}
if(GUILayout.Button("VS Computer")) {
audio.PlayOneShot(Resources.Load("audio/Click"));
// if(GUI.Button(Rect (0, Screen.height*.1, Screen.height*.75, Screen.height*.1), "Play")) {
Application.LoadLevel(PvAIScene);
}
if (TutorialEngine.phoneCheck() || TutorialEngine.editorCheck()) {
if(GUILayout.Button("Achievements")) {
audio.PlayOneShot(Resources.Load("audio/Click"));
if(PlayerPrefs.GetInt("signedIn") == 1){
PlayerPrefs.SetInt("showAchievements", 1);
}
else{
menuType = "signInInstructions";
}
}
}
if(GUILayout.Button("Options")) {
audio.PlayOneShot(Resources.Load("audio/Click"));
// if(GUI.Button(Rect (0, Screen.height*.1, Screen.height*.75, Screen.height*.1), "Play")) {
menuType = "options";
contSliderValue = PlayerPrefs.GetFloat("contSliderValue");
coolSliderValue = PlayerPrefs.GetFloat("coolSliderValue");
scoreSliderInt = PlayerPrefs.GetInt("scoreSliderValue");
aiDifficulty = PlayerPrefs.GetInt("aiDifficulty");
}
/*
if(GUILayout.Button("Instructions")) {
audio.PlayOneShot(Resources.Load("audio/Click"));
// if(GUI.Button(Rect (0, Screen.height*.1, Screen.height*.75, Screen.height*.1), "Play")) {
menuType = "instructions";
}
*/
if(GUILayout.Button("Tutorial")) {
audio.PlayOneShot(Resources.Load("audio/Click"));
Application.LoadLevel(TutorialScene);
}
if(GUILayout.Button("About")) {
audio.PlayOneShot(Resources.Load("audio/Click"));
menuType = "about";
}
GUI.skin = BackSkin;
if(GUILayout.Button("Quit")) {
audio.PlayOneShot(Resources.Load("audio/Click"));
Application.Quit();
}
GUI.skin = MyGUISkin2;
}
if(menuType == "signInInstructions"){
GUI.skin = MyGUISkin3;
GUILayout.Label("Sign into Google+ to use this feature.");
GUI.skin = MyGUISkin2;
if(GUILayout.Button("Okay")){
menuType = "main";
}
}
if(menuType == "matchmaking"){
if(PlayerPrefs.GetInt("OnRoomSetupProgress") == 0 && PlayerPrefs.GetInt("Connecting") == 0){
if(GUILayout.Button("Same Device")) {
audio.PlayOneShot(Resources.Load("audio/Click"));
// if(GUI.Button(Rect (0, Screen.height*.1, Screen.height*.75, Screen.height*.1), "Play")) {
Application.LoadLevel(PvPScene);
}
//LastMultiType, Quick = 0 , Regular = 1
if(GUILayout.Button("Quick Online Game")) {
audio.PlayOneShot(Resources.Load("audio/Click"));
PlayerPrefs.SetInt("LastMultiType", 0);
if(PlayerPrefs.GetInt("signedIn") == 1){
PlayerPrefs.SetInt("showQuickGame", 1);
PlayerPrefs.SetInt("Connecting", 1);
}
else{
menuType = "signInInstructions";
}
}
if(GUILayout.Button("Create MP Game")) {
audio.PlayOneShot(Resources.Load("audio/Click"));
PlayerPrefs.SetInt("LastMultiType", 1);
if(PlayerPrefs.GetInt("signedIn") == 1){
PlayerPrefs.SetInt("showInviteScreen", 1);
PlayerPrefs.SetInt("type", 0);
PlayerPrefs.SetInt("Connecting", 1);
}
else{
menuType = "signInInstructions";
}
}
if(GUILayout.Button("Join MP Game")) {
audio.PlayOneShot(Resources.Load("audio/Click"));
PlayerPrefs.SetInt("LastMultiType", 1);
if(PlayerPrefs.GetInt("signedIn") == 1){
PlayerPrefs.SetInt("joinMultiplayer", 1);
PlayerPrefs.SetInt("type", 1);
PlayerPrefs.SetInt("Connecting", 1);
}
else{
menuType = "signInInstructions";
}
}
}
if(PlayerPrefs.GetInt("Connecting") == 1){
GUI.skin = MyGUISkin3;
GUILayout.Label("Connecting to Google Play...");
}
if(PlayerPrefs.GetInt("OnRoomSetupProgress") == 1){
PlayerPrefs.SetInt("Connecting", 0);
GUI.skin = MyGUISkin3;
GUILayout.Label("Connecting to opponent...");
}
GUI.skin = BackSkin;
if(GUILayout.Button("Back")) {
PlayerPrefs.SetInt("Disconnect", 1);
audio.PlayOneShot(Resources.Load("audio/Click"));
PlayerPrefs.SetInt("type", 0);
menuType = "main";
}
if(Input.GetKeyDown("escape")){
PlayerPrefs.SetInt("Disconnect", 1);
PlayerPrefs.SetInt("type", 0);
menuType = "main";
}
GUI.skin = MyGUISkin2;
}
if(menuType == "about"){
GUI.skin = SubHeadingSkin;
GUILayout.Label("About");
GUI.skin = MyGUISkin3;
GUILayout.Label("Developers: \n Krish Masand & Mark Tai");
GUILayout.Label("Special Thanks: \n Music - Markus Heichelbech \n Test Devices - UIUC's ACM SIGMobile Chapter \n Inspiration - Julie Rooney & Melissa Antonacci");
GUILayout.Space(30);
GUI.skin = BackSkin;
if(GUILayout.Button("Back")) {
menuType = "main";
audio.PlayOneShot(Resources.Load("audio/Click"));
}
if(Input.GetKeyDown("escape")){
menuType = "main";
}
GUI.skin = MyGUISkin2;
}
//Options Menu
if(menuType == "options") {
GUILayout.BeginArea(new Rect(0, 0, Screen.width*0.8, Screen.height*0.7), "");
optionScrollPosition = GUILayout.BeginScrollView (optionScrollPosition);
for (var touch : Touch in Input.touches) {
if (touch.phase == TouchPhase.Moved) {
optionScrollPosition.y += touch.deltaPosition.y;
optionScrollPosition.x += touch.deltaPosition.x;
}
}
GUI.skin = SubHeadingSkin;
GUILayout.Label("Options");
GUI.skin = MyGUISkin3;
GUILayout.Space(5);
GUILayout.Label("Max VS Score: " + scoreSliderInt.ToString());
scoreSliderInt = GUILayout.HorizontalSlider(scoreSliderInt, 1.0, 30.0);
PlayerPrefs.SetInt("scoreSliderValue", scoreSliderInt);
GUILayout.Label("VS Control Time: " + (contSliderValue).ToString("F2"));
contSliderValue = GUILayout.HorizontalSlider(contSliderValue, 0.0, 10.0);
PlayerPrefs.SetFloat("contSliderValue", contSliderValue);
GUILayout.Label("VS Cooldown Time: " + (coolSliderValue).ToString("F2"));
coolSliderValue = GUILayout.HorizontalSlider(coolSliderValue, 0.0, 10.0);
PlayerPrefs.SetFloat("coolSliderValue", coolSliderValue);
var aiText:String = "AI Difficulty: ";
if (aiDifficulty == 0) aiText += "Easy";
else if (aiDifficulty == 1) aiText += "Medium";
else if (aiDifficulty == 2) aiText += "Hard";
else if (aiDifficulty == 3) aiText += "Insane";
GUILayout.Label(aiText);
aiDifficulty = GUILayout.HorizontalSlider(aiDifficulty, 0, 2);
PlayerPrefs.SetInt("aiDifficulty", aiDifficulty);
// var adText:String;
// if (PlayerPrefs.GetInt("adsEnabled") == 1) {
// adText = "Turn Ads Off";
// GUI.skin = BackSkin;
// }
// else if (PlayerPrefs.GetInt("adsEnabled") == 0) {
// adText = "Turn Ads On";
// GUI.skin = MyGUISkin2;
// }
// if (GUILayout.Button(adText)) {
// audio.PlayOneShot(Resources.Load("audio/Click"));
// PlayerPrefs.SetInt("adsEnabled", 1 - PlayerPrefs.GetInt("adsEnabled")); //toggles between 1 and 0
// }
GUI.skin = MyGUISkin2;
if (PlayerPrefs.GetInt("paid") == 0) {
if (GUILayout.Button("Donate+Remove Ads")) {
audio.PlayOneShot(Resources.Load("audio/Click"));
gameObject.SendMessage("buyCookie");
}
}
else {
if (GUILayout.Button("Enjoy the Cookie!")) {
audio.PlayOneShot(Resources.Load("audio/Click"));
throwCookie();
}
}
var joystickText:String;
if (PlayerPrefs.GetInt("restingJoystickEnabled") == 0) {
joystickText = "Rest Joystick is Off";
GUI.skin = MyGUISkin2;
}
else if (PlayerPrefs.GetInt("restingJoystickEnabled") == 1) {
joystickText = "Rest Joystick is On";
GUI.skin = BackSkin;
}
if (GUILayout.Button(joystickText)) {
audio.PlayOneShot(Resources.Load("audio/Click"));
PlayerPrefs.SetInt("restingJoystickEnabled", 1 - PlayerPrefs.GetInt("restingJoystickEnabled")); //toggles between 1 and 0
}
var tiltText:String;
if (PlayerPrefs.GetInt("tiltControlEnabled") == 0) {
tiltText = "Tilt Control is Off";
GUI.skin = MyGUISkin2;
}
else if (PlayerPrefs.GetInt("tiltControlEnabled") == 1) {
tiltText = "Tilt Control is On";
GUI.skin = BackSkin;
}
if (GUILayout.Button(tiltText)) {
audio.PlayOneShot(Resources.Load("audio/Click"));
PlayerPrefs.SetInt("tiltControlEnabled", 1 - PlayerPrefs.GetInt("tiltControlEnabled")); //toggles between 1 and 0
}
if (PlayerPrefs.GetFloat("contSliderValue") <= .02 && PlayerPrefs.GetFloat("coolSliderValue") >= 9.98 && PlayerPrefs.GetInt("scoreSliderValue") == 23) { //Gives you everything
// PlayerPrefs.SetInt("unlockedLevel", 40);
// PlayerPrefs.SetInt("extraBalls", 500);
// PlayerPrefs.SetInt("invincible", 100);
// PlayerPrefs.SetInt("moreConTime", 100);
// PlayerPrefs.SetInt("longerPaddle", 100);
if (!cheatCheck) {
if (devBuild) {
togglePay = true;
}
else {
PlayerPrefs.SetInt("adsEnabled", 0);
PlayerPrefs.SetInt("redditor", 1);
}
cheatCheck = true;
}
}
else {
cheatCheck = false;
}
GUI.skin = MyGUISkin2;
if(GUILayout.Button("Reset to Default")) {
audio.PlayOneShot(Resources.Load("audio/Click"));
resetOptions();
contSliderValue = PlayerPrefs.GetFloat("contSliderValue");
coolSliderValue = PlayerPrefs.GetFloat("coolSliderValue");
scoreSliderInt = PlayerPrefs.GetInt("scoreSliderValue");
aiDifficulty = PlayerPrefs.GetInt("aiDifficulty");
}
GUI.skin = BackSkin;
if(GUILayout.Button("Reset Progress")) {
audio.PlayOneShot(Resources.Load("audio/Click"));
menuType = "reset";
}
if(GUILayout.Button("Back")) {
audio.PlayOneShot(Resources.Load("audio/Click"));
menuType = "main";
}
if(Input.GetKeyDown("escape")){
menuType = "main";
}
GUI.skin = MyGUISkin2;
GUILayout.EndScrollView ();
GUILayout.EndArea();
}
if(menuType == "reset"){
GUI.skin = MyGUISkin2;
GUILayout.Label("Options");
GUI.skin = MyGUISkin3;
GUILayout.Space(5);
GUILayout.Label("Are you sure you want to reset your Smash Bricks progress?");
GUI.skin = BackSkin;
if(GUILayout.Button("Yes")) {
audio.PlayOneShot(Resources.Load("audio/Click"));
menuType = "options";
resetProgress();
}
GUI.skin = MyGUISkin2;
if(GUILayout.Button("No")) {
audio.PlayOneShot(Resources.Load("audio/Click"));
menuType = "options";
}
//GUILayout.label
if(Input.GetKeyDown("escape")){
menuType = "options";
}
}
if(menuType == "instructions") {
GUI.skin = BackSkin;
if(GUILayout.Button("Back")) {
audio.PlayOneShot(Resources.Load("audio/Click"));
menuType = "main";
}
if(Input.GetKeyDown("escape")){
menuType = "main";
}
GUI.skin = MyGUISkin;
instructionScrollPosition = GUILayout.BeginScrollView (instructionScrollPosition);
for (var touch : Touch in Input.touches)
{
if (touch.phase == TouchPhase.Moved)
{
instructionScrollPosition.y += touch.deltaPosition.y;
instructionScrollPosition.x += touch.deltaPosition.x;
}
}
GUILayout.Label("Instructions");
GUILayout.Space(1);
GUILayout.Label("CurveBall is a pong variation with one major difference: ball control!\nControls:\nPaddle - Under the colored line, touch to the left and right of the paddle to move it. \nBall - Between the white and colored line, touch and hold to move the ball in that direction. The ball control is limited, so use it wisely!");
GUILayout.Label("Notes:");
GUILayout.Label("The ball cannot be controlled when past the colored lines.");
GUILayout.Label("A colored number means you can control the ball. A white number means cooldown.");
GUILayout.Label("Tip: Try to control the ball here!");
GUILayout.EndScrollView ();
}
if (menuType == "rate") {
GUI.skin = SubHeadingSkin;
GUILayout.Label("We're glad that you're enjoying CurveBall! Would you like rate our app?");
GUI.skin = MyGUISkin2;
if(GUILayout.Button("Yes")){
Application.OpenURL("market://details?id=com.curveBall.curveBall");
PlayerPrefs.SetInt("timesToWait", -2);
menuType = "thanksRate";
}
if (GUILayout.Button("Maybe Later")) {
PlayerPrefs.SetInt("timesToWait", 7);
menuType = "main";
}
if(GUILayout.Button("I Already Have")){
PlayerPrefs.SetInt("timesToWait", -2);
menuType = "thanksRate";
}
GUI.skin = BackSkin;
if(GUILayout.Button("No")){
PlayerPrefs.SetInt("timesToWait", -2);
menuType = "main";
}
GUI.skin = MyGUISkin;
}
if (menuType == "thanksRate"){
GUI.skin = SubHeadingSkin;
GUILayout.Label("Thanks for rating! We're working hard to make sure your experience is as awesome as possible!");
GUI.skin = BackSkin;
if(GUILayout.Button("Main Menu")){
menuType = "main";
}
}
GUILayout.EndArea();
GUILayout.BeginArea(new Rect(0 , 0, Screen.width, Screen.height), "");
for( var cookiePosition:Vector2 in cookiePositions) {
if (cookiePosition.y + 338 >= 0 && cookiePosition.y <= Screen.height) { // COOKIE!
var aTexture:Texture = Resources.Load("Textures/Transparent Cookie");
GUI.DrawTexture(new Rect(cookiePosition.x, cookiePosition.y, 340, 338), aTexture);
}
}
GUILayout.EndArea();
// GUILayout.EndScrollView ();
}
function Start () {
if (resetData) {
resetAllData();
resetData = false;
}
menuType = "main";
PauseMenu.EnableButton();
BackSkin = Resources.Load("GUISkins/BackSkin");
var audioSource = gameObject.AddComponent(AudioSource);
PlayerPrefs.SetInt("adsOn", 0);
//to not make the phone think that it's connected to multiplayer when the app starts
PlayerPrefs.SetInt("OnRoomSetupProgress", 0);
//makes sure thinks is mp host before mp starts, changed if becomes client
PlayerPrefs.SetInt("type", 0);
instantiatePlayerPrefFloat("contSliderValue", 1.75);
instantiatePlayerPrefFloat("coolSliderValue", 4.00);
instantiatePlayerPrefInt("scoreSliderValue", 5);
instantiatePlayerPrefInt("aiDifficulty", 00);
contSliderValue = PlayerPrefs.GetFloat("contSliderValue");
coolSliderValue = PlayerPrefs.GetFloat("coolSliderValue");
scoreSliderInt = PlayerPrefs.GetInt("scoreSliderValue");
aiDifficulty = PlayerPrefs.GetInt("aiDifficulty");
if(!PlayerPrefs.HasKey("unlockedLevel")){
resetProgress();
}
instantiatePlayerPrefInt("paid", 0);
instantiatePlayerPrefInt("cookiesEaten", 0);
instantiatePlayerPrefInt("mute", 0);
instantiatePlayerPrefInt("adsEnabled", 1);
instantiatePlayerPrefInt("restingJoystickEnabled", 1);
instantiatePlayerPrefInt("tiltControlEnabled", 0);
instantiatePlayerPrefInt("timesToWait", -1);
instantiatePlayerPrefInt("signedIn", 0);
instantiatePlayerPrefInt("firstTime", 1);
instantiatePlayerPrefInt("firstTimeComputerMultiplayer", 1);
//instantiatePlayerPrefString("debugText", "arst");
if (PlayerPrefs.GetInt("firstTime") == 1) {
Application.LoadLevel(TutorialScene); //Goes to tutorial
}
if (PlayerPrefs.GetInt("timesToWait") > 0) {
PlayerPrefs.SetInt("timesToWait", PlayerPrefs.GetInt("timesToWait") - 1);
}
Time.timeScale = 1;
}
function instantiatePlayerPrefInt(key:String, value:int) {
if (!PlayerPrefs.HasKey(key)) {
PlayerPrefs.SetInt(key, value);
}
}
function instantiatePlayerPrefFloat(key:String, value:float) {
if (!PlayerPrefs.HasKey(key)) {
PlayerPrefs.SetFloat(key, value);
}
}
function instantiatePlayerPrefString(key:String, value:String) {
if (!PlayerPrefs.HasKey(key)) {
PlayerPrefs.SetString(key, value);
}
}
function Update () {
if (PlayerPrefs.GetInt("timesToWait") == 0) {
menuType = "rate";
}
else if (PlayerPrefs.GetInt("timesToWait") == -1 && (PlayerPrefs.GetInt("unlockedLevel") >= 7)) { //Put cases to ask for ratings here
PlayerPrefs.SetInt("timesToWait", 1) ;
}
//MyGUISkin2.label.fontSize*=(Screen.height/1280);
MyGUISkin.label.fontSize=30*(Screen.height/1280.00);
MyGUISkin2.label.fontSize=120*(Screen.height/1280.00);
MyGUISkin3.label.fontSize=30*(Screen.height/1280.00);
SubHeadingSkin.label.fontSize=60*(Screen.height/1280.00);
MyGUISkin.button.fontSize=60*(Screen.height/1280.00);
MyGUISkin2.button.fontSize=60*(Screen.height/1280.00);
MyGUISkin3.button.fontSize=60*(Screen.height/1280.00);
BackSkin.button.fontSize=60*(Screen.height/1280.00);
MyGUISkin.button.fontSize=60*(Screen.height/1280.00);
//buttonGuiStyle.button.fontSize=60*(Screen.height/1280.00);
MyGUISkin3.horizontalSlider.fixedHeight=50*(Screen.height/1280.00);
MyGUISkin3.horizontalSliderThumb.fixedHeight=50*(Screen.height/1280.00);
MyGUISkin3.horizontalSliderThumb.fixedWidth =50*(Screen.height/1280.00);
if (resetData) {
resetAllData();
resetData = false;
}
if (togglePay && PlayerPrefs.GetInt("paid") == 0) {
fakePay();
togglePay = false;
}
else if (togglePay) {
unpay();
togglePay = false;
}
if(PlayerPrefs.GetInt("InviteAccepted") == 1){
PlayerPrefs.SetInt("InviteAccepted", 0);
autoAcceptInvite();
}
if (PlayerPrefs.GetInt("paid") == 1) {
PlayerPrefs.SetInt("adsEnabled", 0);
}
for(var i:int = cookiePositions.Count - 1; i >= 0; i--) { //Goes down to account for possible deleting
var cookiePosition:Vector2 = cookiePositions[i];
if (cookiePosition.y + 338 >= 0 && cookiePosition.y <= Screen.height) { // COOKIE!
cookiePosition.y = cookiePosition.y + Time.deltaTime/1.58 * (Screen.height); //1.58 seconds is the delay of COOKIE to nomnomnom
cookiePositions[i] = cookiePosition;
}
else if (cookiePosition.y > Screen.height) {
cookiePositions.RemoveAt(i);
PlayerPrefs.SetInt("cookiesEaten", PlayerPrefs.GetInt("cookiesEaten") + 1);
}
}
}
function fakePay() {
PlayerPrefs.SetInt("paid", 1);
}
function unpay() {
PlayerPrefs.SetInt("paid", 0);
}
function throwCookie() {
cookiePositions.Add(Vector2(Screen.width/2 - 340/2,-338));
audio.PlayOneShot(Resources.Load("audio/COOKIE"));
}
function autoAcceptInvite(){
menuType = "matchmaking";
//PlayerPrefs.SetInt("joinMultiplayer", 1);
PlayerPrefs.SetInt("type", 1);
}
static function resetOptions() {
PlayerPrefs.SetFloat("contSliderValue", 1.75);
PlayerPrefs.SetFloat("coolSliderValue", 4.00);
PlayerPrefs.SetInt("scoreSliderValue", 5);
PlayerPrefs.SetInt("aiDifficulty", 0);
PlayerPrefs.SetInt("mute", 0);
PlayerPrefs.SetInt("adsEnabled", 1);
PlayerPrefs.SetInt("restingJoystickEnabled", 1);
PlayerPrefs.SetInt("tiltControlEnabled", 0);
}
static function resetProgress(){
PlayerPrefs.SetInt("unlockedLevel", 1);
PlayerPrefs.SetInt("extraBalls", 0);
PlayerPrefs.SetInt("invincible", 0);
PlayerPrefs.SetInt("moreConTime", 0);
PlayerPrefs.SetInt("longerPaddle", 0);
PlayerPrefs.SetInt("ELScore", 0);
PlayerPrefs.SetInt("resetCloud", 1);
}
static function resetPowerups() {
if(PlayerPrefs.GetInt("invincibleEnabled") == 1){
PlayerPrefs.SetInt("invincibleEnabled", 0);
PlayerPrefs.SetInt("invincible", PlayerPrefs.GetInt("invincible") - 1);
}
if(PlayerPrefs.GetInt("extraBallEnabled") == 1){
PlayerPrefs.SetInt("extraBallEnabled", 0);
if (PlayerPrefs.GetInt("extraBalls") >= 5) {
PlayerPrefs.SetInt("extraBalls", PlayerPrefs.GetInt("extraBalls") - 4) ;
}
else{
PlayerPrefs.SetInt("extraBalls", 0);
}
}
if(PlayerPrefs.GetInt("moreConEnabled") == 1){
PlayerPrefs.SetInt("moreConEnabled", 0);
PlayerPrefs.SetInt("moreConTime", PlayerPrefs.GetInt("moreConTime") - 1);
}
if(PlayerPrefs.GetInt("longPaddleEnabled") == 1){
PlayerPrefs.SetInt("longPaddleEnabled", 0);
PlayerPrefs.SetInt("longerPaddle", PlayerPrefs.GetInt("longerPaddle") - 1);
}
}
static function resetAllData() {
resetProgress();
resetOptions();
PlayerPrefs.SetInt("firstTime", 1);
PlayerPrefs.SetInt("firstTimeComputerMultiplayer", 1);
PlayerPrefs.DeleteAll();
}