import { eventTarget, PLAY_BREAKING_SOUND, PLAY_DROP_SOUND, PLAY_ROLLING_SOUND } from "./Events";


const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property(cc.AudioSource)
    private rollingSound: cc.AudioSource = null;

    @property(cc.AudioSource)
    private breakingSound: cc.AudioSource = null;

    @property(cc.AudioSource)
    private dropSound: cc.AudioSource = null;

    onLoad () {
        eventTarget.on(PLAY_ROLLING_SOUND, this.playRollingSound, this);
        eventTarget.on(PLAY_BREAKING_SOUND, this.playBreakingSound, this);
        eventTarget.on(PLAY_DROP_SOUND, this.playDropSound, this);
    }

    private playRollingSound() {
        this.rollingSound.play();
    }

    private playBreakingSound() {
        this.breakingSound.play();
    }

    private playDropSound() {
        this.dropSound.play();
    }

}
