diff --git a/src/components/Customer.ts b/src/components/Customer.ts index a009247..1b619bd 100644 --- a/src/components/Customer.ts +++ b/src/components/Customer.ts @@ -63,7 +63,7 @@ export class Customer extends Button { private cellSize: number; private spriteCont: Phaser.GameObjects.Container; private sprite: Phaser.GameObjects.Sprite; - private customColor: number; + private hitarea: Phaser.GameObjects.Rectangle; // private graphics: Phaser.GameObjects.Graphics; private thoughtBubble: ThoughtBubble; private angryImage: Phaser.GameObjects.Sprite; @@ -118,32 +118,6 @@ export class Customer extends Button { this.sprite.setScale(this.spriteSize / this.sprite.width); this.spriteCont.add(this.sprite); - const colors = [ - Color.Red600, - Color.Orange600, - Color.Amber600, - Color.Yellow600, - Color.Lime600, - Color.Green600, - Color.Emerald600, - Color.Teal600, - Color.Cyan600, - Color.Sky600, - Color.Blue600, - Color.Indigo600, - Color.Violet600, - Color.Purple600, - Color.Fuchsia600, - Color.Pink600, - Color.Rose600, - ]; - // White wash - this.customColor = interpolateColor( - Phaser.Math.RND.pick(colors), - 0xffffff, - 0.8 - ); - // this.graphics = this.scene.add.graphics(); const s = this.spriteSize; @@ -174,8 +148,12 @@ export class Customer extends Button { this.itemList = []; this.sprList = []; - this.bindInteractive(this.sprite, true); - this.sprite.input!.enabled = false; + this.hitarea = this.scene.add + .rectangle(0, 0, cellSize, 1.5 * cellSize, 0, 0) + .setOrigin(0.5, 0.625); + this.add(this.hitarea); + this.bindInteractive(this.hitarea, true); + this.hitarea.input!.enabled = false; } update(time: number, delta: number) { @@ -385,7 +363,7 @@ export class Customer extends Button { this.sprite.setTexture(this.spriteKeys.sit); this.sprite.flipX = false; this.hasEnteredShop = true; - this.sprite.input!.enabled = true; + this.hitarea.input!.enabled = true; this.scene.sound.play("letgo1", { volume: 0.2 }); this.emit("seated"); }, @@ -401,7 +379,8 @@ export class Customer extends Button { duration: 200, ease: "Sine.easeInOut", onUpdate: (tween, target, key, current) => { - this.spriteCont.y = this.spriteOffset - 0.25 * this.cellSize * current; + this.spriteCont.y = + this.spriteOffset - 0.25 * this.cellSize * current; }, onYoyo: () => { this.setMask(station.foregroundMask); @@ -434,7 +413,7 @@ export class Customer extends Button { setEmployee(employee: Employee | null) { this.currentEmployee = employee; - this.sprite.input!.enabled = !employee; + this.hitarea.input!.enabled = !employee; if (employee) { this.untoggleTimer(); @@ -505,7 +484,7 @@ export class Customer extends Button { } leave() { - this.sprite.input!.enabled = false; + this.hitarea.input!.enabled = false; this.testTimer.setVisible(false); this.setRequest(null); this.patienceTimer.setVisible(false); @@ -681,10 +660,10 @@ export class Customer extends Button { } pauseClickable() { - if (!this.sprite.input!.enabled) { + if (!this.hitarea.input!.enabled) { this.garchomp = true; } else { - this.sprite.input!.enabled = false; + this.hitarea.input!.enabled = false; } } @@ -692,7 +671,7 @@ export class Customer extends Button { if (this.garchomp) { this.garchomp = false; } else { - this.sprite.input!.enabled = true; + this.hitarea.input!.enabled = true; } } diff --git a/src/components/UpgradeOverlay.ts b/src/components/UpgradeOverlay.ts index 817e17c..1028823 100644 --- a/src/components/UpgradeOverlay.ts +++ b/src/components/UpgradeOverlay.ts @@ -10,8 +10,8 @@ import { numberWithCommas } from "@/utils/functions"; export class UpgradeOverlay extends Phaser.GameObjects.Container { public scene: GameScene; - private selectedStation: Station | null = null; - private selectedEmployee: Employee | null = null; + public selectedStation: Station | null = null; + public selectedEmployee: Employee | null = null; private background: Phaser.GameObjects.Rectangle; private panel: RoundRectangle; @@ -200,6 +200,8 @@ export class UpgradeOverlay extends Phaser.GameObjects.Container { duration: 200, onComplete: () => { this.setVisible(false); + this.selectedStation = null; + this.selectedEmployee = null; this.emit("close"); }, }); diff --git a/src/scenes/GameScene.ts b/src/scenes/GameScene.ts index 1ac197a..b624f38 100644 --- a/src/scenes/GameScene.ts +++ b/src/scenes/GameScene.ts @@ -366,11 +366,6 @@ export class GameScene extends BaseScene { } this.upgradeOverlay.update(time, delta); - // Depth sorting hack - if (this.state === GameState.Day) { - this.sortDepth(); - } - // Highlight button for tutorial if (this.shopTutorialIndex == 0) { this.invButton.setScale(0.5 + 0.08 * Math.sin(time / 100)); @@ -378,6 +373,7 @@ export class GameScene extends BaseScene { this.invButton.setScale(0.5); } + this.sortDepth(); this.updateMusicState(); } @@ -515,10 +511,6 @@ export class GameScene extends BaseScene { angryCustomers: 0, }; - // Reset depth - this.stations.forEach((s) => s.setDepth(0)); - this.employees.forEach((e) => e.setDepth(0)); - // Reset customer spawning if (this.customerSpawnTimer) this.customerSpawnTimer.destroy(); this.updateSpawnPool(); @@ -666,9 +658,6 @@ export class GameScene extends BaseScene { station.on("click", () => { if (this.state === GameState.Shopping && !this.upgradeOverlay.visible) { this.upgradeOverlay.selectStation(station); - - this.sortDepth(); - station.setDepth(2000); } }); } @@ -709,9 +698,6 @@ export class GameScene extends BaseScene { employee.on("click", () => { if (this.state === GameState.Shopping && !this.upgradeOverlay.visible) { this.upgradeOverlay.selectEmployee(employee); - - this.sortDepth(); - employee.setDepth(2000); } }); } @@ -1372,6 +1358,15 @@ export class GameScene extends BaseScene { this.stations.forEach((s) => s.setDepth(s.y / 50 + 0)); this.employees.forEach((e) => e.setDepth(e.y / 50 + 1)); this.customers.forEach((c) => c.setDepth(c.y / 50 + (c.dragged ? 100 : 1))); + + const focusStation = this.stations.find( + (s) => this.upgradeOverlay.selectedStation == s + ); + const focusEmployee = this.employees.find( + (e) => this.upgradeOverlay.selectedEmployee == e + ); + if (focusStation) focusStation.setDepth(2000); + if (focusEmployee) focusEmployee.setDepth(2000); } refreshStationIDArray() {