11package archipelago ;
22
33import objects .charting .ChartingStrumNote as StrumNote ;
4+ import objects .Note ;
5+ import openfl .events .KeyboardEvent ;
6+ import flixel .input .keyboard .FlxKey ;
7+ import archipelago .substates .UnownSubState ;
48
59class TrapLinkFunctions {
610 static var bfPosition : Array <Float >;
@@ -53,37 +57,41 @@ class TrapLinkFunctions {
5357 }
5458
5559 static var daCoolTween : FlxTween ;
56- static var grpNotes : FlxTween ;
57- static var randArray : FlxTween ;
60+ static var grpNotes : Array <StrumNote >;
61+ static var randArray : Array <Int >;
62+ public static var keysArray : Array <Array <Dynamic >>; // Specifically for this one thing
5863 public static function doBushwakThings (? length : Int = 4 ) {
64+ if (keysArray == null )
65+ keysArray = backend. Keybinds .fill ();
66+
5967 randArray = [for (i in 0 ... length ) FlxG .random .int (0 , 3 )];
6068
61- for (i in grpNotes ) { i .kill (); APPlatState .instance .remove (i ); i .destroy (); }
69+ for (i in grpNotes ) { i .kill (); APPlayState .instance .remove (i ); i .destroy (); }
6270
6371 grpNotes = [];
6472
6573 var colArray = [' purple' , ' blue' , ' green' , ' red' ];
6674
6775 for (i in 0 ... randArray .length ) {
68- cool = new StrumNote (0 , 0 , randArray [i ], 0 );
69- if (! APPlatState . instance .isPixelStage ) cool .animation .addByPrefix (' color' , colArray [cool .noteData ] + ' 0' , 24 , true );
76+ var cool : StrumNote = new StrumNote (0 , 0 , randArray [i ], 0 );
77+ if (! PlayState .isPixelStage ) cool .animation .addByPrefix (' color' , colArray [cool .noteData ] + ' 0' , 24 , true );
7078 cool .playAnim (' static' );
7179 cool. ID = i ;
7280 cool .scrollFactor .set (1 , 1 );
73- cool .x = APPlatState .instance .boyfriend .x + (APPlatState .instance .boyfriend .width / 2 ) - ((Note .swagWidth * randArray .length ) / 2 );
81+ cool .x = APPlayState .instance .boyfriend .x + (APPlayState .instance .boyfriend .width / 2 ) - ((Note .swagWidth * randArray .length ) / 2 );
7482 cool .x + = Note .swagWidth * i ;
75- cool .y = APPlatState .instance .boyfriend .y - Note .swagWidth - 5 ;
76- APPlatState .instance .add (cool );
83+ cool .y = APPlayState .instance .boyfriend .y - Note .swagWidth - 5 ;
84+ APPlayState .instance .add (cool );
7785 grpNotes [i ] = cool ;
7886 }
7987
8088 var tag = ' ajgnaidngkjsfohijaoihjpdafgnadjoiashmfmhiobad' ;
8189
8290 daCoolTween = FlxTween .num (6.1 , 0 , 2 , { ease : FlxEase .expoOut }, function (num ) {
8391 for (j in grpNotes ) {
84- j .x = APPlatState .instance .boyfriend .x + (APPlatState .instance .boyfriend .width / 2 ) - ((Note .swagWidth * randArray .length ) / 2 );
92+ j .x = APPlayState .instance .boyfriend .x + (APPlayState .instance .boyfriend .width / 2 ) - ((Note .swagWidth * randArray .length ) / 2 );
8593 j .x + = Note .swagWidth * j. ID ;
86- j .y = APPlatState .instance .boyfriend .y - Note .swagWidth - 5 ;
94+ j .y = APPlayState .instance .boyfriend .y - Note .swagWidth - 5 ;
8795 j .x + = FlxG .random .float (- num , num );
8896 j .y + = FlxG .random .float (- num , num );
8997 j .angle = FlxG .random .float (- num / 2 , num / 2 );
@@ -93,80 +101,96 @@ class TrapLinkFunctions {
93101 for (j in 0 ... grpNotes .length ) {
94102 var strum = grpNotes [j ];
95103 strum .playAnim (' confirm' , true );
96- strum .animation .finishCallback = function () {
97- if (APPlatState . instance .isPixelStage ) strum .playAnim (colArray [strum .noteData ]);
104+ strum .animation .finishCallback = function (animName : String ) {
105+ if (PlayState .isPixelStage ) strum .playAnim (colArray [strum .noteData ]);
98106 else strum .playAnim (' color' , true );
99107 }
100108 }
101109
102110 position = - 1 ;
103- didcoolthing = false
111+ didcoolthing = false ;
104112 FlxG .stage .addEventListener (KeyboardEvent .KEY_DOWN , onKeyPress );
105113 }
106114
107- var position = - 1 ;
108- var didcoolthing : Bool = false ;
109- function onKeyPress (k ) {
110- if (APPlatState .instance .health > 0.05 ) {
115+ public static function getKeyFromEvent (key : FlxKey ): Int
116+ {
117+ if (key != NONE )
118+ for (i in 0 ... keysArray [3 ].length )
119+ for (j in 0 ... keysArray [3 ][i ].length )
120+ if (key == keysArray [3 ][i ][j ])
121+ return i ;
122+ return - 1 ;
123+ }
124+
125+ static var position = - 1 ;
126+ static var didcoolthing : Bool = false ;
127+ function onKeyPress (k : KeyboardEvent ) {
128+ var eventKey : FlxKey = k .keyCode ;
129+ var key : Int = getKeyFromEvent (eventKey );
130+ if (APPlayState .instance .health > 0.05 ) {
111131 if (randArray != null && randArray .length > 0 ) {
112- if (k == randArray [1 ]) {
113- position = position + 1
132+ if (key == randArray [0 ]) {
133+ position = position + 1 ;
114134 var strum = grpNotes [position ];
115135 strum .playAnim (' pressed' , true );
116136 strum .resetAnim = 0.15 ;
117- table .remove (randArray , 1 )
137+ randArray .remove (randArray [ 0 ]);
118138 if (randArray .length < 1 && ! didcoolthing ) {
119139 if (daCoolTween != null ) daCoolTween .cancel ();
120140 for (j in grpNotes ) {
121141 j .acceleration .y = FlxG .random .float (300 , 600 );
122142 j .velocity .y = FlxG .random .float (- 200 , - 300 );
123143 j .velocity .x = FlxG .random .float (- 10 , 10 );
124144 j .angularVelocity = FlxG .random .float (- 15 , 15 );
125- FlxTween .tween (j , { alpha : 0 }, 0.2 / game .playbackRate , {
145+ FlxTween .tween (j , { alpha : 0 }, 0.2 / APPlayState . instance .playbackRate , {
126146 onComplete : function (tween : FlxTween )
127147 {
128148 j .kill ();
129- game .remove (j );
149+ APPlayState . instance .remove (j );
130150 },
131- startDelay : Conductor .crochet * 0.002 / game .playbackRate
151+ startDelay : Conductor .crochet * 0.002 / APPlayState . instance .playbackRate
132152 });
133153 }
134- APPlatState .instance .playerStrums .forEach (function (str ) { str .alpha = 1 ; });
135- APPlatState .instance .isCameraOnForcedPos = false ;
136- APPlatState .instance .moveCameraSection ();
154+ APPlayState .instance .playerStrums .forEach (function (str ) { str .alpha = 1 ; });
155+ APPlayState .instance .isCameraOnForcedPos = false ;
156+ APPlayState .instance .moveCameraSection ();
137157 FlxG .sound .play (Paths .sound (' bf_vine_defeat' ));
138- APPlatState .instance .boyfriend .stunned = true ;
139- if (APPlatState .instance .health > 0.1 )
140- APPlatState .instance .boyfriend .playAnim (' dodge' , true );
158+ APPlayState .instance .boyfriend .stunned = true ;
159+ if (APPlayState .instance .health > 0.1 )
160+ APPlayState .instance .boyfriend .playAnim (' dodge' , true );
141161
142- didcoolthing = true
143- FlxG . stage . removeEventListener ( KeyboardEvent . KEY_DOWN , onKeyPress );
162+ didcoolthing = true ;
163+ removeListener ( );
144164 }
145165 }
146166 else {
147- FlxG . stage . removeEventListener ( KeyboardEvent . KEY_DOWN , onKeyPress );
167+ removeListener ( );
148168 doBushwakThings ();
149169 }
150170 }
151171 }
152172 }
153173
174+ function removeListener () {
175+ FlxG .stage .removeEventListener (KeyboardEvent .KEY_DOWN , onKeyPress );
176+ }
177+
154178 public static function startUnown (? timer : Int = 15 , ? word : String = ' pain' ): Void {
155- APPlatState .instance .canPause = false ;
156- APPlatState .instance .persistentUpdate = true ;
157- APPlatState .instance .persistentDraw = true ;
158- APPlatState .instance .boyfriend .stunned = true ;
179+ APPlayState .instance .canPause = false ;
180+ APPlayState .instance .persistentUpdate = true ;
181+ APPlayState .instance .persistentDraw = true ;
182+ APPlayState .instance .boyfriend .stunned = true ;
159183 var realTimer = timer ;
160184 var unownState = new UnownSubState (realTimer , word );
161185 unownState .win = wonUnown ;
162- unownState .lose = APPlayState .instance .die ;
163- unownState .cameras = [APPlatState .instance .camHUD ];
186+ unownState .lose = APPlayState .instance .killhimtodeath ;
187+ unownState .cameras = [APPlayState .instance .camHUD ];
164188 FlxG .autoPause = false ;
165- openSubState (unownState );
189+ FlxG . state . openSubState (unownState );
166190 }
167191
168- function wonUnown (): Void {
169- APPlatState .instance .canPause = true ;
170- APPlatState .instance .boyfriend .stunned = false ;
192+ static function wonUnown (): Void {
193+ APPlayState .instance .canPause = true ;
194+ APPlayState .instance .boyfriend .stunned = false ;
171195 }
172196}
0 commit comments