-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlayerController.cs
More file actions
1227 lines (1127 loc) · 44.6 KB
/
PlayerController.cs
File metadata and controls
1227 lines (1127 loc) · 44.6 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
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
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using UnityEngine;
using UnityEngine.Experimental;
using UnityEngine.UI;
using System.Collections;
using UnityEngine.SceneManagement;
public class PlayerController : MonoBehaviour {
//Stuff from the Unity environment
public float force;
public float jumpHeight;
private Rigidbody2D rb;
public Animator playerAnimator;
public SpriteRenderer playerRenderer;
public Image controlsImage;
public AudioSource typing;
public AudioSource alarm;
public AudioSource staticSound;
//Movement
public bool finishedJump;
public bool canMove;
public bool moving;
private bool crouch;
private float scalD;
private float currD;
private bool sprint;
private float airMult;
private readonly float WALK_STARTSPEED = 0.6f;
private readonly float WALK_SPEEDCAP = 4.5f;
private readonly float RUN_SPEEDCAP = 9.0f;
private readonly float SPR_MULT = 1.8f;
//Ladder movement
private bool hasLadder = false;
private bool onLadder = false;
private bool hasUpL = false;
private bool hasDownL = false;
private float[] ladderBounds;
private readonly float ON_OFF_VARIANCE_TOP = 0.16f;
private readonly float ON_OFF_VARIANCE_BOT = 0.6f;
private float climbSpeed;
private bool lCoolReady = true;
private readonly float COOL_TIME = 0.4f;
private readonly float MAX_SNAP_DISTANCE = 0.36f; //So that the player snaps to the center of the ladder, but a jump that is too large seems unnatural
//Appearance, death, respawning, other miscellaneous player variables
public bool hasSuit;
public static bool isTouchingSuit = false;
public bool suffocated;
public bool isAlive;
private float xSpawn;
private float ySpawn;
public bool isAwake;
public bool awakeSequenceStarted;
public bool loading;
public bool gameEnd;
public bool endSequenceStarted;
//Items and inventory
private bool groundItem;
private int gItemID;
private GameObject currItem;
private GameObject inv;
//Hints
public bool activeHint;
public bool activeTab;
public GameObject hintBox;
public Text hintText;
public int currentObjective;
//Death timer
private float tTime;
//
private string inventoryString;
public string[] obtainedObj;
public float fadeSpeed = 1.5f;
//Objectives
public bool deadCrew;
public int numDead;
public bool commsCenterInit;
public bool keyCards;
public int numKeys;
public bool accessCommsCenter;
public bool commandCenter;
public bool manual;
public bool engineeringItems;
public bool medicItems;
public bool engineItems;
public bool commsCenterFinal;
public bool repairComms;
//Fading
public Image FadeImg;
public bool introDone;
public SpriteRenderer glow;
public SpriteRenderer darkness;
public Image AlarmUI;
public bool bounce;
public bool alarmIsStarted = false;
//Spawning
private Vector3[] lvCoords;
private int nextScene;
public bool firstSpawnInLV1 = true;
void Start()
{
introDone = false;
gameEnd = false;
endSequenceStarted = false;
GameObject.DontDestroyOnLoad (GameObject.FindWithTag("Full Player"));
loading = false;
isAlive = true;
isAwake = false;
deadCrew = false;
numDead = 0;
keyCards = false;
numKeys = 0;
awakeSequenceStarted = false;
moving = false;
hasSuit = false;
canMove = true;
crouch = false;
finishedJump = true;
rb = gameObject.GetComponent<Rigidbody2D>();
scalD = -0.011f;
currD = 0f;
lvCoords = new Vector3[6];
groundItem = false;
gItemID = 0;
currItem = null;
activeTab = false;
inv = GameObject.Find("Inventory Slots");
glow = GameObject.Find ("Glowstick-Glow_Only").GetComponent<SpriteRenderer> ();
glow.color = new Color(0,0,0,0);
darkness = GameObject.Find("BlackBG").GetComponent<SpriteRenderer> ();
playerAnimator.Play ("StellaStand");
currentObjective = 0;
hintBox = GameObject.FindWithTag ("HintBox");
hintText = hintBox.GetComponentInChildren<Text> ();
hintBox.SetActive (false);
activeHint = true;
obtainedObj = new string[8];
obtainedObj [0] = "Power Drill";
obtainedObj [1] = "Wrench";
obtainedObj [2] = "Switchblade";
obtainedObj [3] = "Hammer";
obtainedObj [4] = "Saw";
obtainedObj [5] = "Blow Torch";
obtainedObj [6] = "Screw Driver";
obtainedObj [7] = "Wire Cutters";
bounce = false;
climbSpeed = 0.06f;
typing = gameObject.GetComponent<AudioSource> ();
FadeImg = GameObject.Find ("Fade").GetComponent<Image>();
controlsImage = GameObject.Find ("ControlsImage").GetComponent<Image>();
controlsImage.color = Color.clear;
InvokeRepeating ("FadeToClear", 0.0f, 0.1f);
tTime = 0;
}
void Update()
{
if (isAwake && !gameEnd) {
if (Input.GetKeyUp (KeyCode.Tab) && !activeTab && !loading && introDone && FadeImg.color.a == 0.0f && controlsImage.color.a == 0.0f && !activeHint) {
canMove = false;
activeTab = true;
FadeImg.color = new Color (1, 1, 1, 0.5f);
controlsImage.color = Color.white;
rb.velocity = new Vector2 (0, rb.velocity.y);
if (!hasSuit) {
playerAnimator.Play ("StellaStand");
} else {
playerAnimator.Play ("SpaceStand");
}
} else if (Input.GetKeyUp (KeyCode.Tab) && activeTab && !loading && introDone && controlsImage.color.a == 1.0f) {
canMove = true;
activeTab = false;
FadeImg.color = Color.clear;
controlsImage.color = Color.clear;
}
if (Input.GetKeyDown(KeyCode.H) && !activeHint && !onLadder && !activeTab && FadeImg.color.a == 0.0f)
{
if (playerAnimator.speed == 0) {
playerAnimator.speed = 1;
}
rb.velocity = new Vector2(0, rb.velocity.y);
if (!hasSuit)
{
playerAnimator.Play("StellaStand");
}
else
{
playerAnimator.Play("SpaceStand");
}
StartCoroutine("displayHint");
activeHint = true;
}
}
if (SceneManager.GetActiveScene ().name == "Engineering Wing" && alarm == null) {
Debug.Log ("Woo");
alarm = GameObject.Find ("AlarmSound").GetComponent<AudioSource> ();
staticSound = GameObject.Find ("staticsound").GetComponent<AudioSource> ();
}
}
void FixedUpdate ()
{
if (SceneManager.GetActiveScene ().name == "Credits") {
DestroyImmediate (GameObject.FindWithTag ("Full Player"));
}
if (hintBox == null && !gameEnd) {
loading = false;
activeHint = false;
activeTab = false;
if (hasSuit) {
playerAnimator.Play ("SpaceStand");
} else {
playerAnimator.Play ("StellaStand");
}
FadeImg = GameObject.Find ("Fade").GetComponent<Image>();
FadeImg.color = Color.black;
InvokeRepeating ("FadeToClear", 0.0f, 0.1f);
hintBox = GameObject.FindWithTag ("HintBox");
hintText = hintBox.GetComponentInChildren<Text> ();
hintBox.SetActive (false);
controlsImage = GameObject.Find ("ControlsImage").GetComponent<Image>();
controlsImage.color = Color.clear;
}
if (gameEnd && !endSequenceStarted) {
endSequenceStarted = true;
canMove = false;
activeHint = true;
activeTab = true;
GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezePositionX | RigidbodyConstraints2D.FreezePositionY | RigidbodyConstraints2D.FreezeRotation;
StartCoroutine ("endGame");
}
if (isAwake && !gameEnd)
{
if ((Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S)) && activeHint == false && activeTab == false && !onLadder)
{
if (playerAnimator.speed == 0) {
playerAnimator.speed = 1;
}
if (isAlive)
{
canMove = false;
crouch = true;
if (!hasSuit)
{
playerAnimator.Play("StellaCrouching");
}
else
{
playerAnimator.Play("SpaceCrouch");
}
}
}
else
{
if (isAlive && activeHint == false && activeTab == false)
{
canMove = true;
crouch = false;
}
}
//Ladder management code
if (onLadder)
{
glow.sortingOrder = 48;
if (gameObject.transform.position.y > ladderBounds[0])
hasDownL = true;
else hasDownL = false;
if (gameObject.transform.position.y < ladderBounds[1])
hasUpL = true;
else hasUpL = false;
}
//Movement
if (!onLadder)
{
glow.sortingOrder = 60;
playerAnimator.speed = 1;
if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
{
sprint = true;
}
else
{
sprint = false;
}
if (finishedJump)
{
airMult = 1.0f;
}
else
{
airMult = 0.5f;
}
if (canMove && !activeHint && !activeTab)
{
//Move right
if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
{
//Causes instant stop if character is moving left
if (rb.velocity.x < 0)
{
rb.velocity = new Vector2(0, rb.velocity.y);
}
playerRenderer.flipX = true;
glow.flipX = true;
moving = true;
if (sprint)
{
if (rb.velocity.x < RUN_SPEEDCAP)
{
rb.AddForce(new Vector2(SPR_MULT * airMult * force, 0));
}
else
{
rb.velocity = new Vector2(RUN_SPEEDCAP, rb.velocity.y);
}
//Animation
if (finishedJump)
{
if (!hasSuit)
{
playerAnimator.Play("StellaRunning");
}
else
{
playerAnimator.Play("SpaceRun");
}
}
}
else
{
if (rb.velocity.x < WALK_SPEEDCAP)
{
rb.AddForce(new Vector2(airMult * force, 0));
}
else
{
rb.velocity = new Vector2(WALK_SPEEDCAP, rb.velocity.y);
}
//Animation
if (finishedJump)
{
if (!hasSuit)
{
playerAnimator.Play("StellaWalking");
}
else
{
playerAnimator.Play("SpaceWalk");
}
}
}
//This line checks to see if the speed in the x direction is below a certain value. If it is, it sets the velocity.
//This helps to make movement a bit more responsive but still smooth.
if (checkV())
rb.velocity = new Vector2(WALK_STARTSPEED, rb.velocity.y);
}
//Move left
else if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
{
//Causes instant stop if character is moving right
if (rb.velocity.x > 0)
{
rb.velocity = new Vector2(0, rb.velocity.y);
}
playerRenderer.flipX = false;
glow.flipX = false;
moving = true;
if (sprint)
{
if (rb.velocity.x > -RUN_SPEEDCAP)
{
rb.AddForce(new Vector2(-SPR_MULT * airMult * force, 0));
}
else
{
rb.velocity = new Vector2(-RUN_SPEEDCAP, rb.velocity.y);
}
//Animation
if (finishedJump)
{
if (!hasSuit)
{
playerAnimator.Play("StellaRunning");
}
else
{
playerAnimator.Play("SpaceRun");
}
}
}
else
{
if (rb.velocity.x > -WALK_SPEEDCAP)
{
rb.AddForce(new Vector2(-airMult * force, 0));
}
else
{
rb.velocity = new Vector2(-WALK_SPEEDCAP, rb.velocity.y);
}
//Animation
if (finishedJump)
{
if (!hasSuit)
{
playerAnimator.Play("StellaWalking");
}
else
{
playerAnimator.Play("SpaceWalk");
}
}
}
if (checkV())
rb.velocity = new Vector2(-WALK_STARTSPEED, rb.velocity.y);
}
else
{
moving = false;
}
//Jump code
if (Input.GetKey(KeyCode.Space) && finishedJump)
{
rb.velocity = new Vector2(rb.velocity.x, jumpHeight);
if (!hasSuit)
{
playerAnimator.Play("StellaJumping");
}
else
{
playerAnimator.Play("SpaceJump");
}
finishedJump = false;
}
}
}
//Ladder key input
else
{
rb.velocity = new Vector2 (0, 0);
if (!hasSuit) {
playerAnimator.Play ("StellaClimbing");
} else {
playerAnimator.Play ("SpaceClimb");
}
if ((Input.GetKey (KeyCode.UpArrow) || Input.GetKey (KeyCode.W)) && hasUpL && activeHint == false && activeTab == false) {
rb.position += new Vector2 (0, climbSpeed);
if (!hasSuit) {
playerAnimator.speed = 2;
playerAnimator.Play ("StellaClimbing");
} else {
playerAnimator.speed = 2;
playerAnimator.Play ("SpaceClimb");
}
} else if ((Input.GetKey (KeyCode.DownArrow) || Input.GetKey (KeyCode.S)) && hasDownL && activeHint == false && activeTab == false) {
rb.position += new Vector2 (0, -climbSpeed);
if (!hasSuit) {
playerAnimator.speed = 2;
playerAnimator.Play ("StellaClimbing");
} else {
playerAnimator.speed = 2;
playerAnimator.Play ("SpaceClimb");
}
} else {
if (!hasSuit) {
playerAnimator.speed = 0;
} else {
playerAnimator.speed = 0;
}
}
}
//Increases falling rate
if (!finishedJump && !onLadder)
{
currD += scalD;
if (currD < -2)
currD = -5;
rb.velocity += new Vector2(0, currD);
}
if (onLadder) currD = 0f;
if (finishedJump && !moving && canMove && !onLadder)
{
if (playerAnimator.speed == 0) {
playerAnimator.speed = 1;
}
if (!hasSuit)
{
playerAnimator.Play("StellaStand");
rb.velocity = new Vector2(0, rb.velocity.y);
}
else
{
playerAnimator.Play("SpaceStand");
rb.velocity = new Vector2(0, rb.velocity.y);
}
}
//If player is dead, countdown to respawn
if (!isAlive)
tdTimer();
//Picks up item if there is one [yay for items and inventory systems :'( ]
if (Input.GetKey(KeyCode.E))
{
if (groundItem)
{
if (currItem.CompareTag("Spacesuit"))
pickUpSuit();
else
pickUpItem();
}
//Ladder code for getting on ladder
else if (hasLadder && !onLadder && lCoolReady && System.Math.Abs(gameObject.transform.position.x-ladderBounds[2])<MAX_SNAP_DISTANCE && activeHint == false && activeTab == false)
{
onLadder = true;
gameObject.GetComponent<BoxCollider2D>().enabled = false;
gameObject.transform.position = new Vector2(ladderBounds[2],gameObject.transform.position.y);
rb.velocity = new Vector2(0, 0);
gameObject.GetComponent<Rigidbody2D>().gravityScale = 0;
lCoolReady = false;
Invoke("lCoolDone", COOL_TIME);
}
else if (onLadder && lCoolReady && lCoolDiff() && activeHint == false && activeTab == false)
{
onLadder = false;
gameObject.GetComponent<BoxCollider2D>().enabled = true;
rb.velocity = new Vector2(0, 0);
gameObject.GetComponent<Rigidbody2D>().gravityScale = 1;
lCoolReady = false;
Invoke("lCoolDone", COOL_TIME);
}
}
updateObjective();
if (currentObjective > 6) {
inventoryCheck ();
}
}
else
{
if (awakeSequenceStarted == false)
{
awakeSequenceStarted = true;
StartCoroutine("WakePlayer");
}
}
}
void OnCollisionEnter2D(Collision2D coll)
{
if(coll.gameObject.CompareTag("Floor") && finishedJump == false && isAlive)
{
finishedJump = true;
if (!crouch)
{
if (!hasSuit)
{
playerAnimator.Play("StellaStand");
}
else
{
playerAnimator.Play("SpaceStand");
}
}
if (activeHint == false && activeTab == false) {
canMove = true;
}
currD = 0;
}
if(coll.gameObject.CompareTag("Wall") && isAlive)
{
if (!finishedJump) {
canMove = false;
}
// else {
// ;
// }
}
if (coll.gameObject.CompareTag("Hazard")) die();
}
private bool checkV()
{
if (System.Math.Abs(rb.velocity.x) < 0.4f) return true;
else return false;
}
private void die()
{
GetComponent<Rigidbody2D> ().velocity = new Vector2 (0, 0);
GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezePositionY | RigidbodyConstraints2D.FreezeRotation;
if(onLadder)
{
gameObject.GetComponent<BoxCollider2D>().enabled = true;
gameObject.GetComponent<Rigidbody2D>().gravityScale = 1;
onLadder = false;
hasLadder = false;
}
isAlive = false;
canMove = false;
if (!hasSuit) {
if (suffocated) {
playerAnimator.Play ("StellaSuffocation");
}
else {
playerAnimator.Play ("StellaDeath");
}
}
else {
playerAnimator.Play ("SpaceDie");
}
}
private void respawn()
{
GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;
gameObject.transform.position = new Vector2(xSpawn,ySpawn);
suffocated = false;
isAlive = true;
canMove = true;
}
private void tdTimer()
{
if (tTime < 3)
tTime += Time.fixedDeltaTime;
else
{
tTime = 0;
respawn();
}
}
public void canPickUp(bool a)
{
groundItem = a;
}
public void setItemID(int num)
{
gItemID = num;
}
public void setRef(GameObject o)
{
currItem = o;
}
private void pickUpItem()
{
currItem.SendMessage("claim");
inv.SendMessage("claim", gItemID);
groundItem = false;
gItemID = 0;
currItem = null;
}
private void pickUpSuit()
{
hasSuit = true;
currItem.SendMessage("claim");
groundItem = false;
currItem = null;
}
public void tp(Vector3 a)
{
gameObject.transform.parent.position = new Vector3(a.x, a.y, 0);
gameObject.transform.position = new Vector3(a.x, a.y, 0);
Debug.Log (rb);
rb.velocity = new Vector2(0f,0f);
}
public void canClimb(bool c)
{
hasLadder = c;
}
private bool lCoolDiff()
{
if (System.Math.Abs(gameObject.transform.position.y - ladderBounds[1]) < ON_OFF_VARIANCE_TOP || System.Math.Abs(gameObject.transform.position.y - ladderBounds[0]) < ON_OFF_VARIANCE_BOT || gameObject.transform.position.y < ladderBounds[0])
return true;
else return false;
}
public void passLadderBounds(float[] a)
{
ladderBounds = a;
}
private void lCoolDone()
{
lCoolReady = true;
}
public IEnumerator displayHint()
{
if (isAlive) {
canMove = false;
hintBox.SetActive (true);
if (currentObjective == 0) {
hintText.text = "<color=fuchsia>Stella</color>: (...I need to find my crew members and check if they're alright...)";
}
else if (currentObjective == 1) {
hintText.text = "<color=fuchsia>Stella</color>: (...I need to get into the communications room to send out an SOS signal...)";
}
else if (currentObjective == 2) {
hintText.text = "<color=fuchsia>Stella</color>: (...I need to search the rooms for two omnicards in order to get into the communications room...)";
}
else if (currentObjective == 3) {
hintText.text = "<color=fuchsia>Stella</color>: (...I should go into the communications room and send out an SOS signal before I do anything else...)";
}
else if (currentObjective == 4) {
hintText.text = "<color=fuchsia>Stella</color>: (...I should try to send my location out using the GPS Tracker in the command center...)";
}
else if (currentObjective == 5) {
hintText.text = "<color=fuchsia>Stella</color>: (...I need the repair manual located in the engineering wing in order to find the tools I need...)";
}
else if (currentObjective == 6) {
hintText.text = "<color=fuchsia>Stella</color>: (...The ship's oxygen system is failing! I need to find a spacesuit before oxygen levels drop to zero...)";
}
else if (currentObjective == 7) {
inventoryString = "";
hintText.text = "<color=fuchsia>Stella</color>: (...I need to find the following item(s) in the Engineering Wing...) \n";
yield return new WaitUntil (() => Input.GetKeyDown (KeyCode.Return));
yield return new WaitForSeconds (0.2f);
for (int i = 0; i < 2; i++) {
if (obtainedObj [i] != "") {
inventoryString += "\t(" + obtainedObj[i] + ")\n";
Debug.Log (inventoryString);
}
}
hintText.text = inventoryString;
}
else if (currentObjective == 8) {
inventoryString = "";
hintText.text = "<color=fuchsia>Stella</color>: (...I need to find the following item(s) in the Medical Ward...) \n";
yield return new WaitUntil (() => Input.GetKeyDown (KeyCode.Return));
yield return new WaitForSeconds (0.2f);
for (int i = 2; i < 5; i++) {
if (obtainedObj [i] != "") {
inventoryString += "\t(" + obtainedObj[i] + ")\n";
}
}
hintText.text = inventoryString;
}
else if (currentObjective == 9) {
inventoryString = "";
hintText.text = "<color=fuchsia>Stella</color>: (...I need to find the following item(s) in the Engine Room...) \n";
yield return new WaitUntil (() => Input.GetKeyDown (KeyCode.Return));
yield return new WaitForSeconds (0.2f);
for (int i = 5; i < 8; i++) {
if (obtainedObj [i] != "") {
inventoryString += "\t(" + obtainedObj[i] + ")\n";
}
}
hintText.text = inventoryString;
}
else if (currentObjective == 10) {
hintText.text = "<color=fuchsia>Stella</color>: (...Now that I have all the repair tools, I can head back to the communications room back on the first floor...)";
}
else if (currentObjective == 11) {
hintText.text = "<color=fuchsia>Stella</color>: (...I can finally repair the communications terminal and send out an SOS signal...)";
}
yield return new WaitUntil (() => Input.GetKeyDown (KeyCode.Return));
hintBox.SetActive (false);
canMove = true;
activeHint = false;
}
StopCoroutine ("displayHint");
}
public void updateObjective ()
{
if (deadCrew && currentObjective == 0) {
currentObjective = 1;
}
else if (commsCenterInit && currentObjective == 1) {
currentObjective = 2;
}
else if (keyCards && currentObjective == 2) {
currentObjective = 3;
}
else if (accessCommsCenter && currentObjective == 3) {
currentObjective = 4;
}
else if (commandCenter && currentObjective == 4) {
currentObjective = 5;
}
else if (manual && currentObjective == 5 && alarmIsStarted) {
currentObjective = 6;
InvokeRepeating("alarmOn", 0.0f, 0.05f);
alarm.Play ();
}
else if (hasSuit && currentObjective == 6) {
StartCoroutine("AlarmOffSequence");
currentObjective = 7;
}
else if (engineeringItems && currentObjective == 7) {
currentObjective = 8;
}
else if (medicItems && currentObjective == 8) {
currentObjective = 9;
}
else if (engineItems && currentObjective == 9) {
StartCoroutine ("allItems");
currentObjective = 10;
}
else if (commsCenterFinal && currentObjective == 10) {
currentObjective = 11;
}
else if (repairComms && currentObjective == 11) {
}
}
public void inventoryCheck()
{
if (currentObjective == 7) {
if (obtainedObj [0] == "" && obtainedObj [1] == "") {
engineeringItems = true;
}
}
else if (currentObjective == 8) {
if (obtainedObj [2] == "" && obtainedObj [3] == "" && obtainedObj[4] == "") {
medicItems = true;
}
}
else if (currentObjective == 9) {
if (obtainedObj [5] == "" && obtainedObj [6] == "" && obtainedObj[7] == "") {
engineItems = true;
}
}
}
public IEnumerator WakePlayer()
{
playerAnimator.Play ("StellaWakingUp");
yield return new WaitForSeconds (4.75f);
darkness.color = new Color(0,0,0,0);
glow.color = new Color(1,1,1,1);
hintBox.SetActive (true);
setHintText ("<color=fuchsia>Stella</color>: Ugh...what happened? Did...we crash? ");
yield return new WaitUntil (() => Input.GetKeyDown (KeyCode.Return));
yield return new WaitForSeconds (0.2f);
setHintText ("<color=fuchsia>Stella</color>: We were on our way to that planetary system, Xylo. ");
yield return new WaitUntil (() => Input.GetKeyDown (KeyCode.Return));
yield return new WaitForSeconds (0.2f);
setHintText ("<color=fuchsia>Stella</color>: Yeah, yeah that's right...but what the hell happened?");
yield return new WaitUntil (() => Input.GetKeyDown (KeyCode.Return));
yield return new WaitForSeconds (0.2f);
setHintText ("<color=fuchsia>Stella</color>: I think I'm alright, no bruises or broken bones. ");
yield return new WaitUntil (() => Input.GetKeyDown (KeyCode.Return));
yield return new WaitForSeconds (0.2f);
setHintText ("<color=fuchsia>Stella</color>: I need to see if the others are okay before I do anything else.");
yield return new WaitUntil (() => Input.GetKeyDown (KeyCode.Return));
hintBox.SetActive (false);
isAwake = true;
StopCoroutine ("WakePlayer");
}
public void setHintText(string hint)
{
hintText.text = hint;
}
public void alarmOn()
{
AlarmUI = GameObject.Find ("Alarm").GetComponent<Image>();
if (AlarmUI == null) {
CancelInvoke("alarmOn");
return;
}
if (!bounce && AlarmUI.color.a < 0.5f) {
AlarmUI.color = Color.Lerp (AlarmUI.color, Color.red, fadeSpeed * Time.deltaTime);
}
else if (!bounce && AlarmUI.color.a >= 0.5f) {
bounce = true;
}
else if (bounce && AlarmUI.color.a > 0.15f) {
AlarmUI.color = Color.Lerp (AlarmUI.color, Color.clear, fadeSpeed * Time.deltaTime);
}
else if (bounce && AlarmUI.color.a <= 0.15f) {
bounce = false;
}
}
public void FadeToBlack()
{
FadeImg.color = Color.Lerp (FadeImg.color, Color.black, fadeSpeed * Time.deltaTime);
if (FadeImg.color.a == 1.0f) {
CancelInvoke ("FadeToBlack");
}
}
public void FadeToClear()
{
//Bug: this gets called again whenever Level One is entered
FadeImg.color = Color.Lerp (FadeImg.color, Color.clear, fadeSpeed * Time.deltaTime);
if (FadeImg.color.a < 0.2f) {
CancelInvoke ("FadeToClear");
introDone = true;
FadeImg.color = Color.clear;
Debug.Log (FadeImg.color.a);
activeHint = false;
}
}
public void setLv1Coords()
{
lvCoords[0] = gameObject.transform.position;
}
public void setLv1Coords(Vector3 a)
{
lvCoords[0] = a;
}
public void updateSpawn(Vector3 cp)
{
xSpawn = cp.x;
ySpawn = cp.y;
}
public void tpL1()
{
Debug.Log(lvCoords[0]);
tp(lvCoords[0]);
Debug.Log(gameObject.transform.position);
}
public IEnumerator endGame()
{
hintBox.SetActive (true);
playerAnimator.Play ("StellaLook");
setHintText ("<color=fuchsia>Stella</color>: There! It should be fully operational now!");
yield return new WaitUntil (() => Input.GetKeyDown (KeyCode.Return));
yield return new WaitForSeconds (0.5f);
hintBox.SetActive (false);
playerAnimator.Play ("SpaceType");
typing.Play ();
yield return new WaitForSeconds (3.0f);
hintBox.SetActive (true);
typing.Stop ();
playerAnimator.Play ("StellaLook");