Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
NightLightLumie committed Aug 19, 2024
2 parents 366104f + b618dfe commit a3a418b
Show file tree
Hide file tree
Showing 24 changed files with 450 additions and 141 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"dependencies": {
"@neutralinojs/lib": "^5.3.0",
"navmesh": "^2.3.1",
"phaser": "^3.80.1",
"phaser3-rex-plugins": "^1.80.6"
},
Expand Down
4 changes: 4 additions & 0 deletions src/assets/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ const images: Image[] = [
// Items
image('items/coin', 'coin'),
image('items/bath1', 'bath_1'),
image('items/bath1f', 'bath_1_front'),
image('items/bath2', 'bath_2'),
image('items/bath2f', 'bath_2_front'),
image('items/bath3', 'bath_3'),
image('items/bath3f', 'bath_3_front'),
image('items/wax1', 'wax_1'),
image('items/wax2', 'wax_2'),
image('items/wax3', 'wax_3'),
Expand All @@ -65,6 +68,7 @@ const images: Image[] = [
image('ui/question', 'question'),
image('ui/sad', 'sad'),
image('ui/timer', 'timer'),
image('ui/plus', 'plus'),

// Titlescreen
image('titlescreen/sky', 'title_sky'),
Expand Down
Binary file modified src/assets/images/backgrounds/grid2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/images/items/bath1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/items/bath1f.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/images/items/bath2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/items/bath2f.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/images/items/bath3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/items/bath3f.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/images/items/nail1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/images/items/nail2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/images/items/nail3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/images/items/wax1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/ui/plus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 13 additions & 1 deletion src/components/Board.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { GameScene } from "@/scenes/GameScene";

export type GridPoint = {
gridX: number,
gridY: number
};

export class Board extends Phaser.GameObjects.Container {
public scene: GameScene;
public size: number;
public width: number;
public height: number;

private grid: Phaser.GameObjects.Grid;
private things: any[];
Expand All @@ -21,6 +28,9 @@ export class Board extends Phaser.GameObjects.Container {

// this.size = scene.H / (height + 2);
this.size = cellSize;
this.width = width;
this.height = height

this.grid = this.scene.add.grid(
0,
0,
Expand All @@ -44,6 +54,8 @@ export class Board extends Phaser.GameObjects.Container {
resize(width: number, height: number, cellSize: number) {
// this.size = this.scene.H / height;
this.size = cellSize;
this.width = width;
this.height = height

this.grid.destroy();
this.grid = this.scene.add.grid(
Expand All @@ -70,7 +82,7 @@ export class Board extends Phaser.GameObjects.Container {
}

// Return grid cell of the coordinates
coordToGrid(x: number, y: number) {
coordToGrid(x: number, y: number): GridPoint {
const gridX = Math.floor((x - this.x + this.grid.width / 2) / this.size);
const gridY = Math.floor((y - this.y + this.grid.height / 2) / this.size);
return { gridX, gridY };
Expand Down
31 changes: 27 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,13 @@ 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,12 +99,25 @@ 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);
}
}

// 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 Expand Up @@ -140,7 +157,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: 300,
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,
},
};
23 changes: 8 additions & 15 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 All @@ -37,13 +37,13 @@ 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],
upgradeCost: 1000,
},
{
id: LevelId.Level2,
Expand All @@ -60,17 +60,14 @@ 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,
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 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,
],
},
];
45 changes: 36 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,14 +226,29 @@ 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;
this.sprite.setScale(this.spriteSize / this.sprite.width);
}
}

// 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 Expand Up @@ -280,15 +299,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 +355,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
Loading

0 comments on commit a3a418b

Please sign in to comment.