-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlayerGUI.cs
982 lines (893 loc) · 46.4 KB
/
PlayerGUI.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
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
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
using UnityEngine;
using UnityEngine.SceneManagement;
public class PlayerGUI : MonoBehaviour
{
private PlayerController playerController;
private GameManager gameManager;
private StateManager stateManager;
private InventoryManager playerInventory;
private TextureDictionary textureDictionary;
private Texture2D paintSelectionTexture;
private GuiCoordinates guiCoordinates;
public GUISkin thisGUIskin;
public GameObject videoPlayer;
private Descriptions descriptions;
private bool controlsMenuOpen;
private bool graphicsMenuOpen;
private bool schematic1;
private bool schematic2;
private bool schematic3;
private bool schematic4;
private bool schematic5;
private bool schematic6;
private bool schematic7;
//! Called by unity engine on start up to initialize variables.
public void Start()
{
playerController = GetComponent<PlayerController>();
playerInventory = GetComponent<InventoryManager>();
stateManager = GameObject.Find("GameManager").GetComponent<StateManager>();
gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
textureDictionary = gameManager.GetComponent<TextureDictionary>();
descriptions = new Descriptions();
guiCoordinates = new GuiCoordinates();
paintSelectionTexture = new Texture2D(512, 128);
}
//! Returns true if the escape menu should be displayed.
private bool MenuAvailable()
{
return playerController.helpMenuOpen == false
&& playerController.optionsGUIopen == false
&& cGUI.showingInputGUI == false
&& playerController.exiting == false
&& playerController.requestedSave == false
&& gameManager.dataSaveRequested == false
&& stateManager.saving == false;
}
//! Returns true if the block is a building block, used with combined meshes.
private bool IsStandardBlock(string type)
{
return playerController.GetComponent<BuildController>().blockDictionary.blockDictionary.ContainsKey(type);
}
//! Returns true if the saving world message should be displayed.
private bool SavingMessageRequired()
{
return playerController.exiting == true
|| playerController.requestedSave == true
|| gameManager.dataSaveRequested == true
|| stateManager.saving == true;
}
//! Returns true if a tablet notification should be displayed.
private bool TabletNotificationRequired()
{
return playerController.meteorShowerWarningActive == true
|| playerController.timeToDeliverWarningRecieved == true
|| playerController.pirateAttackWarningActive == true
|| playerController.destructionMessageActive == true;
}
//! Stops displaying schematics when the menu is closed.
private void ClearSchematic()
{
schematic1 = false;
schematic2 = false;
schematic3 = false;
schematic4 = false;
schematic5 = false;
schematic6 = false;
schematic7 = false;
}
//! Returns true if any schematic is being displayed.
private bool SchematicActive()
{
return schematic1 == true
|| schematic2 == true
|| schematic3 == true
|| schematic4 == true
|| schematic5 == true
|| schematic6 == true
|| schematic7 == true;
}
//! Returns true if the crosshair should be displayed.
private bool ShowCrosshair()
{
return playerController.crosshairEnabled &&
!playerController.GuiOpen() &&
!playerController.paintGunActive;
}
//! Gets the size of in pixels of text so it can be positioned on the screen accordingly.
private Vector2 GetStringSize(string str)
{
GUIContent content = new GUIContent(str);
GUIStyle style = GUI.skin.box;
style.alignment = TextAnchor.MiddleCenter;
return style.CalcSize(content);
}
//! Called by unity engine for rendering and handling GUI events.
public void OnGUI()
{
// STYLE
GUI.skin = thisGUIskin;
// ASPECT RATIO
float ScreenHeight = Screen.height;
float ScreenWidth = Screen.width;
if (ScreenWidth / ScreenHeight < 1.7f)
{
ScreenHeight = (ScreenHeight * 0.75f);
}
if (ScreenHeight < 700)
{
GUI.skin.label.fontSize = 10;
}
if (playerController.stateManager.worldLoaded == true && GetComponent<MainMenu>().finishedLoading == true)
{
// BUILD ITEM HUD AT TOP RIGHT OF SCREEN
if (playerController.displayingBuildItem == true)
{
GUI.Label(guiCoordinates.topRightInfoRect, "\n\nBuild item set to " + playerController.buildType);
if (textureDictionary.dictionary.ContainsKey(playerController.previousBuildType + "_Icon"))
{
GUI.DrawTexture(guiCoordinates.previousBuildItemTextureRect, textureDictionary.dictionary[playerController.previousBuildType + "_Icon"]);
}
else
{
GUI.DrawTexture(guiCoordinates.previousBuildItemTextureRect, textureDictionary.dictionary[playerController.previousBuildType]);
}
if (textureDictionary.dictionary.ContainsKey(playerController.buildType + "_Icon"))
{
GUI.DrawTexture(guiCoordinates.buildItemTextureRect, textureDictionary.dictionary[playerController.buildType + "_Icon"]);
}
else
{
GUI.DrawTexture(guiCoordinates.buildItemTextureRect, textureDictionary.dictionary[playerController.buildType]);
}
if (textureDictionary.dictionary.ContainsKey(playerController.buildType + "_Icon"))
{
GUI.DrawTexture(guiCoordinates.currentBuildItemTextureRect, textureDictionary.dictionary[playerController.buildType + "_Icon"]);
}
else
{
GUI.DrawTexture(guiCoordinates.currentBuildItemTextureRect, textureDictionary.dictionary[playerController.buildType]);
}
GUI.DrawTexture(guiCoordinates.buildItemTextureRect, textureDictionary.dictionary["Selection Box"]);
if (textureDictionary.dictionary.ContainsKey(playerController.nextBuildType + "_Icon"))
{
GUI.DrawTexture(guiCoordinates.nextBuildItemTextureRect, textureDictionary.dictionary[playerController.nextBuildType + "_Icon"]);
}
else
{
GUI.DrawTexture(guiCoordinates.nextBuildItemTextureRect, textureDictionary.dictionary[playerController.nextBuildType]);
}
int buildItemCount = 0;
foreach (InventorySlot slot in playerInventory.inventory)
{
if (slot.typeInSlot.Equals(playerController.buildType))
{
buildItemCount += slot.amountInSlot;
}
}
GUI.Label(guiCoordinates.buildItemCountRect, "" + buildItemCount);
}
// METEOR SHOWER WARNINGS
if (TabletNotificationRequired())
{
GUI.Label(guiCoordinates.topLeftInfoRect, "Urgent message received! Check your tablet for more information.");
}
// TABLET
if (playerController.tabletOpen == true)
{
int day = GameObject.Find("Rocket").GetComponent<Rocket>().day;
int hour = (int)GameObject.Find("Rocket").GetComponent<Rocket>().gameTime;
string hourString = "";
if (hour < 10)
{
hourString = "000" + hour;
}
else if (hour >= 10 && hour < 100)
{
hourString = "00" + hour;
}
else if (hour >= 100 && hour < 1000)
{
hourString = "0" + hour;
}
else if (hour >= 1000)
{
hourString = "" + hour;
}
GUI.DrawTexture(guiCoordinates.tabletBackgroundRect, textureDictionary.dictionary["Tablet"]);
GUI.Label(guiCoordinates.tabletMessageRect, playerController.currentTabletMessage);
GUI.Label(guiCoordinates.tabletTimeRect, "\nDay: " + day + " Hour: " + hourString + ", Income: $" + playerController.money.ToString("N0"));
if (GUI.Button(guiCoordinates.tabletButtonRect, "CLOSE"))
{
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
playerController.tabletOpen = false;
playerController.PlayButtonSound();
}
}
// OPTIONS/EXIT MENU
if (playerController.escapeMenuOpen == true)
{
if (MenuAvailable())
{
GUI.DrawTexture(guiCoordinates.escapeMenuRect, textureDictionary.dictionary["Menu Background"]);
if (GUI.Button(guiCoordinates.escapeButton1Rect, "Resume"))
{
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
gameObject.GetComponent<MSCameraController>().enabled = true;
playerController.escapeMenuOpen = false;
playerController.optionsGUIopen = false;
playerController.helpMenuOpen = false;
playerController.videoMenuOpen = false;
playerController.schematicMenuOpen = false;
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.escapeButton2Rect, "Save"))
{
playerController.requestedSave = true;
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.escapeButton3Rect, "Options"))
{
playerController.optionsGUIopen = true;
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.escapeButton4Rect, "Help"))
{
playerController.helpMenuOpen = true;
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.escapeButton5Rect, "Exit"))
{
playerController.exiting = true;
playerController.requestedSave = true;
playerController.PlayButtonSound();
}
}
else
{
if (SavingMessageRequired())
{
int current = stateManager.saveManager.currentObject;
int total = stateManager.saveManager.totalObjects;
GUI.DrawTexture(guiCoordinates.saveMessageBackgroundRect, textureDictionary.dictionary["Interface Background"]);
if (total > 0)
{
GUI.Label(guiCoordinates.saveMessageRect, "Saving world... "+current+"/"+total);
}
else
{
GUI.Label(guiCoordinates.saveMessageRect, "Saving world... " + "preparing");
}
}
}
}
// HELP MENU
if (playerController.helpMenuOpen == true)
{
if (playerController.videoMenuOpen == false && playerController.schematicMenuOpen == false)
{
GUI.DrawTexture(guiCoordinates.escapeMenuRect, textureDictionary.dictionary["Menu Background"]);
if (GUI.Button(guiCoordinates.escapeButton1Rect, "Videos"))
{
playerController.videoMenuOpen = true;
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.escapeButton2Rect, "Schematics"))
{
playerController.schematicMenuOpen = true;
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.escapeButton4Rect, "BACK"))
{
playerController.helpMenuOpen = false;
playerController.PlayButtonSound();
}
}
if (playerController.videoMenuOpen == true)
{
if (playerController.mCam.GetComponent<UnityEngine.Video.VideoPlayer>().isPlaying == false)
{
GUI.DrawTexture(guiCoordinates.videoMenuBackgroundRect, textureDictionary.dictionary["Menu Background"]);
}
if (playerController.mCam.GetComponent<UnityEngine.Video.VideoPlayer>().isPlaying == false)
{
if (GUI.Button(guiCoordinates.helpButton1Rect, "Intro"))
{
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
videoPlayer.GetComponent<VP>().PlayVideo("Guide.webm", false, 0.5f);
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.helpButton2Rect, "Dark Matter"))
{
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
videoPlayer.GetComponent<VP>().PlayVideo("DarkMatter.webm", false, 0.5f);
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.helpButton3Rect, "Universal Extractor"))
{
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
videoPlayer.GetComponent<VP>().PlayVideo("Extractor.webm", false, 0.5f);
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.helpButton4Rect, "Heat Exchanger"))
{
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
videoPlayer.GetComponent<VP>().PlayVideo("HeatExchanger.webm", false, 0.5f);
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.helpButton5Rect, "Alloy Smelter"))
{
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
videoPlayer.GetComponent<VP>().PlayVideo("AlloySmelter.webm", false, 0.5f);
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.helpButton6Rect, "Hazards"))
{
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
videoPlayer.GetComponent<VP>().PlayVideo("Hazards.webm", false, 0.5f);
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.helpButton7Rect, "Rail Carts"))
{
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
videoPlayer.GetComponent<VP>().PlayVideo("RailCarts.webm", false, 0.5f);
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.helpButton8Rect, "Storage Computers"))
{
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
videoPlayer.GetComponent<VP>().PlayVideo("StorageComputers.webm", false, 0.5f);
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.helpButton9Rect, "Nuclear Reactors"))
{
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
videoPlayer.GetComponent<VP>().PlayVideo("NuclearReactors.webm", false, 0.5f);
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.helpButton10Rect, "BACK"))
{
playerController.videoMenuOpen = false;
playerController.PlayButtonSound();
}
}
if (playerController.mCam.GetComponent<UnityEngine.Video.VideoPlayer>().isPlaying == false)
{
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
videoPlayer.GetComponent<VP>().StopVideo();
}
if (playerController.mCam.GetComponent<UnityEngine.Video.VideoPlayer>().isPlaying == true && Input.anyKey)
{
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
videoPlayer.GetComponent<VP>().StopVideo();
}
}
if (playerController.schematicMenuOpen == true)
{
if (!SchematicActive())
{
GUI.DrawTexture(guiCoordinates.schematicsMenuBackgroundRect, textureDictionary.dictionary["Menu Background"]);
if (GUI.Button(guiCoordinates.helpButton1Rect, "Dark Matter"))
{
if (schematic1 == false)
{
schematic1 = true;
}
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.helpButton2Rect, "Plates"))
{
if (schematic2 == false)
{
schematic2 = true;
}
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.helpButton3Rect, "Wires"))
{
if (schematic3 == false)
{
schematic3 = true;
}
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.helpButton4Rect, "Gears"))
{
if (schematic4 == false)
{
schematic4 = true;
}
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.helpButton5Rect, "Steel"))
{
if (schematic5 == false)
{
schematic5 = true;
}
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.helpButton6Rect, "Bronze"))
{
if (schematic6 == false)
{
schematic6 = true;
}
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.helpButton7Rect, "Heat Exchangers"))
{
if (schematic7 == false)
{
schematic7 = true;
}
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.helpButton8Rect, "BACK"))
{
playerController.schematicMenuOpen = false;
playerController.PlayButtonSound();
}
}
if (schematic1 == true)
{
GUI.DrawTexture(new Rect(0, 0, ScreenWidth, ScreenHeight), textureDictionary.dictionary["Dark Matter Schematic"]);
}
if (schematic2 == true)
{
GUI.DrawTexture(new Rect(0, 0, ScreenWidth, ScreenHeight), textureDictionary.dictionary["Plate Schematic"]);
}
if (schematic3 == true)
{
GUI.DrawTexture(new Rect(0, 0, ScreenWidth, ScreenHeight), textureDictionary.dictionary["Wire Schematic"]);
}
if (schematic4 == true)
{
GUI.DrawTexture(new Rect(0, 0, ScreenWidth, ScreenHeight), textureDictionary.dictionary["Gear Schematic"]);
}
if (schematic5 == true)
{
GUI.DrawTexture(new Rect(0, 0, ScreenWidth, ScreenHeight), textureDictionary.dictionary["Steel Schematic"]);
}
if (schematic6 == true)
{
GUI.DrawTexture(new Rect(0, 0, ScreenWidth, ScreenHeight), textureDictionary.dictionary["Bronze Schematic"]);
}
if (schematic7 == true)
{
GUI.DrawTexture(new Rect(0, 0, ScreenWidth, ScreenHeight), textureDictionary.dictionary["Heat Exchanger Schematic"]);
}
if (SchematicActive())
{
if (GUI.Button(guiCoordinates.schematicCloseRect,"CLOSE") || Input.GetKeyDown(KeyCode.Escape))
{
ClearSchematic();
playerController.PlayButtonSound();
}
}
}
else
{
ClearSchematic();
}
}
// OPTIONS MENU
if (playerController.optionsGUIopen == true)
{
Vector2 mousePos = Event.current.mousePosition;
if (controlsMenuOpen == false && graphicsMenuOpen == false)
{
GUI.DrawTexture(guiCoordinates.optionsMenuBackgroundRect, textureDictionary.dictionary["Menu Background"]);
if (GUI.Button(guiCoordinates.optionsButton1Rect, "Graphics"))
{
graphicsMenuOpen = true;
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.optionsButton2Rect, "Controls"))
{
controlsMenuOpen = true;
playerController.PlayButtonSound();
}
GUI.Label(guiCoordinates.sliderLabel1Rect, "Audio Volume");
GUI.Label(guiCoordinates.sliderLabel2Rect, "Chunk Size " + "(" + gameManager.chunkSize + ")");
int simSpeed = (int)(gameManager.simulationSpeed * 5000);
GUI.Label(guiCoordinates.sliderLabel3Rect, "Simulation Speed " + "(" + simSpeed + "%)");
AudioListener.volume = GUI.HorizontalSlider(guiCoordinates.optionsButton4Rect, AudioListener.volume, 0, 5);
GetComponent<MSCameraController>().cameras[0].volume = AudioListener.volume;
gameManager.chunkSize = (int)GUI.HorizontalSlider(guiCoordinates.optionsButton5Rect, gameManager.chunkSize, 20, 100);
if (guiCoordinates.optionsButton5Rect.Contains(mousePos))
{
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.chunkSize);
}
gameManager.simulationSpeed = GUI.HorizontalSlider(guiCoordinates.optionsButton6Rect, gameManager.simulationSpeed, 0.0051f, 0.1f);
if (guiCoordinates.optionsButton6Rect.Contains(mousePos))
{
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.simulationSpeed);
}
string blockPhysicsDisplay = gameManager.blockPhysics == true ? "ON" : "OFF";
if (GUI.Button(guiCoordinates.optionsButton7Rect, "Block Physics: "+ blockPhysicsDisplay))
{
if (PlayerPrefsX.GetPersistentBool("multiplayer") == false)
{
gameManager.blockPhysics = !gameManager.blockPhysics;
}
playerController.PlayButtonSound();
}
if (guiCoordinates.optionsButton7Rect.Contains(mousePos))
{
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.blockPhysics);
}
string hazardsEnabledDisplay = gameManager.hazardsEnabled == true ? "ON" : "OFF";
if (GUI.Button(guiCoordinates.optionsButton8Rect, "Hazards: " + hazardsEnabledDisplay))
{
if (PlayerPrefsX.GetPersistentBool("multiplayer") == false)
{
gameManager.hazardsEnabled = !gameManager.hazardsEnabled;
}
else if (PlayerPrefsX.GetPersistentBool("hosting") == true)
{
gameManager.hazardsEnabled = !gameManager.hazardsEnabled;
playerController.networkController.networkSend.SendHazardData(gameManager.hazardsEnabled);
}
playerController.PlayButtonSound();
}
if (guiCoordinates.optionsButton8Rect.Contains(mousePos))
{
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.hazards);
}
if (GUI.Button(guiCoordinates.optionsButton9Rect, "BACK"))
{
playerController.ApplySettings();
playerController.optionsGUIopen = false;
playerController.PlayButtonSound();
}
}
if (controlsMenuOpen == true && cGUI.showingInputGUI == false)
{
GUI.DrawTexture(guiCoordinates.optionsSubMenuBackgroundRect, textureDictionary.dictionary["Menu Background"]);
if (GUI.Button(guiCoordinates.optionsButton1Rect, "Bindings"))
{
cGUI.ToggleGUI();
playerController.PlayButtonSound();
}
MSACC_SettingsCameraFirstPerson csInverted = GetComponent<MSCameraController>().CameraSettings.firstPerson;
string invertYInput = csInverted.invertYInput == true ? "ON" : "OFF";
if (GUI.Button(guiCoordinates.optionsButton2Rect, "Invert Y Axis: " + invertYInput))
{
csInverted.invertYInput = !csInverted.invertYInput;
playerController.PlayButtonSound();
}
GUI.Label(guiCoordinates.sliderLabel1Rect, "X sensitivity");
GUI.Label(guiCoordinates.sliderLabel2Rect, "Y sensitivity");
MSACC_SettingsCameraFirstPerson csSensitivity = GetComponent<MSCameraController>().CameraSettings.firstPerson;
csSensitivity.sensibilityX = GUI.HorizontalSlider(guiCoordinates.optionsButton4Rect, csSensitivity.sensibilityX, 0, 10);
csSensitivity.sensibilityY = GUI.HorizontalSlider(guiCoordinates.optionsButton5Rect, csSensitivity.sensibilityY, 0, 10);
if (GUI.Button(guiCoordinates.optionsButton8Rect, "BACK"))
{
controlsMenuOpen = false;
playerController.PlayButtonSound();
playerController.PlayButtonSound();
}
}
if (graphicsMenuOpen == true)
{
GUI.DrawTexture(guiCoordinates.optionsSubMenuBackgroundRect, textureDictionary.dictionary["Menu Background"]);
string fogDisplay = RenderSettings.fog == true ? "ON" : "OFF";
if (GUI.Button(guiCoordinates.optionsButton1Rect, "Fog: " + fogDisplay))
{
if (!SceneManager.GetActiveScene().name.Equals("QE_World"))
{
RenderSettings.fog = !RenderSettings.fog;
}
else
{
RenderSettings.fog = false;
}
playerController.PlayButtonSound();
}
GUI.Label(guiCoordinates.sliderLabel0Rect, "Fog Density");
GUI.Label(guiCoordinates.sliderLabel1Rect, "FOV");
GUI.Label(guiCoordinates.sliderLabel2Rect, "Draw Distance");
GUI.Label(guiCoordinates.sliderLabel3Rect, "Graphics Quality " + "(" + QualitySettings.names[(int)playerController.graphicsQuality] + ")");
RenderSettings.fogDensity = GUI.HorizontalSlider(guiCoordinates.optionsButton3Rect, RenderSettings.fogDensity, 0.00025f, 0.025f);
playerController.mCam.fieldOfView = GUI.HorizontalSlider(guiCoordinates.optionsButton4Rect, playerController.mCam.fieldOfView, 60, 80);
playerController.mCam.farClipPlane = GUI.HorizontalSlider(guiCoordinates.optionsButton5Rect, playerController.mCam.farClipPlane, 1000, 10000);
playerController.graphicsQuality = GUI.HorizontalSlider(guiCoordinates.optionsButton6Rect, playerController.graphicsQuality, 0, QualitySettings.names.Length - 1);
string vsyncDisplay = QualitySettings.vSyncCount == 1 ? "ON" : "OFF";
if (GUI.Button(guiCoordinates.optionsButton7Rect, "Vsync: " + vsyncDisplay))
{
QualitySettings.vSyncCount = QualitySettings.vSyncCount == 0 ? 1 : 0;
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.optionsButton8Rect, "BACK"))
{
graphicsMenuOpen = false;
playerController.PlayButtonSound();
}
}
}
else
{
graphicsMenuOpen = false;
controlsMenuOpen = false;
}
//END OPTIONS MENU
if (playerController.cannotCollect == true)
{
if (playerController.cannotCollectTimer < 3)
{
GUI.DrawTexture(guiCoordinates.midMessageBackgroundRect, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.midMessageRect, "No space in inventory.");
playerController.cannotCollectTimer += 1 * Time.deltaTime;
}
else
{
playerController.cannotCollect = false;
playerController.cannotCollectTimer = 0;
}
}
if (playerController.invalidAugerPlacement == true)
{
if (playerController.invalidAugerPlacementTimer < 3)
{
GUI.DrawTexture(guiCoordinates.lowMessageBackgroundRect, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.lowMessageRect, "Invalid location.");
playerController.invalidAugerPlacementTimer += 1 * Time.deltaTime;
}
else
{
playerController.invalidAugerPlacement = false;
playerController.invalidAugerPlacementTimer = 0;
}
}
if (playerController.autoAxisMessage == true)
{
if (playerController.autoAxisMessageTimer < 3)
{
if (GetComponent<BuildController>().autoAxis == true)
{
GUI.DrawTexture(guiCoordinates.lowMessageBackgroundRect, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.lowMessageRect, "Auto Axis Snap");
}
else
{
GUI.DrawTexture(guiCoordinates.lowMessageBackgroundRect, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.lowMessageRect, "Manual Axis Snap");
}
playerController.autoAxisMessageTimer += 1 * Time.deltaTime;
}
else
{
playerController.autoAxisMessage = false;
playerController.autoAxisMessageTimer = 0;
}
}
if (playerController.invalidRailCartPlacement == true)
{
if (playerController.invalidRailCartPlacementTimer < 3)
{
GUI.DrawTexture(guiCoordinates.lowMessageBackgroundRect, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.lowMessageRect, "Invalid location.");
playerController.invalidRailCartPlacementTimer += 1 * Time.deltaTime;
}
else
{
playerController.invalidRailCartPlacement = false;
playerController.invalidRailCartPlacementTimer = 0;
}
}
if (playerController.stoppingBuildCoRoutine == true || playerController.requestedBuildingStop == true)
{
GUI.DrawTexture(guiCoordinates.buildingMessageBackgroundRect, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.buildingMessageRect, "Stopping Build System...");
}
if (playerController.blockLimitMessage == true)
{
if (playerController.blockLimitMessageTimer < 3)
{
GUI.DrawTexture(guiCoordinates.secondLineHighMessageBackgroundRect, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.secondLineHighMessageRect, "World limit exceeded!");
playerController.blockLimitMessageTimer += 1 * Time.deltaTime;
}
else
{
playerController.blockLimitMessage = false;
playerController.blockLimitMessageTimer = 0;
}
}
// BUILDING INSTRUCTIONS
if (playerController.building == true && !playerController.GuiOpen())
{
if (textureDictionary.dictionary.ContainsKey(playerController.buildType + "_Icon"))
{
GUI.DrawTexture(guiCoordinates.currentBuildItemTextureRect, textureDictionary.dictionary[playerController.buildType + "_Icon"]);
}
else
{
GUI.DrawTexture(guiCoordinates.currentBuildItemTextureRect, textureDictionary.dictionary[playerController.buildType]);
}
int buildItemCount = 0;
foreach (InventorySlot slot in playerInventory.inventory)
{
if (slot.typeInSlot.Equals(playerController.buildType))
{
buildItemCount += slot.amountInSlot;
}
}
if (IsStandardBlock(playerController.buildType))
{
GUI.Label(guiCoordinates.buildItemCountRect, "" + buildItemCount + "\nx" + playerController.buildMultiplier);
}
else
{
GUI.Label(guiCoordinates.buildItemCountRect, "" + buildItemCount);
}
if (playerController.machineInSight == null)
{
GUI.DrawTexture(guiCoordinates.buildInfoRectBG, textureDictionary.dictionary["Interface Background"]);
int f = GUI.skin.label.fontSize;
GUI.skin.label.fontSize = 16;
GUI.Label(guiCoordinates.buildInfoRect, "Right click to place block.\nPress F to collect.\nPress R or Ctrl+R to rotate.\nPress B to stop building.");
GUI.skin.label.fontSize = f;
}
}
// PAINT COLOR SELECTION WINDOW
if (playerController.paintGunActive == true)
{
if (playerController.paintColorSelected == false)
{
GUI.DrawTexture(guiCoordinates.paintGunMenuBackgroundRect, textureDictionary.dictionary["Menu Background"]);
int f = GUI.skin.label.fontSize;
GUI.skin.label.fontSize = 14;
GUIStyle style = GUI.skin.box;
style.alignment = TextAnchor.MiddleCenter;
GUIContent content = new GUIContent("Paint Gun");
Vector2 size = style.CalcSize(content);
Rect titleRect = new Rect((Screen.width / 2) - (size.x / 2.5f), ScreenHeight * 0.05f, size.x, size.y);
GUI.Label(titleRect, "Paint Gun");
GUIStyle style2 = GUI.skin.box;
style2.alignment = TextAnchor.MiddleCenter;
GUIContent content2 = new GUIContent("Select Color");
Vector2 size2 = style2.CalcSize(content2);
Rect titleRect2 = new Rect((Screen.width / 2) - (size2.x / 2.5f), ScreenHeight * 0.11f, size2.x, size2.y);
GUI.Label(titleRect2, "Select Color");
GUI.skin.label.fontSize = f;
GUI.Label(guiCoordinates.sliderLabel2Rect, "Red");
GUI.Label(guiCoordinates.sliderLabel3Rect, "Green");
GUI.Label(guiCoordinates.sliderLabel4Rect, "Blue");
playerController.paintRed = GUI.HorizontalSlider(guiCoordinates.optionsButton5Rect, playerController.paintRed, 0, 1);
playerController.paintGreen = GUI.HorizontalSlider(guiCoordinates.optionsButton6Rect, playerController.paintGreen, 0, 1);
playerController.paintBlue = GUI.HorizontalSlider(guiCoordinates.optionsButton7Rect, playerController.paintBlue, 0, 1);
Color paintcolor = new Color(playerController.paintRed, playerController.paintGreen, playerController.paintBlue);
Material tankMat = playerController.paintGunTank.GetComponent<Renderer>().material;
Material adjTankMat = playerController.adjustedPaintGunTank.GetComponent<Renderer>().material;
Material adjTank2Mat = playerController.adjustedPaintGunTank2.GetComponent<Renderer>().material;
tankMat.color = paintcolor;
adjTankMat.color = paintcolor;
adjTank2Mat.color = paintcolor;
GUI.color = paintcolor;
GUI.DrawTexture(guiCoordinates.optionsButton3Rect, paintSelectionTexture);
GUI.color = Color.white;
if (GUI.Button(guiCoordinates.optionsButton8Rect, "DONE"))
{
playerController.paintColorSelected = true;
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
gameObject.GetComponent<MSCameraController>().enabled = true;
playerController.PlayButtonSound();
}
}
else if (playerController.lookingAtCombinedMesh == true)
{
GUI.DrawTexture(guiCoordinates.twoLineHighMessageBackgroundRect, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.highMessageRect, "Left click to paint.\nRight click to stop.");
}
else
{
GUI.DrawTexture(guiCoordinates.longHighMessageBackgroundRect, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.longHighMessageRect, "Only structures can be painted...");
}
}
// BUILD SETTINGS
if (playerController.buildSettingsGuiOpen)
{
GUI.DrawTexture(guiCoordinates.buildSettingsRect, textureDictionary.dictionary["Menu Background"]);
int f = GUI.skin.label.fontSize;
GUI.skin.label.fontSize = 14;
Vector2 size = GetStringSize("Build Settings");
Rect messagePos = new Rect((Screen.width / 2) - (size.x / 2.2f), ScreenHeight * 0.14f, size.x, size.y);
GUI.Label(messagePos, "Build Settings");
GUI.skin.label.fontSize = f;
GUI.Label(guiCoordinates.optionsButton3Rect, "Build Multiplier");
string amountString = GUI.TextField(guiCoordinates.buildAmountTextFieldRect, playerController.buildMultiplier.ToString(), 3);
try
{
playerController.buildMultiplier = int.Parse(amountString);
}
catch
{
// NOOP
}
int i = playerController.buildMultiplier;
i = i > 100 ? 100 : i;
playerController.buildMultiplier = i;
GUI.Label(guiCoordinates.sliderLabel3Rect, "Machine Range " + "(" + (double)playerController.defaultRange / 10 + " meters" + ")");
playerController.defaultRange = (int)GUI.HorizontalSlider(guiCoordinates.optionsButton6Rect, playerController.defaultRange, 10, 120);
if (GUI.Button(guiCoordinates.optionsButton7Rect, "OK"))
{
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
playerController.buildSettingsGuiOpen = false;
playerController.PlayButtonSound();
}
}
// DOOR SETTINGS
if (playerController.doorGUIopen)
{
GUI.DrawTexture(guiCoordinates.doorSettingsRect, textureDictionary.dictionary["Menu Background"]);
int f = GUI.skin.label.fontSize;
GUI.skin.label.fontSize = 12;
GUI.Label(guiCoordinates.doorTitleRect, "Door Settings");
GUI.skin.label.fontSize = f;
if (GUI.Button(guiCoordinates.doorTextureRect,"Material"))
{
Door door = playerController.doorToEdit;
if (door.textureIndex < door.textures.Length - 1)
door.textureIndex++;
else
door.textureIndex = 0;
door.material = door.textures[door.textureIndex];
gameManager.meshManager.SetMaterial(door.closedObject, door.material);
door.edited = true;
playerController.PlayButtonSound();
}
if (GUI.Button(guiCoordinates.doorSoundRect,"Sound"))
{
Door door = playerController.doorToEdit;
if (door.audioClip < door.audioClips.Length - 1)
door.audioClip++;
else
door.audioClip = 0;
door.GetComponent<AudioSource>().clip = door.audioClips[door.audioClip];
door.GetComponent<AudioSource>().Play();
}
if (GUI.Button(guiCoordinates.doorCloseRect, "OK"))
{
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
playerController.doorGUIopen = false;
playerController.PlayButtonSound();
}
}
// CROSSHAIR
if (ShowCrosshair() == true)
{
GUIContent content = new GUIContent(Resources.Load("Crosshair") as Texture2D);
GUIStyle style = GUI.skin.box;
style.alignment = TextAnchor.MiddleCenter;
Vector2 size = style.CalcSize(content);
size.x = size.x / 3.5f;
size.y = size.y / 4;
Rect crosshairRect = new Rect((Screen.width / 2) - (size.x / 2), (Screen.height / 2) - (size.y / 2), size.x, size.y);
GUI.DrawTexture(crosshairRect, textureDictionary.dictionary["Crosshair"]);
}
}
}
}