app/scripts/core/gameCoordinator.js
/**
   * Resets the gameboard and prepares the next level
   */
Resets the gameboard and prepares the next level
Resets the gameboard and prepares the next level
advanceLevel() {
    this.gameBackend.updateSession({id: this.gameSession.id, points: this.points})
    this.allowPause = false;
    this.cutscene = true;
    this.soundManager.setCutscene(this.cutscene);
    this.allowKeyPresses = false;
    this.soundManager.stopAmbience();
    this.entityList.forEach((entity) => {
      const entityRef = entity;
      entityRef.moving = false;
    });
    this.removeTimer({ detail: { timer: this.fruitTimer } });
    this.removeTimer({ detail: { timer: this.ghostCycleTimer } });
    this.removeTimer({ detail: { timer: this.endIdleTimer } });
    this.removeTimer({ detail: { timer: this.ghostFlashTimer } });
    new Timer(() => {
      this.ghosts.forEach((ghost) => {
        const ghostRef = ghost;
        ghostRef.display = false;
      });
      this.mazeImg.src = mazeWhite;
      new Timer(() => {
        this.mazeImg.src = maze;
        new Timer(() => {
          this.mazeImg.src = mazeWhite;
          new Timer(() => {
            this.mazeImg.src = maze;
            new Timer(() => {
              this.mazeImg.src = mazeWhite;
              new Timer(() => {
                this.mazeImg.src = maze;
                new Timer(() => {
                  this.mazeCover.style.visibility = 'visible';
                  new Timer(() => {
                    this.mazeCover.style.visibility = 'hidden';
                    this.level += 1;
                    this.allowKeyPresses = true;
                    this.entityList.forEach((entity) => {
                      const entityRef = entity;
                      if (entityRef.level) {
                        entityRef.level = this.level;
                      }
                      entityRef.reset();
                      if (entityRef instanceof Ghost) {
                        entityRef.resetDefaultSpeed();
                      }
                      if (
                        entityRef instanceof Pickup
                        && entityRef.type !== 'fruit'
                      ) {
                        this.remainingDots += 1;
                      }
                    });
                    this.startGameplay();
                  }, 500);
                }, 250);
              }, 250);
            }, 250);
          }, 250);
        }, 250);
      }, 250);
    }, 2000);
  }
advanceLevel ( ) { this . gameBackend . updateSession ( { id : this . gameSession . id , points : this . points } ) this . allowPause = false ; this . cutscene = true ; this . soundManager . setCutscene ( this . cutscene ) ; this . allowKeyPresses = false ; this . soundManager . stopAmbience ( ) ; this . entityList . forEach ( ( entity ) => { const entityRef = entity ; entityRef . moving = false ; } ) ; this . removeTimer ( { detail : { timer : this . fruitTimer } } ) ; this . removeTimer ( { detail : { timer : this . ghostCycleTimer } } ) ; this . removeTimer ( { detail : { timer : this . endIdleTimer } } ) ; this . removeTimer ( { detail : { timer : this . ghostFlashTimer } } ) ; new Timer ( ( ) => { this . ghosts . forEach ( ( ghost ) => { const ghostRef = ghost ; ghostRef . display = false ; } ) ; this . mazeImg . src = mazeWhite ; new Timer ( ( ) => { this . mazeImg . src = maze ; new Timer ( ( ) => { this . mazeImg . src = mazeWhite ; new Timer ( ( ) => { this . mazeImg . src = maze ; new Timer ( ( ) => { this . mazeImg . src = mazeWhite ; new Timer ( ( ) => { this . mazeImg . src = maze ; new Timer ( ( ) => { this . mazeCover . style . visibility = 'visible' ; new Timer ( ( ) => { this . mazeCover . style . visibility = 'hidden' ; this . level += 1 ; this . allowKeyPresses = true ; this . entityList . forEach ( ( entity ) => { const entityRef = entity ; if ( entityRef . level ) { entityRef . level = this . level ; } entityRef . reset ( ) ; if ( entityRef instanceof Ghost ) { entityRef . resetDefaultSpeed ( ) ; } if ( entityRef instanceof Pickup && entityRef . type !== 'fruit' ) { this . remainingDots += 1 ; } } ) ; this . startGameplay ( ) ; } , 500 ) ; } , 250 ) ; } , 250 ) ; } , 250 ) ; } , 250 ) ; } , 250 ) ; } , 250 ) ; } , 2000 ) ; }
Resets the gameboard and prepares the next level
Resets the gameboard and prepares the next level