sound effects

This commit is contained in:
icslucas
2025-10-04 19:39:24 +02:00
parent fa9259b1fc
commit 3e90057913
10 changed files with 46 additions and 2 deletions
+1 -1
View File
@@ -5,4 +5,4 @@
export PATH="/usr/local/bin:$HOME/.npm-global/bin:$HOME/.nvm/versions/node/$(node -v)/bin:$PATH"
# Then run lint-staged if tests pass
npx lint-staged
npx.cmd lint-staged
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+3 -1
View File
@@ -109,7 +109,9 @@ export class LocalServer {
if (!this.lobbyConfig.gameRecord) {
if (clientMsg.turnNumber % 100 === 0) {
// In singleplayer, only store hash every 100 turns to reduce size of game record.
this.turns[clientMsg.turnNumber].hash = clientMsg.hash;
if (this.turns[clientMsg.turnNumber]) {
this.turns[clientMsg.turnNumber].hash = clientMsg.hash;
}
}
return;
}
+25
View File
@@ -19,6 +19,7 @@ import { TextFx } from "../fx/TextFx";
import { UnitExplosionFx } from "../fx/UnitExplosionFx";
import { Layer } from "./Layer";
export class FxLayer implements Layer {
private seenNukes: Set<number> = new Set();
private canvas: HTMLCanvasElement;
private context: CanvasRenderingContext2D;
@@ -141,10 +142,26 @@ export class FxLayer implements Layer {
break;
}
case UnitType.AtomBomb:
if (!this.seenNukes.has(unit.id())) {
SoundManager.playSoundEffect(SoundEffect.AtomLaunch);
this.seenNukes.add(unit.id());
}
this.onNukeEvent(unit, 70);
break;
case UnitType.MIRV:
if (!this.seenNukes.has(unit.id())) {
SoundManager.playSoundEffect(SoundEffect.MirvLaunch);
this.seenNukes.add(unit.id());
}
break;
case UnitType.MIRVWarhead:
this.onNukeEvent(unit, 70);
break;
case UnitType.HydrogenBomb:
if (!this.seenNukes.has(unit.id())) {
SoundManager.playSoundEffect(SoundEffect.HydroLaunch);
this.seenNukes.add(unit.id());
}
this.onNukeEvent(unit, 160);
break;
case UnitType.Warship:
@@ -263,6 +280,14 @@ export class FxLayer implements Layer {
}
handleNukeExplosion(unit: UnitView, radius: number) {
if (unit.type() === UnitType.AtomBomb) {
SoundManager.playSoundEffect(SoundEffect.AtomHit);
} else if (unit.type() === UnitType.HydrogenBomb) {
SoundManager.playSoundEffect(SoundEffect.HydroHit);
} else if (unit.type() === UnitType.MIRVWarhead) {
SoundManager.playSoundEffect(SoundEffect.MirvHit);
}
const x = this.game.x(unit.lastTile());
const y = this.game.y(unit.lastTile());
const nukeFx = nukeFxFactory(
+17
View File
@@ -1,4 +1,9 @@
import { Howl } from "howler";
import atomHitSound from "../../../proprietary/sounds/effects/atom_hit.mp3";
import atomLaunchSound from "../../../proprietary/sounds/effects/atom_launch.mp3";
import hydroHitSound from "../../../proprietary/sounds/effects/hydrogen_hit.mp3";
import hydroLaunchSound from "../../../proprietary/sounds/effects/hydrogen_launch.mp3";
import mirvLaunchSound from "../../../proprietary/sounds/effects/mirv_launch.mp3";
import of4 from "../../../proprietary/sounds/music/of4.mp3";
import openfront from "../../../proprietary/sounds/music/openfront.mp3";
import war from "../../../proprietary/sounds/music/war.mp3";
@@ -6,6 +11,12 @@ import kaChingSound from "../../../resources/sounds/effects/ka-ching.mp3";
export enum SoundEffect {
KaChing = "ka-ching",
AtomLaunch = "atom_launch",
AtomHit = "atom_hit",
HydroLaunch = "hydro_launch",
HydroHit = "hydro_hit",
MirvHit = "mirv_hit",
MirvLaunch = "mirv_launch",
}
class SoundManager {
@@ -37,6 +48,12 @@ class SoundManager {
}),
];
this.loadSoundEffect(SoundEffect.KaChing, kaChingSound);
this.loadSoundEffect(SoundEffect.AtomLaunch, atomLaunchSound);
this.loadSoundEffect(SoundEffect.AtomHit, atomHitSound);
this.loadSoundEffect(SoundEffect.HydroLaunch, hydroLaunchSound);
this.loadSoundEffect(SoundEffect.HydroHit, hydroHitSound);
this.loadSoundEffect(SoundEffect.MirvHit, atomHitSound);
this.loadSoundEffect(SoundEffect.MirvLaunch, mirvLaunchSound);
}
public playBackgroundMusic(): void {