X-Git-Url: http://git.megabrutal.com/?p=wgj58.git;a=blobdiff_plain;f=wgj58.js;h=5b5929a73cb46963c3b51d5a10075663392fcb9f;hp=8fe220f63a39ac710d93b8402fe35192e682dfe9;hb=775ea6b84786cc901dcc918f6d0a8837087fb53a;hpb=d9b347a8804fedc728550ae5372306a670b5b6a8 diff --git a/wgj58.js b/wgj58.js index 8fe220f..5b5929a 100644 --- a/wgj58.js +++ b/wgj58.js @@ -43,6 +43,7 @@ class Door extends Phaser.TileSprite { constructor(x, y, name, rotation, vector, longpanel) { super(game, x, y, 64, 64, 'objects'); this.name = name; + this.longpanel = longpanel; if (!longpanel) { this.anchor = new Phaser.Point(0.5, 0.5); this.tilePosition = new Phaser.Point(-64, -64); @@ -54,12 +55,30 @@ class Door extends Phaser.TileSprite { this.tilePosition = new Phaser.Point(0, -64); this.openvector = Phaser.Point.multiply(vector, new Phaser.Point(116, 116)); } + if (rotation === undefined) rotation = 0; this.rotation = rotation * (Math.PI / 180); - console.log("Calculated vector:", this.openvector); 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; + game.physics.arcade.enable(this); + this.body.immovable = true; + this.setBody(rotation); + } + + setBody(rotation) { + switch(rotation) { + case 0: + case 180: + this.body.setSize(this.width, 10, this.longpanel * (rotation / 180) * 64, 27); + break; + case 90: + case 270: + this.body.setSize(10, this.width, 27 + (this.longpanel * 64), this.longpanel * ((rotation - 270) / 180) * 64); + break; + default: + console.log("Unable to set body due to unknown rotation:", rotation); + } } open() { @@ -75,6 +94,10 @@ class Door extends Phaser.TileSprite { this.isOpen = false; } } + + update() { + game.debug.body(this); + } } class Player extends Phaser.Sprite { @@ -212,7 +235,6 @@ class NPC_Clara extends GameNPC { { 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: @@ -250,11 +272,117 @@ class NPC_Clara extends GameNPC { logic.gameinterface.dropNotice(this.shortname + ": Have a great day, John!"); } + actionTake() { + logic.openDoor("cutedoor"); + return super.actionTake(); + } + endTalk() { return (this.talkcount < 6); } } +class NPC_Carlos extends GameNPC { + actionTalk() { + if (logic.clara.alive) { + switch (this.talkcount) { + case 0: + logic.gameinterface.talk(new Dialogue( [ { actor: logic.player, text: "Good morning, Carlos! What's up?" }, + { actor: this, text: "Hey, John! Not too much, I'm just trying to sell some shit to this new client." }, + { actor: logic.player, text: "And so? Is it hard to convince them?" }, + { actor: this, text: "Of course, they don't want to buy. It's shit." }, + { actor: this, text: "I mean, who would want to buy shit?" }, + { actor: logic.player, text: "Yeah. Relatable... But why are you trying to sell shit? I mean, why not one of our cutting edge technologies?" }, + { actor: this, text: "They couldn't afford it." }, + { actor: logic.player, text: "Then why are you trying to sell them... anything at all? They'd better off with a cheaper company." }, + { actor: this, text: "Company policies. Plus the management instructed me to sell to them, no matter what." }, + { actor: logic.player, text: "That sucks... Well... good luck!" }, + { actor: this, text: "Thanks..." } ] )); + logic.closeDoor("cutedoor"); + logic.openDoor("carlosdoor"); + break; + case 1: + logic.gameinterface.talk(new Dialogue( [ { actor: this, text: "*Sigh.* I'll probably not work here for long, if I can't sell this shit to the customer." }, + { actor: this, text: "These layoffs are terrifying. They let go of anyone for even the slightest mistake." }, + { actor: logic.player, text: "But it's not a mistake when our client doesn't buy something they don't need." }, + { actor: this, text: "Tell this to my boss..." } ] )); + break; + case 2: + logic.gameinterface.talk(new Dialogue( [ { actor: this, text: "You know, generally, I think it sucks being a child. One thing I miss though, if you're a child, you're allowed to be silly." }, + { actor: this, text: "..." }, + { actor: this, text: "For example, when my Dad told me that semen is the seed of animals, I theoretized, if I'd bury some pig semen in the garden, a pig would grow out of it..." }, + { actor: this, text: "I was totally fascinated by the thought, because I really wanted to have a pet pig, but Dad wouldn't let me to have one." }, + { actor: this, text: "So I thought I could grow my own pig in the garden from pig seeds!" }, + { actor: logic.player, text: "Interesting. Where are you going with this?" }, + { actor: this, text: "I don't know... sometimes I feel like I'd rather sell pig semen to our clients, heh!" }, + { actor: this, text: "Uhm..." }, + { actor: this, text: "Totally don't tell this to Saiki!" } ] )); + this.pigsemen = true; + break; + case 3: + logic.gameinterface.talk(new Dialogue( [ { actor: this, text: "Weren't you heading to the IT department to the right?" }, + { actor: this, text: "You know... the green department which looks way better than blue!" }, + { actor: this, text: "..." }, + { actor: this, text: "Damn, why do I have to work in blue? I just feel... so blue about it." } ] )); + break; + case 4: + logic.gameinterface.talk(new Dialogue( [ { actor: this, text: "Weren't you heading to the conveniently green department to the right? I guess Saiki is waiting for you." }, + { actor: this, text: "You're so lucky that you can work with her every day!" } ] )); + break; + default: + logic.gameinterface.talk(new Dialogue( [ { actor: this, text: "Guess you'll stay here then. It's cool, you're great company anyway." } ] )); + } + } + else { + switch (this.talkcount) { + case 0: + logic.gameinterface.talk(new Dialogue( [ { actor: logic.player, text: "Good morning, Carlos!" }, + { actor: this, text: "Whoa, Clara! You have changed so much! I barely recognize you. What's up?" }, + { actor: logic.player, text: "I need to talk to Saiki at the IT department, but... my card doesn't allow me to enter there." }, + { actor: this, text: "Well... I can certainly help you with that..." }, + { actor: this, text: "..." } ] )); + break; + case 1: + logic.gameinterface.talk(new Dialogue( [ { actor: logic.player, text: "Carlos. You promised to help me." }, + { actor: this, text: "Uhm... It's just... Please give me 5 mins to finish this e-mail." }, + { actor: logic.player, text: "I don't have much time, Carlos." }, + { actor: this, text: "See, it's just 5 mins, please be patient. I have a chocolate bar in the fridge. I give it to you. Feel free to have it meanwhile." }, + { actor: logic.player, text: "..." } ] )); + break; + case 2: + logic.gameinterface.talk(new Dialogue( [ { actor: logic.player, text: "Time is up, Carlos!" }, + { actor: this, text: "Please give me just another min." }, + { actor: logic.player, text: "Fine. Please just give me your card and I'll help myself!" }, + { actor: this, text: "But... you know that company policies forbid that, Clara! Please just be a little more patient!" }, + { actor: logic.player, text: "You will give me your card now or you will regret!" }, + { actor: this, text: "...?" }, + { actor: this, text: "You're not gonna treat me like this. Forget it!" }, + { actor: logic.player, text: "You'll not work here tomorrow." } ] )); + break; + default: + logic.gameinterface.talk(new Dialogue( [ { actor: this, text: "..." } ] )); + } + } + super.actionTalk(); + } + + actionLeave() { + if (logic.clara.alive) { + logic.gameinterface.dropNotice(this.shortname + ": Bye, John! Pass on my greetings to Saiki!"); + } + } + + actionTake() { + logic.closeDoor("cutedoor"); + logic.openDoor("carlosdoor"); + return super.actionTake(); + } + + endTalk() { + return (logic.clara.alive) || (this.talkcount < 3); + } +} + class GameInterface extends Phaser.Group { constructor(game, parent) { @@ -447,6 +575,10 @@ class GameLogic { newChar = new NPC_Clara(object.x, object.y, 'clara', "Clara", "Clara Tnavelerri", 200); this.clara = newChar; break; + case 'carlos': + newChar = new NPC_Carlos(object.x, object.y, 'carlos', "Carlos", "Carlos Elbacalper", 150); + this.carlos = newChar; + break; default: console.error("Unknown character:", object); } @@ -501,7 +633,6 @@ class GameLogic { } openDoor(doorname) { - console.log("Opening doors."); this.doors.children.forEach(function(o) { if (o.name == doorname) o.open(); }); } @@ -536,6 +667,7 @@ class GamePlay extends Phaser.State { game.load.image('player', 'john.png'); game.load.image('clara', 'clara.png'); + game.load.image('carlos', 'carlos.png'); game.load.image('saiki', 'saiki.png'); game.load.image('tileset', 'tileset.png'); game.load.image('objects', 'objects.png'); @@ -548,6 +680,7 @@ class GamePlay extends Phaser.State { game.world.setBounds(0, 0, 800, 600); game.stage.backgroundColor = '#000000'; game.physics.startSystem(Phaser.Physics.ARCADE); + console.log("Debug enabled:", !game.debug.isDisabled); var map = game.add.tilemap('gamemap'); map.addTilesetImage('tileset', 'tileset'); @@ -574,6 +707,7 @@ class GamePlay extends Phaser.State { game.physics.arcade.collide(logic.player, this.layer_walls); game.physics.arcade.collide(logic.player, this.layer_furniture); + game.physics.arcade.collide(logic.player, logic.doors); logic.update(); }