

export enum VoiceType {
    crashrole,crashwall,win,lose,fly,speedup,coin
}

export enum BGMType{ bgm };
export class AudioManager {

    static play = true;

    private static voiceres(_type: VoiceType): string  {
        return "subpackage2/res/music/" + VoiceType[_type] + ".mp3";
    }
    private static bgmres(_type:BGMType):string{
        return "subpackage2/res/music/"+BGMType[_type] + ".mp3";
    }
    //暂停音效
    static ClearAudio()  {
        Laya.SoundManager.stopAllSound();
    }
    //暂停背景音乐
    public static StopMusic(){
        Laya.SoundManager.stopMusic();
    }
    //播放背景音乐
    public static PlayBGM(_type:BGMType){
        if(!this.play)return
        Laya.SoundManager.musicVolume = 0.3;
        Laya.SoundManager.playMusic(this.bgmres(_type),0);
    }
    //播放音效
    static PlayVoice(_type: VoiceType,_loop:boolean = false)  {
        if (!this.play) return;
        var loop = _loop?0:1;
        Laya.SoundManager.soundVolume = 1
        if(_type == VoiceType.coin){
            Laya.SoundManager.soundVolume = 0.3
        } 
        Laya.SoundManager.playSound(this.voiceres(_type),loop);
    }
}