import Common5 from "../../Platform/th/Common5";
import GameReport from "../Report/ZyZyReport";

const { ccclass, property } = cc._decorator;

@ccclass
export default class WordGameBaseComponent extends cc.Component {
    startDaDianTime: number;
    jsonData = null
    gameName: string = ''
    start(): void {
        let biaoti = this.node.getChildByName('标题')
        if (biaoti) {
            biaoti.active = false
        }
        if (this.node.getChildByName("tipsBtn")) {
            this.node.getChildByName("tipsBtn").active = false;
        }
        if (this.node.getChildByName("GZTipBtn")) {
            this.node.getChildByName("GZTipBtn").active = false;
        }


        this.startDaDianTime = new Date().getTime();
        let title = Common5.gameConfig.zmGameConfig[Common5.selectGameNum].title2;
        console.log("start++++++++++++++++++++++++++++++++++++" + title + ":" + this.startDaDianTime);
        this.gameName = title

    }

    onDestroy(): void {
        let endDaDianTime = new Date().getTime();
        let time_ = endDaDianTime - this.startDaDianTime
        let times = Math.floor(time_ / 1000) //秒
        if (times > 0) {
            let title = this.gameName//Common5.gameConfig.zmGameConfig[Common5.selectGameNum].title2;
            Common5.ReportDYTime("inLevel", title, times);
            //当前关卡
            GameReport.StayTimeReport(times, Common5.selectGameInfo.titleUrl)
            console.log("end++++++++++++++++++++++++++++++++++++" + title + ":" + times + "s");
        }
    }

    //改变位置
    changePosi(curNode) {

        let HeadNodeList = curNode.getChildByName('HeadNodeList')
        if (HeadNodeList) {
            let posiX = HeadNodeList.getPosition().x
            let posiY = HeadNodeList.getPosition().y
            HeadNodeList.setPosition(posiX, posiY + 55)
        }
        let chadianIconList = curNode.getChildByName('chadianIconList')
        if (chadianIconList) {
            let posiX = chadianIconList.getPosition().x
            let posiY = chadianIconList.getPosition().y
            chadianIconList.setPosition(posiX, posiY + 55)
        }
    }



}