// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import { ryw_Event } from "../../FrameWork/Event/EventEnum";
import EventMgr from "../../FrameWork/Event/EventMgr";
import User from "../../FrameWork/User/User";
import Common5 from "../../Platform/th/Common5";
import TaskManager, { MainTaskIdEnum } from "../JuQingChat/TaskManager";
import BagManager from "../Manager/BagManager";
import LevelUpManager from "../Manager/LevelUpManager";
import UserManager from "../Manager/UserManager";
import PrefabManage, { GameType } from "../PrefabManager/PrefabManage";
// import buildManager from "../Manager/buildManager";

const { ccclass, property } = cc._decorator;

@ccclass
export default class PinTuFinish extends cc.Component {

    @property(cc.Sprite)
    caipuSpr: cc.Sprite = null;

    @property(cc.Sprite)
    caipuSpr2: cc.Sprite = null;



    @property(cc.Label)
    shouyiLabel: cc.Label = null;

    @property(cc.Label)
    shouyiLabelQian: cc.Label = null;
    @property(cc.Label)
    shouyiLabelHou: cc.Label = null;

    // LIFE-CYCLE CALLBACKS:
    name = ''
    setPintuName(name) {
        this.name = name
    }
    // onLoad () {}

    start() {
        //TaskManager.checkIsFinishPinTuTaskArray() //检测拼图多个
        Common5.getSpriteFrameFromBundle("PinTuGame", 'pic/菜谱完成/' + this.name + '1', this.caipuSpr);
        Common5.getSpriteFrameFromBundle("PinTuGame", 'pic/菜谱完成/' + this.name + '2', this.caipuSpr2);

        // let buildName = buildManager.getBuildNameByCaipuName(this.name)
        // let shouyi = 10//buildManager.getBuildIncome(buildName)

        // this.shouyiLabel.string = Common5.getNumberChangeHanzi(shouyi*15)+''

        // this.shouyiLabelQian.string = Common5.getNumberChangeHanzi(shouyi)+''

        // this.shouyiLabelHou.string = Common5.getNumberChangeHanzi(shouyi*15)+''


        // this.checkTaskFinsh()
        User.setStatistics('smallgameptCurGoLevel', User.getStatistics('smallgameptCurGoLevel') + 1)
        Common5.showInterstitialAd()
        EventMgr.onEvent_custom(ryw_Event.ExitBtnEvent, () => {
            if (User.getStatistics('smallgameptCurGoLevel') > 0) {
                PrefabManage.loadPrefabByType(GameType.SuccessGetMoney, null, (prefab) => {
                    prefab.getComponent('SuccessGetMoney').setViewDate("", 1, 5)
                })
            }
        }, this)
    }

    onTouchNext() {
        User.setStatistics('PinTuLevel', User.getStatistics('PinTuLevel') + 1)
        PrefabManage.loadPrefabByType(GameType.PinTuEnter)
        this.node.removeFromParent()
        this.node.destroy()
    }

    // update (dt) {}
}