File tree Expand file tree Collapse file tree 5 files changed +31
-4
lines changed
Expand file tree Collapse file tree 5 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -198,7 +198,7 @@ export class Player extends Sprite {
198198 GameComponent . player . preventInput = false ;
199199 destinationDoor . play ( ) ;
200200
201- GameComponent . player . setPosition ( destinationDoor . getDestination ( ) . getPosition ( ) ) ;
201+ GameComponent . player . setPosition ( destinationDoor . getPosition ( ) ) ;
202202 }
203203 }
204204
Original file line number Diff line number Diff line change @@ -322,11 +322,28 @@ export class Level extends Sprite {
322322 this . getDoors ( ) . forEach ( door => {
323323 if ( this . getFinalDoor ( ) === door ) return ;
324324
325- if ( door . checkCollision ( GameComponent . player ) && isKeyPressed ( 'w' ) && GameComponent . player . collectedKeys >= 1 && GameComponent . player . isOnGround && ! GameComponent . player . isReceivingDamage ) {
325+ if ( door . checkCollision ( GameComponent . player ) && isKeyPressed ( 'w' ) && GameComponent . player . isOnGround && ! GameComponent . player . isReceivingDamage ) {
326326
327327 if ( GameComponent . player . isAttacking ) return ;
328328
329- if ( ! door . isLocked ( ) ) return ;
329+ if ( ! door . isLocked ( ) ) {
330+ GameComponent . player . getVelocity ( ) . setY ( 0 ) ;
331+ GameComponent . player . getVelocity ( ) . setX ( 0 ) ;
332+ GameComponent . player . preventInput = true ;
333+
334+ this . doors . forEach ( destination => {
335+ if ( destination . getDestination ( ) === door ) {
336+ GameComponent . player . switchSprite ( 'enterIntermediateDoor' , destination ) ;
337+ } else {
338+ GameComponent . player . switchSprite ( 'enterIntermediateDoor' , door . getDestination ( ) ) ;
339+ }
340+ } )
341+
342+
343+ return ;
344+ }
345+
346+ if ( GameComponent . player . collectedKeys < 1 ) return ;
330347
331348 door . setLocked ( false ) ;
332349
Original file line number Diff line number Diff line change @@ -45,6 +45,10 @@ export class GameComponent implements AfterViewInit {
4545 GameComponent . player = new Player ( ) ;
4646 initializeSounds ( ) ;
4747 this . registerGuiListener ( ) ;
48+
49+ if ( localStorage . getItem ( 'name' ) ) {
50+ this . leaderboard . name = localStorage . getItem ( 'name' ) ! ;
51+ }
4852 }
4953
5054 public static getPlayer ( ) : Player {
Original file line number Diff line number Diff line change @@ -19,9 +19,11 @@ export class IntroComponent {
1919 public readonly router : Router ) {
2020
2121
22+
2223 }
2324
2425 public redirect ( ) : void {
26+ localStorage . setItem ( 'name' , this . leaderboardService . name ) ;
2527 this . router . navigate ( [ '/game' ] ) . then ( r => console . log ( r ) ) ;
2628 }
2729
Original file line number Diff line number Diff line change @@ -8,7 +8,11 @@ export class LeaderboardService {
88
99 public name : string = 'Anonymous' ;
1010 public time : number = 0 ;
11- constructor ( ) { }
11+ constructor ( ) {
12+ if ( localStorage . getItem ( 'name' ) ) {
13+ this . name = localStorage . getItem ( 'name' ) ?? 'Anonymous' ;
14+ }
15+ }
1216
1317
1418}
You can’t perform that action at this time.
0 commit comments