
                (function() {
                    var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined';
                    var __module = nodeEnv ? module : {exports:{}};
                    var __filename = 'preview-scripts/assets/Script/GameManager.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, 'b0432BA295DjIOcuitdGKO1', 'GameManager');
// Script/GameManager.ts

"use strict";
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 Block_1 = require("./Block");
// 主游戏控制类
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var GameManager = /** @class */ (function (_super) {
    __extends(GameManager, _super);
    function GameManager() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.Map = null;
        _this.Block = null;
        _this.Time = null;
        _this.Countdown = null;
        _this.Guide = null;
        return _this;
    }
    GameManager.prototype.onLoad = function () {
    };
    GameManager.prototype.start = function () {
        cc.fx.GameConfig.CLICK_init();
        this.fit();
        this.init();
    };
    //处理地图数据 第一关完全随机，从第二关开始，赢了根据5秒洪峰来临增加难度步数，输了当前难度减步数
    GameManager.prototype.getMap = function () {
        var custom = 0;
        var map = [];
        if (cc.fx.GameConfig.GM_INFO.level == 1) {
            custom = Math.floor(Math.random() * cc.fx.GameConfig.LEVEL_INFO[cc.fx.GameConfig.GM_INFO.level].length);
        }
        else {
            var arr = cc.fx.GameConfig.LEVEL_INFO[cc.fx.GameConfig.GM_INFO.level];
            if (cc.fx.GameConfig.GM_INFO.min_Time == -1) {
                map = this.getMapArray(arr, cc.fx.GameConfig.GM_INFO.min_Steps - 1, false);
            }
            else if (cc.fx.GameConfig.GM_INFO.min_Time >= 5) {
                map = this.getMapArray(arr, cc.fx.GameConfig.GM_INFO.min_Steps + 2, true);
            }
            else {
                map = this.getMapArray(arr, cc.fx.GameConfig.GM_INFO.min_Steps + 1, true);
            }
            var random = Math.floor(Math.random() * map.length);
            custom = map[random];
            // console.log(custom,map);
        }
        //记录当前最小步数
        cc.fx.GameConfig.GM_INFO.min_Steps = cc.fx.GameConfig.LEVEL_INFO[cc.fx.GameConfig.GM_INFO.level][custom].min_steps;
        cc.fx.GameConfig.GM_INFO.min_Time = 0;
        return custom;
    };
    /**
    * 获取下一关难度，步数增加2或者1，如果没有则降到有.
    * @param arr 配置里读取，当前（x*x）地图等级内所有地图数组
    * @param min_steps 最佳步数，下一关难度或者输了降难度，根据最佳步数增加或者减少。
    * @param type  true为增加步数，false为输了降低难度步数
    */
    GameManager.prototype.getMapArray = function (arr, min_steps, type) {
        var map = [];
        for (var i = 0; i < arr.length; i++) {
            if (arr[i].min_steps == min_steps) {
                map.push(i);
            }
        }
        if (map.length == 0) {
            if (type)
                map = this.getMapArray(arr, min_steps - 1, type);
            else
                map = this.getMapArray(arr, min_steps + 1, type);
        }
        return map;
    };
    //初始化数据
    GameManager.prototype.init = function () {
        var name = cc.fx.GameConfig.GM_INFO.gameId + "_guide";
        var data = JSON.parse(localStorage.getItem(name));
        if (data != false) {
            cc.fx.GameConfig.GM_INFO.guide = true;
            cc.fx.StorageMessage.setStorage(name, cc.fx.GameConfig.GM_INFO.guide);
        }
        else {
            cc.fx.GameConfig.GM_INFO.guide = cc.fx.StorageMessage.getStorage(name);
        }
        this.initMap();
        this.finishiTime = 0;
        this.scoreTime = 0;
        this.replaceTime = 0;
        this.startTime = cc.fx.GameTool.getTime();
        this.countTime = cc.fx.GameConfig.TIME_INFO.totalTime;
        if (this.countTime == 0) {
            this.gameOver();
        }
        this.waterTime = cc.fx.GameConfig.TIME_INFO.waterTime[cc.fx.GameConfig.GM_INFO.level];
        // if(this.countTime < this.waterTime) this.replaceTime = this.countTime;
        this.Time.string = cc.fx.GameTool.getTimeMargin(this.countTime);
        if (!cc.fx.GameConfig.GM_INFO.guide) {
            this.Guide.active = false;
            this.step = 0;
            var head = this.node.getChildByName("Top").getChildByName("head");
            var progress = this.node.getChildByName("Top").getChildByName("progress").getComponent(cc.Sprite);
            head.runAction(cc.moveTo(this.waterTime, cc.v2(310, head.y)));
            this.waterTween = cc.tween(progress)
                .to(this.waterTime, { fillRange: 1 })
                .start();
            this.schedule(this.updateWaterTime, 1);
            this.schedule(this.updateCountDownTime, 1);
        }
        else {
            this.Guide.active = true;
            this.guideNext();
        }
    };
    //初始化地图
    GameManager.prototype.initMap = function () {
        cc.fx.GameConfig.GM_INFO.round += 1;
        cc.fx.GameConfig.GM_INFO.fen = 0;
        this.block_Array = [];
        this.path_Array = [];
        this.water_Array = [];
        this.map_Array = [];
        this.tip_Array = [];
        this.plan_over = false;
        this.map_Hight = 0;
        this.map_Width = 0;
        this.step = 0;
        this.bgClick = false;
        this.btnClick = false;
        this.custom = 0; //9
        if (!cc.fx.GameConfig.GM_INFO.guide && cc.fx.GameConfig.GM_INFO.level == 0) {
            cc.fx.GameConfig.GM_INFO.level = 1;
            this.custom = this.getMap();
        }
        else if (!cc.fx.GameConfig.GM_INFO.guide) {
            this.custom = this.getMap();
        }
        // this.custom = 7;
        // console.log(this.custom);
        var arr = cc.fx.GameConfig.LEVEL_INFO[cc.fx.GameConfig.GM_INFO.level][this.custom].map;
        if (cc.fx.GameConfig.GM_INFO.level == 0) {
            this.Map.scale = 1.2;
        }
        this.node.getChildByName("Top").getChildByName("id").getComponent(cc.Label).string =
            cc.fx.GameConfig.GM_INFO.score;
        //将地图x,y轴切换
        this.map_Array = arr[0].map(function (item, i) {
            return arr.map(function (val) { return val[i]; });
        });
        this.map_Width = this.map_Array.length;
        this.map_Hight = this.map_Array[0].length;
        this.Map.x = (6 - this.map_Array.length) * 48;
        this.Map.y = (this.map_Array[0].length - 6.5) * 48;
        for (var i = 0; i < this.map_Array.length; i++) {
            for (var j = 0; j < this.map_Array[i].length; j++) {
                var block = cc.instantiate(this.Block);
                block.parent = this.Map;
                block.getComponent("Block").initData(this.map_Array[i][j], cc.v2(i, j), cc.v2(this.map_Width, this.map_Hight));
                if (this.map_Array[i][j] == cc.Enum(Block_1.BlockType).Start) {
                    this.path_Array.push(cc.v3(i, j, cc.Enum(Block_1.BlockType).Nomal));
                    // this.water_Array.push(cc.v3(i,j,cc.Enum(BlockType).Nomal));
                }
                block.setPosition(cc.v2(-block.width * 2.5 + i * block.width, block.height * 4 - j * block.height));
                this.block_Array.push(block);
            }
        }
    };
    /**
    * 开始后，按玩家操作，将路径中地图块放入数组中
    * @param data 根据当前操作，添加建筑地图数组
    */
    GameManager.prototype.setMap = function (data) {
        for (var i = 0; i < data.length; i++) {
            var start = this.path_Array[this.path_Array.length - 1];
            switch (data[i]) {
                case "up":
                    this.path_Array.push(cc.v3(start.x, start.y - 1, cc.Enum(Block_1.BlockType).Nomal));
                    break;
                case "down":
                    this.path_Array.push(cc.v3(start.x, start.y + 1, cc.Enum(Block_1.BlockType).Nomal));
                    break;
                case "left":
                    this.path_Array.push(cc.v3(start.x - 1, start.y, cc.Enum(Block_1.BlockType).Nomal));
                    break;
                case "right":
                    this.path_Array.push(cc.v3(start.x + 1, start.y, cc.Enum(Block_1.BlockType).Nomal));
                    break;
                case "reinforce":
                    this.path_Array.push(cc.v3(start.x, start.y, cc.Enum(Block_1.BlockType).Reinforce));
                    break;
                case "soil":
                    this.path_Array.push(cc.v3(start.x, start.y, cc.Enum(Block_1.BlockType).Xi_Soil));
                    break;
            }
        }
        if (this.path_Array[this.path_Array.length - 1].z != 0) {
            this.path_Array.pop();
        }
        this.runRoad(0);
    };
    /**
     * 开始执行洪峰来了的动画
     * @param order 建筑地图数组里的执行的序列号，依次往下加
     */
    GameManager.prototype.runRoad = function (order) {
        var _this = this;
        order = parseInt(order);
        if (order > 0) {
            if (this.path_Array[order - 1].z == 0) {
                //console.log("1正常放入",this.path_Array[order-1].x,this.path_Array[order-1].y,this.path_Array[order-1].z)
                this.changeWater(cc.v3(this.path_Array[order - 1].x, this.path_Array[order - 1].y, 0));
                if (order == this.path_Array.length - 1) {
                    this.changeWater(cc.v3(this.path_Array[order].x, this.path_Array[order].y, 0));
                    // console.log("最后放入",this.path_Array[order].x,this.path_Array[order].y)
                }
            }
            else {
                //console.log("2插入",this.path_Array[order].x,this.path_Array[order].y,this.path_Array[order].z)
                this.changeWater(cc.v3(this.path_Array[order].x, this.path_Array[order].y, 0));
            }
        }
        if (order <= this.path_Array.length - 1) {
            var i = this.path_Array[order].x * this.map_Array[0].length + this.path_Array[order].y;
            var direction = "";
            var circulate = true;
            //最后一步结束
            if (order == this.path_Array.length - 1) {
                circulate = false;
                direction = "End";
                // console.log("进入结束");
                if (this.path_Array.length > 1) {
                    // console.log("准备出水");
                    setTimeout(function () {
                        if (!_this.plan_over) {
                            _this.plan_over = true;
                            var head = _this.node.getChildByName("Top").getChildByName("head");
                            var progress = _this.node.getChildByName("Top").getChildByName("progress").getComponent(cc.Sprite);
                            head.stopAllActions();
                            head.setPosition(310, head.y);
                            if (_this.waterTween)
                                _this.waterTween.stop();
                            progress.fillRange = 1;
                            cc.fx.GameConfig.GM_INFO.min_Time = _this.waterTime;
                            _this.runWater(0);
                        }
                    }, 500);
                }
                else {
                    direction = "err";
                    // console.log("进入结束err");
                }
            }
            else {
                if (this.path_Array[order].z == 6 && order + 1 < this.path_Array.length) {
                    direction = "Reinforce";
                    i = this.path_Array[order + 1].x * this.map_Array[0].length + this.path_Array[order + 1].y;
                }
                else if (order + 1 < this.path_Array.length) {
                    if (this.path_Array[order + 1].z == 5) {
                        direction = "Xi_Soil";
                    }
                    else if (this.path_Array[order + 1].z == 6 && order == 0 && order + 1 < this.path_Array.length) {
                        // direction = this.getDirection(order+1,this.path_Array);
                        direction = this.getDirection(order, this.path_Array);
                    }
                    else {
                        direction = this.getDirection(order, this.path_Array);
                    }
                }
                else {
                    direction = this.getDirection(order, this.path_Array);
                }
            }
            // console.log(order,this.path_Array[order].x,this.path_Array[order].y,i);
            // console.log("步骤:",order,"方向",direction);
            var jg = this.getBoundary(order, this.path_Array[order].x, this.path_Array[order].y, direction, this.path_Array);
            // if(direction == "" || jg == false) return;
            if (direction == "err" || direction == "" || jg == false) {
                cc.fx.Notifications.emit(cc.fx.Message.showResult, "lose");
                return;
            }
            if (i < 0 || i > (this.block_Array.length - 1)) {
                cc.fx.Notifications.emit(cc.fx.Message.showResult, "lose");
                return;
            }
            var target = this.block_Array[i].getComponent("Block");
            target.setPath(direction);
            if (order > 0 && order < this.path_Array.length - 1) {
                if (this.path_Array[order + 1].z == 5) {
                    this.set_Soil(order + 1, this.path_Array, "road");
                    circulate = false;
                    return;
                }
                else if (order == 1 && this.path_Array[order].z == 5) {
                    this.set_Soil(order, this.path_Array, "road");
                    circulate = false;
                    return;
                }
            }
            var pos = cc.v2();
            if (direction == "End") {
                if (order > 0) {
                    // if(this.path_Array[order-1].z == 0){
                    pos = cc.v2(this.path_Array[order - 1].x, this.path_Array[order - 1].y);
                    // }
                }
            }
            var data = {
                order: order,
                time: cc.fx.GameConfig.TIME_INFO.waterSpeed[cc.fx.GameConfig.GM_INFO.level],
                type: this.path_Array[order].z,
                circulate: circulate,
                last: pos
            };
            target.runRoad(data);
        }
    };
    /**
     * 判断边界。或者撞山，或者湿地没有加固
     * @param order 建筑地图数组里的执行的序列号
     * @param x 当前操作地块横坐标
     * @param y 当前操作地块纵坐标
     * @param direction 当前操作方向，若不是方向则为息壤或者加固
     * @param road 建筑地图数组，可理解为路径数组，path_Array
     */
    GameManager.prototype.getBoundary = function (order, x, y, direction, road) {
        var jg = true;
        if (x < 0 || x >= this.map_Width || y < 0 || y >= this.map_Hight) {
            jg = false;
            // console.log("超过边界，游戏结束");
            // alert("超过边界，治水失败");
            cc.fx.Notifications.emit(cc.fx.Message.showResult, "lose");
        }
        else {
            var i = road[order].x * this.map_Array[0].length + road[order].y;
            var target = this.block_Array[i].getComponent("Block");
            if (target.block_Type == 3) {
                jg = false;
                // console.log("修筑山峰，游戏结束");
                // alert("修筑山峰，治水失败");
                cc.fx.Notifications.emit(cc.fx.Message.showResult, "lose");
            }
            else if (target.block_Type == 2 && direction != "Reinforce") {
                jg = false;
                // console.log("修筑未加固湿地,游戏结束");
                // alert("修筑未加固湿地,游戏结束");
                cc.fx.Notifications.emit(cc.fx.Message.showResult, "lose");
            }
        }
        return jg;
    };
    /**
     * 开始执行洪峰来了的动画
     * @param order 建筑地图数组里的执行的序列号，依次往下加
     */
    GameManager.prototype.runWater = function (order) {
        order = parseInt(order);
        if (order <= this.water_Array.length - 1) {
            var i = this.water_Array[order].x * this.map_Array[0].length + this.water_Array[order].y;
            var direction = "";
            var circulate = true;
            //最后一步结束
            if (order == this.water_Array.length - 1) {
                circulate = false;
                direction = "End";
            }
            else {
                if (this.water_Array[order].z == 6 && order + 1 < this.water_Array.length && order != 1) {
                    direction = "Reinforce";
                    i = this.water_Array[order + 1].x * this.map_Array[0].length + this.water_Array[order + 1].y;
                }
                else if (order + 1 < this.water_Array.length) {
                    if (this.water_Array[order + 1].z == 5) {
                        direction = "Xi_Soil";
                    }
                    else if (this.water_Array[order + 1].z == 6 && order == 0) {
                        direction = "Reinforce";
                    }
                    else {
                        direction = this.getDirection(order, this.water_Array);
                    }
                }
                else {
                    direction = this.getDirection(order, this.water_Array);
                }
            }
            var jg = this.getBoundary(order, this.water_Array[order].x, this.water_Array[order].y, direction, this.water_Array);
            if (direction == "" || jg == false || direction == "err") {
                cc.fx.Notifications.emit(cc.fx.Message.showResult, "lose");
                return;
            }
            var target = this.block_Array[i].getComponent("Block");
            target.setPath(direction);
            if (order > 0 && order < this.water_Array.length - 1) {
                if (this.water_Array[order + 1].z == 5) {
                    this.set_Soil(order + 1, this.water_Array, "water");
                    circulate = false;
                    return;
                }
                else if (order == 1 && this.water_Array[order].z == 5) {
                    this.set_Soil(order, this.water_Array, "water");
                    circulate = false;
                    return;
                }
            }
            var pos = cc.v2();
            if (direction == "End") {
                if (order > 0) {
                    if (this.water_Array[order - 1].z == 0) {
                        pos = cc.v2(this.water_Array[order - 1].x, this.water_Array[order - 1].y);
                    }
                }
            }
            var data = {
                order: order,
                time: cc.fx.GameConfig.TIME_INFO.waterSpeed[cc.fx.GameConfig.GM_INFO.level],
                type: this.water_Array[order].z,
                circulate: circulate,
                last: pos
            };
            target.runWater(data);
        }
    };
    /**
     * 获取息壤的格子的方向
     * @param order 建筑地图数组里的执行的序列号，依次往下加
     * @param road 建筑地图数组或者洪峰路径数组，可理解为路径数组，path_Array water_Array
     */
    GameManager.prototype.getXi_Soil = function (order, road) {
        var direction = null;
        //如果息壤后面还有下一步的话
        if (order + 1 < road.length) {
            direction = this.getDirection(order, road);
            if (direction == "up" || direction == "right_up" || direction == "left_up") {
                direction = "up";
            }
            else if (direction == "down" || direction == "left_down" || direction == "right_down") {
                direction = "down";
            }
            else if (direction == "left" || direction == "up_left" || direction == "down_left") {
                direction = "left";
            }
            else if (direction == "right" || direction == "up_right" || direction == "down_right") {
                direction = "right";
            }
        }
        return direction;
    };
    /**
     * 设置息壤执行方法
     * @param order 建筑地图数组里的执行的序列号，依次往下加
     * @param road 建筑地图数组或者洪峰路径数组，可理解为路径数组，path_Array water_Array
     * @param name road或者water,建筑路径或者洪峰路径
     */
    GameManager.prototype.set_Soil = function (order, road, name) {
        var direction = this.getXi_Soil(order, road);
        var length = 0;
        if (direction == "right") {
            length = this.map_Width - 1;
            // let temp = this.map_Width - 1;
            for (var i = road[order].x; i <= length; i++) {
                var n = i * this.map_Array[0].length + road[order].y;
                var target = this.block_Array[n].getComponent("Block");
                if (target.block_Type == 3 || target.block_Type == 4) {
                    length = i - 1;
                    if (target.block_Type == 4) {
                        length += 1;
                    }
                    i = 10000;
                    break;
                }
            }
        }
        else if (direction == "left") {
            length = 0;
            for (var i = road[order].x; i >= length; i--) {
                var n = i * this.map_Array[0].length + road[order].y;
                var target = this.block_Array[n].getComponent("Block");
                if (target.block_Type == 3 || target.block_Type == 4) {
                    length = i + 1;
                    if (target.block_Type == 4) {
                        length -= 1;
                    }
                    i = -1;
                    break;
                }
            }
        }
        else if (direction == "up") {
            length = 0;
            for (var i = road[order].y; i >= length; i--) {
                var n = road[order].x * this.map_Array[0].length + i;
                var target = this.block_Array[n].getComponent("Block");
                if (target.block_Type == 3 || target.block_Type == 4) {
                    length = i + 1;
                    if (target.block_Type == 4) {
                        length -= 1;
                    }
                    i = -1;
                    break;
                }
            }
        }
        else if (direction == "down") {
            length = this.map_Hight - 1;
            for (var i = road[order].y; i <= length; i++) {
                var n = road[order].x * this.map_Array[0].length + i;
                var target = this.block_Array[n].getComponent("Block");
                if (target.block_Type == 3 || target.block_Type == 4) {
                    length = i - 1;
                    if (target.block_Type == 4) {
                        length += 1;
                    }
                    i = 10000;
                    break;
                }
            }
        }
        this.soil_Find(direction, order, length, road, name);
    };
    //查找息壤蛮遗憾路径
    GameManager.prototype.soil_Find = function (direction, order, length, road, name) {
        var start = road[order].x;
        if (direction == "right") {
            for (var i = start; i <= length; i++) {
                var n = i * this.map_Array[0].length + road[order].y;
                var target = this.block_Array[n].getComponent("Block");
                if (i == start) {
                    if (i == start && i == length) {
                        cc.fx.Notifications.emit(cc.fx.Message.showResult, "lose");
                        target.set_Xi_SoilType(this.getDirection(order, road), order, name);
                    }
                    else
                        target.set_Xi_SoilType(this.getDirection(order, road), null, name);
                    var value = cc.v3(this.path_Array[order].x, this.path_Array[order].y, 0);
                    if (this.water_Array[this.water_Array.length - 1] != value) {
                        // console.log("特别插入:",this.path_Array[order].x,this.path_Array[order].y);
                        this.changeWater(value);
                    }
                }
                else {
                    var jg = null;
                    if (i == length) {
                        var number = i - start - 1;
                        this.changePath(order, number, false, road);
                        jg = order;
                    }
                    target.set_Xi_SoilType(direction, jg, name);
                }
            }
        }
        else if (direction == "left") {
            for (var i = start; i >= length; i--) {
                var n = i * this.map_Array[0].length + road[order].y;
                var target = this.block_Array[n].getComponent("Block");
                if (i == start) {
                    if (i == start && i == length) {
                        cc.fx.Notifications.emit(cc.fx.Message.showResult, "lose");
                        target.set_Xi_SoilType(this.getDirection(order, road), order, name);
                    }
                    else
                        target.set_Xi_SoilType(this.getDirection(order, road), null, name);
                    var value = cc.v3(this.path_Array[order].x, this.path_Array[order].y, 0);
                    if (this.water_Array[this.water_Array.length - 1] != value) {
                        // console.log("特别插入:",this.path_Array[order].x,this.path_Array[order].y);
                        this.changeWater(value);
                    }
                }
                else {
                    var jg = null;
                    if (i == length) {
                        var number = i - start + 1;
                        this.changePath(order, number, false, road);
                        jg = order;
                    }
                    target.set_Xi_SoilType(direction, jg, name);
                }
            }
        }
        else if (direction == "up") {
            start = road[order].y;
            for (var i = start; i >= length; i--) {
                var n = road[order].x * this.map_Array[0].length + i;
                var target = this.block_Array[n].getComponent("Block");
                if (i == start) {
                    if (i == start && i == length) {
                        cc.fx.Notifications.emit(cc.fx.Message.showResult, "lose");
                        target.set_Xi_SoilType(this.getDirection(order, road), order, name);
                    }
                    else {
                        target.set_Xi_SoilType(this.getDirection(order, road), null, name);
                    }
                    var value = cc.v3(this.path_Array[order].x, this.path_Array[order].y, 0);
                    if (this.water_Array[this.water_Array.length - 1] != value) {
                        // console.log("特别插入:",this.path_Array[order].x,this.path_Array[order].y);
                        this.changeWater(value);
                    }
                }
                else {
                    var jg = null;
                    if (i == length) {
                        var number = i - start + 1;
                        this.changePath(order, number, true, road);
                        jg = order;
                    }
                    // console.log("想上息壤插入:",this.path_Array[order].x,i);
                    target.set_Xi_SoilType(direction, jg, name);
                }
            }
        }
        else if (direction == "down") {
            start = road[order].y;
            for (var i = start; i <= length; i++) {
                var n = road[order].x * this.map_Array[0].length + i;
                var target = this.block_Array[n].getComponent("Block");
                if (i == start) {
                    if (i == start && i == length) {
                        cc.fx.Notifications.emit(cc.fx.Message.showResult, "lose");
                        target.set_Xi_SoilType(this.getDirection(order, road), order, name);
                    }
                    else
                        target.set_Xi_SoilType(this.getDirection(order, road), null, name);
                    var value = cc.v3(this.path_Array[order].x, this.path_Array[order].y, 0);
                    if (this.water_Array[this.water_Array.length - 1] != value) {
                        // console.log("特别插入:",this.path_Array[order].x,this.path_Array[order].y);
                        this.changeWater(value);
                    }
                }
                else {
                    var jg = null;
                    if (i == length) {
                        var number = i - start - 1;
                        this.changePath(order, number, true, road);
                        jg = order;
                    }
                    target.set_Xi_SoilType(direction, jg, name);
                }
            }
        }
    };
    /**
     * 改变水流地图
     * @param value 需要根据使用息壤情况，插入到洪峰路径的点
     */
    GameManager.prototype.changeWater = function (value) {
        var jg = true;
        if (this.water_Array.length > 0) {
            if (this.water_Array[this.water_Array.length - 1].x == value.x && this.water_Array[this.water_Array.length - 1].y == value.y) {
                jg = false;
            }
        }
        if (jg)
            this.water_Array.push(value);
    };
    /**
     * 息壤过后改变修筑路径
     * @param order 建筑地图数组里的执行的序列号
     * @param number 息壤执行长度,改变息壤用后其他路径的X或Y值
     * @param direction 只为两个方向，横向false,纵向true
     * @param road 建筑地图数组或者洪峰路径数组，可理解为路径数组，path_Array water_Array
     */
    GameManager.prototype.changePath = function (order, number, direction, road) {
        for (var i = (order + 1); i < road.length; i++) {
            if (!direction) {
                road[i].x += (number);
            }
            else {
                road[i].y += (number);
            }
        }
        if (direction) {
            if (number < 0) {
                for (var n = -number; n > 0; n--) {
                    this.changeWater(cc.v3(this.path_Array[order + 1].x, this.path_Array[order + 1].y + n, 0));
                    // console.log("1特殊放入:",this.path_Array[order+1].x,this.path_Array[order+1].y+n)
                }
            }
            else {
                for (var n = number; n > 0; n--) {
                    this.changeWater(cc.v3(this.path_Array[order + 1].x, this.path_Array[order + 1].y - n, 0));
                    // console.log("2特殊放入:",this.path_Array[order+1].x,this.path_Array[order+1].y-n)
                }
            }
        }
        else {
            if (number < 0) {
                for (var m = -number; m > 0; m--) {
                    this.changeWater(cc.v3(this.path_Array[order + 1].x + m, this.path_Array[order + 1].y, 0));
                    // console.log("3特殊放入:",this.path_Array[order+1].x+m,this.path_Array[order+1].y)
                }
            }
            else {
                for (var m = number; m > 0; m--) {
                    this.changeWater(cc.v3(this.path_Array[order + 1].x - m, this.path_Array[order + 1].y, 0));
                    // console.log("4特殊放入:",this.path_Array[order+1].x-m,this.path_Array[order+1].y)
                }
            }
        }
    };
    /**
     * 获取洪峰方向
     * @param order 建筑地图数组里的执行的序列号
     * @param road 建筑地图数组或者洪峰路径数组，可理解为路径数组，path_Array water_Array
     */
    GameManager.prototype.getDirection = function (order, road) {
        var name = "";
        //入海口比较复杂单独判断
        if (order == 0) {
            if (this.path_Array[order + 1].z == 6 && road == this.path_Array)
                order += 1;
            var nextX = road[order + 1].x - road[order].x;
            var nextY = road[order].y - road[order + 1].y;
            //在底边
            if (road[order].y == this.map_Array[0].length - 1) {
                if (nextX == 0) {
                    if (nextY == 1)
                        name = "up";
                    else if (nextY == -1)
                        name = "err";
                }
                else if (nextX == 1)
                    name = "up_right";
                else if (nextX == -1)
                    name = "up_left";
            }
            //在顶边
            else if (road[order].y == 0) {
                if (nextX == 0) {
                    if (nextY == 1)
                        name = "err";
                    else if (nextY == -1)
                        name = "down";
                }
                else if (nextX == 1)
                    name = "down_right";
                else if (nextX == -1)
                    name = "down_left";
            }
            //在左边
            else if (road[order].x == 0) {
                if (nextX == 0) {
                    if (nextY == 1)
                        name = "right_up";
                    else if (nextY == -1)
                        name = "right_down";
                }
                else if (nextX == 1)
                    name = "right";
                else if (nextX == -1)
                    name = "err";
            }
            //在右边
            else if (road[order].x == this.map_Array.length - 1) {
                if (nextX == 0) {
                    if (nextY == 1)
                        name = "left_up";
                    else if (nextY == -1)
                        name = "left_down";
                }
                else if (nextX == 1)
                    name = "err";
                else if (nextX == -1)
                    name = "left";
            }
        }
        //不是第一步，已经走过一步
        else if (order > 0) {
            var next = 1;
            if (order + 2 < road.length) {
                if (road[order + 1].z == 6)
                    next = 2;
            }
            //用于判断此点的上一个点，是为了判断当前方块洪水七点，以及下一个移动方向，判断洪终点方向
            var nextX = road[order + next].x - road[order].x;
            var nextY = road[order].y - road[order + next].y;
            var previousX = road[order].x - road[order - 1].x;
            var previousY = road[order - 1].y - road[order].y;
            if (previousX == 0 && previousY == 0) {
                if (order > 1) {
                    previousX = road[order].x - road[order - 2].x;
                    previousY = road[order - 2].y - road[order].y;
                }
                else if (order + 1 < road.length) {
                    previousX = road[order + 1].x - road[order].x;
                    previousY = road[order].y - road[order + 1].y;
                    // console.log("息壤，上下坐标差距",previousX,previousY);
                }
            }
            if (previousX == 0 && previousY >= 1) {
                if (nextX == 0) {
                    if (nextY == 1)
                        name = "up";
                    else if (nextY == -1)
                        name = "err";
                }
                else if (nextX == 1)
                    name = "up_right";
                else if (nextX == -1)
                    name = "up_left";
            }
            else if (previousX == 0 && previousY <= -1) {
                if (nextX == 0) {
                    if (nextY == 1)
                        name = "err";
                    else if (nextY == -1)
                        name = "down";
                }
                else if (nextX == 1)
                    name = "down_right";
                else if (nextX == -1)
                    name = "down_left";
            }
            else if (previousX >= 1 && previousY == 0) {
                if (nextX == 0) {
                    if (nextY == 1)
                        name = "right_up";
                    else if (nextY == -1)
                        name = "right_down";
                }
                else if (nextX == 1)
                    name = "right";
                else if (nextX == -1)
                    name = "err";
            }
            else if (previousX <= -1 && previousY == 0) {
                if (nextX == 0) {
                    if (nextY == 1)
                        name = "left_up";
                    else if (nextY == -1)
                        name = "left_down";
                }
                else if (nextX == 1)
                    name = "err";
                else if (nextX == -1)
                    name = "left";
            }
        }
        return name;
    };
    //根据是否全面屏，做独立适配方面
    GameManager.prototype.fit = function () {
        var jg = this.setFit();
        if (!jg) {
            this.Map.scale = 1.2;
        }
        else {
            this.Map.scale = 1;
        }
    };
    //判断全面屏
    GameManager.prototype.getSetScreenResolutionFlag = function () {
        var size = cc.winSize;
        var width = size.width;
        var height = size.height;
        if ((height / width) > (16.2 / 9))
            return false;
        return true;
    };
    //判断全面屏适配
    GameManager.prototype.setFit = function () {
        var flag = this.getSetScreenResolutionFlag();
        if (flag) {
        }
        else {
        }
        return flag;
    };
    //返回首页
    GameManager.prototype.backScene = function () {
        cc.director.loadScene("LoadScene");
    };
    /**
     * 开始修筑
     * @param data 记录操作的数组
     */
    GameManager.prototype.startGame = function (data) {
        this.unschedule(this.updateWaterTime);
        for (var i = 0; i < this.block_Array.length; i++) {
            this.block_Array[i].getChildByName("tipWin").active = false;
            this.block_Array[i].getChildByName("tipLose").active = false;
        }
        this.unschedule(this.updateCountDownTime);
        var now = cc.fx.GameTool.getTime();
        var finishi = now - this.finishiTime;
        var totalTime = now - this.startTime;
        this.scoreTime = this.waterTime;
        if (this.waterTime <= 0.5)
            finishi = -1;
        // console.log("submitTime:",finishi,this.finishiTime);
        cc.fx.GameConfig.CLICK_SET("submitTime", finishi);
        if (finishi == -1)
            cc.fx.GameConfig.CLICK_SET("duration", cc.fx.GameConfig.TIME_INFO.waterTime[cc.fx.GameConfig.GM_INFO.level]);
        else
            cc.fx.GameConfig.CLICK_SET("duration", totalTime);
        cc.fx.GameConfig.CLICK_SET("usedSteps", data.length);
        this.setMap(data);
        var arr = this.changeStep(data);
        cc.fx.GameConfig.CLICK_SET("stepList", arr);
    };
    /**
     * 用于埋点记录 转变方向名称为埋点所需要格式
     * @param data 记录操作的数组
     */
    GameManager.prototype.changeStep = function (data) {
        var arr = [];
        if (data.length > 0) {
            for (var i = 0; i < data.length; i++) {
                if (data[i] == "up")
                    arr[i] = "U";
                else if (data[i] == "down")
                    arr[i] = "D";
                else if (data[i] == "left")
                    arr[i] = "L";
                else if (data[i] == "right")
                    arr[i] = "R";
                else if (data[i] == "soil")
                    arr[i] = "X";
                else if (data[i] == "reinforce")
                    arr[i] = "F";
            }
        }
        return arr;
    };
    //洪峰倒计时，计时器
    GameManager.prototype.updateWaterTime = function () {
        var _this = this;
        if (this.waterTime > 0) {
            this.waterTime -= 1;
            this.Countdown.string = cc.fx.GameTool.getTimeMargin(this.waterTime);
            if (this.waterTime <= 0) {
                this.unschedule(this.updateWaterTime);
                if (!this.plan_over) {
                    this.waterTime = 0;
                    this.plan_over = true;
                    setTimeout(function () {
                        if (_this.water_Array.length == 0) {
                            cc.fx.Notifications.emit(cc.fx.Message.showResult, "lose");
                        }
                        else {
                            cc.fx.GameConfig.GM_INFO.min_Time = _this.waterTime;
                            _this.runWater(0);
                        }
                    }, 500);
                }
            }
        }
    };
    //如果是倒计时 调用此方法
    GameManager.prototype.updateCountDownTime = function () {
        if (this.countTime > 0) {
            this.countTime -= 1;
            cc.fx.GameConfig.TIME_INFO.totalTime = this.countTime;
            this.Time.string = cc.fx.GameTool.getTimeMargin(this.countTime);
            if (this.countTime < 5) {
                var over = this.node.getChildByName("Over");
                cc.tween(over)
                    .to(0.2, { opacity: 255 })
                    .delay(0.1)
                    .to(0.2, { opacity: 0 })
                    .start();
            }
            if (this.countTime <= 0) {
                this.countTime = 0;
                this.setData("lose");
                this.unschedule(this.updateCountDownTime);
                this.gameOver();
            }
        }
    };
    //上传每次操作数据 success为成功还是失败
    GameManager.prototype.setData = function (success) {
        //设置埋点数据
        cc.fx.GameConfig.CLICK_SET("mapId", cc.fx.GameConfig.LEVEL_INFO[cc.fx.GameConfig.GM_INFO.level][this.custom].id);
        cc.fx.GameConfig.CLICK_SET("difficulty", cc.fx.GameConfig.GM_INFO.level);
        cc.fx.GameConfig.CLICK_SET("optimizedSteps", cc.fx.GameConfig.LEVEL_INFO[cc.fx.GameConfig.GM_INFO.level][this.custom].min_steps);
        cc.fx.GameConfig.CLICK_SET("round", cc.fx.GameConfig.GM_INFO.round);
        cc.fx.GameConfig.CLICK_SET("timer", cc.fx.GameConfig.TIME_INFO.totalTime);
        cc.fx.GameConfig.CLICK_SET("cumulativeScore", cc.fx.GameConfig.GM_INFO.score);
        success = success == "lose" ? false : true;
        if (success != null) {
            cc.fx.GameConfig.CLICK_SET("success", success);
            cc.fx.GameConfig.GM_INFO.fen = this.getScore();
            if (!success)
                cc.fx.GameConfig.GM_INFO.fen = 0;
            cc.fx.GameConfig.CLICK_SET("getScore", cc.fx.GameConfig.GM_INFO.fen);
            cc.fx.GameConfig.GM_INFO.score += cc.fx.GameConfig.GM_INFO.fen;
            this.node.getChildByName("Top").getChildByName("id").getComponent(cc.Label).string =
                cc.fx.GameConfig.GM_INFO.score;
            cc.fx.GameConfig.CLICK_SET("cumulativeScore", cc.fx.GameConfig.GM_INFO.score);
            if (this.countTime != 0)
                cc.fx.GameConfig.GM_INFO.successList.push(success);
        }
        cc.fx.GameTool.setGameData();
    };
    //计算得分
    GameManager.prototype.getScore = function () {
        //最小步数
        var min = cc.fx.GameConfig.LEVEL_INFO[cc.fx.GameConfig.GM_INFO.level][this.custom].min_steps;
        //实际使用步数
        var now = this.path_Array.length - 1;
        if (now <= 0)
            now = 0;
        var x = (2.5 * min - now) / min;
        var score = Math.pow(Math.pow(min, x), 0.5);
        score = score * (this.scoreTime + 10) * 100;
        return Math.floor(score);
    };
    //上传排行榜数据
    GameManager.prototype.gameOver = function () {
        var rate = 0;
        var successList = cc.fx.GameConfig.GM_INFO.successList;
        if (successList.length > 0) {
            var success = 0;
            for (var i = 0; i < successList.length; i++) {
                if (successList[i] == true)
                    success += 1;
            }
            rate = success / successList.length;
        }
        rate = Math.floor(rate * 1000) / 10;
        var data = {
            score: cc.fx.GameConfig.GM_INFO.score,
            rate: rate
        };
        cc.fx.GameTool.setRank(data);
        this.node.getChildByName("GameOver").active = true;
        this.node.getChildByName("GameOver").opacity = 0;
        cc.tween(this.node.getChildByName("GameOver"))
            .to(0.4, { opacity: 255 })
            .delay(1)
            .to(0.4, { opacity: 50 })
            .call(function () {
            cc.director.loadScene("OverScene");
        })
            .start();
    };
    //展示结果 data为成功或者失败
    GameManager.prototype.showResult = function (data) {
        if (this.node.getChildByName("GameOver").active == false && this.node.getChildByName("Window").active == false) {
            cc.fx.Notifications.emit(cc.fx.Message.setData, data);
            if (data == "lose") {
                cc.fx.AudioManager._instance.playEffect("lose", null);
                cc.fx.GameConfig.GM_INFO.min_Time = -1;
            }
            else {
                cc.fx.AudioManager._instance.playEffect("win", null);
            }
            this.node.getChildByName("Window").active = true;
            this.node.getChildByName("Window").getComponent("Window").init(data);
        }
    };
    //记录反应时长，以及做步骤提示 data为操作名称
    GameManager.prototype.clickSun = function (data) {
        //如果没有记录过 回合开始到操作反应时长，则第一次记录， 后面不记录
        if (cc.fx.GameConfig.CLICK_DATA.startTime == -1) {
            this.finishiTime = cc.fx.GameTool.getTime();
            var now = this.finishiTime - this.startTime;
            // console.log("startTime:",this.finishiTime);
            cc.fx.GameConfig.CLICK_SET("startTime", now);
        }
        if (cc.fx.GameConfig.GM_INFO.level > 3)
            return;
        //步骤提示
        var nowPos = this.path_Array[0];
        if (this.tip_Array.length != 0) {
            if (this.tip_Array[this.tip_Array.length - 1] == null) {
                this.tip_Array.push(null);
                return;
            }
            nowPos = this.tip_Array[this.tip_Array.length - 1][this.tip_Array[this.tip_Array.length - 1].length - 1];
            if (nowPos) {
                var n = nowPos.x * this.map_Array[0].length + nowPos.y;
                var targetNode = this.block_Array[n];
                if (targetNode.getChildByName("tipLose").active == true) {
                    this.tip_Array.push(null);
                    return;
                }
            }
            else {
                return;
            }
        }
        if (data == "up") {
            var n = cc.v2(nowPos.x, nowPos.y - 1);
            this.tipCan(n, data);
        }
        else if (data == "down") {
            var n = cc.v2(nowPos.x, nowPos.y + 1);
            this.tipCan(n, data);
        }
        else if (data == "left") {
            var n = cc.v2(nowPos.x - 1, nowPos.y);
            this.tipCan(n, data);
        }
        else if (data == "right") {
            var n = cc.v2(nowPos.x + 1, nowPos.y);
            this.tipCan(n, data);
        }
        else if (data == "reinforce") {
            var n = cc.v3(nowPos.x, nowPos.y, 2);
            this.tip_Array.push([n]);
        }
        else if (data == "soil") {
            var n = cc.v3(nowPos.x, nowPos.y, 3);
            this.tip_Array.push([n]);
        }
    };
    //提示是否错误  只前三关有 ,pos为位置，data为操作方向
    GameManager.prototype.tipCan = function (pos, data) {
        //先判断是否出边界
        if (pos.x < 0 || pos.x > this.map_Array.length - 1 || pos.y < 0 || pos.y > this.map_Array[0].length - 1) {
            this.tip_Array.push(null);
            return;
        }
        var n = pos.x * this.map_Array[0].length + pos.y;
        var target = this.block_Array[n].getComponent("Block");
        target.node.getChildByName("tipWin").active = true;
        //重复路回头路，或者山峰
        if (target.repeatRoad(false, null) == true || target.block_Type == 3) {
            this.tip_Array.push([cc.v3(pos.x, pos.y, 0)]);
            target.node.getChildByName("tipLose").active = true;
            target.node.getChildByName("tipWin").active = false;
        }
        //湿地 上一步如果没用息壤或者加固
        else if (target.block_Type == 2) {
            if (this.tip_Array.length > 0) {
                if (this.tip_Array[this.tip_Array.length - 1][0].z == 0) {
                    target.node.getChildByName("tipLose").active = true;
                    target.node.getChildByName("tipWin").active = false;
                }
                else if (this.tip_Array[this.tip_Array.length - 1][0].z == 2) {
                    target.node.getChildByName("tipLose").active = false;
                    target.node.getChildByName("tipWin").active = true;
                }
            }
            else {
                target.node.getChildByName("tipLose").active = true;
                target.node.getChildByName("tipWin").active = false;
            }
        }
        if (this.tip_Array.length > 0) {
            if (this.tip_Array[this.tip_Array.length - 1][0].z == 3) {
                if (data == "up") {
                    var arr = [];
                    for (var i = pos.y; i >= 0; i--) {
                        var block = this.block_Array[pos.x * this.map_Array[0].length + i].getComponent("Block");
                        if (block.block_Type == 3) {
                            i = -10000;
                        }
                        else {
                            block.node.getChildByName("tipWin").active = true;
                            arr.push(cc.v3(pos.x, i, 0));
                            if (block.block_Type == 4)
                                i = -10000;
                        }
                    }
                    this.tip_Array.push(arr);
                }
                else if (data == "down") {
                    var arr = [];
                    for (var i = pos.y; i < this.map_Array[0].length; i++) {
                        var block = this.block_Array[pos.x * this.map_Array[0].length + i].getComponent("Block");
                        if (block.block_Type == 3) {
                            i = 10000;
                        }
                        else {
                            block.node.getChildByName("tipWin").active = true;
                            arr.push(cc.v3(pos.x, i, 0));
                            if (block.block_Type == 4)
                                i = 10000;
                        }
                    }
                    this.tip_Array.push(arr);
                }
                else if (data == "right") {
                    var arr = [];
                    for (var i = pos.x; i < this.map_Array.length; i++) {
                        var block = this.block_Array[i * this.map_Array[0].length + pos.y].getComponent("Block");
                        if (block.block_Type == 3) {
                            i = 10000;
                        }
                        else {
                            block.node.getChildByName("tipWin").active = true;
                            arr.push(cc.v3(i, pos.y, 0));
                            if (block.block_Type == 4)
                                i = 10000;
                        }
                    }
                    this.tip_Array.push(arr);
                }
                else if (data == "left") {
                    var arr = [];
                    for (var i = pos.x; i >= 0; i--) {
                        var block = this.block_Array[i * this.map_Array[0].length + pos.y].getComponent("Block");
                        if (block.block_Type == 3) {
                            i = -10000;
                        }
                        else {
                            block.node.getChildByName("tipWin").active = true;
                            arr.push(cc.v3(i, pos.y, 0));
                            if (block.block_Type == 4)
                                i = -10000;
                        }
                    }
                    this.tip_Array.push(arr);
                }
            }
            else {
                var posJg_1 = cc.v3(pos.x, pos.y, 0);
                if (data == "reinforce")
                    pos.z = 2;
                if (data == "soil")
                    pos.z = 3;
                this.tip_Array.push([posJg_1]);
            }
            // console.log(this.tip_Array);
            return;
        }
        var posJg = cc.v3(pos.x, pos.y, 0);
        if (data == "reinforce")
            pos.z = 2;
        if (data == "soil")
            pos.z = 3;
        this.tip_Array.push([posJg]);
        // console.log(this.tip_Array);
    };
    //移除提示
    GameManager.prototype.removeTip = function (data) {
        if (cc.fx.GameConfig.GM_INFO.level > 3)
            return;
        //分为撤回一步 和全部清空
        if (this.tip_Array.length > 0) {
            if (data == "back") {
                var target = this.tip_Array[this.tip_Array.length - 1];
                if (target == null) {
                    this.tip_Array.pop();
                }
                else {
                    this.tip_Array.pop();
                    for (var i = 0; i < target.length; i++) {
                        if (target[i]) {
                            if (target[0].z == 0) {
                                var n = target[i].x * this.map_Array[0].length + target[i].y;
                                var node = this.block_Array[n];
                                node.getChildByName("tipWin").active = false;
                                node.getChildByName("tipLose").active = false;
                            }
                        }
                    }
                }
            }
            else if (data == "remove") {
                for (var j = 0; j < this.tip_Array.length; j++) {
                    var target = this.tip_Array[j];
                    if (target != null) {
                        for (var i = 0; i < target.length; i++) {
                            if (target[i]) {
                                var n = target[i].x * this.map_Array[0].length + target[i].y;
                                var node = this.block_Array[n];
                                node.getChildByName("tipWin").active = false;
                                node.getChildByName("tipLose").active = false;
                            }
                        }
                    }
                }
                this.tip_Array = [];
            }
        }
    };
    //获取引导名字
    GameManager.prototype.getGuideName = function () {
        var name = "one";
        switch (this.step) {
            case 1:
                name = "one";
                this.btnClick = false;
                this.bgClick = true;
                break;
            case 2:
                name = "two";
                this.btnClick = false;
                this.bgClick = true;
                break;
            case 3:
                name = "three";
                this.btnClick = false;
                this.bgClick = true;
                break;
            case 4:
                name = "four";
                this.btnClick = false;
                this.bgClick = true;
                break;
            case 5:
                name = "five";
                this.btnClick = true;
                this.bgClick = false;
                break;
            case 6:
                name = "six";
                this.btnClick = true;
                this.bgClick = false;
                break;
            case 7:
                name = "seven";
                this.btnClick = false;
                this.bgClick = true;
                break;
            case 8:
                name = "eight";
                this.btnClick = false;
                this.bgClick = true;
                break;
            case 9:
                name = "nine";
                this.btnClick = false;
                this.bgClick = true;
                break;
            case 10:
                name = "ten";
                this.btnClick = true;
                this.bgClick = false;
                break;
            case 11:
                name = "eleven";
                this.btnClick = false;
                this.bgClick = true;
                break;
            case 12:
                name = "twelve";
                this.btnClick = true;
                this.bgClick = false;
                break;
            case 13:
                name = "thirteen";
                this.btnClick = true;
                this.bgClick = false;
                break;
            case 14:
                name = "fourteen";
                this.btnClick = true;
                this.bgClick = false;
                break;
            case 15:
                name = "fiveteen";
                this.btnClick = true;
                this.bgClick = false;
                break;
            case 16:
                name = "sixteen";
                this.btnClick = true;
                this.bgClick = false;
                break;
            case 17:
                name = "last";
                this.btnClick = true;
                this.bgClick = false;
                break;
        }
        return name;
    };
    //引导下一步
    GameManager.prototype.guideNext = function () {
        //每次先把所有的
        console.log(this.step, this.Guide.children.length);
        if (this.step + 1 == this.Guide.children.length) {
            cc.fx.GameConfig.GM_INFO.guide = false;
            // cc.director.loadScene("GameScene");
            var name_1 = cc.fx.GameConfig.GM_INFO.gameId + "_guide";
            cc.fx.StorageMessage.setStorage(name_1, cc.fx.GameConfig.GM_INFO.guide);
        }
        if (this.step > 0)
            this.Guide.children[this.step - 1].active = false;
        this.step += 1;
        var name = this.getGuideName();
        var target = this.Guide.getChildByName(name);
        target.active = true;
        var size = cc.winSize;
        if (size.height > 1334) {
            var height = (size.height - 1334) / 2;
            target.getChildByName("sp").height += height;
        }
    };
    GameManager.prototype.onEnable = function () {
        cc.fx.Notifications.on(cc.fx.Message.control, this.clickSun, this);
        cc.fx.Notifications.on(cc.fx.Message.next, this.runRoad, this);
        cc.fx.Notifications.on(cc.fx.Message.nextWater, this.runWater, this);
        cc.fx.Notifications.on(cc.fx.Message.startGame, this.startGame, this);
        cc.fx.Notifications.on(cc.fx.Message.changePath, this.changePath, this);
        cc.fx.Notifications.on(cc.fx.Message.setData, this.setData, this);
        cc.fx.Notifications.on(cc.fx.Message.guideNext, this.guideNext, this);
        cc.fx.Notifications.on(cc.fx.Message.showResult, this.showResult, this);
        cc.fx.Notifications.on(cc.fx.Message.removeTip, this.removeTip, this);
    };
    GameManager.prototype.onDisable = function () {
        cc.fx.Notifications.off(cc.fx.Message.control, this.clickSun);
        cc.fx.Notifications.off(cc.fx.Message.next, this.runRoad);
        cc.fx.Notifications.off(cc.fx.Message.nextWater, this.runWater);
        cc.fx.Notifications.off(cc.fx.Message.startGame, this.startGame);
        cc.fx.Notifications.off(cc.fx.Message.changePath, this.changePath);
        cc.fx.Notifications.off(cc.fx.Message.setData, this.setData);
        cc.fx.Notifications.off(cc.fx.Message.guideNext, this.guideNext);
        cc.fx.Notifications.off(cc.fx.Message.showResult, this.showResult);
        cc.fx.Notifications.off(cc.fx.Message.removeTip, this.removeTip);
    };
    GameManager.prototype.update = function (dt) {
    };
    __decorate([
        property(cc.Node)
    ], GameManager.prototype, "Map", void 0);
    __decorate([
        property(cc.Prefab)
    ], GameManager.prototype, "Block", void 0);
    __decorate([
        property(cc.Label)
    ], GameManager.prototype, "Time", void 0);
    __decorate([
        property(cc.Label)
    ], GameManager.prototype, "Countdown", void 0);
    __decorate([
        property(cc.Node)
    ], GameManager.prototype, "Guide", void 0);
    GameManager = __decorate([
        ccclass
    ], GameManager);
    return GameManager;
}(cc.Component));
exports.default = GameManager;

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, 158744 characters]