//通关任务奖励脚本
var TableReader =require("TableReader");

cc.Class({
    extends: cc.Component,

    properties: {
        jinbiIcon: cc.Sprite,
        content: cc.Node,  //内容节点  
        _tempGold: null,
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    init: function(tempGold){
        this._tempGold =tempGold;
    },

    start () {
    },

    onEnable: function(){
        var actionScaleIn = cc.sequence(cc.scaleTo(0.3, 1.05, 1.05).easing(cc.easeCubicActionOut()),cc.scaleTo(0.1, 1, 1).easing(cc.easeCubicActionOut()));
        this.content.scale = 0.5;
        this.content.runAction(actionScaleIn);

        let skin =TableReader.getTableRowByNum("knifeItems",this._tempGold);
        cc.HQ.GameMgr.onReplaceKnife(this.jinbiIcon,skin);
    },

    onSure: function(){
        cc.HQ.Global.showTips(2,"恭喜获得通关武器奖励!",1.5);     //通关武器奖励
        let arr =cc.HQ.GameMgr.getKnife();
        arr =cc.HQ.GameMgr.onChangeData(arr);
        arr.push(this._tempGold);
        cc.HQ.GameMgr.setKnife(arr);
        
        //当前装备的飞刀皮肤
        cc.HQ.GameMgr.setCurKnife(this._tempGold);

        this.node.active =false;
        //埋点
        sdk.setSceneEvent("通关奖励弹框","点击","确定按钮",{},null);
    },

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