X-Git-Url: http://git.megabrutal.com/?p=wgj58.git;a=blobdiff_plain;f=wgj58.js;h=a50e494c279fa916ccdf27dfa76f50cd8857c2ef;hp=ad6bbf82b9f1a34333cfada27581fb0d3c6ad444;hb=411f2853d9a619185ca5d7cdac63e82f0c56415c;hpb=cf792c3120fd82f3d5c39b1638b2b6b4bb8ae241 diff --git a/wgj58.js b/wgj58.js index ad6bbf8..a50e494 100644 --- a/wgj58.js +++ b/wgj58.js @@ -172,11 +172,13 @@ class GameNPC extends Phaser.Sprite { this.interaction_distance = interaction_distance; this.interactable = false; this.talkcount = 0; + this.happy = false; } kill() { super.kill(); this.exists = false; + this.happy = false; // Dead people are not happy. } update() { @@ -191,6 +193,11 @@ class GameNPC extends Phaser.Sprite { logic.player.offerInteraction(null); this.interactable = false; } + if ((this.teleport_instructions) && (game.physics.arcade.distanceBetween(this, logic.player) > (game.width + 200))) { + this.position = this.teleport_instructions.newPosition; + this.teleport_instructions.callback(this.teleport_instructions.callbackValue); + this.teleport_instructions = null; + } } actionTalk() { @@ -209,6 +216,16 @@ class GameNPC extends Phaser.Sprite { endTalk() { return true; } + + makeHappy() { + this.happy = true; + console.log(this.shortname, "is happy!"); + } + + offscreenTeleportation(newPosition, callback, callbackValue) { + this.teleport_instructions = { newPosition: newPosition, callback: callback, callbackValue: callbackValue }; + console.log("Offscreen teleport request registered:", this.teleport_instructions); + } } class NPC_Clara extends GameNPC { @@ -437,7 +454,7 @@ class NPC_Saiki extends GameNPC { { actor: this, text: "Indeed. But this is the point. He's stuck in one place, cannot move. Like you in life. So you feel sympathy for him." }, { actor: logic.player, text: "You have a point." }, { actor: this, text: "I think I'll catch Carlos and talk to him. I always liked that guy but I didn't know he's such imaginative." } ] )); - //this.offscreenTeleportation(new Phaser.Point(logic.carlos.x + 128, logic.carlos.y), this.tpdone); + this.offscreenTeleportation(new Phaser.Point(logic.carlos.x, logic.carlos.y + 64), this.tpDone, this); } else { if (Phaser.Math.random() < 0.5) { @@ -495,6 +512,12 @@ class NPC_Saiki extends GameNPC { endTalk() { return (logic.carlos.alive); } + + tpDone(value) { + console.log("Woot-woot! Teleport complete:", value); + value.makeHappy(); + logic.carlos.makeHappy(); + } }