Commit 1f9e5ca8 authored by Terence Martin's avatar Terence Martin

Swap to final ball drop state when bricks gone

Now the maze will invoke a method on the listener to tell it that all
of the gray bricks have vanished out of the maze and have been reaped.

The Game state uses this to transition into the final ball drop state,
so that it can start the final ball drop of the round.
parent 364531a8
......@@ -4273,11 +4273,12 @@ var nurdz;
// been vanished out of the level because all of the balls have been
// played.
//
// If this collects all gray bricks, we can set the flag that
// indicates that we're done removing them now.
// If this collects all gray bricks, we can tell our listener that
// we're done removing them now.
if (this.reapHiddenEntitiesFromPool(this._grayBricks) > 0 &&
this._grayBricks.liveEntities.length == 0) {
console.log("DEBUG: All gray bricks have fully vanished");
if (this._listener != null)
this._listener.grayBrickRemovalComplete();
}
// If there is a dropping ball and it's time to drop it, take a step
// now.
......@@ -4938,6 +4939,16 @@ var nurdz;
break;
}
};
/**
* The Maze is telling us that it is now empty of gray bricks because it
* has just reaped the last fully hidden gray brick.
*
* This triggers the start of the final ball drop.
*/
GameScene.prototype.grayBrickRemovalComplete = function () {
// Swap states to the final ball drop
this.state = game.GameState.FINAL_BALL_DROP;
};
/**
* This gets triggered every time our state machine gets put into a new
* state.
......
......@@ -45,6 +45,16 @@ module nurdz.game
* our generation is finally completed.
*/
mazeGenerationComplete () : void;
/**
* This will get invoked by the Maze update loop when it actively reaps
* gray bricks that are finished vanishing (or just plain hidden) and it
* detects that there are no further such bricks left.
*
* Once this triggers, it cannot trigger again unless something puts
* more bricks into the maze.
*/
grayBrickRemovalComplete () : void;
}
/**
......@@ -839,13 +849,14 @@ module nurdz.game
// been vanished out of the level because all of the balls have been
// played.
//
// If this collects all gray bricks, we can set the flag that
// indicates that we're done removing them now.
// If this collects all gray bricks, we can tell our listener that
// we're done removing them now.
if (this.reapHiddenEntitiesFromPool (this._grayBricks) > 0 &&
this._grayBricks.liveEntities.length == 0)
{
console.log("DEBUG: All gray bricks have fully vanished");
}
{
if (this._listener != null)
this._listener.grayBrickRemovalComplete ();
}
// If there is a dropping ball and it's time to drop it, take a step
// now.
......
......@@ -528,6 +528,18 @@ module nurdz.game
}
}
/**
* The Maze is telling us that it is now empty of gray bricks because it
* has just reaped the last fully hidden gray brick.
*
* This triggers the start of the final ball drop.
*/
grayBrickRemovalComplete () : void
{
// Swap states to the final ball drop
this.state = GameState.FINAL_BALL_DROP;
}
/**
* This gets triggered every time our state machine gets put into a new
* state.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment