Skip to content

Commit

Permalink
Add tier 0 for stations and employees. Make them purchasable.
Browse files Browse the repository at this point in the history
  • Loading branch information
Golen87 committed Aug 18, 2024
1 parent 0c5d5eb commit 5882a05
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 57 deletions.
27 changes: 23 additions & 4 deletions src/components/Employee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { EmployeeData, EmployeeId, EmployeeType } from "./EmployeeData";

export class Employee extends Button {
public employeeId: EmployeeId;
public hasBeenPurchased: boolean;
public currentCustomer: Customer | null;
public doingCuteThing: boolean;

Expand Down Expand Up @@ -33,6 +34,9 @@ export class Employee extends Button {
this.startX = x;
this.startY = y;

// Initially not purchased
this.hasBeenPurchased = false;

/* Sprite */
this.spriteCont = this.scene.add.container(0, this.spriteOffset);
this.add(this.spriteCont);
Expand All @@ -48,13 +52,17 @@ export class Employee extends Button {
}

update(time: number, delta: number) {
const factor = this.doingCuteThing ? 0.1 : 0.02;
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);
}

setCustomer(customer: Customer | null) {
if(customer){
if (customer) {
this.scene.sound.play("sqk");
}

Expand Down Expand Up @@ -95,7 +103,12 @@ export class Employee extends Button {
}

upgrade() {
if (this.upgradeTo) {
// this.scene.sound.play("upgrade");

if (!this.hasBeenPurchased) {
this.hasBeenPurchased = true;
this.setAlpha(1.0);
} else if (this.upgradeTo) {
this.employeeId = this.upgradeTo!;
this.sprite.setTexture(this.spriteKey);
}
Expand Down Expand Up @@ -140,7 +153,13 @@ export class Employee extends Button {
}

get upgradeCost(): number {
return EmployeeData[this.employeeId].upgradeCost ?? 0;
if (!this.hasBeenPurchased) {
return EmployeeData[this.employeeId].cost;
}
if (this.upgradeTo) {
return EmployeeData[this.upgradeTo].cost;
}
return 0;
}

get upgradeTo(): EmployeeId | undefined {
Expand Down
12 changes: 7 additions & 5 deletions src/components/EmployeeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface EmployeeInterface {
spriteKey: string; // Employee image key
walkSpeed: number; // Speed of the employee walking
workSpeed: number; // Speed of the employee working
upgradeCost?: number; // Cost to upgrade the employee
cost: number; // Cost to purchase that tier of employee
upgradeTo?: EmployeeId; // Employee to upgrade to
}

Expand All @@ -35,7 +35,7 @@ export const EmployeeData: { [key in EmployeeId]: EmployeeInterface } = {
spriteKey: "worker",
walkSpeed: 1,
workSpeed: 1,
upgradeCost: 100,
cost: 1000,
upgradeTo: EmployeeId.RaccoonTier2,
},
[EmployeeId.RaccoonTier2]: {
Expand All @@ -45,7 +45,7 @@ export const EmployeeData: { [key in EmployeeId]: EmployeeInterface } = {
spriteKey: "worker",
walkSpeed: 2,
workSpeed: 2,
upgradeCost: 500,
cost: 400,
upgradeTo: EmployeeId.RaccoonTier3,
},
[EmployeeId.RaccoonTier3]: {
Expand All @@ -55,6 +55,7 @@ export const EmployeeData: { [key in EmployeeId]: EmployeeInterface } = {
spriteKey: "worker",
walkSpeed: 3,
workSpeed: 3,
cost: 800,
},

[EmployeeId.HumanTier1]: {
Expand All @@ -64,7 +65,7 @@ export const EmployeeData: { [key in EmployeeId]: EmployeeInterface } = {
spriteKey: "player",
walkSpeed: 1,
workSpeed: 1,
upgradeCost: 100,
cost: 1000,
upgradeTo: EmployeeId.HumanTier2,
},
[EmployeeId.HumanTier2]: {
Expand All @@ -74,7 +75,7 @@ export const EmployeeData: { [key in EmployeeId]: EmployeeInterface } = {
spriteKey: "player",
walkSpeed: 2,
workSpeed: 2,
upgradeCost: 500,
cost: 400,
upgradeTo: EmployeeId.HumanTier3,
},
[EmployeeId.HumanTier3]: {
Expand All @@ -84,5 +85,6 @@ export const EmployeeData: { [key in EmployeeId]: EmployeeInterface } = {
spriteKey: "player",
walkSpeed: 3,
workSpeed: 3,
cost: 800,
},
};
10 changes: 5 additions & 5 deletions src/components/Levels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ export const LevelData: Level[] = [
cellSize: 190,
grid: [
[X, X, X, X, X, X, X, X],
[X, 2, _, 9, 9, _, 4, X],
[X, 2, _, 3, 3, _, 4, X],
[X, 2, _, _, _, _, 4, X],
[_, _, _, 5, 5, _, _, X],
[X, 9, 9, _, _, 6, _, _],
[_, _, _, _, _, _, _, X],
[X, _, 5, 5, _, 6, _, _],
[X, X, X, X, X, X, X, X],
],
customerArrivalTimes: [0, 10, 20, 30, 40, 50, 60, 70, 80, 90],
Expand All @@ -67,10 +67,10 @@ export const LevelData: Level[] = [
},
{
id: LevelId.Level3,
background: "grid3",
background: "grid2",
width: 8 + 2,
height: 6 + 2,
cellSize: 109,
cellSize: 138,
grid: [
[X, X, X, X, X, X, X, X, X, X],
[X, 2, _, _, _, _, _, _, _, X],
Expand Down
35 changes: 26 additions & 9 deletions src/components/Station.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { TextEffect } from "./TextEffect";

export class Station extends Button {
public stationId: StationId;
public hasBeenPurchased: boolean;
public currentCustomer: Customer | null; // The customer using the station
//public taskDuration: number; // Time it takes to complete a task
public taskSpeed: number = 1; // For permanent bonuses

//temp variables
Expand Down Expand Up @@ -54,6 +54,9 @@ export class Station extends Button {
this.cellSize = cellSize;
this.currentCustomer = null;

// Initially not purchased
this.hasBeenPurchased = false;

/* Sprite */
this.spriteCont = this.scene.add.container(0, this.spriteOffset);
this.add(this.spriteCont);
Expand Down Expand Up @@ -109,7 +112,8 @@ export class Station extends Button {
}

update(time: number, delta: number) {
const squish = 1.0 + 0.02 * Math.sin((6 * time) / 1000);
const amount = this.hasBeenPurchased ? 0.02 : 0;
const squish = 1.0 + amount * Math.sin((6 * time) / 1000);
this.spriteCont.setScale(1.0, squish - 0.2 * this.holdSmooth);
}

Expand All @@ -124,7 +128,7 @@ export class Station extends Button {
? (this.taskHaste *= this.currentCustomer.workMultiplier)
: (this.taskHaste *= 1);
this.parseItems();
if(this.queueFail) {
if (this.queueFail) {
this.scene.sound.play("rip");
} else {
this.playJingle();
Expand Down Expand Up @@ -222,7 +226,12 @@ export class Station extends Button {
}

upgrade() {
if (this.upgradeTo) {
// this.scene.sound.play("upgrade");

if (!this.hasBeenPurchased) {
this.hasBeenPurchased = true;
this.setAlpha(1.0);
} else if (this.upgradeTo) {
this.stationId = this.upgradeTo!;
this.sprite.setTexture(this.spriteKey);
this.spriteCont.y = this.spriteOffset;
Expand Down Expand Up @@ -280,15 +289,17 @@ export class Station extends Button {
//this.scene.sound.play("meme_explosion_sound");
}

playJingle(){
switch(this.stationType){
playJingle() {
switch (this.stationType) {
case StationType.ScalePolish: {
this.scene.sound.play("polish");
break;
} case StationType.GoldBath: {
}
case StationType.GoldBath: {
this.scene.sound.play("goldbath");
break;
} case StationType.HornAndNails: {
}
case StationType.HornAndNails: {
this.scene.sound.play("snip");
break;
}
Expand Down Expand Up @@ -334,7 +345,13 @@ export class Station extends Button {
}

get upgradeCost(): number {
return StationData[this.stationId].upgradeCost ?? 0;
if (!this.hasBeenPurchased) {
return StationData[this.stationId].cost;
}
if (this.upgradeTo) {
return StationData[this.upgradeTo].cost;
}
return 0;
}

get upgradeTo(): StationId | undefined {
Expand Down
23 changes: 14 additions & 9 deletions src/components/StationData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export interface StationInterface {
spriteScale: number; // Multiplier for sprite size
taskDuration?: number; // Time it takes to complete a task
admissionFee?: number; // Customer pays this amount to use the station
upgradeCost?: number; // Cost to upgrade the station
cost: number; // Cost to purchase the station
upgradeTo?: StationId; // Station to upgrade to
}

Expand All @@ -73,7 +73,7 @@ export const StationData: { [key in StationId]: StationInterface } = {
tier: 1,
spriteKey: "waitchair_1",
spriteScale: 1.0,
upgradeCost: 100,
cost: 100,
upgradeTo: StationId.WaitingSeatTier2,
},
[StationId.WaitingSeatTier2]: {
Expand All @@ -82,7 +82,7 @@ export const StationData: { [key in StationId]: StationInterface } = {
tier: 2,
spriteKey: "waitchair_2",
spriteScale: 1.25,
upgradeCost: 500,
cost: 250,
upgradeTo: StationId.WaitingSeatTier3,
},
[StationId.WaitingSeatTier3]: {
Expand All @@ -91,6 +91,7 @@ export const StationData: { [key in StationId]: StationInterface } = {
tier: 3,
spriteKey: "waitchair_3",
spriteScale: 1.5,
cost: 500,
},

[StationId.HornAndNailsTier1]: {
Expand All @@ -101,7 +102,7 @@ export const StationData: { [key in StationId]: StationInterface } = {
spriteScale: 1.0,
taskDuration: 3000,
admissionFee: 20,
upgradeCost: 100,
cost: 150,
upgradeTo: StationId.HornAndNailsTier2,
},
[StationId.HornAndNailsTier2]: {
Expand All @@ -112,7 +113,7 @@ export const StationData: { [key in StationId]: StationInterface } = {
spriteScale: 1.25,
taskDuration: 2500,
admissionFee: 40,
upgradeCost: 300,
cost: 250,
upgradeTo: StationId.HornAndNailsTier3,
},
[StationId.HornAndNailsTier3]: {
Expand All @@ -123,6 +124,7 @@ export const StationData: { [key in StationId]: StationInterface } = {
spriteScale: 1.5,
taskDuration: 2000,
admissionFee: 60,
cost: 400,
},

[StationId.ScalePolishTier1]: {
Expand All @@ -133,7 +135,7 @@ export const StationData: { [key in StationId]: StationInterface } = {
spriteScale: 1.0,
taskDuration: 2000,
admissionFee: 10,
upgradeCost: 150,
cost: 100,
upgradeTo: StationId.ScalePolishTier2,
},
[StationId.ScalePolishTier2]: {
Expand All @@ -144,7 +146,7 @@ export const StationData: { [key in StationId]: StationInterface } = {
spriteScale: 1.25,
taskDuration: 1500,
admissionFee: 20,
upgradeCost: 400,
cost: 250,
upgradeTo: StationId.ScalePolishTier3,
},
[StationId.ScalePolishTier3]: {
Expand All @@ -155,6 +157,7 @@ export const StationData: { [key in StationId]: StationInterface } = {
spriteScale: 1.5,
taskDuration: 1000,
admissionFee: 30,
cost: 500,
},

[StationId.GoldBathTier1]: {
Expand All @@ -165,7 +168,7 @@ export const StationData: { [key in StationId]: StationInterface } = {
spriteScale: 1.0,
taskDuration: 4000,
admissionFee: 20,
upgradeCost: 200,
cost: 200,
upgradeTo: StationId.GoldBathTier2,
},
[StationId.GoldBathTier2]: {
Expand All @@ -176,7 +179,7 @@ export const StationData: { [key in StationId]: StationInterface } = {
spriteScale: 1.25,
taskDuration: 3000,
admissionFee: 30,
upgradeCost: 600,
cost: 350,
upgradeTo: StationId.GoldBathTier3,
},
[StationId.GoldBathTier3]: {
Expand All @@ -187,6 +190,7 @@ export const StationData: { [key in StationId]: StationInterface } = {
spriteScale: 1.5,
taskDuration: 2000,
admissionFee: 40,
cost: 600,
},

[StationId.CashRegister]: {
Expand All @@ -196,5 +200,6 @@ export const StationData: { [key in StationId]: StationInterface } = {
spriteKey: "checkout",
spriteScale: 1.4,
taskDuration: 500,
cost: 0,
},
};
1 change: 1 addition & 0 deletions src/components/UI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export class UI extends Phaser.GameObjects.Container {
this.newLocationButton.on("click", () => {
this.emit("nextLevel");
});
this.newLocationButton.setVisible(false);
}

update(time: number, delta: number) {}
Expand Down
Loading

0 comments on commit 5882a05

Please sign in to comment.