X-Git-Url: http://git.megabrutal.com/?p=wgj58.git;a=blobdiff_plain;f=wgj58.js;h=a50e494c279fa916ccdf27dfa76f50cd8857c2ef;hp=645ec529dc975380f69741b8c148b733ace1ac8b;hb=411f2853d9a619185ca5d7cdac63e82f0c56415c;hpb=06d4672b7c48de81f881e4452ce08c185bfb0f38 diff --git a/wgj58.js b/wgj58.js index 645ec52..a50e494 100644 --- a/wgj58.js +++ b/wgj58.js @@ -159,6 +159,7 @@ class Player extends Phaser.Sprite { takeMe(npc) { this.loadTexture(npc.key); npc.kill(); + this.disguise = npc; } } @@ -171,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() { @@ -190,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() { @@ -208,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 { @@ -429,16 +447,22 @@ class NPC_Saiki extends GameNPC { { actor: this, text: "Hmm..." }, { actor: this, text: "I guess it didn't work." }, { actor: this, text: "So do you want to know what I think about this?" }, + { actor: this, text: "..." }, { actor: this, text: "IT'S BRILLIANT!!!" }, { actor: this, text: "You know, it really sparkled my artistic vision! Now I must draw a pig with its legs rooted into the ground!" }, { actor: logic.player, text: "That's gross. Poor pig." }, { 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 { - logic.gameinterface.talk(new Dialogue( [ { actor: this, text: "I've found an orchestrated rendition of „Potential for Anything”. You'll have to check it out, it's breathtaking!" } ] )); + if (Phaser.Math.random() < 0.5) { + logic.gameinterface.talk(new Dialogue( [ { actor: this, text: "I've found an orchestrated rendition of „Potential for Anything”. You'll have to check it out, it's breathtaking!" } ] )); + } + else { + logic.gameinterface.talk(new Dialogue( [ { actor: this, text: "I don't like that our department is green. The blue one, where Carlos works, looks much better." } ] )); + } } } } @@ -467,7 +491,7 @@ class NPC_Saiki extends GameNPC { { actor: this, text: "..." } ] )); break; default: - logic.gameinterface.talk(new Dialogue( [ { actor: this, text: "Don't you have anything better to do?" } ] )); + logic.gameinterface.talk(new Dialogue( [ { actor: this, text: "Don't you have anything better to do, Carlos?" } ] )); } } super.actionTalk(); @@ -488,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(); + } } @@ -538,9 +568,14 @@ class GameInterface extends Phaser.Group { this.back_talk.lineTo(this.back_talk.width - 10, 35); this.add(this.back_talk); style = { align: 'left', fill: 'yellow', font: 'Ubuntu Mono', fontSize: 22, fontWeight: 'bold' }; - this.text_talktitle = new Phaser.Text(game, this.back_talk.x, this.back_talk.y, null, style); - this.text_talktitle.anchor.setTo(-0.2, -0.2); + this.text_talktitle = new Phaser.Text(game, this.back_talk.x + 15, this.back_talk.y + 6, null, style); + //this.text_talktitle.anchor.setTo(-0.2, -0.2); this.add(this.text_talktitle); + this.strikethrough_talktitle = new Phaser.Graphics(game, this.back_talk.x, this.back_talk.y); + this.strikethrough_talktitle.lineStyle(3, Phaser.Color.RED, 1); + this.strikethrough_talktitle.moveTo(12, 20); + this.strikethrough_talktitle.lineTo(67, 20); + this.add(this.strikethrough_talktitle); style = { align: 'left', fill: 'white', font: 'Ubuntu Mono', fontSize: 18, fontWeight: 'bold' }; this.text_talk = new Phaser.Text(game, this.back_talk.x + 35, this.back_talk.y + 40, null, style); this.text_talk.wordWrap = true; @@ -603,6 +638,7 @@ class GameInterface extends Phaser.Group { this.dialogue = null; this.back_talk.visible = false; this.text_talktitle.visible = false; + this.strikethrough_talktitle.visible = false; this.text_talk.visible = false; } @@ -611,7 +647,14 @@ class GameInterface extends Phaser.Group { console.log(this.dialogue.actual()); var actualdialogue = this.dialogue.actual(); if (actualdialogue) { - this.text_talktitle.text = actualdialogue.actor.shortname; + if (actualdialogue.actor.disguise) { + this.text_talktitle.text = actualdialogue.actor.shortname + " " + actualdialogue.actor.disguise.shortname; + this.strikethrough_talktitle.visible = true; + } + else { + this.text_talktitle.text = actualdialogue.actor.shortname; + this.strikethrough_talktitle.visible = false; + } this.text_talk.text = actualdialogue.text; this.dialogue.advance(); } @@ -687,7 +730,7 @@ class GameLogic { this.carlos = newChar; break; case 'saiki': - newChar = new NPC_Saiki(object.x, object.y, 'saiki', "Saiki", "Saiki Ytpme", 200); + newChar = new NPC_Saiki(object.x, object.y, 'saiki', "Saiki", "Saiki Ytpme", 150); this.saiki = newChar; break; default: