Fixed key checking on portal
This commit is contained in:
parent
643ca24bad
commit
082dca9bd4
@ -78,36 +78,15 @@ class Portal extends TileSprite {
|
||||
}
|
||||
|
||||
if (this.key != "") {
|
||||
if (this.player.items.keys.length > 0) {
|
||||
for (let index = 0; index < this.player.items.keys.length; index++) {
|
||||
const element = this.player.items.keys[index];
|
||||
console.log(this.key);
|
||||
console.log(element);
|
||||
if (element == this.key) {
|
||||
if (this.player.items.keys.includes(this.key)) {
|
||||
// Correct key
|
||||
this.pointer.anims.play("white");
|
||||
if (this.keys.action) {
|
||||
this.action();
|
||||
console.warn("action");
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
// Not the correct key
|
||||
console.log("correct keyn't");
|
||||
this.pointer.anims.play("red");
|
||||
if (this.keys.action) {
|
||||
if (!sounds.forbidden.playing && !this.pressed) {
|
||||
sounds.forbidden.play();
|
||||
this.pressed = true;
|
||||
}
|
||||
} else {
|
||||
this.pressed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// No keys at all
|
||||
console.log("You have no keys");
|
||||
// No key or not the correct key
|
||||
this.pointer.anims.play("red");
|
||||
if (this.keys.action) {
|
||||
if (!sounds.forbidden.playing && !this.pressed) {
|
||||
|
@ -12,6 +12,7 @@ class GameScreen extends Container {
|
||||
constructor(game, window, keys, onGameOver) {
|
||||
super();
|
||||
|
||||
this.game = game;
|
||||
this.window = window;
|
||||
this.keys = keys;
|
||||
this.onGameOver = onGameOver;
|
||||
|
Loading…
Reference in New Issue
Block a user