Skip to content

Commit

Permalink
random assets
Browse files Browse the repository at this point in the history
  • Loading branch information
NightLightLumie committed Aug 16, 2024
1 parent 82a3162 commit 49a0adb
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/assets/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ const images: Image[] = [
image('titlescreen/background', 'title_background'),
image('titlescreen/foreground', 'title_foreground'),
image('titlescreen/character', 'title_character'),



];

/* Spritesheets */
const spritesheets: SpriteSheet[] = [

//temp
spritesheet('temp/invbutton', 'invbutton', 128, 128),
];

/* Audios */
Expand Down
Binary file added src/assets/images/temp/invbutton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 80 additions & 0 deletions src/components/elements/TextButton.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { BaseScene } from "@/scenes/BaseScene";
import { Button } from "./Button";

export class TextButton extends Button {
public index: number;
public value: string;
private sprite: Phaser.GameObjects.Sprite;
private tdisplay: Phaser.GameObjects.Text;
private disabled: boolean = false;



constructor(scene: BaseScene, x: number, y: number, v: string, spr: string, fsize: number = 40) {
super(scene, x, y);
this.sprite = scene.add.sprite(0, 0, spr, 0);
this.sprite.setOrigin(0.5,0.5);
this.add(this.sprite);
this.bindInteractive(this.sprite);
this.value = v;
this.tdisplay = scene.addText({ text: v, color: "white", size: fsize });
this.tdisplay.setOrigin(0.5);
this.add(this.tdisplay);
this.index = -1;
this.disabled = false;
}

reCenter(x: number, y: number) {
this.sprite.setOrigin(x,y);
this.tdisplay.setOrigin(x,y);
}

setValue(data: string){
this.value = data;
this.tdisplay.setText(this.value);
}

setIndex(i: number){
this.index = i;
}

turnOff(){
this.disabled = true;
this.resetState();
}

turnOn(){
this.disabled = false;
this.resetState();
}

resetState(){
this.tdisplay.setColor("white");
this.sprite.setFrame(0);
}

onDown(
pointer: Phaser.Input.Pointer,
localX: number,
localY: number,
event: Phaser.Types.Input.EventData
) {
if (!this.disabled) {
super.onDown(pointer, localX, localY, event);
this.tdisplay.setColor("green");
this.sprite.setFrame(1);
}
}
onUp(
pointer: Phaser.Input.Pointer,
localX: number,
localY: number,
event: Phaser.Types.Input.EventData
) {
if (!this.disabled) {
super.onUp(pointer, localX, localY, event);
this.tdisplay.setColor("white");
this.sprite.setFrame(0);
}
}
}
9 changes: 9 additions & 0 deletions src/scenes/GameScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export class GameScene extends BaseScene {
private employees: Employee[];
private customers: Customer[];
private ui: UI;
private paused: boolean = false;
private browsing: boolean = false;

constructor() {
super({ key: "GameScene" });
Expand Down Expand Up @@ -49,6 +51,9 @@ export class GameScene extends BaseScene {
}

update(time: number, delta: number) {
if(this.browsing || this.paused) {
return;
}
this.stations.forEach((s) => s.update(time, delta));
this.employees.forEach((e) => e.update(time, delta));
this.customers.forEach((c) => c.update(time, delta));
Expand All @@ -75,6 +80,10 @@ export class GameScene extends BaseScene {
});
}

openInventory(){
this.browsing = true;
}

// Add new employee
addEmployee(gridX: number, gridY: number) {
const coord = this.board.gridToCoord(gridX, gridY);
Expand Down

0 comments on commit 49a0adb

Please sign in to comment.