Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
LuxxArt committed Aug 19, 2024
2 parents 072d333 + 9cf462b commit b618dfe
Show file tree
Hide file tree
Showing 7 changed files with 173 additions and 98 deletions.
14 changes: 9 additions & 5 deletions src/components/Employee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ export class Employee extends Button {
}

update(time: number, delta: number) {
const factor = this.doingCuteThing
? 0.1
: this.hasBeenPurchased
? 0.02
: 0;
const factor = this.doingCuteThing ? 0.1 : this.hasBeenPurchased ? 0.02 : 0;
const squish = 1.0 + factor * Math.sin((6 * time) / 1000);
this.spriteCont.setScale(1.0, squish - 0.2 * this.holdSmooth);
}
Expand Down Expand Up @@ -114,6 +110,14 @@ export class Employee extends Button {
}
}

// Only used when loading levels
forceUpgrade(id: EmployeeId) {
this.hasBeenPurchased = true;
this.setAlpha(1.0);
this.employeeId = id;
this.sprite.setTexture(this.spriteKey);
}

/* Getters */

get employeeType(): EmployeeType {
Expand Down
2 changes: 1 addition & 1 deletion src/components/EmployeeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const EmployeeData: { [key in EmployeeId]: EmployeeInterface } = {
spriteKey: "worker",
walkSpeed: 1,
workSpeed: 1,
cost: 1000,
cost: 300,
upgradeTo: EmployeeId.RaccoonTier2,
},
[EmployeeId.RaccoonTier2]: {
Expand Down
13 changes: 3 additions & 10 deletions src/components/Levels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface Level {
height: number;
cellSize: number;
grid: number[][];
customerArrivalTimes: number[];
upgradeCost?: number;
}

export enum BlockType {
Expand Down Expand Up @@ -43,7 +43,7 @@ export const LevelData: Level[] = [
[X, _, 5, 5, _, 6, _, _],
[X, X, X, X, X, X, X, X],
],
customerArrivalTimes: [0, 10, 20, 30, 40, 50, 60, 70, 80, 90],
upgradeCost: 1000,
},
{
id: LevelId.Level2,
Expand All @@ -60,10 +60,7 @@ export const LevelData: Level[] = [
[X, 9, 9, 9, _, _, 6, _, _],
[X, X, X, X, X, X, X, X, X],
],
customerArrivalTimes: [
0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90,
95, 100,
],
upgradeCost: 2000,
},
{
id: LevelId.Level3,
Expand All @@ -81,9 +78,5 @@ export const LevelData: Level[] = [
[X, 9, 9, 9, 9, _, _, 6, _, _],
[X, X, X, X, X, X, X, X, X, X],
],
customerArrivalTimes: [
0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90,
95, 100,
],
},
];
10 changes: 10 additions & 0 deletions src/components/Station.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,16 @@ export class Station extends Button {
}
}

// Only used when loading levels
forceUpgrade(id: StationId) {
this.hasBeenPurchased = true;
this.setAlpha(1.0);
this.stationId = id;
this.sprite.setTexture(this.spriteKey);
this.spriteCont.y = this.spriteOffset;
this.sprite.setScale(this.spriteSize / this.sprite.width);
}

applyItem(id: number, sp: string) {
this.appliedItems.push(id);
let st = new Phaser.GameObjects.Sprite(
Expand Down
26 changes: 13 additions & 13 deletions src/components/StationData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export interface StationInterface {
export const StationData: { [key in StationId]: StationInterface } = {
[StationId.WaitingSeatTier1]: {
type: StationType.WaitingSeat,
name: "WaitingSeat station",
name: "Waiting seat",
tier: 1,
spriteKey: "waitchair_1",
spriteScale: 1.0,
Expand All @@ -78,7 +78,7 @@ export const StationData: { [key in StationId]: StationInterface } = {
},
[StationId.WaitingSeatTier2]: {
type: StationType.WaitingSeat,
name: "WaitingSeat station",
name: "Waiting armchair",
tier: 2,
spriteKey: "waitchair_2",
spriteScale: 1.25,
Expand All @@ -87,7 +87,7 @@ export const StationData: { [key in StationId]: StationInterface } = {
},
[StationId.WaitingSeatTier3]: {
type: StationType.WaitingSeat,
name: "WaitingSeat station",
name: "Waiting throne",
tier: 3,
spriteKey: "waitchair_3",
spriteScale: 1.5,
Expand All @@ -96,7 +96,7 @@ export const StationData: { [key in StationId]: StationInterface } = {

[StationId.HornAndNailsTier1]: {
type: StationType.HornAndNails,
name: "HornAndNails station",
name: "Talonicure pillow",
tier: 1,
spriteKey: "nail_1",
spriteScale: 1.0,
Expand All @@ -107,7 +107,7 @@ export const StationData: { [key in StationId]: StationInterface } = {
},
[StationId.HornAndNailsTier2]: {
type: StationType.HornAndNails,
name: "HornAndNails station",
name: "Talonicure beanbag",
tier: 2,
spriteKey: "nail_2",
spriteScale: 1.25,
Expand All @@ -118,7 +118,7 @@ export const StationData: { [key in StationId]: StationInterface } = {
},
[StationId.HornAndNailsTier3]: {
type: StationType.HornAndNails,
name: "HornAndNails station",
name: "Talonicure bed",
tier: 3,
spriteKey: "nail_3",
spriteScale: 1.5,
Expand All @@ -129,7 +129,7 @@ export const StationData: { [key in StationId]: StationInterface } = {

[StationId.ScalePolishTier1]: {
type: StationType.ScalePolish,
name: "ScalePolish station",
name: "Scalicure chair",
tier: 1,
spriteKey: "wax_1",
spriteScale: 1.0,
Expand All @@ -140,7 +140,7 @@ export const StationData: { [key in StationId]: StationInterface } = {
},
[StationId.ScalePolishTier2]: {
type: StationType.ScalePolish,
name: "ScalePolish station",
name: "Scalicure station",
tier: 2,
spriteKey: "wax_2",
spriteScale: 1.25,
Expand All @@ -151,7 +151,7 @@ export const StationData: { [key in StationId]: StationInterface } = {
},
[StationId.ScalePolishTier3]: {
type: StationType.ScalePolish,
name: "ScalePolish station",
name: "Scalicure divan",
tier: 3,
spriteKey: "wax_3",
spriteScale: 1.5,
Expand All @@ -162,7 +162,7 @@ export const StationData: { [key in StationId]: StationInterface } = {

[StationId.GoldBathTier1]: {
type: StationType.GoldBath,
name: "GoldBath station",
name: "Draconic bath",
tier: 1,
spriteKey: "bath_1",
spriteScale: 1.0,
Expand All @@ -173,7 +173,7 @@ export const StationData: { [key in StationId]: StationInterface } = {
},
[StationId.GoldBathTier2]: {
type: StationType.GoldBath,
name: "GoldBath station",
name: "Draconic shower",
tier: 2,
spriteKey: "bath_2",
spriteScale: 1.25,
Expand All @@ -184,7 +184,7 @@ export const StationData: { [key in StationId]: StationInterface } = {
},
[StationId.GoldBathTier3]: {
type: StationType.GoldBath,
name: "GoldBath station",
name: "Dracuzzi",
tier: 3,
spriteKey: "bath_3",
spriteScale: 1.5,
Expand All @@ -195,7 +195,7 @@ export const StationData: { [key in StationId]: StationInterface } = {

[StationId.CashRegister]: {
type: StationType.CashRegister,
name: "CashRegister station",
name: "Cash register",
tier: 1,
spriteKey: "checkout",
spriteScale: 1.4,
Expand Down
24 changes: 20 additions & 4 deletions src/components/UI.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { GameScene } from "@/scenes/GameScene";
import { Timer } from "./Timer";
import { TextButton } from "./TextButton";
import { Level } from "./Levels";

export class UI extends Phaser.GameObjects.Container {
public scene: GameScene;
Expand Down Expand Up @@ -72,21 +73,23 @@ export class UI extends Phaser.GameObjects.Container {
this.moneyText.setOrigin(0.5);
this.panel.add(this.moneyText);

this.nextButton = new TextButton(scene, 0, 300, 240, 80, "Next day");
this.nextButton = new TextButton(scene, 0, 600, 300, 80, "Start day");
this.panel.add(this.nextButton);
this.nextButton.on("click", () => {
this.emit("nextDay");
});

this.newLocationButton = new TextButton(scene, 0, 440, 240, 80, "Move");
this.newLocationButton = new TextButton(scene, 0, 400, 300, 200, "...");
this.panel.add(this.newLocationButton);
this.newLocationButton.on("click", () => {
this.emit("nextLevel");
});
this.newLocationButton.setVisible(false);
}

update(time: number, delta: number) {}
update(time: number, delta: number) {
this.nextButton.update(time, delta);
this.newLocationButton.update(time, delta);
}

setDay(day: number) {
this.dayText.setText(`Day ${day}`);
Expand All @@ -96,8 +99,21 @@ export class UI extends Phaser.GameObjects.Container {
this.dayProgressTimer.redraw(time);
}

setLevel(level: Level) {
this.newLocationButton.setData("cost", level.upgradeCost);
this.newLocationButton.setVisible(level.upgradeCost !== undefined);
this.newLocationButton.setText(
`Upgrade\n shop\n $${level.upgradeCost}`
);
}

setMoney(money: number) {
this.moneyText.setText(`Money: $${money}`);

const upgradeCost = this.newLocationButton.getData("cost");
const canUpgrade = money >= upgradeCost;
this.newLocationButton.setAlpha(canUpgrade ? 1 : 0.5);
this.newLocationButton.enabled = canUpgrade;
}

setShoppingMode(isShopping: boolean) {
Expand Down
Loading

0 comments on commit b618dfe

Please sign in to comment.