From 4e9b032d0185099302c0bbf35962012b5b9c3f01 Mon Sep 17 00:00:00 2001 From: Golen Date: Tue, 20 Aug 2024 16:06:29 +0200 Subject: [PATCH] Adjust customer pathing --- src/assets/images/ui/bubble.png | Bin 1587 -> 5713 bytes src/components/Customer.ts | 10 +++-- src/components/PatienceTimer.ts | 1 + src/scenes/GameScene.ts | 76 ++++++++++++++++++++++---------- 4 files changed, 60 insertions(+), 27 deletions(-) diff --git a/src/assets/images/ui/bubble.png b/src/assets/images/ui/bubble.png index 88bebb9b1a1b8b345d985ac8834744ea2fd83643..470fdb80f7ce151741db804d8ea99ff52412b3fb 100644 GIT binary patch literal 5713 zcmeHLX;f3!7QU!BfT$p}b*QFssDdF0H*<-A!3r{kQJ@aoB=PlgKmP@K?* z?NzK;8~}$(i$DkJ^l-db2Na9?q*NS=)Tt;^%YFL>2VCu1Z@Jd%KhIhrIp^&C?eF{c zId>&2SBB1Tav14=Ac#|7fPVzMmou+{ec`V|>G*x{c4$#ltR(_VV;M~bLYsoKEa^s^ zg@h$%F9kiSc9KFc74~*heeD&wY4d4W%K1l`^4k|fE**c+ zvVFt4gqS@u6+cbh-CnT1onI`He6~O~$Zp&5kzw2t`rs4Syar`!{@QB;Do*?F-+Fi6 zG?&2N{cAG^Z)EO?|yU5*t@^VfBlc$w66|Zb|sEJ<8(Rr{oxU!YWI#>c0Xt5 ze$LUKMsHf*>bm$?qrA`J+Wd!8Xmi%;ybaaw3|pI*7*}7pT%5O4+&=PVhN_^@bya7P zmD=X$;$xcA(YeZe7XLVL1u;<`HpL~V&NJrQPYZ)LTUSVS-0t7%7`H}v`lF(bnVa|D zJu&Z{)1y32&E6?pIsUDRej{9>8p1!c7qwK5+!h;fKJ)M~pX*(?sqDIYPJ!Ak`j&FG zPv_XDzg~0?4z&jU)bGsiEt0Y0e6M+)nJ+p0xZ>x^(ClW^h+Cdsn8|> zv2E(zA*qia-6a=h`8eM*W!ruJ;1HZSs}{~yY)G(7ZP0mQ8iNY=wCap-=n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vzf=NGr-TCmrII^fq{Y7)59eQNG||k4rU;^M{v44kYX$ja(7}_cTVOd0|Qe> zfKQ0)W*&hKrh4u!p<6)d8zn)0!T;$G>gi!6!}jQ+y+Ci5db&7H2|ses$l zx%my^)od=*th^v1aCkZgzfHW33Cod>u7{W}eixg?nDjHwN!!8XzOo6^kl?)AtaGl!wE)$LlEjKw@|4sDaoZoT|0qEc0tTliZv-a@Uw_W zz5aDTc-CthCt;~Kb%%w5c>6q@7Td0|a9Zap=_>KFhtZ!U;mu*@dbNFTM6$Vq=i4gG z;^&$1dxM>%QcZxvsdg5XS_g+)?Zp!f>?9PPJ2P&w<4Jf>D`37xRi0_Xi_7fODu40& zn$9;e2&vt5z{+3rhC%JD17`DX-SWx!`jX*xrPcwtdvysf9)D$8|7o$i(5^~b?KO($ zHsqCbpL{f<(a+v*gQvQ6+_7q_(ruPYk3U*{UESDz-OU48h0o4Bmpmfcxb|rHBd!DQ zUVTpGH2CBz>nOq1vDjKuL8PA{>0^A#C)__DXLzbP0l+XkKjhqSp diff --git a/src/components/Customer.ts b/src/components/Customer.ts index c3145d4..bf0e186 100644 --- a/src/components/Customer.ts +++ b/src/components/Customer.ts @@ -235,10 +235,10 @@ export class Customer extends Button { ); this.emit("pay", this.moneySpent); } else { - this.scene.sound.play("rip", { volume: 0.4 }); + this.scene.sound.play("rip", { volume: 0.3 }); } } else { - this.scene.sound.play("rip", { volume: 0.4 }); + this.scene.sound.play("rip", { volume: 0.3 }); } this.leave(); this.thoughtBubble.showSymbol("sad"); @@ -269,7 +269,7 @@ export class Customer extends Button { } } if (this.playFail) { - this.scene.sound.play("rip", { volume: 0.4 }); + this.scene.sound.play("rip", { volume: 0.3 }); this.playFail = false; } } @@ -422,7 +422,7 @@ export class Customer extends Button { this.untoggleTimer(); this.lockTimer(); } - this.thoughtBubble.showSymbol(Phaser.Math.RND.pick(["happy", "love"])); + this.thoughtBubble.showSymbol("love"); } setAction(temp: boolean) { @@ -513,6 +513,8 @@ export class Customer extends Button { this.emit("offscreen"); }, }); + + // this.scene.moveCustomerToEntrance(this); } recheckHappiness() { if (this.hasCompleted) { diff --git a/src/components/PatienceTimer.ts b/src/components/PatienceTimer.ts index 61fd1b7..a29e557 100644 --- a/src/components/PatienceTimer.ts +++ b/src/components/PatienceTimer.ts @@ -35,6 +35,7 @@ export class PatienceTimer extends Phaser.GameObjects.Container { this.sparks = new Phaser.GameObjects.Sprite(this.scene,0,64,"defaultspark"); this.sparks.setTint(0x00FF00); this.sparks.setScale(0.5); + this.anger.setVisible(false); this.add(this.bar); this.add(this.sparks); diff --git a/src/scenes/GameScene.ts b/src/scenes/GameScene.ts index a051c3f..30bc038 100644 --- a/src/scenes/GameScene.ts +++ b/src/scenes/GameScene.ts @@ -679,29 +679,7 @@ export class GameScene extends BaseScene { customer.setStation(seat); // customer.snapTo(seat.x, seat.y); - // Pathfinding to seat - const startY = LevelData[this.level].height - 3; - const startCoord = this.board.gridToCoord(0, startY); - const start = this.board.coordToNav(startCoord.x, startCoord.y); - const goal = this.board.coordToNav(seat.x, seat.y); - - // Starting location outside of screen - customer.snapTo(startCoord.x - 2 * this.board.size, startCoord.y, true); - - const navPath = this.navmesh.findPath(start, goal); - if (navPath) { - const points = navPath.map((pos) => - this.board.navGridToCoord(pos.x, pos.y) - ); - const path = new Phaser.Curves.Path(); - path.moveTo(customer.x, customer.y); - points.forEach((point) => path.lineTo(point.x, point.y)); - - customer.walk(path); - } else { - // Snap to station if pathfinding fails - console.warn("No path found", start, "->", goal); - } + this.moveCustomerToSeat(customer, seat); } else { console.error("Whoops"); } @@ -908,6 +886,58 @@ export class GameScene extends BaseScene { } } + moveCustomerToSeat(customer: Customer, seat: Station) { + // Pathfinding to seat + const startY = LevelData[this.level].height - 3; + const startCoord = this.board.gridToCoord(0, startY); + const start = this.board.coordToNav(startCoord.x, startCoord.y); + const goal = this.board.coordToNav(seat.x, seat.y); + + // Starting location outside of screen + customer.snapTo(startCoord.x - 2 * this.board.size, startCoord.y, true); + + const navPath = this.navmesh.findPath(start, goal); + if (navPath) { + const points = navPath.map((pos) => + this.board.navGridToCoord(pos.x, pos.y) + ); + const path = new Phaser.Curves.Path(); + path.moveTo(customer.x, customer.y); + points.forEach((point) => path.lineTo(point.x, point.y)); + + customer.walk(path); + } else { + const path = new Phaser.Curves.Path(); + path.moveTo(customer.x, customer.y); + path.lineTo(seat.x, seat.y); + } + } + + moveCustomerToEntrance(customer: Customer) { + // Pathfinding to left entrance + const doorY = LevelData[this.level].height - 3; + const doorCoord = this.board.gridToCoord(0, doorY); + const goal = this.board.coordToNav(doorCoord.x, doorCoord.y); + const start = this.board.coordToNav(customer.x, customer.y); + + const navPath = this.navmesh.findPath(start, goal); + if (navPath) { + const points = navPath.map((pos) => + this.board.navGridToCoord(pos.x, pos.y) + ); + const path = new Phaser.Curves.Path(); + path.moveTo(customer.x, customer.y); + points.forEach((point) => path.lineTo(point.x, point.y)); + path.lineTo(-this.board.size, doorCoord.y); + + customer.walk(path); + } else { + const path = new Phaser.Curves.Path(); + path.moveTo(customer.x, customer.y); + path.lineTo(doorCoord.x, doorCoord.y); + } + } + // Generate a list of requests for the customer setCustomerItinerary(customer: Customer) { // Check availibility of stations