class Door extends Phaser.TileSprite {
constructor(x, y, name, rotation, vector, longpanel) {
super(game, x, y, 64, 64, 'objects');
+ this.name = name;
if (!longpanel) {
this.anchor = new Phaser.Point(0.5, 0.5);
this.tilePosition = new Phaser.Point(-64, -64);
this.closetween = game.add.tween(this).to({ x: this.position.x, y: this.position.y }, 1000, Phaser.Easing.Sinusoidal.InOut, false, 0, 0, false);
this.openposition = Phaser.Point.add(this.position, this.openvector);
this.opentween = game.add.tween(this).to({ x: this.openposition.x, y: this.openposition.y }, 1000, Phaser.Easing.Sinusoidal.InOut, false, 0, 0, false);
+ this.isOpen = false;
}
- update() {
- if ((this.opentween) && (game.time.now > 5000)) {
- console.log(game.time.now, "Opening door.");
+ open() {
+ if (!this.isOpen) {
this.opentween.start();
- this.opentween = null;
+ this.isOpen = true;
}
- else if ((this.closetween) && (game.time.now > 10000)) {
- console.log(game.time.now, "Closing door.");
+ }
+
+ close() {
+ if (this.isOpen) {
this.closetween.start();
- this.closetween = null;
+ this.isOpen = false;
}
}
}
{ actor: this, text: "Wish it worked like that... Is it some superstition like the belief that having an umbrella with you prevents rain?" },
{ actor: logic.player, text: "Nah, that actually works; it's not a superstition, but Murphy's Law!" },
{ actor: this, text: "If you say so..." } ] ));
+ logic.openDoor("cutedoor");
break;
case 1:
logic.gameinterface.talk(new Dialogue( [ { actor: this, text: "John, have you ever thought about losing your employee card?" },
{ actor: this, text: "If I had no card, would I still exist?" },
{ actor: logic.player, text: "..." },
{ actor: logic.player, text: "You sound very philosophical today." } ] ));
+ logic.closeDoor("cutedoor");
break;
case 2:
case 3:
}
}
+ openDoor(doorname) {
+ console.log("Opening doors.");
+ this.doors.children.forEach(function(o) { if (o.name == doorname) o.open(); });
+ }
+
+ closeDoor(doorname) {
+ this.doors.children.forEach(function(o) { if (o.name == doorname) o.close(); });
+ }
+
update() {
if ((game.input.keyboard.isDown(Phaser.Keyboard.ENTER)) && (hasTimePassed(this.last_menuselect, WAIT_MENUSTEP))) {
if ((this.player.interactablenpc) && (this.player.interactablenpc.interactable) && (!this.gameinterface.inMenu) && (!this.gameinterface.inTalk)) {