
const {ccclass, property} = cc._decorator;
@ccclass
export default class GameData extends cc.Component {
    static _instance: any;
    GM_INFO: {};
    AudioManager: any;//音频管理
    GAME_DATA: any[];//备用
    LEVEL_INFO: { //第一难度
        number: number; //太阳总数 
        moveNumber: number; //太阳可移动个数
        moveSpeed: number; //太阳移动速度等级
        maxDistance: number; //布局后移动最大距离
        maxMove: number; //初始布局最大移动距离
        repeat: number; //是否重叠，现在0 不重叠 1 重叠1个
    }[];
    //上报数据，有的游戏为一整局游戏一次上报，有的为每次操作上报
    CLICK_DATA: { type: number; success: boolean; round: number; totalSunCount: number; movedSunCount: number; sunSpeed: number; overlapSunCount: number; colorList: any[]; duration: number; difficultyLevel: number; sunList: any[]; stepTimeList: any[]; remainder: number; };

    onLoad () {
        if (GameData._instance == null) {
            GameData._instance = this;
            cc.game.addPersistRootNode(this.node);
            //设置为常驻，绑定音频以及游戏各类信息
            this.AudioManager = this.node.getComponent('AudioManager');
        }
        else {
            this.node.destroy();
            return;
        }
    }

    start () {
        this.GM_INFO_init();
        this.CLICK_init();
        this.LEVEL_INFO_init();
        //GAME_DATA 废弃了，暂时不删除以防后面修改回 一整局传一次
        this.GAME_DATA = [
        ]
    }

    GM_INFO_init(){
        this.GM_INFO = { 
            // isEnd: false,
            mean_Time:0,                //平均放箭速度
            total:0,                    //总共对的个数
            currSeed: 203213,           //用于随机数种子
            gameId:'100009',
            userId:200139,
            guide:true,                 //是否有引导
            url:"http://api.sparkus.cn",
            success:false,
            matchId:null,
            custom: 0
        };
    }

    CLICK_init(){
        this.CLICK_DATA = 
        {
            type:1,
            success:false,
            round:0,
            totalSunCount:0,
            movedSunCount:0,
            sunSpeed:0,
            overlapSunCount:0,
            colorList:[],
            duration:0,
            difficultyLevel:0,
            sunList:[],
            stepTimeList:[],
            remainder:120
        }
    }
    LEVEL_INFO_init(){
        this.LEVEL_INFO = [
            {   //第一难度
                number:3,       //太阳总数 
                moveNumber:0,   //太阳可移动个数
                moveSpeed:0,    //太阳移动速度等级
                maxDistance:200, //布局后移动最大距离
                maxMove:1200,
                repeat:0        //是否重叠，现在0 不重叠 1 重叠1个
                
            },
            {   //第二难度
                number:4,
                moveNumber:0,
                moveSpeed:0,
                maxDistance:200,
                maxMove:1200,
                repeat:0
            },
            {   //第三难度
                number:4,
                moveNumber:0,
                moveSpeed:0,
                maxDistance:200,
                maxMove:1200,
                repeat:1
            },
            {   //第四难度
                number:5,
                moveNumber:1,
                moveSpeed:6,
                maxDistance:200,
                maxMove:1200,
                repeat:0
            },
            {   //第五难度
                number:5,
                moveNumber:0,
                moveSpeed:6,
                maxDistance:200,
                maxMove:1200,
                repeat:1
            },
            {   //第六难度
                number:6,
                moveNumber:0,
                moveSpeed:6,
                maxDistance:200,
                maxMove:1200,
                repeat:1
            },
            {   //第七难度
                number:6,
                moveNumber:3,
                moveSpeed:4,
                maxDistance:200,
                maxMove:1200,
                repeat:0
            },
            {   //第八难度
                number:7,
                moveNumber:0,
                moveSpeed:4,
                maxDistance:200,
                maxMove:1200,
                repeat:0
            },
            {   //第九难度
                number:7,
                moveNumber:3,
                moveSpeed:4,
                maxDistance:200,
                maxMove:1200,
                repeat:0
            },
            {   //第十难度
                number:7,
                moveNumber:3,
                moveSpeed:6,
                maxDistance:200,
                maxMove:1200,
                repeat:1
            },
            {   //第十一难度
                number:8,
                moveNumber:3,
                moveSpeed:6,
                maxDistance:200,
                maxMove:1200,
                repeat:0
            },
            {   //第十二难度
                number:8,
                moveNumber:5,
                moveSpeed:6,
                maxDistance:200,
                maxMove:1200,
                repeat:1
            },
            {   //第十三难度
                number:9,
                moveNumber:3,
                moveSpeed:6,
                maxDistance:200,
                maxMove:1200,
                repeat:0
            },
            {   //第十四难度
                number:9,
                moveNumber:5,
                moveSpeed:6,
                maxDistance:200,
                maxMove:1200,
                repeat:1
            },
            {   //第十五难度
                number:10,
                moveNumber:5,
                moveSpeed:6,
                maxDistance:200,
                maxMove:1200,
                repeat:1
            },
            {   //11 
                number:3,
                moveNumber:0,
                moveSpeed:6,
                maxDistance:200,
                maxMove:1200,
                repeat:0
            },
            {   //12 
                number:4,
                moveNumber:0,
                moveSpeed:0,
                maxDistance:200,
                maxMove:1200,
                repeat:0
            },
            {   //13 
                number:4,
                moveNumber:1,
                moveSpeed:6,
                maxDistance:200,
                maxMove:1200,
                repeat:0
            },
            {   //14 
                number:4,
                moveNumber:0,
                moveSpeed:6,
                maxDistance:200,
                maxMove:1200,
                repeat:1
            },
            {   //15 
                number:4,
                moveNumber:1,
                moveSpeed:6,
                maxDistance:200,
                maxMove:1200,
                repeat:1
            },
            {   //16 
                number:5,
                moveNumber:1,
                moveSpeed:6,
                maxDistance:200,
                maxMove:1200,
                repeat:0
            },
            {   //17 
                number:5,
                moveNumber:0,
                moveSpeed:6,
                maxDistance:200,
                maxMove:1200,
                repeat:1
            },
            {   //18 
                number:5,
                moveNumber:1,
                moveSpeed:6,
                maxDistance:200,
                maxMove:1200,
                repeat:1
            },
            {   //19 
                number:5,
                moveNumber:2,
                moveSpeed:6,
                maxDistance:200,
                maxMove:1200,
                repeat:1
            },
            {   //20 
                number:5,
                moveNumber:3,
                moveSpeed:6,
                maxDistance:200,
                maxMove:1200,
                repeat:1
            }

        ]
    }
}
