From 82a3162ef5ad0dc75f71b75702d8be34d2a0f90a Mon Sep 17 00:00:00 2001 From: Golen Date: Sat, 17 Aug 2024 01:05:22 +0200 Subject: [PATCH] Add customer request --- src/assets/assets.ts | 1 + src/assets/images/ui/bubble.png | Bin 0 -> 1215 bytes src/components/Customer.ts | 38 ++++++++++++++++++++++++++---- src/components/Station.ts | 40 ++++++++++++++++++++++---------- src/scenes/GameScene.ts | 31 ++++++++++++++++++------- 5 files changed, 84 insertions(+), 26 deletions(-) create mode 100644 src/assets/images/ui/bubble.png diff --git a/src/assets/assets.ts b/src/assets/assets.ts index 00a659e..7e43470 100644 --- a/src/assets/assets.ts +++ b/src/assets/assets.ts @@ -16,6 +16,7 @@ const images: Image[] = [ // UI image('ui/hud', 'hud'), + image('ui/bubble', 'bubble'), // Titlescreen image('titlescreen/sky', 'title_sky'), diff --git a/src/assets/images/ui/bubble.png b/src/assets/images/ui/bubble.png new file mode 100644 index 0000000000000000000000000000000000000000..24781fd8155c8c0881b99c258d6f55851a2b2821 GIT binary patch literal 1215 zcmV;w1VHEX>4Tx04R}tkv&MmKpe$iTct%S3U&}t$WWauh>AFB6^c+H)C#RSm|Xe=O&XFE z7e~Rh;NZt%)xpJCR|i)?5c~jfc5qU3krMxx6k5c1aNLh~_a1le0DryARI_6oP&La) zCE`LRyD9`<5kepO(T!n=nfjb4CgC~0?&0I>U5saWpZjz4C^?e>K7n|a>4rtTK|H-_ z>74h8BdjPX#OK6g23?T&k?XR{Z=4Gb`*~)>NT=qBBg8_Xjpa6GMMEW?B91DmM*04X z%L?Z$&T6^Jn)l={4Cl0!Wv+@x?E=zOv5j}aia3p8rB{e5iPjT0d73|wg~f29u0e3D*k zY0)E~cN@64ZfWu!aJd5vJn51lIZ}Y8Kc5HQ&*+=7K>sb!wdVHL+{ftykfyGZH^9Lm zFj}DOb&q$4+I#!=OtZfqL&S2F)eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{00NguL_t(|+U?!ZO2jY_hS5&({a?9W$U>17YTIo7H0Qe( z#d4fUbk$n)wr$(C)*qv)%9H-%*?0tfPyz~OG)g!h4zm|1aKU^$K1c_H3FLf83q)AK z1QE_rU_uFJ3``hdje`j#pm8vvgfk8%l(0s@1QO0Tm{7ubwiQZEbH;?y^o)ZEC8SX> zfdn)PCXjH(!Guz+aIPM$9&;-O6bchgS>+O#0#gE0(_DUBfMjAyU~2ePZk@}-l>Rd@ zO--4Y5||o(m0RbEg$bylVZteAOlkS~M*-{6H}tp^IWgf>+!@n(Q=eSpr(nXVmLM-( zeynx5m20|bd3u#w>1qY?)tASk6pXj6a%W971ANyzvetFyAiH(q!Ku5pXp>b8D3p;f z0R{1DZsm%+=r;dgrY4k;Fd+rdD%Vi>VkV}k31uuyNCAw83Fw^YhJgtul(8^{Bfjd zX<}O8U`k*LOj+Y#N?@9nU_vP{p#)PEd?f&U`k+`mS74>FrgHf zP=X1iz!aD=Ex{C+GA+TBz%(rf&YvL!GV{65_(>oAgIZ968HEx^XG{r9fhmD0m!HR9 dfLwes`Ud { this.emit("taskend"); - this.sprite.fillColor = this.currentCustomer ? 0x7777ff : 0xff0000; - this.text.setText("Click me!"); + this.sprite.alpha = this.currentCustomer ? 0.75 : 0.5; + this.text.setText("Click me!"); }); } } diff --git a/src/scenes/GameScene.ts b/src/scenes/GameScene.ts index 82010cf..3cd6049 100644 --- a/src/scenes/GameScene.ts +++ b/src/scenes/GameScene.ts @@ -2,7 +2,7 @@ import { BaseScene } from "@/scenes/BaseScene"; import { Board } from "@/components/Board"; import { Employee } from "@/components/Employee"; import { Customer } from "@/components/Customer"; -import { Station } from "@/components/Station"; +import { Station, StationType } from "@/components/Station"; import { UI } from "@/components/UI"; import { custom } from "@neutralinojs/lib"; @@ -30,10 +30,10 @@ export class GameScene extends BaseScene { this.board = new Board(this, 900, 500); this.stations = []; - this.addStation(2, 3); - this.addStation(4, 3); - this.addStation(6, 3); - this.addStation(6, 1); + this.addStation(2, 3, StationType.HornAndNails); + this.addStation(4, 3, StationType.HornAndNails); + this.addStation(6, 3, StationType.ScalePolish); + this.addStation(6, 1, StationType.GoldBath); this.employees = []; this.addEmployee(5, 5); @@ -55,9 +55,9 @@ export class GameScene extends BaseScene { } // Add new station - addStation(gridX: number, gridY: number) { + addStation(gridX: number, gridY: number, type: StationType) { const coord = this.board.gridToCoord(gridX, gridY); - const station = new Station(this, coord.x, coord.y); + const station = new Station(this, coord.x, coord.y, type); this.stations.push(station); // Station task completed @@ -69,6 +69,8 @@ export class GameScene extends BaseScene { customer.setEmployee(null); employee.setAction(false); employee.setCustomer(null); + + this.setCustomerRequest(customer); } }); } @@ -101,6 +103,9 @@ export class GameScene extends BaseScene { const customer = new Customer(this, coord.x, coord.y); this.customers.push(customer); + // Set random customer request + this.setCustomerRequest(customer); + // Picking up a customer customer.on("pickup", () => { if (customer.currentStation) { @@ -140,7 +145,6 @@ export class GameScene extends BaseScene { // Clicking a customer customer.on("click", () => { - console.log("CLICK"); this.callEmployee(customer); }); } @@ -161,7 +165,8 @@ export class GameScene extends BaseScene { if ( !station.currentCustomer && distance < closestDistance && - distance < maxDistance + distance < maxDistance && + station.stationType === customer.requestedStation ) { closestStation = station; closestDistance = distance; @@ -199,9 +204,17 @@ export class GameScene extends BaseScene { const { x, y } = this.board.gridToCoord(gridX, gridY - 1); customer.setEmployee(closestEmployee); + customer.setRequest(null); + closestEmployee.setCustomer(customer); closestEmployee.walkTo(x, y); // Wait for employee.on("walkend") } } + + // Set a random request for the customer + setCustomerRequest(customer: Customer) { + const type = Phaser.Math.RND.between(0, 2); + customer.setRequest(type); + } }