Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Chocobois/built-to-scale
Browse files Browse the repository at this point in the history
  • Loading branch information
Golen87 committed Aug 20, 2024
2 parents bfd9754 + aa73155 commit 42d43a0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
4 changes: 4 additions & 0 deletions src/components/Intermission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const enum Mode {
export class Intermission extends Phaser.GameObjects.Container {
public scene: GameScene;
public mode: Mode;
public transitionProgress: number;

private graphics: Phaser.GameObjects.Graphics;
private cutscene: Phaser.GameObjects.Image;
Expand Down Expand Up @@ -75,6 +76,7 @@ export class Intermission extends Phaser.GameObjects.Container {
this.add(this.subtitles);

this.queuedLines = [];
this.transitionProgress = 0;

/* Button */

Expand Down Expand Up @@ -218,11 +220,13 @@ export class Intermission extends Phaser.GameObjects.Container {
to: 1,
ease: Phaser.Math.Easing.Quintic.InOut,
onUpdate: (tween, target, key, current: number) => {
this.transitionProgress = current;
let radius = current * 0.6 * this.scene.W;
this.redrawMask(this.scene.CX, this.scene.CY, radius);
},
onComplete: () => {
this.setVisible(false);
this.transitionProgress = 0;
},
});
}
Expand Down
35 changes: 17 additions & 18 deletions src/scenes/GameScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1403,33 +1403,32 @@ export class GameScene extends BaseScene {
}

updateMusicState() {
const clamp = Phaser.Math.Clamp;
const tween = this.intermission.transitionProgress;
const volumeModifier = 0.4;

let intendedVolume = {
base: 1,
cutscene: 0,
downtime: 0,
}

switch (this.state) {
case GameState.Shopping:
case GameState.Cutscene:
case GameState.Intermission:
intendedVolume = {
base: 0,
cutscene: 0,
downtime: 1,
};
break;

case GameState.Day:
default:
break;
if (this.state != GameState.Day) intendedVolume = {
base: 0,
cutscene: 0,
downtime: 1,
};

if (this.intermission.visible) {
intendedVolume.cutscene = 1 - tween;
intendedVolume.downtime *= tween;
intendedVolume.base *= tween;
}

console.log(intendedVolume)
console.debug(tween, intendedVolume)

this.musicBase.setVolume(intendedVolume.base * volumeModifier);
this.musicDowntime.setVolume(intendedVolume.downtime * volumeModifier);
this.musicCutscene.setVolume(intendedVolume.cutscene * volumeModifier);
this.musicBase.setVolume( clamp(intendedVolume.base, 0, 1) * volumeModifier);
this.musicDowntime.setVolume(clamp(intendedVolume.downtime, 0, 1) * volumeModifier);
this.musicCutscene.setVolume(clamp(intendedVolume.cutscene, 0, 1) * volumeModifier);
}
}

0 comments on commit 42d43a0

Please sign in to comment.