assassin-bug/framework/ui/text/sound-manager.js

28 lines
906 B
JavaScript
Raw Normal View History

2022-11-26 01:22:02 +00:00
export class SoundManager {
constructor(instance, soundSet) {
this.instance = instance;
this.soundSet = soundSet;
}
setSoundSet(soundSet) {
this.soundSet = soundSet;
}
init() {
this.instance.on('character.appear', this.handleCharacterAppear.bind(this));
this.instance.on('open', this.handleOpen.bind(this));
this.instance.on('close', this.handleClose.bind(this));
this.instance.on('advance', this.handleAdvance.bind(this));
}
handleOpen() {
this.soundSet.open && this.soundSet.open.play();
}
handleCharacterAppear() {
this.soundSet.characterAppear && this.soundSet.characterAppear.play();
}
handleAdvance() {
this.soundSet.scroll && this.soundSet.scroll.play();
}
handleClose() {
this.soundSet.close && this.soundSet.close.play();
}
}