

import { eventTarget, SHOW_CARD_POPUP, SHOW_START_SCREEN, STOP_ANIM_CHUM } from "../Events";

const { ccclass, property } = cc._decorator;

@ccclass
export default class CardPopup extends cc.Component {

    private _replayBtn: cc.Node;


    onLoad() {
        this._replayBtn = this.node.getComponentInChildren(cc.Button).node;
        this.node.active = false;
        this.node.position = cc.v3();
        eventTarget.on(SHOW_CARD_POPUP, this.showCard, this);
        this._replayBtn.on('click', this.onReplayBtnClick, this);
    }


    private showCard() {
        this.node.active = true;
    }

    private onReplayBtnClick() {
        this.node.active = false;
        eventTarget.emit(SHOW_START_SCREEN);
        eventTarget.emit(STOP_ANIM_CHUM);
    }
}
