Skip to content

Commit

Permalink
Merge pull request #99 from casonpollak/main
Browse files Browse the repository at this point in the history
Work
  • Loading branch information
Parallaxes authored Jan 28, 2025
2 parents c1146e6 + 09e5c9e commit d05dd6c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions assets/js/platformer/PlayerWater.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,20 @@ export class PlayerWater extends PlayerBase {
super.handlePlayerReaction();

if (GameEnv.ifWater) {
for (let obj of GameEnv.gameObjects) {
if (obj.jsonifiedElement.id === "coin") {
console.log("All coins not collected; cannot advance to next level.");
return;
}
// Check if all coins are collected before allowing level exit
const allCoinsCollected = GameEnv.gameObjects.every(obj => obj.jsonifiedElement.id !== "coin");
if (!allCoinsCollected) {
console.log("All coins must be collected to proceed.");
return; // Stop here if not all coins are collected
} else {
console.log("All coins collected! You can now exit the level.");
}
}

switch (this.state.collision) {
case "finishline":
if (GameEnv.keyCollected) {
GameControl.transitionToNextLevel();
GameControl.transitionToNextLevel(); // Proceed to the next level if key is collected
}
break;

Expand Down Expand Up @@ -168,4 +170,4 @@ GameControl.showGameCompleteScreen = function () {
document.body.appendChild(messageElement);
};

export default PlayerWater;
export default PlayerWater;

0 comments on commit d05dd6c

Please # to comment.