-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlayerControllerCW.cs
6609 lines (6353 loc) · 296 KB
/
PlayerControllerCW.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
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Threading.Tasks;
using System.Linq;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.Experimental.Rendering.Universal;
using UnityEngine.Tilemaps;
using Cinemachine;
using UnityEngine.Playables;
using UnityEngine.Timeline;
using UnityEngine.Events;
public class PlayerControllerCW : MonoBehaviour
{
private float saveStamp = -5.0f;
public Rigidbody2D rb;
public SpriteRenderer sr;
public Transform ts;
public GameObject spriteobj;
//object with sprite on it
public static GameObject roomBox;
//the bounding box of the current room
public BoxCollider2D bc;
public Vector2 bcsize;
public GameObject SceneManagerObj;
public GameObject SceneManagerPrefab;
public SceneManagerCW sm;
public float framesSinceSceneLoad = 0;
public bool roomTransitioning;
public int lockRoomTransitioning;
//xmovement
public float xspeed;
//the target acceleration the player moves at that we change
public float xaccel;
//the target acceleration the player moves at that we change
public int xframes;
//the target number of frames that it takes to reach full accel
public int xframesmod;
//the number of frames left to acceleration, used to calculate
public float xinput;
//input.getaxis
private float prevxinput;
//to detect when to accel
private bool prevxheld;
//for switchback input
public float xvelmove;
public static float timerscale;
public int directionOfTravel;
//direction of travel -> integer version of xinput
public float prevxvel;
public float prevxvelreal;
private int slopeBuffer;
private int ignoreSlopeBufferFrames;
//for anims
public bool accelerationControl;
public int accelerationValue;
private float accelerationMagnitude;
private float decelerationMagnitude;
//ground detection
public bool onGround;
//self-explanatory
private bool onGroundFar;
private bool prevGrounded;
public bool isWalledLeft;
public bool isWalledRight;
public bool ceiled;
//on ceiling
public GameObject groundPoint;
//point at which raycasts originate for grounding
public GameObject cameraPoint;
private CameraControllerCW cameraController;
public LayerMask groundMask;
//mask to detect what will make onground true in the raycast
public LayerMask boundsMask;
public LayerMask waterBlockMask;
public GameObject semisolidGround;
public bool inGround;
//ymovement
public float ycap;
//y velocity cap, target y acceleration
public float yvel = 0.0f;
//the number put as rb.velocity.y to apply vertical forces
public float yaccel;
//how fast you accelerate downwards
public float jumpForce;
//how fast you accelerate downwards
public bool jumping;
//to communicate between update and fixedupdate
public bool canJump;
//so that pressing jump feels better overall
public int coyoteFrames;
//for coyote time jumps (off platform)
public float jumpTimer;
//wallJumping
public bool wallJumping;
public float wallJumpApplyForce;
private float wallJumpForceApplicationTimestamp;
//tracker for assisted wallsliding
public int assistWallSlide;
//the leeway that it gives for you to jump better, timer
private float jumpTimerHeight;
//to control the height of jumps
public float jumpBuffer;
//the leeway that it gives for you to jump better, can set to see result, input buffering
public bool dashBuffer;
private int isBufferedDash;
private float dashInputTimer = -9.0f;
//leeway for dash
public float squish;
//squish the player
public float yveladd;
//instance of yvel before applied other y velocities that would be bigger than cap and mess with squish
private float yvelsquish;
//adds to yvel
public float yvelset;
//sets yvel to new number
public bool canyveladd;
//adds to yvel
public bool canyvelset;
//sets yvel to new number
public bool wallSliding;
//are u wallsliding? ok
private bool prevWallSliding;
private bool ignorePrevWallSliding;
private bool wallSlidingAnims;
private bool prevWallSlidingAnims;
private float slideStamp = -9.0f;
private float cancelSlideStamp = -9.0f;
private bool cancelSlide;
private int wallDir;
public bool lockedWallSliding;
public float xveladd;
//adds to yvel
public float xvelset;
//sets yvel to new number
public bool canxveladd;
//adds to yvel
public bool canxvelset;
//sets yvel to new number
public int facingdir;
//dirfacing
private int saveFacingDir;
private int yinput;
//input.getaxis
public float prevyvel;
//death
public float health;
private bool knockbackDisable = false;
//knockbackDisables input
private float knockbackDisableTimer;
//to count the time until knockbackDisable ends
public bool inputDisable = false;
//disables input
public float inputDisableTimer;
public bool invincible;
//knockbackDisables damage
private float invincibilityTimer;
//to count the time until invincibility ends
private bool touchingDeath;
//if u r touching death this is true
private bool touchingConduit;
private float blinkTimer;
//to count the time until invincibility ends
public static int resetting;
public static int spikeResetting;
private bool hitDeath;
private float respawnStamp;
//if u hit death? used while disabled
//slowDash
public bool slowmo;
//time is changing
public bool prevslowmo;
//anims
public bool canslowDash;
//can slowDash aim, when let go you will go
public bool prevcanslowDash;
//can slowDash aim, when let go you will go
public bool sdDisable;
//disables movement
public float sdDisableTimer;
//times how long dash should be
public bool slowDashing;
//if you are dashing rn
private int startSlowDash;
//did u start dash last frame? ok
public Vector2 slowDir;
//direction to dash
public bool onTarget;
//if you are locked on or not
public float dashDistance;
//if you are locked on or not
public LayerMask dashMask;
//mask to detect what will make onground true in the raycast
public LayerMask boundsCheck;
public float dashTime;
//time that it takes to do dash
public bool dashinvincible;
//invincible during dash
public int dashFrameCount;
//dashframecount for normal dashing, keeping same distance
public Vector2 dashHitPoint;
public bool airDash;
//only dash once
//public float dashMeter;
//for dash doing damage
public GameObject dashHitbox;
private GameObject dolphinHitbox;
private bool dashHitExtend;
private float dashHitTimer;
private AttackCW atk;
public Vector2 spikePoint;
private bool ensureSpikePoint;
public bool dashCancel;
//did u cancel ur dash? ok cool
public bool saveTargetDash;
//are u in a target dash? ok cool
public bool dashInputBool;
public bool gravityCancel;
private float keepTargetCheckStamp;
private GameObject dashHitboxObj;
//attacks
public bool attackLock = false;
//locks all attacks and flipping
private bool crouching;
//are u crouching? ok cool
private float attackStamp;
public GameObject staffSwing;
private float extendDashInvincibilityStamp=-9.0f;
private bool extendNormalDashMomentum = false;
private bool spongeExtending;
private float stopNormalDashMomentumStamp = -9.0f;
private int framesSinceEndedNormalDash;
//private bool extendDashCancel = true;
private float dashInvincibilityTimer = -9.0f;
private float cameraZoneExitStamp = - 9.0f;
private GameObject saveCameraZone;
private GameObject cameraZoneRoomBox;
private bool exitedCameraZone;
public bool changingScene;
private float changeSceneStamp = -9.0f;
//scenes
private int sceneNum;
private Vector2 keepSlowDir;
private int turnAroundFrames;
//graphics (not anims)
public Light2D pointLight;
public Light2D emanateLight;
float plIntensity;
float plOuter;
float emIntensity;
float emOuter;
float rpoint;
float gpoint;
float bpoint;
private Animator anim;
private int attackAnimIndex;
private bool attackAnimLock;
private int animFlipDir;
public GameObject maskobj;
private string[] attackAnims;
private bool inJump;
public bool disableMaskChanges;
private int atkdir;
public int atkfloat;
public float lineRendererResetStamp;
public int downPressed;
public int disablePlatforms;
public int disablePlatformsBuffer;
private float WallJumpXvel;
private float framesSinceWallJump;
private int whichBound;
public bool dashTurn;
private ParticleSystem dashTrail;
private ParticleSystem bubbleTrail;
//healing
public int healing;
public GameObject healingOrb;
public GameObject healEffect;
private float healStamp = -9.0f;
private float healStamp2 = -9.0f;
private bool queueHeal = false;
//slam
private int slamInput;
private float slamInputStamp = -9.0f;
public bool slamming;
public int slamState;
private bool revertSlamVelocity;
private bool prevSlamming;
private GameObject targetSelect;
public GameObject targetSelected;
private float slamStallStamp;
//zipline
public bool ziplining;
public Vector2 zipDir;
private Vector2 zipPos;
private int zipSetPos;
private bool extendZipMomentum;
private float timeEndedZip;
private bool zipJumpable;
private GameObject otherZipPoint;
public GameObject targetHit;
private bool inZiplinePoint;
private bool prevInZiplinePoint;
private Collider2D savedZiplinePoint;
//misc ig
private float spikeFadeStamp;
public bool spikeInvincible;
private GameObject deathFade;
private SpriteRenderer deathFadeSprite;
private float deathFadeTimer = -9.0f;
public bool deathFading;
private bool deathFadeReset;
private GameObject deathFadePlayer;
public GameObject[] blackBars;
public bool disableAllActions;
private bool crossSceneDeath = false;
private bool stopDeathStopTimer = false;
private bool slamInputBool = false;
private GameObject hookObject;
private Vector2 hookPoint;
private AudioSource dashSoundReference;
private AudioSource slowdownSoundReference;
private GameObject slamShockwave;
private GameObject slashEffect;
private GameObject slashGraphic;
private GameObject gliderBack;
private GameObject gliderDestroyParticle;
//mushroom
/*
public bool mushroomJump;
private float mushroomJumpTimer;
private bool mushroomCharging;
*/
private bool wallAttacking;
public bool gliderObtained;
public bool gliderActivated;
private bool prevGliderActivated;
public GameObject currentGliderReference;
private bool ventGliding;
public bool onCrumble;
public bool noclip;
public float noclipSpeed = 10;
private float noclipyinput;
private bool noclipprevy;
private float noclipprevyinput;
public bool superInvincible;
private float conduitHitTimestamp;
public Vector3 cameraZoneTargetPoint;
private Vector3 cameraZoneSavePos;
public bool inCamshiftZone;
private GameObject dashCancelGraphic;
public float ventCancelTimer = -9.0f;
private Vector2 returnPos;
private bool smoothTargetAngle;
private bool prevDashCancel;
private int smoothWaitFrames;
private int framesSinceLastRecordingSpawn;
//spin attack
public bool chargingSpin;
private float spinChargeStamp;
public bool spinAttacking;
private bool spinAttackFrame;
private float spinAttackTimer;
private int spinAttackStage;
private int spinAttackType;
private GameObject spinAttackAir;
private GameObject spinChargeParticle;
private GameObject spinChargeParticle2;
private float spinChargeParticleStamp;
private float spinAttackSpeed;
private GameObject previousZiplinePoint;
private bool zipReenterDisable;
//water blocks
public bool swimming;
public Vector2 swimDir;
private GameObject waterBlockChecker;
private GameObject waterBlockChecker2;
private int swimCancelLock;
private int framesSinceEndedSwim;
public float swimSpeed;
public bool dolphinJumping;
private int dolphinJumpFrames;
private GameObject waterBlockCollider;
public bool extendDolphinMomentum;
private float dolphinJumpStamp;
private float dolphinGravFloat;
public int inWhirlpool;
private List<Vector3> whirlpoolCenters;
public bool inCannon;
public bool superdashing;
private float cannonLaunchStamp;
private GameObject tempSpike;
public bool canCreateTempSpike;
public bool inPurpleWater;
private float waterBlockWaitTime;
public bool touchingSponge;
private GameObject cannonRef;
private float superdashEndStamp = -9.0f;
private bool hideHook;
private float initialDolphinX;
public float waterLockTurningTimer = -9.0f;
private GameObject splash1Ref;
private GameObject splash2Ref;
private Edge savedEdge;
private Vector2 savedEdgePos;
private bool otherIgnoreInvinc;
private bool noInvincibleBlink;
public bool inBubble;
public int hasExitedBubble;
public bool bubbleWarping;
public bool bubbleTeleporting;
private float bubbleWarpTimestamp;
public Vector2 bubbleDir;
public GameObject bubbleRef;
private Vector2 bubbleSaveDir;
private Vector2 bubbleSavePos;
public bool bubbleCancelTeleporting;
public bool bubbleCancelling = false;
private float swimStartStamp = -9.0f;
private Vector3 swimStartPoint;
private bool exitBubbleFrameBuffer;
public int bubbleBuffer;
public GameObject dolphinAttack;
private float logSlamHeight;
public bool bubbleExtendLocking;
private float bubbleExtendLockStamp;
private bool dolphinTransFrame;
private int dolphinSmoothWaitFrames;
private bool smoothDolphinTargetAngle;
private float dolphinLerpWaitStamp;
private bool prevRoomBoxCleared;
private GameObject screenLock;
private SpriteRenderer screenLockSprite;
private Animator screenLockAnim;
private bool cancelDolphinMomentum;
public Vector4 quadrantCounter;
private GameObject quadrantParent;
private bool touchingQuadrant;
public Vector3 lastPosOutsideWater;
private int standingOnOneWayFrames;
private bool eventRoomBuffer;
private bool enterSceneLock;
private float enterSceneStamp;
public PlayableDirector timeline;
public TaskCompletionSource<bool> pauseTask;
public float xPosToReach;
public DialogueManagerCW dm;
private bool crouchAttackCutscene;
private bool touchEdgeCutscene;
private bool waitingForDashCutsceneLand;
public bool freezePosition;
private bool cutscene42Dash;
private Vector2 cutscene42SavePos;
private bool animSlowingTime;
private float animSpeed;
public int slowdownStartFrames = 0;
public bool inCutscene;
private bool timelineSpeedOverride;
private bool timelinePause;
private double timelinePauseTime;
private List<IMarker> markers;
private int markerIndex;
private bool attackBuffer = false;
private float attackInputTimer = -9.0f;
private bool upDooring;
private float upDoorStamp;
private Vector2 upDoorPos;
public bool disableSpikePointSave = false;
public bool beingPushed;
public bool dying;
public bool freeze;
public float freezeStamp;
public bool inAbductorCircle;
public Sprite frozenSprite;
private int frozenFrames;
public bool reducedGravity;
public bool extremeGravity;
public int reducedGravity2;
public bool specialTarget;
public bool cyprusBubble;
private int unclearRepeatedly;
private int clearRepeatedly;
public bool cutsceneCameraParented;
void Awake()
{
framesSinceSceneLoad = 0;
if (SaveDataCW.savedGames.Count == 0) {
for (int i=0;i<3;i++) SaveDataCW.savedGames.Add(null);
}
SaveDataCW.Load();
if (Game.loadedGame == null) {
Game.loadedGame = SaveDataCW.savedGames[0];
}
SaveDataCW.Save();
}
void Start()
{
resetting = 0;
spikeResetting = 0;
Setup();
ObjectSetup();
Reset();
//SetPosition();
//health = StaticDataCW.Health;
health = 3;
}
void Setup()
{
rb = GetComponent<Rigidbody2D>();
ts = GetComponent<Transform>();
bc = GetComponent<BoxCollider2D>();
groundMask |= (1 << 8);
groundMask |= (1 << 19);
groundMask |= (1 << 20);
dashMask |= (1 << 8);
dashMask |= (1 << 10);
dashMask |= (1 << 12);
dashMask |= (1 << 13);
dashMask |= (1 << 20);
dashMask |= (1 << 21);
dashMask |= (1 << 24);
dashMask |= (1 << 27);
boundsCheck |= (1 << 8);
boundsCheck |= (1 << 10);
boundsCheck |= (1 << 13);
boundsCheck |= (1 << 20);
boundsCheck |= (1 << 21);
boundsCheck |= (1 << 27);
boundsMask |= (1 << 12);
boundsMask |= (1 << 14);
waterBlockMask |= (1 << 24);
returnPos = new Vector2(Game.loadedGame.currentSpikePointx, Game.loadedGame.currentSpikePointy);
}
void Reset()
{
freezePosition = false;
pauseTask = new TaskCompletionSource<bool>();
//rb.position = new Vector3(29.5f,3f,0f);
rb.velocity = new Vector3(0f,0f,0f);
sr.enabled = true;
prevxheld = false;
knockbackDisable = false;
knockbackDisableTimer = 0f;
touchingDeath = false;
touchingConduit = false;
invincible = true;
dashinvincible = false;
invincibilityTimer = StaticDataCW.Time - 0.6f;
airDash = true;
slowmo = false;
prevslowmo = false;
inJump = false;
xspeed = 6.2f;
xaccel = 0;
xframes = 8;
xframesmod = 0;
xvelmove = 0;
ycap = -12.5f;
yaccel = 0.75f;
jumpForce = 16;
jumpBuffer = 0.1f;
dashBuffer = false;
isBufferedDash = 0;
dashInputTimer = -9.0f;
jumping = false;
coyoteFrames = 0;
sdDisable = false;
knockbackDisable = false;
yvel = 0f;
facingdir = 1;
canJump = false;
animSlowingTime = false;
squish = 1f;
canyveladd = false;
animSpeed = 1f;
canyvelset = false;
canxveladd = false;
canxvelset = false;
knockbackDisableTimer = -9.0f;
canslowDash = false;
slowDashing = false;
if (dashTrail != null) {
dashTrail.Stop();
}
if (bubbleTrail != null) {
bubbleTrail.Stop();
}
if (dashHitboxObj != null) {
Destroy(dashHitboxObj);
}
dashHitTimer = -9.0f;
dashHitExtend = false;
if (dashSoundReference != null) {
SceneManagerCW.StopSound(dashSoundReference, "Dashing");
}
onTarget = false;
dashDistance = 0f;
dashTime = 0f;
unclearRepeatedly = 0;
clearRepeatedly = 0;
dashinvincible = false;
dashFrameCount = 0;
slowmo = false;
dashCancel = false;
attackLock = false;
turnAroundFrames = 0;
ceiled = false;
prevyvel = 0f;
attackAnimIndex = 0;
startSlowDash = 0;
saveTargetDash = false;
attackAnims = new string[6] {"Attack1betr", "Attack2", "Attack3", "DownAttack", "UpAttack 1", "DownAttackGoingUp"};
//dashMeter = 1;
slopeBuffer = 0;
ignoreSlopeBufferFrames = 0;
prevGrounded = true;
prevSlamming = false;
disableMaskChanges = false;
atkfloat = 0;
gravityCancel = false;
keepTargetCheckStamp = -9.0f;
slowDir = new Vector2(0,0);
wallSliding = false;
wallSlidingAnims = false;
slideStamp = -9.0f;
cancelSlideStamp = -9.0f;
cancelSlide = false;
wallDir = 0;
wallAttacking = false;
disablePlatforms = 0;
disablePlatformsBuffer = 0;
plIntensity = 0.5f;
plOuter = 0.5f;
emIntensity = 0.3f;
emOuter = 1.5f;
cameraZoneExitStamp = -9.0f;
extendNormalDashMomentum = false;
spongeExtending = false;
extendDolphinMomentum = false;
stopNormalDashMomentumStamp = -9.0f;
healing = 0;
healStamp = -9.0f;
healStamp2 = -9.0f;
queueHeal = false;
ensureSpikePoint = false;
if (SpecialSpikeCast(Vector2.down, false).x > -9998.9f || SpecialSpikeCast(Vector2.down, false).y > -9998.9f || SpecialSpikeCast(Vector2.down, false).x < -9999.1f || SpecialSpikeCast(Vector2.down, false).y < -9999.1f) {
spikePoint = SpecialSpikeCast(Vector2.down, false);
} else {
if (CheckGroundedPlatformOneWay((Vector2) groundPoint.transform.position, 2f, Vector2.up)) {
spikePoint = SpecialSpikeCast(Vector2.up, false);
} else {
spikePoint = SpecialSpikeCast(Vector2.down, true);
}
}
slamInputStamp = -9.0f;
slamInput = 0;
slamState = 0;
slamming = false;
accelerationControl = false;
assistWallSlide = 0;
lockedWallSliding = false;
crossSceneDeath = false;
inGround = false;
slamInputBool = false;
/*
mushroomJump = false;
mushroomCharging = false;
*/
gliderObtained = false;
gliderActivated = false;
inZiplinePoint = false;
prevInZiplinePoint = false;
wallJumpApplyForce = 0f;
wallJumpForceApplicationTimestamp = -9.0f;
ventGliding = false;
onCrumble = false;
currentGliderReference = null;
conduitHitTimestamp = -9.0f;
if (hookObject != null) {
hookObject.transform.GetChild(0).gameObject.GetComponent<SpriteRenderer>().enabled = false;
}
if (roomBox != null) {
roomBox.GetComponentsInChildren<CinemachineVirtualCamera>()[0].GetCinemachineComponent<CinemachineFramingTransposer>().m_YDamping = 1.4f;
}
ventCancelTimer = -9.0f;
spinAttacking = false;
if (slashGraphic != null) {
Destroy(slashGraphic);
}
spinAttackFrame = false;
spinAttackStage = 0;
chargingSpin = false;
spinChargeStamp = -9.0f;
spinChargeParticleStamp = -9.0f;
spinAttackTimer = -9.0f;
zipReenterDisable = false;
swimming = false;
dolphinJumping = false;
//inWhirlpool = 0;
whirlpoolCenters = new List<Vector3>();
inCannon = false;
superdashing = false;
cannonLaunchStamp = -9.0f;
inPurpleWater = false;
canCreateTempSpike = true;
waterBlockWaitTime = -9.0f;
touchingSponge = false;
superdashEndStamp = -9.0f;
hideHook = false;
otherIgnoreInvinc = false;
noInvincibleBlink = false;
inBubble = false;
bubbleWarping = false;
spikeInvincible = false;
bubbleCancelling = false;
bubbleWarpTimestamp = -9.0f;
swimStartStamp = -9.0f;
bubbleBuffer = 0;
waterLockTurningTimer = -9.0f;
logSlamHeight = 0f;
bubbleExtendLockStamp = -9.0f;
bubbleExtendLocking = false;
dolphinTransFrame = false;
smoothDolphinTargetAngle = false;
dolphinLerpWaitStamp = -9.0f;
if (screenLock != null) {
Destroy(screenLock);
}
lockRoomTransitioning = 0;
cancelDolphinMomentum = false;
bubbleCancelTeleporting = false;
quadrantCounter = Vector4.zero;
touchingQuadrant = false;
waitingForDashCutsceneLand = false;
cutscene42Dash = false;
slowdownStartFrames = 0;
inCutscene = false;
timelineSpeedOverride = false;
timelinePause = false;
timelinePauseTime = 0.0;
markers = null;
markerIndex = 0;
respawnStamp = StaticDataCW.Time;
attackBuffer = false;
attackInputTimer = -9.0f;
upDooring = false;
beingPushed = false;
dying = false;
freeze = false;
freezeStamp = -9.0f;
inAbductorCircle = false;
if (anim != null) {
anim.enabled = true;
}
reducedGravity = false;
reducedGravity2 = 0;
extremeGravity = false;
specialTarget = false;
cyprusBubble = false;
cutsceneCameraParented = false;
if (cameraPoint != null)
{
cameraPoint.transform.parent = transform;
}
}
void ObjectSetup()
{
if (groundPoint == null)
{
groundPoint = new GameObject(this.name + " GroundPoint");
groundPoint.transform.parent = this.gameObject.transform;
bcsize = bc.size;
groundPoint.transform.localPosition = new Vector3(0f,(-0.5f*bcsize.y) + bc.offset.y,0f);
groundPoint.tag = "Groundpoint";
}
if (cameraPoint == null)
{
cameraPoint = new GameObject(this.name + " CameraPoint");
cameraPoint.transform.parent = this.gameObject.transform;
cameraPoint.transform.localPosition = new Vector3(0f, 0f, 0f);
cameraPoint.tag = "CameraPoint";
}
if (waterBlockChecker == null)
{
waterBlockChecker = new GameObject(this.name + " WaterBlockChecker");
waterBlockChecker.transform.parent = this.gameObject.transform;
waterBlockChecker.transform.localPosition = new Vector3(0f, 0f, 0f);
waterBlockChecker.layer = 25;
waterBlockChecker.AddComponent<BoxCollider2D>();
waterBlockChecker.GetComponent<BoxCollider2D>().isTrigger = false;
waterBlockChecker.GetComponent<BoxCollider2D>().size = new Vector2(0.05f, 0.05f);
waterBlockChecker.AddComponent<FrostGuardDetectorCW>();
waterBlockChecker.AddComponent<Rigidbody2D>();
waterBlockChecker.GetComponent<Rigidbody2D>().bodyType = RigidbodyType2D.Kinematic;
waterBlockChecker.GetComponent<Rigidbody2D>().constraints |= RigidbodyConstraints2D.FreezeRotation;
waterBlockChecker.GetComponent<Rigidbody2D>().collisionDetectionMode = CollisionDetectionMode2D.Continuous;
}
if (waterBlockChecker2 == null)
{
waterBlockChecker2 = new GameObject(this.name + " WaterBlockChecker2");
waterBlockChecker2.transform.parent = this.gameObject.transform;
waterBlockChecker2.transform.localPosition = new Vector3(0f, 0f, 0f);
waterBlockChecker2.layer = 25;
waterBlockChecker2.AddComponent<BoxCollider2D>();
waterBlockChecker2.GetComponent<BoxCollider2D>().isTrigger = false;
waterBlockChecker2.GetComponent<BoxCollider2D>().size = new Vector2(0.51f, 0.9f);
waterBlockChecker2.AddComponent<FrostGuardDetectorCW>();
waterBlockChecker2.AddComponent<Rigidbody2D>();
waterBlockChecker2.GetComponent<Rigidbody2D>().bodyType = RigidbodyType2D.Kinematic;
waterBlockChecker2.GetComponent<Rigidbody2D>().constraints |= RigidbodyConstraints2D.FreezeRotation;
waterBlockChecker2.GetComponent<Rigidbody2D>().collisionDetectionMode = CollisionDetectionMode2D.Continuous;
}
if (waterBlockCollider == null)
{
waterBlockCollider = Instantiate(Resources.Load<GameObject>("Prefabs/WaterBlockCollider") as GameObject);
waterBlockCollider.transform.parent = this.gameObject.transform;
waterBlockCollider.transform.localPosition = new Vector3(0f, 0f, 0f);
}
if (semisolidGround == null) {
semisolidGround = GameObject.FindWithTag("Semisolid");
}
if (spriteobj == null)
{
spriteobj = GameObject.FindWithTag("Spriteobj");
sr = spriteobj.GetComponent<SpriteRenderer>();
anim = spriteobj.GetComponent<Animator>();
}
frozenSprite = Resources.Load<Sprite>("Textures/PlayerFrozen");
staffSwing = Resources.Load<GameObject>("Prefabs/Swing");
spinAttackAir = Resources.Load<GameObject>("Prefabs/SpinAttackAir");
spinChargeParticle = Resources.Load<GameObject>("Prefabs/SpinChargeParticles");
spinChargeParticle2 = Resources.Load<GameObject>("Prefabs/SpinChargeParticles2");
healingOrb = Resources.Load<GameObject>("Prefabs/HealingOrb");
healEffect = Resources.Load<GameObject>("Prefabs/HealEffect");
dashHitbox = Resources.Load<GameObject>("Prefabs/DashHitbox");
dolphinHitbox = Resources.Load<GameObject>("Prefabs/DolphinHitbox");
splash1Ref = Resources.Load<GameObject>("Prefabs/Splash");
splash2Ref = Resources.Load<GameObject>("Prefabs/Splash2");
SceneManagerPrefab = Resources.Load<GameObject>("Prefabs/SceneManager");
if (GameObject.FindWithTag("SceneManager") == null) {
SceneManagerObj = Instantiate(SceneManagerPrefab);
} else {
SceneManagerObj = GameObject.FindWithTag("SceneManager");
}
cameraController = GameObject.FindWithTag("MainCamera").GetComponent<CameraControllerCW>();
sm = SceneManagerObj.GetComponent<SceneManagerCW>();
//Instantiate(Resources.Load<GameObject>("Prefabs/LineRenderer"), transform.position, Quaternion.identity);
if (pointLight == null)
{
GameObject lightobj = new GameObject(this.name + "Point Light");
lightobj.transform.parent = this.gameObject.transform;
lightobj.transform.localPosition = new Vector3(0, 0.485f, 0);
lightobj.tag = "Light";
pointLight = lightobj.AddComponent<Light2D>();
pointLight.lightType = (Light2D.LightType)Light2D.LightType.Point;
pointLight.pointLightInnerRadius = 0.2f;
pointLight.pointLightOuterRadius = 0.25f;
pointLight.color = Color.red;
pointLight.intensity = 1f;
pointLight.applyToSortingLayers = new int[1];
if (GameObject.Find("GameController") != null){
pointLight.applyToSortingLayers[0] = 0; //default
}
}
if (dashTrail == null)
{
GameObject dashTrailObj = Instantiate(Resources.Load("Prefabs/DashTrail")) as GameObject;
dashTrailObj.transform.parent = this.gameObject.transform;
dashTrailObj.transform.localPosition = new Vector3(0, 0, 0);
dashTrail = dashTrailObj.GetComponent<ParticleSystem>();
dashTrail.Stop();
}
if (bubbleTrail == null)
{
GameObject bubbleTrailObj = Instantiate(Resources.Load("Prefabs/BubbleTrail")) as GameObject;
bubbleTrailObj.transform.parent = this.gameObject.transform;
bubbleTrailObj.transform.localPosition = new Vector3(0, 0, 0);
bubbleTrail = bubbleTrailObj.GetComponent<ParticleSystem>();
bubbleTrail.Stop();
}
if (emanateLight == null)
{
GameObject emlightobj = new GameObject(this.name + "Emanate Light");
emlightobj.transform.parent = this.gameObject.transform;
emlightobj.transform.localPosition = new Vector3(0, 0.485f, 0);
emlightobj.tag = "Light";
emanateLight = emlightobj.AddComponent<Light2D>();
emanateLight.lightType = (Light2D.LightType)Light2D.LightType.Point;
emanateLight.pointLightInnerRadius = 0.5f;
emanateLight.pointLightOuterRadius = 1.5f;
emanateLight.color = Color.red;
emanateLight.intensity = 0.5f;
emanateLight.applyToSortingLayers = new int[2];
if (GameObject.Find("GameController") != null){
emanateLight.applyToSortingLayers[0] = GameInitializerCW.SortIDs["Decals"]; //decals
}
if (GameObject.Find("GameController") != null){
emanateLight.applyToSortingLayers[1] = GameInitializerCW.SortIDs["Wall"]; //wall
}
}
if (maskobj == null)
{
maskobj = Instantiate(Resources.Load<GameObject>("Prefabs/PlayerMask"), transform.position, Quaternion.identity);
maskobj.transform.parent = this.gameObject.transform;
maskobj.transform.localPosition = Vector3.zero;
}
/*if (dashCancelGraphic == null) {
dashCancelGraphic = Instantiate(Resources.Load<GameObject>("Prefabs/DashCancel"), transform.position, Quaternion.identity);
dashCancelGraphic.transform.parent = this.gameObject.transform;
dashCancelGraphic.transform.localPosition = Vector3.zero;
dashCancelGraphic.SetActive(false);
}*/
if (targetSelect == null)
{
targetSelect = Resources.Load<GameObject>("Prefabs/DashSelector");
}
if (slamShockwave == null)
{
slamShockwave = Resources.Load<GameObject>("Prefabs/SlamCharge");
}
if (hookObject == null)
{
hookObject = Instantiate(Resources.Load<GameObject>("Prefabs/HookObject"), transform.position, Quaternion.identity);
}
if (dm == null)
{
if (GameObject.FindWithTag("Canvas") != null) {
dm = GameObject.FindWithTag("Canvas").GetComponent<DialogueManagerCW>();
}
}
if (slashEffect == null)
{
slashEffect = Resources.Load<GameObject>("Prefabs/Slash");
}
if (gliderBack == null)
{
gliderBack = Instantiate(Resources.Load<GameObject>("Prefabs/GliderBack"), transform.position, Quaternion.identity);
gliderBack.transform.parent = this.gameObject.transform;
gliderBack.transform.localPosition = Vector3.zero;
gliderBack.GetComponent<SpriteRenderer>().enabled = false;
}
if (gliderDestroyParticle == null)
{
gliderDestroyParticle = Resources.Load<GameObject>("Prefabs/GliderDestroyParticle");
}
if (tempSpike == null) {
tempSpike = Resources.Load<GameObject>("Prefabs/TempSpike");
}
}
public void SetPosition()
{
int i;
for (i = 0; i < StaticDataCW.AllScenes.Length; i++) {
sceneNum = StaticDataCW.AllScenes[i].IndexOf(SceneManager.GetActiveScene().name);
if (sceneNum != -1) {
break;
}
}
Game.loadedGame.abilitiesUnlocked = 0;
if (StaticDataCW.SpawnAtCP == 1) {
if (i == 0) {
Game.loadedGame.abilitiesUnlocked = -2;
}
if (GameObject.FindWithTag("CheckpointFirst") != null) {
transform.position = GameObject.FindWithTag("CheckpointFirst").transform.position;
StaticDataCW.CurrentCheckpointPos = (new Vector2(GameObject.FindWithTag("CheckpointFirst").GetComponent<Transform>().position.x,GameObject.FindWithTag("CheckpointFirst").GetComponent<Transform>().position.y));
StaticDataCW.CurrentCheckpointScene = (SceneManager.GetActiveScene().name);
SaveDataCW.Load();
int cpNum = GameObject.FindWithTag("CheckpointFirst").GetComponent<CheckpointCW>().checkpointNum;
if (Game.loadedGame != null && cpNum > Game.loadedGame.furthestCP) {
Game.loadedGame.furthestCP = cpNum;