const GameNotificationKey = require('../utils/GameEnum').GameNotificationKey;
const JobPageType = require('../utils/GameEnum').JobPageType;
cc.Class({
    extends: cc.Component,

    properties: {
        alert: cc.Node,
        talentSprite: cc.Node,
    },

    onLoad() {
        this.alert.on(cc.Node.EventType.TOUCH_END, () => {
            this.toTalent();
        }, this)

        this.talentSprite.on(cc.Node.EventType.TOUCH_END, () => {
            this.toTalent();
        }, this)
    },

    start() {

    },

    show() {
        this.node.parent = cc.find('Canvas');
        this.node.active = true;

        this.talentSprite.x = -471;
        this.alert.opacity = 0;

        let animEnd = cc.callFunc(() => {
            this.alert.runAction(cc.fadeIn(0.5));
        }, this);

        this.talentSprite.runAction(cc.sequence(cc.moveBy(0.3, 300, 0).easing(cc.easeBackOut()), animEnd));

    },

    toTalent() {
        let animEnd = cc.callFunc(() => {
            Global.GameEvent.fire(GameNotificationKey.ShowJobPageFromTalent, JobPageType.ChooseJob);
            this.close();
        }, this);
        this.alert.opacity = 0;
        this.talentSprite.runAction(cc.sequence(cc.moveBy(0.4, -471, 0).easing(cc.easeBackOut()), animEnd));
    },

    close() {
        this.node.active = false;
    }

    // update (dt) {},
});
