import { _decorator, Component, Node } from 'cc';
import { ColorDate } from './ColorDate';
import { Global } from './Global';
const { ccclass, property } = _decorator;

@ccclass('DataModel')
export class DataModel {
    //颜色设置
    public static base_color_arr = [
        //深青1   	0  0  
        ColorDate.new_bean(0,238, 0 ,10009),
        //1
        ColorDate.new_bean(255,69, 0 ,10008),
        //171, 177, 187  灰白1
        ColorDate.new_bean(105,105,105,10002 ), 
        //11, 246, 235  青1   	  
        ColorDate.new_bean(202,255,112,10001),
         //18, 101, 246 绿1  
         ColorDate.new_bean(162,  205,  90 ,10003),
        //紫色1    	  	 85 
        ColorDate.new_bean(186,85, 211 ,10007),
        //5, 127, 201 浅蓝1  
        ColorDate.new_bean(0, 154,205,10004),
        //255, 87, 51 橘红1 	  
        ColorDate.new_bean(255, 127, 36 ,10006),
        //255, 195, 黄1
        ColorDate.new_bean(255,215,0,10005),

    ];

    //备份一下原始的设置
    public static base_color_arr_back = [
        //深青
        ColorDate.new_bean(13,105, 105 ,10009),
        //💜
        ColorDate.new_bean(241,24, 245 ,10008),
        //171, 177, 187  灰白
        ColorDate.new_bean(171, 177, 187,10002 ),
        //11, 246, 235  青
        ColorDate.new_bean(11,246,235,10001),
         //18, 101, 246 绿
         ColorDate.new_bean(130,  235,  93 ,10003),
        //紫色
        ColorDate.new_bean(124,87, 229 ,10007),
        //5, 127, 201 浅蓝
        ColorDate.new_bean(38, 119,  204 ,10004),
        //255, 87, 51 橘红
        ColorDate.new_bean(239, 91, 122 ,10006),
        //255, 195, 黄
        ColorDate.new_bean(208,186, 74 ,10005),

    ];

    private static lvl_color_arr = [];
    public static generate_lvl_color_arr(args:number){
        DataModel.lvl_color_arr = [];
        for(let i = 0;i<DataModel.base_color_arr.length;i++){
            DataModel.lvl_color_arr.push(DataModel.base_color_arr[i].clone());
            if(DataModel.lvl_color_arr.length>=args){
                break;
            } 
        }
    }

    private static lvl_color_index: number = 0;
    public static get_lvl_color(): ColorDate {
        let ret = DataModel.lvl_color_arr[DataModel.lvl_color_index];
        DataModel.lvl_color_index += 1;
        if (DataModel.lvl_color_index >= DataModel.lvl_color_arr.length) {
            DataModel.lvl_color_index = 0;
        }
        return ret;
    }

    private static layer_color_index: number = 0;
    public static get_layer_color(): ColorDate {
        let ret = DataModel.base_color_arr[DataModel.layer_color_index];
        DataModel.layer_color_index += 1;
        if (DataModel.layer_color_index >= DataModel.base_color_arr.length) {
            DataModel.layer_color_index = 0;
        }
        return ret;
    }

    public static random_base_color() {
        DataModel.base_color_arr.sort(() => {
            return 0.5 - Math.random();
        });
    }



    // group_index_arr = [];
    private static cur_group_index = 0;

    public static get_new_group_index() {
        let temp = 1 << DataModel.cur_group_index;
        DataModel.cur_group_index += 1;
        if (DataModel.cur_group_index > 30) {
            DataModel.cur_group_index = 0;
        }
        // console.log("group:::::",temp);
        return temp;
    }
}

