
cc.Class({
    extends: cc.Component,

    properties: {
        Territories: {
            default: [],
            type: [cc.Node],
            serializable: true,
            visible: false,
        },

        //灰色地图
        oldMapDivideTiledMap: {
            default: null,
            type: cc.TiledMap,
            serializable: true,
        },
    },
    // start() {

    // },
    InitManageMap() {
        if (GlobalD.TiledMap != null) {
            //先初始化tiledmap的障碍物
            // GlobalD.TiledMap.onInitSolid();

            // this.InitOpenMap();
        }
    },
    InitOpenMap: function () {
        // 隐藏TiledLayer
        for (let i = 0; i < 8; i++) {
            if (!this.oldMapDivideTiledMap) break;
            let tempMap_Blue = this.oldMapDivideTiledMap.getLayer('NotOpenedMap' + i + '_Blue');
            tempMap_Blue.enabled = false;
            let tempMap_Black = this.oldMapDivideTiledMap.getLayer('NotOpenedMap' + i + '_Black');
            // tempMap2.enabled = false;
            this.Territories.push(tempMap_Black);
        }

        let TerritoryStateArray = GlobalD.GameData.GetTerritoryStateArray();
        // cc.log('TerritoryStateArray=' + TerritoryStateArray)
        for (let i = 0; i < TerritoryStateArray.length; i++) {
            if (TerritoryStateArray[i] == 0) {
                this.Territories[i].enabled = true;
                continue;
            }
            GlobalD.TiledMap.onClearRailingFromTilesPos(i);

            this.Territories[i].enabled = false;
        }
    },

    //根据地图下标清除对应的区域
    onClearSolidArea(_mapIndex) {
        GlobalD.TiledMap.onClearRailingFromTilesPos(_mapIndex);
    },

});
