
                (function() {
                    var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined';
                    var __module = nodeEnv ? module : {exports:{}};
                    var __filename = 'preview-scripts/assets/Script/Map.js';
                    var __require = nodeEnv ? function (request) {
                        return cc.require(request);
                    } : function (request) {
                        return __quick_compile_project__.require(request, __filename);
                    };
                    function __define (exports, require, module) {
                        if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict";
cc._RF.push(module, '2234assp7RIvpDgrnqljp2R', 'Map');
// Script/Map.ts

"use strict";
// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var GameManager_1 = require("./GameManager");
var NumberToImage_1 = require("./NumberToImage");
var MiniGameSdk_1 = require("./Sdk/MiniGameSdk");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var MapConroler = /** @class */ (function (_super) {
    __extends(MapConroler, _super);
    function MapConroler() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.Block_Array = [];
        _this.Block_Prop = [];
        _this.MapBlockPrefab = null;
        _this.Block_Color = [];
        _this.Wall_Prefab = [];
        _this.wallTurnPrefab = null;
        _this.timeBtn = null;
        _this.destroyBtn = null;
        _this.magicBtn = null;
        _this.mask = null;
        _this.iceLabel = null;
        _this.hammerLabel = null;
        _this.magicLabel = null;
        _this.magicMask = null;
        _this.hammerMask = null;
        _this.freezeMask = null;
        _this.coinPop = null;
        _this.timeLabel = null;
        _this.levelLabel = null;
        _this.coin = null;
        _this.new_mode = 0;
        _this.mapWidth = 0;
        _this.mapHeight = 0;
        _this.wallNum = 0;
        _this.blockNum = 0;
        _this.homeCanTouch = true; //按钮可用状态
        _this.againCanTouch = true; //重玩按钮可以用状态
        _this.gameOver = false; //游戏结束状态
        _this.gameWin = false; //游戏胜利状态
        _this.gameStart = false; //游戏开始状态
        _this.timeNumber = 0; //游戏时间 用于倒计时
        _this.count_Time = 0; //用于统计总游戏时长
        _this.add_Time = 0; //复活时间
        _this.pause = false; //暂停状态
        _this.hammer = false; //锤子状态
        return _this;
    }
    MapConroler_1 = MapConroler;
    // mapInfo: number[][] = [];
    MapConroler.prototype.onLoad = function () {
        var _this = this;
        cc.fx.GameConfig.GM_INFO.review = 0;
        cc.fx.GameConfig.GM_INFO.gameState = true;
        this.mask.opacity = 0;
        this.node.getChildByName("Adhesive").zIndex = 500;
        cc.game.setFrameRate(63);
        cc.fx.AudioManager._instance.playEffect("zhuan2", null);
        this.node.parent.parent.parent.getChildByName("zhuanchang").active = true;
        this.node.parent.parent.parent.getChildByName("zhuanchang").getComponent(sp.Skeleton).setAnimation(1, "down", false);
        this.node.parent.parent.parent.getChildByName("zhuanchang").getComponent(sp.Skeleton).setCompleteListener(function (entry) {
            if (entry.animation.name === "down") {
                // 动画播放结束后执行的逻辑
                _this.node.parent.parent.parent.getChildByName("zhuanchang").active = false;
            }
        });
        this.blocks = [];
        this.leftDoors = []; //左门
        this.rightDoors = []; //右门
        this.topDoors = []; //上门
        this.bottomDoors = []; //下门
        this.gameWin = false;
        this.gameOver = false;
        this.gameStart = false;
        this.homeCanTouch = true;
        this.againCanTouch = true;
        this.new_mode = 0;
        this.count_Time = 0;
        this.add_Time = 0;
        this.iceLabel.string = cc.fx.GameConfig.GM_INFO.freezeAmount.toString();
        this.hammerLabel.string = cc.fx.GameConfig.GM_INFO.hammerAmount.toString();
        this.magicLabel.string = cc.fx.GameConfig.GM_INFO.magicAmount.toString();
        // cc.game.addPersistRootNode(this.node);
        MapConroler_1._instance = this;
    };
    MapConroler.prototype.start = function () {
        setTimeout(function () {
            cc.director.preloadScene("HomeScene", function (err, asset) {
                if (err) {
                    console.error('动态加载 HomeScene 失败:', err);
                    return;
                }
            });
        }, 1000);
        // console.log("进入GameScene");
        this.Block_Array = GameManager_1.default._instance.Block_Array;
        this.Wall_Prefab = GameManager_1.default._instance.Wall_Prefab;
        this.Block_Color = GameManager_1.default._instance.Block_Color;
        // this.particleEffects = GameManager._instance.particleEffects;
        this.initMap();
    };
    MapConroler.prototype.startUpdate = function () {
        if (this.gameStart == false) {
            this.gameStart = true;
            //发送数数事件——进入关卡
            console.log("准备进入下一关,发送下一关进入");
            cc.fx.GameTool.shushu_Track("enter_stage");
            this.startTimeCutDown();
            for (var i = 0; i < this.blocks.length; i++) {
                if (this.blocks[i].getComponent("Block").type == 6) {
                    this.blocks[i].getChildByName("boom").getComponent("Boom").startBoom();
                }
            }
        }
    };
    MapConroler.prototype.initMap = function () {
        // this.node.getChildByName("Wall").zIndex = 10;
        this.timeLabel = this.node.parent.getChildByName("Top").getChildByName("time");
        this.levelLabel = this.node.parent.getChildByName("Top").getChildByName("level");
        this.coin = this.node.parent.getChildByName("Top").getChildByName("coin");
        this.timeNumber = cc.fx.GameConfig.LEVEL_INFO[0].time;
        console.log("当前关卡时间", this.timeNumber);
        this.count_Time = 0;
        this.add_Time = 0;
        NumberToImage_1.default.getTimeMargin(this.timeNumber, 50, "time_", this.timeLabel);
        NumberToImage_1.default.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
        // var timeTemp = cc.fx.GameTool.getTimeMargin(this.timeNumber);
        // this.timeLabel.string = timeTemp.toString();
        NumberToImage_1.default.numberToImageNodes((cc.fx.GameConfig.GM_INFO.level + 1), 50, 20, "level_", this.levelLabel, false);
        console.log("当前关卡", cc.fx.GameConfig.GM_INFO.level + 1);
        //this.startTimeCutDown();
        this.mapWidth = cc.fx.GameConfig.LEVEL_INFO[0].map[0];
        this.mapHeight = cc.fx.GameConfig.LEVEL_INFO[0].map[1];
        var gap = cc.fx.GameConfig.LEVEL_INFO[0].gap;
        var risefall = cc.fx.GameConfig.LEVEL_INFO[0].risefall;
        this.pause = false;
        this.hammer = false;
        this.wallNum = 0;
        this.setMapInfo();
        this.blocks = [];
        this.mapBlocksWall = [];
        this.mapInfo = [];
        this.wallInfo = [];
        this.openWall = [];
        this.wallArray = [];
        this.freezeWall = [];
        this.riseFallBlcok = [];
        this.mapBlockArray = [];
        this.freezeArray = [];
        this.loackArray = [];
        this.count_Time = 0;
        this.add_Time = 0;
        var startX = this.mapWidth % 2 == 0 ? -(this.mapWidth - 1) * 60 : -(this.mapWidth - 1) * 60;
        var startY = this.mapHeight % 2 == 0 ? -(this.mapHeight - 1) * 60 : -(this.mapHeight - 1) * 60;
        // startX =(this.mapWidth-1)*60 + 60;
        // startY =-(this.mapHeight-1)*60 - 60;
        for (var i = 0; i < this.mapWidth; i++) {
            this.mapBlocksWall[i] = [];
            for (var j = 0; j < this.mapHeight; j++) {
                var block = cc.instantiate(this.MapBlockPrefab);
                block.parent = this.node.getChildByName("mapBlock");
                block.getComponent("MapBlock").init(i, j);
                // block.getChildByName("num").getComponent(cc.Label).string = i + ":" + j;
                block.setPosition(cc.v2(startX + i * 120, startY + j * 120));
                if (risefall != null) {
                    if (this.mapRiseFall(cc.v2(i, j), risefall, block)) {
                        this.riseFallBlcok.push(block);
                    }
                }
                if (gap != null) {
                    if (!this.mapGap(cc.v2(i, j), gap) || i == 0 || i == this.mapWidth - 1
                        || j == 0 || j == this.mapHeight - 1) {
                        block.opacity = 254;
                        block.removeComponent(cc.Sprite);
                        block.removeAllChildren();
                        this.wallInfo.push(block);
                    }
                    else
                        this.mapInfo.push(block);
                }
                else {
                    if (i == 0 || i == this.mapWidth - 1
                        || j == 0 || j == this.mapHeight - 1) {
                        block.opacity = 254;
                        block.removeComponent(cc.Sprite);
                        block.removeAllChildren();
                        this.wallInfo.push(block);
                    }
                    else
                        this.mapInfo.push(block);
                }
                this.mapBlocksWall[i].push(block);
            }
        }
        this.wallInit();
        this.blockInit();
    };
    //创建方块
    // ... 已有代码 ...
    //创建方块
    // ... 已有代码 ...
    MapConroler.prototype.blockInit = function () {
        var _this = this;
        var blockArray = cc.fx.GameConfig.BLOCK_INFO[0];
        blockArray = this.sortBlock(blockArray);
        console.log("创建方块", blockArray);
        var index = 0; // 当前要创建的方块索引
        var BLOCKS_PER_FRAME = 1; // 初始每帧创建的方块数量
        var MAX_PER_FRAME = 10; // 每帧最大创建数量
        var MIN_PER_FRAME = 1; // 每帧最小创建数量
        var createBlocks = function () {
            var startTime = performance.now();
            var _loop_1 = function (i) {
                var blockInfo = blockArray[index];
                // 缓存 Block_Array 访问
                var blockPrefab = _this.Block_Array[blockInfo.block];
                var block = cc.instantiate(blockPrefab);
                block.parent = _this.node;
                block.setPosition(cc.v2(blockInfo.position.x, blockInfo.position.y));
                if (blockInfo.block != 23) {
                    _this.blockNum += 1;
                    _this.blocks.push(block);
                    if (blockInfo.type == 1) {
                        var info = {
                            id: blockInfo.id + 1,
                            block: blockInfo.block,
                            color: blockInfo.stacking,
                            type: 10,
                            position: blockInfo.position,
                            stacking: blockInfo.color
                        };
                        // 缓存 Block_Array 访问
                        var blockUpPrefab = _this.Block_Array[info.block];
                        var blockUp = cc.instantiate(blockUpPrefab);
                        blockUp.parent = _this.node;
                        blockUp.setPosition(cc.v2(info.position.x, info.position.y));
                        _this.blocks.push(blockUp);
                        block.getComponent("Block").init(blockInfo, null, null, blockUp);
                        blockUp.getComponent("Block").init(info, null, null, block);
                        _this.blockNum += 1;
                    }
                    else if (blockInfo.type == 9) {
                        if (blockInfo.adhesiveTime < 2) {
                            index++;
                            return "continue";
                        }
                        index++;
                        var info_1 = blockArray[index];
                        // 缓存 Block_Array 访问
                        var blockUpPrefab = _this.Block_Array[info_1.block];
                        var blockUp_1 = cc.instantiate(blockUpPrefab);
                        blockUp_1.parent = _this.node;
                        blockUp_1.setPosition(cc.v2(info_1.position.x, info_1.position.y));
                        _this.blocks.push(blockUp_1);
                        block.getComponent("Block").init(blockInfo, null, null, blockUp_1, false);
                        setTimeout(function () {
                            blockUp_1.getComponent("Block").init(info_1, null, null, block, true);
                        }, 100);
                        _this.blockNum += 1;
                    }
                    else {
                        block.getComponent("Block").init(blockInfo);
                    }
                }
                else {
                    block.getComponent("Barrier").init(blockInfo);
                }
                index++;
            };
            for (var i = 0; i < BLOCKS_PER_FRAME && index < blockArray.length; i++) {
                _loop_1(i);
            }
            var endTime = performance.now();
            var frameTime = endTime - startTime;
            // 如果当前帧执行时间过长，减少每帧创建数量
            if (frameTime > 16) {
                BLOCKS_PER_FRAME = Math.max(BLOCKS_PER_FRAME - 1, MIN_PER_FRAME);
            }
            else {
                BLOCKS_PER_FRAME = Math.min(BLOCKS_PER_FRAME + 1, MAX_PER_FRAME);
            }
            // 如果还有方块未创建，下一帧继续创建
            if (index < blockArray.length) {
                // 使用 scheduleOnce 在下一帧执行 createBlocks
                _this.scheduleOnce(function () {
                    createBlocks();
                }, 0);
            }
            else {
            }
        };
        // 开始分帧创建方块
        createBlocks();
    };
    //给创建方块排序，用来降低drawcall 合批
    MapConroler.prototype.sortBlock = function (allBlocks) {
        return allBlocks.sort(function (a, b) {
            // 先处理 type 为 1 的情况，将其放到最后
            if (a.type === 1 && b.type !== 1) {
                return 1;
            }
            if (a.type !== 1 && b.type === 1) {
                return -1;
            }
            // 对 type 不为 0 的元素按 type 排序
            if (a.type !== 0 && b.type !== 0) {
                return a.type - b.type;
            }
            if (a.type !== 0 && b.type === 0) {
                return 1;
            }
            if (a.type === 0 && b.type !== 0) {
                return -1;
            }
            // 再处理 block 为 23 的情况，将其放到最前面
            if (a.block === 23 && b.block !== 23) {
                return -1;
            }
            if (a.block !== 23 && b.block === 23) {
                return 1;
            }
            // 其余按 color 升序排列
            return a.color - b.color;
        });
    };
    //创建墙壁
    MapConroler.prototype.wallInit = function () {
        var _this = this;
        var index = 0; // 当前要创建的墙壁索引
        var WALLS_PER_FRAME = 1; // 初始每帧创建的墙壁数量
        var MAX_PER_FRAME = 10; // 每帧最大创建数量
        var MIN_PER_FRAME = 1; // 每帧最小创建数量
        var createWalls = function () {
            var startTime = performance.now();
            for (var i = 0; i < WALLS_PER_FRAME && index < _this.wallInfo.length; i++) {
                var block = _this.wallInfo[index];
                var dir = _this.getWllDiraction("wall", cc.v2(block.getComponent("MapBlock").posX, block.getComponent("MapBlock").posY));
                if (dir != null) {
                    _this.createWall(dir, block);
                }
                index++;
            }
            var endTime = performance.now();
            var frameTime = endTime - startTime;
            // 如果当前帧执行时间过长，减少每帧创建数量
            if (frameTime > 16) {
                WALLS_PER_FRAME = Math.max(WALLS_PER_FRAME - 1, MIN_PER_FRAME);
            }
            else {
                WALLS_PER_FRAME = Math.min(WALLS_PER_FRAME + 1, MAX_PER_FRAME);
            }
            // 如果还有墙壁未创建，下一帧继续创建
            if (index < _this.wallInfo.length) {
                _this.scheduleOnce(function () {
                    createWalls();
                }, 0);
            }
            else {
                // 所有墙壁创建完成后，创建拐角节点
                _this.createCornerNodes();
            }
        };
        // 开始分帧创建墙壁
        createWalls();
    };
    // ... 已有代码 ...
    MapConroler.prototype.getWllDiraction = function (type, pointA) {
        var dir = [];
        var pointB = cc.v2(pointA.x + 1, pointA.y);
        var pointC = cc.v2(pointA.x - 1, pointA.y);
        var pointD = cc.v2(pointA.x, pointA.y + 1);
        var pointE = cc.v2(pointA.x, pointA.y - 1);
        var opacity = 0;
        if (type == "wall")
            opacity = 255;
        if (type == "turn")
            opacity = 250;
        if (pointB.x < this.mapWidth) {
            if (this.mapBlocksWall[pointB.x][pointB.y].opacity == opacity) {
                if (type == "turn" && this.mapBlocksWall[pointB.x][pointB.y].getComponent("MapBlock").direction == "right") {
                }
                else
                    dir.push("right");
            }
        }
        if (pointC.x >= 0) {
            if (this.mapBlocksWall[pointC.x][pointC.y].opacity == opacity) {
                if (type == "turn" && this.mapBlocksWall[pointC.x][pointC.y].getComponent("MapBlock").direction == "left") {
                }
                else
                    dir.push("left");
            }
        }
        if (pointD.y < this.mapHeight) {
            if (this.mapBlocksWall[pointD.x][pointD.y].opacity == opacity) {
                if (type == "turn" && this.mapBlocksWall[pointD.x][pointD.y].getComponent("MapBlock").direction == "up") {
                }
                else
                    dir.push("up");
            }
        }
        if (pointE.y >= 0) {
            if (this.mapBlocksWall[pointE.x][pointE.y].opacity == opacity) {
                if (type == "turn" && this.mapBlocksWall[pointE.x][pointE.y].getComponent("MapBlock").direction == "down") {
                }
                else
                    dir.push("down");
            }
        }
        if (dir.length > 2) {
            return null;
        }
        if (dir.length == 1) {
            if (type == "wall")
                return dir[0];
            else
                return null;
        }
        else if (dir.length == 2) {
            return dir[0] + dir[1];
        }
    };
    MapConroler.prototype.createCornerNodes = function () {
        // 定义拐角位置
        for (var i = 0; i < this.wallInfo.length; i++) {
            var block = this.wallInfo[i];
            if (block.opacity != 250) {
                var dir = this.getWllDiraction("turn", cc.v2(block.getComponent("MapBlock").posX, block.getComponent("MapBlock").posY));
                if (dir != null) {
                    this.createTurn(dir, block, block.getComponent("MapBlock").posX, block.getComponent("MapBlock").posY);
                }
            }
        }
    };
    MapConroler.prototype.createWall = function (direction, node) {
        var wall = null;
        node.getComponent("MapBlock").setDiraction(direction);
        switch (direction) {
            case "right":
                node.opacity = 250;
                wall = cc.instantiate(this.Wall_Prefab[4]);
                this.leftDoors.push(wall);
                // wall.parent = this.node.getChildByName("Wall");
                wall.parent = this.node;
                wall.setPosition(cc.v2(node.x, node.y));
                node.opacity = 250;
                wall.getChildByName("wall").getComponent("Wall").init(null, node.getComponent("MapBlock").posX, node.getComponent("MapBlock").posY, direction);
                //wall.getChildByName("wall").getChildByName("num").getComponent(cc.Label).string = this.wallNum.toString();
                this.setDoorInfo(wall.getChildByName("wall"));
                this.wallNum += 1;
                if (wall.getChildByName("wall").getComponent("Wall").special == 2)
                    this.openWall.push(wall);
                else if (wall.getChildByName("wall").getComponent("Wall").special == 3)
                    this.freezeWall.push(wall);
                break;
            case "left":
                node.opacity = 250;
                wall = cc.instantiate(this.Wall_Prefab[3]);
                // wall.parent = this.node.getChildByName("Wall");
                this.rightDoors.push(wall);
                wall.parent = this.node;
                wall.setPosition(cc.v2(node.x, node.y));
                wall.getChildByName("wall").getComponent("Wall").init(null, node.getComponent("MapBlock").posX, node.getComponent("MapBlock").posY, direction);
                this.setDoorInfo(wall.getChildByName("wall"));
                //wall.getChildByName("wall").getChildByName("num").getComponent(cc.Label).string = this.wallNum.toString();
                this.wallNum += 1;
                if (wall.getChildByName("wall").getComponent("Wall").special == 2)
                    this.openWall.push(wall);
                else if (wall.getChildByName("wall").getComponent("Wall").special == 3)
                    this.freezeWall.push(wall);
                break;
            case "up":
                node.opacity = 250;
                wall = cc.instantiate(this.Wall_Prefab[5]);
                this.topDoors.push(wall);
                // wall.parent = this.node.getChildByName("Wall");
                wall.parent = this.node;
                wall.setPosition(cc.v2(node.x, node.y));
                wall.getChildByName("wall").getComponent("Wall").init(null, node.getComponent("MapBlock").posX, node.getComponent("MapBlock").posY, direction);
                this.setDoorInfo(wall.getChildByName("wall"));
                //wall.getChildByName("wall").getChildByName("num").getComponent(cc.Label).string = this.wallNum.toString();
                this.wallNum += 1;
                if (wall.getChildByName("wall").getComponent("Wall").special == 2)
                    this.openWall.push(wall);
                else if (wall.getChildByName("wall").getComponent("Wall").special == 3)
                    this.freezeWall.push(wall);
                break;
            case "down":
                node.opacity = 250;
                wall = cc.instantiate(this.Wall_Prefab[0]);
                this.bottomDoors.push(wall);
                // wall.parent = this.node.getChildByName("Wall");
                wall.parent = this.node;
                wall.setPosition(cc.v2(node.x, node.y));
                // this.setDoorInfo(wall.getChildByName("wall"));
                wall.getChildByName("wall").getComponent("Wall").init(null, node.getComponent("MapBlock").posX, node.getComponent("MapBlock").posY, direction);
                this.setDoorInfo(wall.getChildByName("wall"));
                //wall.getChildByName("wall").getChildByName("num").getComponent(cc.Label).string = this.wallNum.toString();
                this.wallNum += 1;
                if (wall.getChildByName("wall").getComponent("Wall").special == 2)
                    this.openWall.push(wall);
                else if (wall.getChildByName("wall").getComponent("Wall").special == 3)
                    this.freezeWall.push(wall);
                break;
            case "upright":
            case "rightup":
                node.opacity = 249;
                wall = cc.instantiate(this.Wall_Prefab[7]);
                // wall.parent = this.node.getChildByName("Wall");
                wall.parent = this.node;
                wall.setPosition(cc.v2(node.x, node.y));
                wall.children[1].getComponent("Wall").init(null, node.getComponent("MapBlock").posX, node.getComponent("MapBlock").posY, direction);
                wall.children[2].getComponent("Wall").init(null, node.getComponent("MapBlock").posX, node.getComponent("MapBlock").posY, direction);
                //wall.children[0].getChildByName("num").getComponent(cc.Label).string = this.wallNum.toString();
                this.setDoorInfo(wall.children[0]);
                this.wallNum += 1;
                //wall.children[1].getChildByName("num").getComponent(cc.Label).string = this.wallNum.toString();
                this.setDoorInfo(wall.children[1]);
                this.wallNum += 1;
                break;
            case "upleft":
            case "leftup":
                node.opacity = 249;
                wall = cc.instantiate(this.Wall_Prefab[6]);
                // wall.parent = this.node.getChildByName("Wall");
                wall.parent = this.node;
                wall.setPosition(cc.v2(node.x, node.y));
                wall.children[1].getComponent("Wall").init(null, node.getComponent("MapBlock").posX, node.getComponent("MapBlock").posY, direction);
                wall.children[2].getComponent("Wall").init(null, node.getComponent("MapBlock").posX, node.getComponent("MapBlock").posY, direction);
                //wall.children[0].getChildByName("num").getComponent(cc.Label).string = this.wallNum.toString();
                this.setDoorInfo(wall.children[0]);
                this.wallNum += 1;
                //wall.children[1].getChildByName("num").getComponent(cc.Label).string = this.wallNum.toString();
                this.setDoorInfo(wall.children[1]);
                this.wallNum += 1;
                break;
            case "downright":
            case "rightdown":
                node.opacity = 249;
                wall = cc.instantiate(this.Wall_Prefab[2]);
                // wall.parent = this.node.getChildByName("Wall");
                wall.parent = this.node;
                wall.setPosition(cc.v2(node.x, node.y));
                wall.children[1].getComponent("Wall").init(null, node.getComponent("MapBlock").posX, node.getComponent("MapBlock").posY, direction);
                wall.children[2].getComponent("Wall").init(null, node.getComponent("MapBlock").posX, node.getComponent("MapBlock").posY, direction);
                //wall.children[0].getChildByName("num").getComponent(cc.Label).string = this.wallNum.toString();
                this.setDoorInfo(wall.children[0]);
                this.wallNum += 1;
                //wall.children[1].getChildByName("num").getComponent(cc.Label).string = this.wallNum.toString();
                this.setDoorInfo(wall.children[1]);
                this.wallNum += 1;
                break;
            case "downleft":
            case "leftdown":
                node.opacity = 249;
                wall = cc.instantiate(this.Wall_Prefab[1]);
                // wall.parent = this.node.getChildByName("Wall");
                wall.parent = this.node;
                wall.setPosition(cc.v2(node.x, node.y));
                wall.children[1].getComponent("Wall").init(null, node.getComponent("MapBlock").posX, node.getComponent("MapBlock").posY, direction);
                wall.children[2].getComponent("Wall").init(null, node.getComponent("MapBlock").posX, node.getComponent("MapBlock").posY, direction);
                //wall.children[0].getChildByName("num").getComponent(cc.Label).string = this.wallNum.toString();
                this.setDoorInfo(wall.children[0]);
                this.wallNum += 1;
                //wall.children[1].getChildByName("num").getComponent(cc.Label).string = this.wallNum.toString();
                this.setDoorInfo(wall.children[1]);
                this.wallNum += 1;
                break;
        }
        // if(wallTurn){
        //     wallTurn.getComponent("wallTunr").init(wall);
        // }
    };
    MapConroler.prototype.setDoorInfo = function (wall) {
        var doorInfo = cc.fx.GameConfig.WALL_INFO[0];
        if (doorInfo) {
            for (var j = 0; j < doorInfo.length; j++) {
                if (doorInfo[j].num == this.wallNum) {
                    wall.getComponent("Wall").init(doorInfo[j], null, null, null);
                    this.wallArray.push(wall.parent);
                }
            }
        }
    };
    MapConroler.prototype.createTurn = function (direction, node, posX, posY) {
        var wall = null;
        wall = cc.instantiate(this.wallTurnPrefab);
        wall.parent = this.node;
        wall.setPosition(cc.v2(node.x, node.y));
        switch (direction) {
            case "upright":
            case "rightup":
                wall.angle = 0;
                wall.getChildByName("icon").angle = 0;
                break;
            case "upleft":
            case "leftup":
                wall.angle = 90;
                wall.getChildByName("icon").angle = -90;
                wall.getChildByName("icon").y += 5;
                wall.getChildByName("icon").x -= 1.3;
                break;
            case "downright":
            case "rightdown":
                wall.angle = 270;
                wall.getChildByName("icon").angle = -270;
                wall.getChildByName("icon").x += 2.5;
                wall.getChildByName("icon").y += 1;
                break;
            case "downleft":
            case "leftdown":
                wall.angle = 180;
                wall.getChildByName("icon").angle = -180;
                wall.getChildByName("icon").x += 4.5;
                wall.getChildByName("icon").y += 3.2;
                break;
        }
        // if(direction == "rightdown" || direction == "downright") {
        //     wall.zIndex = 50 + posX - posY*3;
        // }
        // else 
        //     wall.zIndex = 50 + posX - posY*3;
        if (direction == "up" || direction == "leftup" || direction == "upleft") {
            wall.zIndex = 100 + posX - posY * 3;
        }
        else if (direction == "rightup" || direction == "upright" || direction == "rightdown" || direction == "downright" || direction == "downleft") {
            wall.zIndex = 30 + posX - posY * 3;
        }
        else if (direction == "left" || direction == "leftdown") {
            wall.zIndex = 70 + posX - posY * 3;
        }
        else
            wall.zIndex = 70 + posX - posY * 3;
        // wall.getChildByName("num").angle = -wall.angle;
        //wall.getChildByName("num").getComponent(cc.Label).string = direction;
        //wall.getChildByName("num").getComponent(cc.Label).string = wall.zIndex+ "";
        // console.log(posX,posY,wall.zIndex);
        // this.wallNum +=  1;
        // wall.getChildByName("num").getComponent(cc.Label).string = this.wallNum + "";
    };
    //地图底块缺口判断
    MapConroler.prototype.mapGap = function (point, gap) {
        for (var i = 0; i < gap.length; i++) {
            if (point.x == gap[i].x && point.y == gap[i].y) {
                return false;
            }
        }
        return true;
    };
    //升降地块判断
    MapConroler.prototype.mapRiseFall = function (point, risefall, block) {
        for (var i = 0; i < risefall.length; i++) {
            if (point.x == risefall[i].pos.x && point.y == risefall[i].pos.y) {
                block.getChildByName("risefall").active = true;
                block.getChildByName('risefall').getChildByName("color").getComponent(cc.Label).string = risefall[i].color + "";
                block.getChildByName('risefall').addComponent(cc.BoxCollider);
                block.getChildByName('risefall').getComponent(cc.BoxCollider).size = cc.size(110, 110);
                return true;
            }
        }
        return false;
    };
    //升降地块
    MapConroler.prototype.changeRiseFall = function (color, down) {
        color = color.toString();
        for (var i = 0; i < this.riseFallBlcok.length; i++) {
            if (color == this.riseFallBlcok[i].getChildByName("risefall").getChildByName("color").getComponent(cc.Label).string) {
                if (down) {
                    this.riseFallBlcok[i].getChildByName("risefall").active = false;
                    this.riseFallBlcok[i].getChildByName('risefall').removeComponent(cc.BoxCollider);
                }
                else {
                    this.riseFallBlcok[i].getChildByName("risefall").active = true;
                    this.riseFallBlcok[i].getChildByName('risefall').addComponent(cc.BoxCollider);
                    this.riseFallBlcok[i].getChildByName('risefall').getComponent(cc.BoxCollider).size = cc.size(110, 110);
                }
            }
        }
    };
    //查询叠加快id
    MapConroler.prototype.foundDownBlock = function (id) {
        for (var i = 0; i < this.blocks.length; i++) {
            if (this.blocks[i].getComponent("Block").blockId == id) {
                return this.blocks[i];
            }
        }
        return null;
    };
    //删除块
    MapConroler.prototype.removeBlock = function (id) {
        for (var i = 0; i < this.blocks.length; i++) {
            if (this.blocks[i].getComponent("Block").blockId == id) {
                return this.blocks[i];
            }
        }
        return null;
    };
    MapConroler.prototype.getMinAndMax = function (block) {
        var width = Math.floor(block.width / 120);
        var height = Math.floor(block.height / 120);
        var minX = width;
        var maxX = this.mapWidth - 2;
        var minY = 1;
        var maxY = this.mapHeight - 2 - height + 1;
        if (block.name == "block10") {
            minX = width - 1;
            if (this.mapWidth > 3)
                maxX = maxX - 1;
        }
        else if (block.name == "block11") {
            minX = width - 2;
            if (this.mapWidth > 3)
                maxX = maxX - 2;
        }
        else if (block.name == "block14") {
            minX = width - 1;
            maxX = maxX - 1;
        }
        else if (block.name == "block16") {
            minX = width - 1;
            maxX = maxX - 1;
        }
        else if (block.name == "block18") {
            minX = width - 1;
            maxX = maxX - 1;
        }
        else if (block.name == "block21") {
            minX = width - 1;
            maxX = maxX - 1;
        }
        return { minX: minX, maxX: maxX, minY: minY, maxY: maxY };
    };
    //检测落点是否可以消除
    MapConroler.prototype.checkPass = function (node, blocks) {
        var minAndMax = this.getMinAndMax(node);
        var minX = minAndMax.minX;
        var maxX = minAndMax.maxX;
        var minY = minAndMax.minY;
        var maxY = minAndMax.maxY;
        var nodePos = cc.v2(node.getComponent("Block").posX, node.getComponent("Block").posY);
        // 获取地图边界信息
        var allBlocks = [];
        for (var i = 0; i < blocks.length; i++) {
            allBlocks.push(cc.v2(nodePos.x + blocks[i].x, nodePos.y + blocks[i].y));
        }
        // const date1 = new Date().getTime();
        // console.log("将小块放入数组的时间",date1);
        var jg = -1;
        var pz = 0;
        // 获取所有墙壁节点
        // let wall = this.node;
        var direction = this.checkDiraction(allBlocks, maxX, maxY);
        // 判断方块是否在地图边缘
        if (nodePos.x <= minX || direction[0] == true) {
            // const date2 = new Date().getTime();
            // console.log("碰到左边缘",date2);
            pz += 1;
            var leftWalls = [];
            for (var i = 0; i < this.leftDoors.length; i++) {
                var wallLeft = this.leftDoors[i].getChildByName("wall");
                var wallPos = cc.v2(wallLeft.getComponent("Wall").posX, wallLeft.getComponent("Wall").posY);
                for (var i_1 = 0; i_1 < allBlocks.length; i_1++) {
                    if (allBlocks[i_1].y == wallPos.y && allBlocks[i_1].x > wallPos.x) {
                        // console.log("id:",wall.getChildByName("num").getComponent(cc.Label).string);
                        leftWalls.push(wallLeft);
                    }
                }
            }
            // console.log("得到左边墙壁数组",date6);
            if (leftWalls.length != 0) {
                var result = this.detectingBlock("left", node.getComponent("Block").posX, node.getComponent("Block").posY, allBlocks);
                if (result == true)
                    result = this.passWall(result, leftWalls, node);
                // console.log("碰到左边缘结果:",jg);
                if (result) {
                    this.blockNum -= 1;
                    this.special_Treatment(node);
                    jg = 2;
                    this.createParticle(node, jg);
                    return jg;
                }
            }
        }
        if (nodePos.x >= maxX || direction[1] == true) {
            // const date3 = new Date().getTime();
            // console.log("碰到右边缘",date3);
            pz += 1;
            var rightWalls = [];
            for (var i = 0; i < this.rightDoors.length; i++) {
                var wallRight = this.rightDoors[i].getChildByName("wall");
                var wallPos = cc.v2(wallRight.getComponent("Wall").posX, wallRight.getComponent("Wall").posY);
                for (var i_2 = 0; i_2 < allBlocks.length; i_2++) {
                    if (allBlocks[i_2].y == wallPos.y && allBlocks[i_2].x < wallPos.x) {
                        // console.log("id:",wall.getChildByName("num").getComponent(cc.Label).string);
                        rightWalls.push(wallRight);
                    }
                }
            }
            if (rightWalls.length != 0) {
                var result = this.detectingBlock("right", node.getComponent("Block").posX, node.getComponent("Block").posY, allBlocks);
                if (result == true)
                    result = this.passWall(result, rightWalls, node);
                // console.log("碰到右边缘结果:",jg);
                if (result) {
                    this.blockNum -= 1;
                    this.special_Treatment(node);
                    jg = 3;
                    this.createParticle(node, jg);
                    return jg;
                }
            }
        }
        if (nodePos.y <= minY || direction[2] == true) {
            pz += 1;
            // const date4 = new Date().getTime();
            // console.log("碰到下边缘",date4);
            var downWalls = [];
            for (var i = 0; i < this.topDoors.length; i++) {
                var wallBottom = this.topDoors[i].getChildByName("wall");
                var wallPos = cc.v2(wallBottom.getComponent("Wall").posX, wallBottom.getComponent("Wall").posY);
                for (var i_3 = 0; i_3 < allBlocks.length; i_3++) {
                    var luocha = Math.abs(allBlocks[i_3].y - wallPos.y);
                    if (allBlocks[i_3].x == wallPos.x && allBlocks[i_3].y > wallPos.y && luocha <= node.getComponent("Block").shu) {
                        // console.log("id:",wall.getChildByName("num").getComponent(cc.Label).string);
                        downWalls.push(wallBottom);
                    }
                }
            }
            if (downWalls.length != 0) {
                var result = this.detectingBlock("down", node.getComponent("Block").posX, node.getComponent("Block").posY, allBlocks);
                if (result == true)
                    result = this.passWall(result, downWalls, node);
                // console.log("碰到下边缘结果:",jg);
                if (result) {
                    this.blockNum -= 1;
                    this.special_Treatment(node);
                    jg = 1;
                    this.createParticle(node, jg);
                    return jg;
                }
            }
        }
        if (nodePos.y >= maxY || direction[3] == true) {
            pz += 1;
            // const date5 = new Date().getTime();
            // console.log("碰到上边缘",date5);
            var upWalls = [];
            for (var i = 0; i < this.bottomDoors.length; i++) {
                var wallTop = this.bottomDoors[i].getChildByName("wall");
                var wallPos = cc.v2(wallTop.getComponent("Wall").posX, wallTop.getComponent("Wall").posY);
                for (var i_4 = 0; i_4 < allBlocks.length; i_4++) {
                    var luocha = Math.abs(allBlocks[i_4].y - wallPos.y);
                    if (allBlocks[i_4].x == wallPos.x && allBlocks[i_4].y < wallPos.y && luocha <= node.getComponent("Block").shu) {
                        upWalls.push(wallTop);
                    }
                }
            }
            if (upWalls.length != 0) {
                var result = this.detectingBlock("up", node.getComponent("Block").posX, node.getComponent("Block").posY, allBlocks);
                if (result == true)
                    result = this.passWall(result, upWalls, node);
                // console.log("碰到上边缘结果:",result);
                if (result) {
                    this.blockNum -= 1;
                    this.special_Treatment(node);
                    jg = 0;
                    this.createParticle(node, jg);
                    return jg;
                }
            }
        }
        if (pz == 0)
            jg = -1;
        // const date10 = new Date().getTime();
        // console.log("所有检测结束耗时",date10,jg);
        return jg;
    };
    MapConroler.prototype.changeState = function () {
        if (this.openWall.length != 0) {
            for (var i = 0; i < this.openWall.length; i++) {
                this.openWall[i].getChildByName("wall").getComponent("Wall").changeLock();
            }
        }
        if (this.freezeWall.length != 0) {
            for (var i = 0; i < this.freezeWall.length; i++) {
                this.freezeWall[i].getChildByName("wall").getComponent("Wall").changeFreeze();
            }
        }
    };
    //检测是否可以通过门
    MapConroler.prototype.passWall = function (jg, wallArray, node) {
        for (var i = 0; i < wallArray.length; i++) {
            if (wallArray[i].getComponent("Wall").special == 2) {
                console.log("尝试通过开关门:", wallArray[i].getComponent("Wall").open);
            }
            if (wallArray[i].getComponent("Wall").special == 2 && wallArray[i].getComponent("Wall").open == false) {
                jg = false;
                break;
            }
            //console.log(wallArray[i].getChildByName("wall").getComponent("Wall").color,node.getComponent("Block").color)
            if (wallArray[i].getComponent("Wall").color != node.getComponent("Block").color) {
                jg = false;
                break;
            }
            if (node.getComponent("Block").type == 5) {
                if (wallArray[i].getComponent("Wall").special != 1) {
                    jg = false;
                    break;
                }
            }
        }
        if (jg == true && node.getComponent("Block").type == 5) {
            for (var j = 0; j < wallArray.length; j++) {
                if (wallArray[j].getComponent("Wall").special == 1 && wallArray[j].getComponent("Wall").wall_Info.length != 0) {
                    wallArray[j].getComponent("Wall").playStarDoor();
                }
            }
        }
        // const date8 = new Date().getTime();
        // console.log("检测颜色是否能够通过门",date8);
        return jg;
    };
    //检测方块和门中间有没有夹杂其他块
    MapConroler.prototype.detectingBlock = function (direction, posX, posY, blocks) {
        var jg = true;
        var id = "";
        if (blocks.length > 0) {
            for (var i = 0; i < blocks.length; i++) {
                var pos = blocks[i];
                var x = pos.x;
                var y = pos.y;
                id = this.mapBlocksWall[x][y].getComponent("MapBlock").block_Id;
                jg = this.checkAllDirections(id, direction, x, y);
                if (!jg) {
                    // console.log("方向检测没过");
                    i = 1000000;
                    return jg;
                }
            }
        }
        // const date7 = new Date().getTime();
        // console.log("方向检测通过",date7,jg);
        return jg;
    };
    //检测物体各方向是否有别的物块，防止碰到墙壁了但是是凹凸形状，墙与块之间有阻挡物块
    MapConroler.prototype.checkAllDirections = function (id, direction, x, y) {
        var jg = true;
        if (direction == "left") {
            if (this.mapBlocksWall[x - 1][y].getComponent("MapBlock").block_Id != "" && this.mapBlocksWall[x - 1][y].getComponent("MapBlock").block_Id != "Wall"
                && this.mapBlocksWall[x - 1][y].getComponent("MapBlock").block_Id != id) {
                // console.log("左侧有物体")
                jg = false;
                return jg;
            }
            if (this.mapBlocksWall[x - 1][y].opacity == 249) {
                jg = false;
                return jg;
            }
            if ((x - 2) >= 0) {
                if (this.mapBlocksWall[x - 2][y].getComponent("MapBlock").block_Id != "" && this.mapBlocksWall[x - 2][y].getComponent("MapBlock").block_Id != "Wall"
                    && this.mapBlocksWall[x - 2][y].getComponent("MapBlock").block_Id != id) {
                    // console.log("左侧有物体")
                    jg = false;
                    return jg;
                }
                if (this.mapBlocksWall[x - 2][y].opacity == 249) {
                    jg = false;
                    return jg;
                }
            }
        }
        else if (direction == "right") {
            if (this.mapBlocksWall[x + 1][y].getComponent("MapBlock").block_Id != "" && this.mapBlocksWall[x + 1][y].getComponent("MapBlock").block_Id != "Wall"
                && this.mapBlocksWall[x + 1][y].getComponent("MapBlock").block_Id != id) {
                // console.log("右侧有物体")
                jg = false;
                return jg;
            }
            if (this.mapBlocksWall[x + 1][y].opacity == 249) {
                jg = false;
                return jg;
            }
            if ((x + 2) <= this.mapBlocksWall.length - 1) {
                if (this.mapBlocksWall[x + 2][y].getComponent("MapBlock").block_Id != "" && this.mapBlocksWall[x + 2][y].getComponent("MapBlock").block_Id != "Wall"
                    && this.mapBlocksWall[x + 2][y].getComponent("MapBlock").block_Id != id) {
                    // console.log("右侧有物体")
                    jg = false;
                    return jg;
                }
                if (this.mapBlocksWall[x + 2][y].opacity == 249) {
                    jg = false;
                    return jg;
                }
            }
        }
        if (direction == "up") {
            if (this.mapBlocksWall[x][y + 1].getComponent("MapBlock").block_Id != "" && this.mapBlocksWall[x][y + 1].getComponent("MapBlock").block_Id != "Wall"
                && this.mapBlocksWall[x][y + 1].getComponent("MapBlock").block_Id != id) {
                // console.log("上侧有物体")
                jg = false;
                return jg;
            }
            if (this.mapBlocksWall[x][y + 1].opacity == 249) {
                jg = false;
                return jg;
            }
            if ((y + 2) <= this.mapBlocksWall[x].length - 1) {
                if (this.mapBlocksWall[x][y + 2].getComponent("MapBlock").block_Id != "" && this.mapBlocksWall[x][y + 2].getComponent("MapBlock").block_Id != "Wall"
                    && this.mapBlocksWall[x][y + 2].getComponent("MapBlock").block_Id != id) {
                    // console.log("上侧有物体")
                    jg = false;
                    return jg;
                }
                if (this.mapBlocksWall[x][y + 2].opacity == 249) {
                    jg = false;
                    return jg;
                }
            }
        }
        if (direction == "down") {
            if (this.mapBlocksWall[x][y - 1].getComponent("MapBlock").block_Id != "" && this.mapBlocksWall[x][y - 1].getComponent("MapBlock").block_Id != "Wall"
                && this.mapBlocksWall[x][y - 1].getComponent("MapBlock").block_Id != id) {
                // console.log("下侧有物体")
                jg = false;
                return jg;
            }
            if (this.mapBlocksWall[x][y - 1].opacity == 249) {
                jg = false;
                return jg;
            }
            if ((y - 2) >= 0) {
                if (this.mapBlocksWall[x][y - 2].getComponent("MapBlock").block_Id != "" && this.mapBlocksWall[x][y - 2].getComponent("MapBlock").block_Id != "Wall"
                    && this.mapBlocksWall[x][y - 2].getComponent("MapBlock").block_Id != id) {
                    // console.log("下侧有物体")
                    jg = false;
                    return jg;
                }
                if (this.mapBlocksWall[x][y - 2].opacity == 249) {
                    jg = false;
                    return jg;
                }
            }
        }
        // console.log("检测物体各方向是否有别的物块",jg);
        return jg;
    };
    MapConroler.prototype.checkDiraction = function (allBlocks, maxX, maxY) {
        var jg = [false, false, false, false];
        for (var i = 0; i < allBlocks.length; i++) {
            if (allBlocks[i].x > 0 && jg[0] == false) {
                if (this.mapBlocksWall[allBlocks[i].x - 1][allBlocks[i].y].opacity == 250) {
                    jg[0] = true;
                }
            }
            if (jg[1] == false) {
                if (this.mapBlocksWall[allBlocks[i].x + 1][allBlocks[i].y].opacity == 250) {
                    jg[1] = true;
                }
            }
            if (allBlocks[i].y > 0 && jg[2] == false) {
                if (this.mapBlocksWall[allBlocks[i].x][allBlocks[i].y - 1].opacity == 250) {
                    jg[2] = true;
                }
            }
            if (jg[3] == false) {
                if (this.mapBlocksWall[allBlocks[i].x][allBlocks[i].y + 1].opacity == 250) {
                    jg[3] = true;
                }
            }
        }
        return jg;
    };
    MapConroler.prototype.checkLeft = function (allBlocks) {
        var jg = false;
        return jg;
    };
    MapConroler.prototype.checkRight = function (allBlocks, max) {
        var jg = false;
        for (var i = 0; i < allBlocks.length; i++) {
        }
        return jg;
    };
    MapConroler.prototype.checkDown = function (allBlocks) {
        var jg = false;
        for (var i = 0; i < allBlocks.length; i++) {
        }
        return jg;
    };
    MapConroler.prototype.checkUp = function (allBlocks, max) {
        var jg = false;
        for (var i = 0; i < allBlocks.length; i++) {
        }
        return jg;
    };
    //特殊处理，方块带道具或者需要消除冰块
    MapConroler.prototype.special_Treatment = function (node) {
        var freezeBlock = this.node.children.filter(function (child) {
            if (child.getComponent("Block")) {
                if (child.getComponent("Block").type == 4)
                    return child;
            }
        });
        if (freezeBlock.length > 0) {
            for (var i = 0; i < freezeBlock.length; i++) {
                freezeBlock[i].getChildByName("freeze").getComponent("Freeze").reduce(1);
            }
        }
        if (node.getComponent("Block").type == 2 || node.getComponent("Block").type == 4) {
            var lockBlock = this.node.children.filter(function (child) {
                if (child.getComponent("Block")) {
                    if (child.getComponent("Block").type == 3)
                        return child;
                }
            });
            if (lockBlock.length > 0)
                for (var i = 0; i < lockBlock.length; i++) {
                    lockBlock[i].getChildByName("lock").getComponent("Lock").reduce();
                }
        }
        for (var i = 0; i < this.blocks.length; i++) {
            if (this.blocks[i] == node) {
                this.blocks.splice(i, 1);
            }
        }
    };
    //判断游戏成功下一关
    MapConroler.prototype.nextLevel = function () {
        var _this = this;
        this.pause = false;
        this.openIce();
        this.blockNum = this.blocks.length;
        if (this.blockNum == 0 && !this.gameWin && !this.gameOver) {
            // alert("游戏成功");
            this.gameWin = true;
            this.stopTimeCutDown();
            // console.log("成功消除一个");
            cc.fx.GameTool.changeCoin(40);
            cc.fx.GameTool.addLevel(this.count_Time, this.add_Time);
            this.check_NewMode();
            setTimeout(function () {
                _this.node.parent.parent.getChildByName("Win").active = true;
            }, 660);
            // console.log("游戏成功");
        }
        else {
            if (this.gameOver == true) {
                this.failLevel(null);
            }
        }
    };
    MapConroler.prototype.check_NewMode = function () {
        for (var i = 0; i < cc.fx.GameConfig.NEW_LEVEL.length; i++) {
            if ((cc.fx.GameConfig.GM_INFO.level + 1) == cc.fx.GameConfig.NEW_LEVEL[i].level) {
                this.new_mode = 3;
            }
        }
    };
    MapConroler.prototype.winLevel = function () {
        cc.fx.AudioManager._instance.playEffect("anniu_Big", null);
        if (cc.fx.GameConfig.GM_INFO.level > 156) {
            cc.fx.GameConfig.GM_INFO.level = 156;
            // MapConroler._instance = null;
            if (this.new_mode == 3) {
                this.node.parent.parent.getChildByName("Win").active = false;
                this.openNewMode(2);
                cc.fx.GameConfig.LEVEL_INFO_init(false, 0);
                return;
            }
            // cc.fx.GameConfig.LEVEL_INFO_init(true);
            cc.fx.AudioManager._instance.playEffect("zhuan1", null);
            this.node.parent.parent.parent.getChildByName("zhuanchang").active = true;
            this.node.parent.parent.parent.getChildByName("zhuanchang").getComponent(sp.Skeleton).setAnimation(1, "up", false);
            // this.node.parent.parent.parent.getChildByName("zhuanchang").getComponent(sp.Skeleton).setCompleteListener((entry) => {
            //     if (entry.animation.name === "up") {
            //         // 动画播放结束后执行的逻辑
            //         this.node.parent.parent.parent.getChildByName("zhuanchang").active = false;
            //     }
            // });
            cc.director.preloadScene("HomeScene", function (err, asset) {
                if (err) {
                    console.error('动态加载 Prefab 失败:', err);
                    return;
                }
            });
            setTimeout(function () {
                cc.director.loadScene("HomeScene");
            }, 1200);
        }
        else {
            // console.log("下一关");
            // MapConroler._instance = null;
            if (this.new_mode == 3) {
                this.node.parent.parent.getChildByName("Win").active = false;
                this.openNewMode(2);
                cc.fx.GameConfig.LEVEL_INFO_init(false, 0);
                return;
            }
            cc.fx.AudioManager._instance.playEffect("zhuan1", null);
            this.node.parent.parent.parent.getChildByName("zhuanchang").active = true;
            this.node.parent.parent.parent.getChildByName("zhuanchang").getComponent(sp.Skeleton).setAnimation(1, "up", false);
            // this.node.parent.parent.parent.getChildByName("zhuanchang").getComponent(sp.Skeleton).setCompleteListener((entry) => {
            //     if (entry.animation.name === "up") {
            //         // 动画播放结束后执行的逻辑
            //         this.node.parent.parent.parent.getChildByName("zhuanchang").active = false;
            //     }
            // });
            setTimeout(function () {
                cc.fx.GameConfig.LEVEL_INFO_init(true, 0);
            }, 1200);
            // this.node.parent.parent.parent.destroy();
        }
    };
    MapConroler.prototype.againLevel = function () {
        cc.fx.AudioManager._instance.playEffect("anniu_Big", null);
        if (cc.fx.GameConfig.GM_INFO.hp < 1) {
            MiniGameSdk_1.MiniGameSdk.API.showToast("体力值不足");
            return;
        }
        if (!this.againCanTouch)
            return;
        this.againCanTouch = false;
        // MapConroler._instance = null;
        cc.fx.AudioManager._instance.playEffect("zhuan1", null);
        this.node.parent.parent.parent.getChildByName("zhuanchang").active = true;
        this.node.parent.parent.parent.getChildByName("zhuanchang").getComponent(sp.Skeleton).setAnimation(1, "up", false);
        // this.node.parent.parent.parent.getChildByName("zhuanchang").getComponent(sp.Skeleton).setCompleteListener((entry) => {
        //     if (entry.animation.name === "up") {
        //         // 动画播放结束后执行的逻辑
        //         this.node.parent.parent.parent.getChildByName("zhuanchang").active = false;
        //     }
        // });
        setTimeout(function () {
            cc.fx.GameConfig.LEVEL_INFO_init(true, 0);
        }, 1200);
        // this.node.parent.parent.parent.destroy();
    };
    MapConroler.prototype.reviewLevel = function () {
        cc.fx.AudioManager._instance.playEffect("anniu_Big", null);
        var coin = 900;
        if (cc.fx.GameConfig.GM_INFO.review == 1)
            coin = 1900;
        else if (cc.fx.GameConfig.GM_INFO.review == 2)
            coin = 2500;
        // console.log("自身金币:",cc.fx.GameConfig.GM_INFO.coin,"消耗金币:",coin);
        if (cc.fx.GameConfig.GM_INFO.coin < Math.abs(coin)) {
            MiniGameSdk_1.MiniGameSdk.API.showToast("金币不足，无法加时间");
            return;
        }
        else {
            this.runRewive(-coin);
        }
    };
    MapConroler.prototype.runRewive = function (data) {
        console.log("复活回调函数内", data);
        cc.fx.GameTool.changeCoin(data);
        MiniGameSdk_1.MiniGameSdk.API.showToast("继续游戏");
        if (cc.fx.GameConfig.GM_INFO.review < 2)
            cc.fx.GameConfig.GM_INFO.review += 1;
        this.gameOver = false;
        this.timeNumber = 21;
        this.add_Time += 20;
        this.pause = false;
        this.node.parent.parent.getChildByName("Lose").active = false;
        this.startTimeCutDown();
    };
    MapConroler.prototype.homeBtn = function () {
        // alert("游戏失败");
        cc.fx.AudioManager._instance.playEffect("anniu_Big", null);
        if (!this.homeCanTouch)
            return;
        this.homeCanTouch = false;
        this.node.parent.parent.getChildByName("Lose").active = true;
        this.node.parent.parent.getChildByName("Lose").getChildByName("Time").active = false;
        this.node.parent.parent.getChildByName("Lose").getChildByName("Boom").active = false;
        this.node.parent.parent.getChildByName("Lose").getChildByName("Lock").active = false;
        this.node.parent.parent.getChildByName("Lose").getChildByName("Health").active = true;
        var data = {
            time: this.count_Time,
            add_Time: this.add_Time,
            result: "fail"
        };
        cc.fx.GameTool.shushu_Track("finish_stage", data);
        if (this.gameStart == true) {
            cc.fx.GameTool.setUserHealth(-1, function (data) {
            });
        }
        // this.node.parent.parent.parent.destroy();
    };
    MapConroler.prototype.returnHome = function () {
        cc.fx.AudioManager._instance.playEffect("anniu_Big", null);
        if (MapConroler_1._instance = null) {
            return;
        }
        // MiniGameSdk.API.showToast("体力值减少");
        // MapConroler._instance = null;
        cc.fx.GameConfig.LEVEL_INFO_init(false, 0);
        if (this.new_mode == 3) {
            this.node.parent.parent.getChildByName("Win").active = false;
            this.openNewMode(1);
            return;
        }
        cc.fx.AudioManager._instance.playEffect("zhuan1", null);
        this.node.parent.parent.parent.getChildByName("zhuanchang").active = true;
        this.node.parent.parent.parent.getChildByName("zhuanchang").getComponent(sp.Skeleton).setAnimation(1, "up", false);
        cc.director.preloadScene("HomeScene", function (err, asset) {
            if (err) {
                console.error('动态加载 Prefab 失败:', err);
                return;
            }
        });
        setTimeout(function () {
            cc.director.loadScene("HomeScene");
        }, 1200);
    };
    //判断游戏失败
    MapConroler.prototype.failLevel = function (type) {
        var _this = this;
        this.stopTimeCutDown();
        if (this.gameOver == true || this.gameWin == true) {
            return;
        }
        var time = 0;
        this.gameOver = true;
        if (type == "boom") {
            time = 2000;
        }
        setTimeout(function () {
            _this.node.parent.parent.getChildByName("Lose").active = true;
            _this.node.parent.parent.getChildByName("Lose").getChildByName("Time").active = true;
            _this.node.parent.parent.getChildByName("Lose").getChildByName("Boom").active = false;
            var buyBtn = _this.node.parent.parent.getChildByName("Lose").getChildByName("Time").getChildByName("buyBtn");
            buyBtn.getChildByName("coin1").active = buyBtn.getChildByName("coin2").active = buyBtn.getChildByName("coin3").active = false;
            if (cc.fx.GameConfig.GM_INFO.review == 0)
                buyBtn.getChildByName("coin1").active = true;
            else if (cc.fx.GameConfig.GM_INFO.review == 1)
                buyBtn.getChildByName("coin2").active = true;
            else if (cc.fx.GameConfig.GM_INFO.review == 2)
                buyBtn.getChildByName("coin3").active = true;
            if (type) {
                if (type == "boom") {
                    _this.node.parent.parent.getChildByName("Lose").getChildByName("Time").active = false;
                    _this.node.parent.parent.getChildByName("Lose").getChildByName("Boom").active = true;
                }
            }
        }, time);
        // console.log("游戏失败");
    };
    //打开新模式弹窗
    MapConroler.prototype.openNewMode = function (type) {
        var _this = this;
        var index = 0;
        var BLOCKS_PER_FRAME = 5; // 每帧销毁的方块数量
        var destroyBlocks = function () {
            var endIndex = Math.min(index + BLOCKS_PER_FRAME, _this.blocks.length);
            for (; index < endIndex; index++) {
                if (_this.blocks[index]) {
                    _this.blocks[index].destroy();
                }
            }
            // 如果还有方块未销毁，下一帧继续
            if (index < _this.blocks.length) {
                _this.scheduleOnce(destroyBlocks, 0);
            }
            else {
            }
        };
        // 开始分帧销毁方块
        destroyBlocks();
        this.node.parent.parent.getChildByName("NewMode").active = true;
        this.node.parent.parent.getChildByName("NewMode").getComponent("NewMode").setMode(type);
    };
    MapConroler.prototype.downDoor = function (color, type) {
        for (var i = 0; i < this.wallArray.length; i++) {
            if (this.wallArray[i].getChildByName("wall").getComponent("Wall").color == color) {
                if (type) {
                    if (type == 5) {
                        if (this.wallArray[i].getChildByName("wall").getComponent("Wall").special == 1) {
                            this.wallArray[i].getChildByName("wall").getComponent("Wall").downDoor();
                        }
                    }
                    else
                        this.wallArray[i].getChildByName("wall").getComponent("Wall").downDoor();
                }
                else
                    this.wallArray[i].getChildByName("wall").getComponent("Wall").downDoor();
            }
        }
    };
    MapConroler.prototype.upDoor = function () {
        for (var i = 0; i < this.wallArray.length; i++) {
            if (this.wallArray[i].getChildByName("wall").opacity == 0) {
                this.wallArray[i].getChildByName("wall").getComponent("Wall").upDoor();
            }
        }
    };
    //开始倒计时
    MapConroler.prototype.startTimeCutDown = function () {
        this.scheduleCallback = function () {
            if (this.pause)
                return;
            if (this.timeNumber <= 0) {
                this.stopTimeCutDown();
                var timeTemp = cc.fx.GameTool.getTimeMargin(this.timeNumber);
                NumberToImage_1.default.getTimeMargin(this.timeNumber, 50, "time_", this.timeLabel);
                // this.timeLabel.string = timeTemp.toString();
                if (!this.pause)
                    this.failLevel("time");
            }
            else {
                this.timeNumber -= 1;
                this.count_Time += 1;
                var timeTemp = cc.fx.GameTool.getTimeMargin(this.timeNumber);
                NumberToImage_1.default.getTimeMargin(this.timeNumber, 50, "time_", this.timeLabel);
                // this.timeLabel.string = timeTemp.toString();
            }
        }.bind(this);
        this.schedule(this.scheduleCallback, 1);
    };
    // 停止倒计时
    MapConroler.prototype.stopTimeCutDown = function () {
        if (this.scheduleCallback) {
            this.unschedule(this.scheduleCallback);
        }
    };
    //使用时间道具
    MapConroler.prototype.useTimeProp = function () {
        if (this.node.parent.getChildByName("Ice").active == true || this.hammer == true
            || this.magicMask.active == true || this.timeNumber <= 1) {
            return;
        }
        var freezeBtn = this.node.parent.getChildByName("Bottom").getChildByName("timeBtn");
        if (freezeBtn.getComponent("btnControl")._touch) {
            freezeBtn.getComponent("btnControl").setTouch(false);
            if (cc.fx.GameConfig.GM_INFO.freezeAmount < 1) {
                if (cc.fx.GameConfig.GM_INFO.coin < 1500) {
                    MiniGameSdk_1.MiniGameSdk.API.showToast("金币不足，无法购买道具");
                    freezeBtn.getComponent("btnControl").setTouch(true);
                    return;
                }
                this.node.parent.parent.getChildByName("propWindow").active = true;
                this.node.parent.parent.parent.getComponent("SceneManager").openPropBuy("freeze");
            }
            else {
                if (!this.node.parent.getChildByName("Ice").active && !this.pause) {
                    var timestamp = Date.now();
                    this.freezeMask.active = true;
                    this.pause = true;
                    this.node.parent.getChildByName("Ice").active = true;
                    this.node.parent.getChildByName("Top").getChildByName("Ice").active = true;
                    cc.fx.GameConfig.GM_INFO.freezeAmount -= 1;
                    if (cc.fx.GameConfig.GM_INFO.freezeAmount < 0)
                        cc.fx.GameConfig.GM_INFO.freezeAmount = 0;
                    this.iceLabel.string = cc.fx.GameConfig.GM_INFO.freezeAmount.toString();
                    var propInfo = cc.fx.StorageMessage.getStorage("prop");
                    propInfo.freezeAmount = cc.fx.GameConfig.GM_INFO.freezeAmount;
                    propInfo.timestamp = timestamp;
                    cc.fx.StorageMessage.setStorage("prop", propInfo);
                    cc.fx.GameTool.setUserProp(2001, cc.fx.GameConfig.GM_INFO.freezeAmount, function (data) {
                    });
                    var data = {
                        id: "2001",
                        num: -1
                    };
                    cc.fx.GameTool.shushu_Track("resource_cost", data);
                }
                else
                    MiniGameSdk_1.MiniGameSdk.API.showToast("道具使用中，请稍后再试");
            }
        }
    };
    //解开时间冻结
    MapConroler.prototype.openIce = function () {
        if (this.node.parent.getChildByName("Ice").active) {
            this.freezeMask.active = false;
            var freezeBtn = this.node.parent.getChildByName("Bottom").getChildByName("timeBtn");
            freezeBtn.getComponent("btnControl").setTouch(true);
            this.node.parent.getChildByName("Ice").active = false;
            this.node.parent.getChildByName("Top").getChildByName("Ice").active = false;
            this.pause = false;
            // this.startTimeCutDown();
        }
    };
    MapConroler.prototype.handleBuySuccess = function (data) {
        var _this = this;
        this.pause = false;
        var timestamp = Date.now();
        // console.log("回调函数内:",this.pause);
        var freezeBtn = this.node.parent.getChildByName("Bottom").getChildByName("timeBtn");
        var hammerBtn = this.node.parent.getChildByName("Bottom").getChildByName("destroyBtn");
        var magicBtn = this.node.parent.getChildByName("Bottom").getChildByName("magicBtn");
        if (data == "freezeAmount")
            freezeBtn.getComponent("btnControl").setTouch(true);
        else if (data == "hammerAmount")
            hammerBtn.getComponent("btnControl").setTouch(true);
        else if (data == "magicAmount")
            magicBtn.getComponent("btnControl").setTouch(true);
        if (data == "freezeAmount") {
            cc.fx.GameConfig.GM_INFO.freezeAmount += 3;
            var propInfo = cc.fx.StorageMessage.getStorage("prop");
            propInfo.freezeAmount = cc.fx.GameConfig.GM_INFO.freezeAmount;
            propInfo.timestamp = timestamp;
            cc.fx.StorageMessage.setStorage("prop", propInfo);
            this.node.parent.parent.parent.getComponent("SceneManager").closePropBuy();
            setTimeout(function () {
                _this.iceLabel.string = cc.fx.GameConfig.GM_INFO.freezeAmount.toString();
                MiniGameSdk_1.MiniGameSdk.API.showToast("购买冻结时间道具成功");
            }, 200);
        }
        else if (data == "magicAmount") {
            cc.fx.GameConfig.GM_INFO.magicAmount += 3;
            var propInfo = cc.fx.StorageMessage.getStorage("prop");
            propInfo.magicAmount = cc.fx.GameConfig.GM_INFO.magicAmount;
            propInfo.timestamp = timestamp;
            cc.fx.StorageMessage.setStorage("prop", propInfo);
            this.node.parent.parent.parent.getComponent("SceneManager").closePropBuy();
            setTimeout(function () {
                MiniGameSdk_1.MiniGameSdk.API.showToast("购买锤子道具成功");
                _this.magicLabel.string = cc.fx.GameConfig.GM_INFO.magicAmount.toString();
            }, 200);
        }
        else if (data == "hammerAmount") {
            cc.fx.GameConfig.GM_INFO.hammerAmount += 3;
            var propInfo = cc.fx.StorageMessage.getStorage("prop");
            propInfo.hammerAmount = cc.fx.GameConfig.GM_INFO.hammerAmount;
            propInfo.timestamp = timestamp;
            cc.fx.StorageMessage.setStorage("prop", propInfo);
            this.node.parent.parent.parent.getComponent("SceneManager").closePropBuy();
            setTimeout(function () {
                _this.hammerLabel.string = cc.fx.GameConfig.GM_INFO.hammerAmount.toString();
                MiniGameSdk_1.MiniGameSdk.API.showToast("购买魔法棒道具成功");
            }, 200);
        }
    };
    //使用锤子道具
    MapConroler.prototype.useHammer = function () {
        if (this.node.parent.getChildByName("Ice").active == true || this.hammer == true
            || this.magicMask.active == true || this.timeNumber <= 1) {
            return;
        }
        var hammerBtn = this.node.parent.getChildByName("Bottom").getChildByName("destroyBtn");
        if (hammerBtn.getComponent("btnControl")._touch) {
            hammerBtn.getComponent("btnControl").setTouch(false);
            if (cc.fx.GameConfig.GM_INFO.hammerAmount < 1) {
                if (cc.fx.GameConfig.GM_INFO.coin < 1500) {
                    MiniGameSdk_1.MiniGameSdk.API.showToast("金币不足，无法购买道具");
                    hammerBtn.getComponent("btnControl").setTouch(true);
                    return;
                }
                this.node.parent.parent.getChildByName("propWindow").active = true;
                this.node.parent.parent.parent.getComponent("SceneManager").openPropBuy("hammer");
            }
            else {
                if (!this.hammer) {
                    var timestamp = Date.now();
                    this.hammerMask.active = true;
                    this.hammer = true;
                    cc.fx.GameConfig.GM_INFO.hammerAmount -= 1;
                    if (cc.fx.GameConfig.GM_INFO.hammerAmount < 0)
                        cc.fx.GameConfig.GM_INFO.hammerAmount = 0;
                    this.hammerLabel.string = cc.fx.GameConfig.GM_INFO.hammerAmount.toString();
                    var propInfo = cc.fx.StorageMessage.getStorage("prop");
                    console.log("锤子道具信息:", propInfo);
                    propInfo.hammerAmount = cc.fx.GameConfig.GM_INFO.hammerAmount;
                    propInfo.timestamp = timestamp;
                    cc.fx.StorageMessage.setStorage("prop", propInfo);
                    cc.fx.GameTool.setUserProp(2002, cc.fx.GameConfig.GM_INFO.hammerAmount, function (data) {
                    });
                    var data = {
                        id: "2002",
                        num: -1
                    };
                    cc.fx.GameTool.shushu_Track("resource_cost", data);
                }
                else
                    MiniGameSdk_1.MiniGameSdk.API.showToast("道具使用中，请稍后再试");
            }
        }
    };
    MapConroler.prototype.buyMagic = function () {
        if (cc.fx.GameConfig.GM_INFO.coin < 1500) {
            MiniGameSdk_1.MiniGameSdk.API.showToast("金币不足，无法购买道具");
            return;
        }
        cc.fx.GameTool.buyProp(2003, this.handleBuySuccess.bind(this, "magicAmount"));
    };
    MapConroler.prototype.buyHammer = function () {
        if (cc.fx.GameConfig.GM_INFO.coin < 1500) {
            MiniGameSdk_1.MiniGameSdk.API.showToast("金币不足，无法购买道具");
            return;
        }
        cc.fx.GameTool.buyProp(2002, this.handleBuySuccess.bind(this, "hammerAmount"));
    };
    MapConroler.prototype.buyFreeze = function () {
        if (cc.fx.GameConfig.GM_INFO.coin < 1500) {
            MiniGameSdk_1.MiniGameSdk.API.showToast("金币不足，无法购买道具");
            return;
        }
        cc.fx.GameTool.buyProp(2001, this.handleBuySuccess.bind(this, "freezeAmount"));
    };
    //使用魔法棒随机消除两个方块
    MapConroler.prototype.useMagic = function () {
        var _this = this;
        if (this.node.parent.getChildByName("Ice").active == true || this.hammer == true
            || this.magicMask.active == true || this.timeNumber <= 1) {
            return;
        }
        var magicBtn = this.node.parent.getChildByName("Bottom").getChildByName("magicBtn");
        if (magicBtn.getComponent("btnControl")._touch) {
            magicBtn.getComponent("btnControl").setTouch(false);
            if (cc.fx.GameConfig.GM_INFO.magicAmount < 1) {
                if (cc.fx.GameConfig.GM_INFO.coin < 1500) {
                    MiniGameSdk_1.MiniGameSdk.API.showToast("金币不足，无法购买道具");
                    magicBtn.getComponent("btnControl").setTouch(true);
                    return;
                }
                this.node.parent.parent.getChildByName("propWindow").active = true;
                this.node.parent.parent.parent.getComponent("SceneManager").openPropBuy("magic");
                // MiniGameSdk.API.showToast("魔法棒数量不足,自动购买魔法棒");
            }
            else {
                var timestamp = Date.now();
                this.magicMask.active = true;
                setTimeout(function () {
                    _this.magicMask.active = false;
                    magicBtn.getComponent("btnControl").setTouch(true);
                }, 1000);
                cc.fx.GameConfig.GM_INFO.magicAmount -= 1;
                if (cc.fx.GameConfig.GM_INFO.magicAmount < 0)
                    cc.fx.GameConfig.GM_INFO.magicAmount = 0;
                this.magicLabel.string = cc.fx.GameConfig.GM_INFO.magicAmount.toString();
                var propInfo = cc.fx.StorageMessage.getStorage("prop");
                propInfo.magicAmount = cc.fx.GameConfig.GM_INFO.magicAmount;
                propInfo.timestamp = timestamp;
                cc.fx.StorageMessage.setStorage("prop", propInfo);
                cc.fx.GameTool.setUserProp(2003, cc.fx.GameConfig.GM_INFO.magicAmount, function (data) {
                });
                var data = {
                    id: "2003",
                    num: -1
                };
                cc.fx.GameTool.shushu_Track("resource_cost", data);
                var nomalArray_1 = [];
                // this.magicBtn.node.active = false;
                for (var i = 0; i < this.blocks.length; i++) {
                    // console.log("方块类型",this.blocks[i].getComponent("Block").type);
                    if (this.blocks[i].getComponent("Block").type == 3) {
                        this.loackArray.push(this.blocks[i]);
                    }
                    else if (this.blocks[i].getComponent("Block").type == 4) {
                        this.freezeArray.push(this.blocks[i]);
                    }
                    else if (this.blocks[i].getComponent("Block").type == 10) {
                        if (this.blocks[i].getComponent("Block").block_Info.node) {
                            nomalArray_1.push(this.blocks[i].getComponent("Block").block_Info.node);
                        }
                        else
                            nomalArray_1.push(this.blocks[i]);
                    }
                    else {
                        nomalArray_1.push(this.blocks[i]);
                    }
                }
                if (nomalArray_1.length > 1) {
                    nomalArray_1 = cc.fx.GameTool.shuffleArray(nomalArray_1);
                    nomalArray_1[0].getComponent("Block").eliminate();
                    var time = 0;
                    if (nomalArray_1[0].getComponent("Block").type == 1 || nomalArray_1[0].getComponent("Block").type == 9) {
                        time = 200;
                    }
                    if (time > 0) {
                        setTimeout(function () {
                            nomalArray_1[1].getComponent("Block").eliminate();
                        }, time);
                        return;
                    }
                    else {
                        nomalArray_1[1].getComponent("Block").eliminate();
                        return;
                    }
                }
                else if (nomalArray_1.length == 1) {
                    nomalArray_1[0].getComponent("Block").eliminate();
                    var time = 0;
                    if (nomalArray_1[0].getComponent("Block").type == 1 || nomalArray_1[0].getComponent("Block").type == 9) {
                        time = 200;
                    }
                    setTimeout(function () {
                        if (_this.freezeArray.length == 0 && _this.loackArray.length == 0) {
                            // console.log("只剩下一个块道具使用完毕");
                        }
                        else {
                            if (_this.loackArray.length != 0) {
                                // console.log("消除一个普通块后，消除一个带锁块");
                                _this.loackArray[0].getComponent("Block").eliminate();
                                return;
                            }
                            else if (_this.freezeArray.length != 0) {
                                // console.log("消除一个普通块后，消除一个冻结块");
                                _this.freezeArray[0].getComponent("Block").eliminate();
                                return;
                            }
                        }
                    }, 200 + time);
                }
                else {
                    var count_1 = 2;
                    if (this.loackArray.length != 0) {
                        for (var i = 0; i < this.loackArray.length; i++) {
                            // console.log("没有普通快，魔法消除一个带锁块");
                            this.loackArray[i].getComponent("Block").eliminate();
                            count_1 -= 1;
                            if (count_1 == 0) {
                                break;
                            }
                        }
                    }
                    setTimeout(function () {
                        if (count_1 != 0) {
                            for (var i = 0; i < _this.freezeArray.length; i++) {
                                // console.log("没有普通快，魔法消除一个冻结块");
                                // this.freezeArray[i].getComponent("Block").eliminate();
                                count_1 -= 1;
                                if (count_1 == 0) {
                                    break;
                                }
                            }
                        }
                    }, 100);
                }
            }
        }
    };
    //按下暂停按钮
    MapConroler.prototype.usePause = function () {
        if (this.pause) {
            this.pause = false;
        }
        else {
            this.pause = true;
        }
    };
    //根据关卡设置地图大小
    MapConroler.prototype.setMapInfo = function () {
        var width = 0;
        if (this.mapWidth < 10) {
            width = 0.2;
        }
        else if (this.mapWidth < 17) {
            width = 0.15 - (this.mapWidth - 11) * 0.01;
        }
        this.node.scale = 1.6 + (6 - this.mapWidth) * width;
        if (this.mapWidth == 8 && this.mapHeight > 13) {
            this.node.scale = 1;
        }
        // this.node.scale = 1;
        cc.fx.GameConfig.GM_INFO.scale = this.node.scale;
        // this.node.scale = 0.5;
        // console.log(this.node.scale);
        // this.node.scale = 1;
    };
    //创建门的粒子特效
    MapConroler.prototype.createParticle = function (block, jg) {
        var particle = cc.instantiate(MapConroler_1._instance.Block_Prop[9]);
        particle.parent = this.node;
        particle.zIndex = 1000;
        var width = Math.floor(block.width / 120);
        var height = Math.floor(block.height / 120);
        var name = "";
        if (jg == 0 || jg == 1) {
            var y = block.y + block.height;
            var x = block.x - block.width / 2;
            name = "top_" + width + "_" + height;
            if (jg == 1) {
                name = "bot_" + width + "_" + height;
                y = block.y;
            }
            if (block.anchorX == 0.5) {
                x = block.x;
            }
            else if (block.anchorX == 0.33) {
                x = block.x + block.width * (0.5 - 0.33);
            }
            else if (block.anchorX == 0.66) {
                x = block.x + block.width * (0.5 - 0.66);
            }
            particle.setPosition(x, y);
        }
        else if (jg == 2 || jg == 3) {
            name = "left_" + height + "_" + width;
            var x = block.x - block.width;
            var y = block.y + block.height / 2;
            if (block.anchorX == 0.5) {
                x = block.x - block.width / 2;
            }
            else if (block.anchorX == 0.33) {
                x = block.x - block.width * 0.33;
            }
            else if (block.anchorX == 0.66) {
                x = block.x + block.width * 0.66;
            }
            if (jg == 3) {
                name = "right_" + height + "_" + width;
                x = block.x;
                if (block.anchorX == 0.5) {
                    x = block.x + block.width / 2;
                }
                else if (block.anchorX == 0.33) {
                    x = block.x + block.width * 0.66;
                }
                else if (block.anchorX == 0.66) {
                    x = block.x + block.width * 0.33;
                }
            }
            particle.setPosition(x, y);
        }
        var particleNode = particle.getChildByName(name);
        var color = block.getComponent("Block").color - 1;
        particleNode.getComponent(cc.ParticleSystem).spriteFrame = particle.getComponent("Reduce").Block_Color[color];
        particleNode.active = true;
        setTimeout(function () {
            cc.tween(particle)
                .to(2, { opacity: 0 })
                .call(function () {
                particle.destroy();
            })
                .start();
        }, 1200);
    };
    MapConroler.prototype.removeOneBlock = function () {
        // 移除所有方块
        for (var i = 0; i < this.blocks.length; i++) {
            if (this.blocks[i].opacity == 0) {
                this.blocks[i].destroy();
                this.blocks.splice(i, 1);
            }
        }
    };
    MapConroler.prototype.update = function (dt) {
    };
    var MapConroler_1;
    __decorate([
        property({ type: [cc.Prefab], tooltip: "方块数组" })
    ], MapConroler.prototype, "Block_Array", void 0);
    __decorate([
        property({ type: [cc.Prefab], tooltip: "方块道具数组" })
    ], MapConroler.prototype, "Block_Prop", void 0);
    __decorate([
        property(cc.Prefab)
    ], MapConroler.prototype, "MapBlockPrefab", void 0);
    __decorate([
        property({ type: [cc.SpriteAtlas], tooltip: "方块颜色" })
    ], MapConroler.prototype, "Block_Color", void 0);
    __decorate([
        property({ type: [cc.Prefab], tooltip: "墙壁数组" })
    ], MapConroler.prototype, "Wall_Prefab", void 0);
    __decorate([
        property(cc.Prefab)
    ], MapConroler.prototype, "wallTurnPrefab", void 0);
    __decorate([
        property(cc.Button)
    ], MapConroler.prototype, "timeBtn", void 0);
    __decorate([
        property(cc.Button)
    ], MapConroler.prototype, "destroyBtn", void 0);
    __decorate([
        property(cc.Button)
    ], MapConroler.prototype, "magicBtn", void 0);
    __decorate([
        property(cc.Node)
    ], MapConroler.prototype, "mask", void 0);
    __decorate([
        property(cc.Label)
    ], MapConroler.prototype, "iceLabel", void 0);
    __decorate([
        property(cc.Label)
    ], MapConroler.prototype, "hammerLabel", void 0);
    __decorate([
        property(cc.Label)
    ], MapConroler.prototype, "magicLabel", void 0);
    __decorate([
        property(cc.Node)
    ], MapConroler.prototype, "magicMask", void 0);
    __decorate([
        property(cc.Node)
    ], MapConroler.prototype, "hammerMask", void 0);
    __decorate([
        property(cc.Node)
    ], MapConroler.prototype, "freezeMask", void 0);
    __decorate([
        property(cc.Node)
    ], MapConroler.prototype, "coinPop", void 0);
    MapConroler = MapConroler_1 = __decorate([
        ccclass
    ], MapConroler);
    return MapConroler;
}(cc.Component));
exports.default = MapConroler;

cc._RF.pop();
                    }
                    if (nodeEnv) {
                        __define(__module.exports, __require, __module);
                    }
                    else {
                        __quick_compile_project__.registerModuleFunc(__filename, function () {
                            __define(__module.exports, __require, __module);
                        });
                    }
                })();
//# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 226220 characters]