Skip to content

Commit

Permalink
Add customer happiness redness
Browse files Browse the repository at this point in the history
  • Loading branch information
Golen87 committed Aug 17, 2024
1 parent fa41416 commit b6de3c0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
22 changes: 14 additions & 8 deletions src/components/Customer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export class Customer extends Button {
public doingCuteThing: boolean;
public tasksCompleted: number;
public moneySpent: number;
public maxHappiness: number;
public happiness: number;

// Graphics
Expand All @@ -49,8 +48,7 @@ export class Customer extends Button {
this.doingCuteThing = false;
this.tasksCompleted = 0;
this.moneySpent = 0;
this.maxHappiness = 100;
this.happiness = 100;
this.happiness = 1;

/* Sprite */
const size = 150;
Expand All @@ -60,7 +58,12 @@ export class Customer extends Button {
this.sprite.setScale(size / this.sprite.width);
this.add(this.sprite);

this.thoughtBubble = new ThoughtBubble(scene, 0.2 * size, -0.6 * size, size);
this.thoughtBubble = new ThoughtBubble(
scene,
0.2 * size,
-0.6 * size,
size
);
this.add(this.thoughtBubble);

this.happinessTimer = new Timer(
Expand All @@ -84,18 +87,21 @@ export class Customer extends Button {
const squish =
1.0 + wobble * Math.sin((6 * time) / 1000) - 0.2 * this.holdSmooth;
this.setScale(1.0, squish);
this.sprite.setTint(
interpolateColor(0xffffff, 0xff0000, 1 - this.happiness)
);

if (this.isWaiting) {
this.happinessTimer.setVisible(true);
if (!this.dragged) {
this.happiness -= (100 / 20) * (delta / 1000);
// 20 seconds
this.happiness -= (1 / 20) * (delta / 1000);
}

const factor = this.happiness / this.maxHappiness;
this.happinessTimer.setColor(
interpolateColor(0xff0000, 0x00ff00, factor)
interpolateColor(0xff0000, 0x00ff00, this.happiness)
);
this.happinessTimer.redraw(factor);
this.happinessTimer.redraw(this.happiness);

if (this.happiness <= 0) {
this.leave();
Expand Down
4 changes: 2 additions & 2 deletions src/components/Station.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export const StationTypeColors: { [key in StationType]: number } = {
export const StationDuration: { [key in StationType]: number } = {
[StationType.WaitingSeat]: 0,
[StationType.HornAndNails]: 3000,
[StationType.ScalePolish]: 4000,
[StationType.GoldBath]: 2000,
[StationType.ScalePolish]: 2000,
[StationType.GoldBath]: 4000,
[StationType.CashRegister]: 500,
};

Expand Down

0 comments on commit b6de3c0

Please sign in to comment.