
const ADSdk = require("ADSdk");
cc.Class({
    extends: cc.Component,

    properties: {
        signBtn: cc.Node,
        videoBtn: cc.Node,
    },

    onLoad() {
        this.signBtn.on("click", this._sign, this);
        this.videoBtn.on("click", this._video, this);
    },

    init(c) {
        this.awardNum = 2;

        if (c) this.controller = c;
        this.node.active = true;
        let ui = this.node.children[1];
        ui.scaleX = 0.1;
        ui.scaleY = 0.1;
        ui.runAction(
            cc.sequence(
                cc.scaleTo(0.3, 1.1),
                cc.scaleTo(0.2, 1)
            ));
    },

    _sign() {
        this.close();
        this.controller.scoreMgr.onStep(this.awardNum);
    },

    _video() {
        this.close();
        // TODO 广告 视频双倍奖励
        if (AppConst.SHOWADUI) {

            if (AppConst.CHANNEL == AppConst.channel.ANDROID) {
				ADSdk.pay(4, this);
			} else {
                ADSdk.showVideo(null, (result) => {
                    if (result == 1) {
                        this.controller.scoreMgr.onStep(this.awardNum * 2);
                    }
                });
            }

        } else {
            this.controller.scoreMgr.onStep(this.awardNum * 2);
        }


        // this.controller.scoreMgr.onStep(this.awardNum * 2);
    },

    close() {
        Utils.setSignIn();
        this.controller.game.signInBtn.active = false;
        this.node.active = false;
    }
    // update (dt) {},
});
