
                (function() {
                    var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined';
                    var __module = nodeEnv ? module : {exports:{}};
                    var __filename = 'preview-scripts/assets/Script/Block.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, 'c58deN2u1NGZL8nJwvnu1PR', 'Block');
// Script/Block.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 });
exports.PathType = exports.BlockType = void 0;
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var BlockType;
(function (BlockType) {
    /*普通地块 */
    BlockType[BlockType["Nomal"] = 0] = "Nomal";
    /*起点地块 */
    BlockType[BlockType["Start"] = 1] = "Start";
    /*湿地 */
    BlockType[BlockType["Nunja"] = 2] = "Nunja";
    /*山峰 */
    BlockType[BlockType["Peak"] = 3] = "Peak";
    /*终点地块 */
    BlockType[BlockType["End"] = 4] = "End";
    /*息壤 */
    BlockType[BlockType["Xi_Soil"] = 5] = "Xi_Soil";
    /*加固 */
    BlockType[BlockType["Reinforce"] = 6] = "Reinforce";
})(BlockType = exports.BlockType || (exports.BlockType = {}));
var PathType;
(function (PathType) {
    PathType["err"] = "err";
    PathType["up"] = "up";
    PathType["down"] = "down";
    PathType["left"] = "left";
    PathType["right"] = "right";
    PathType["up_left"] = "up_left";
    PathType["up_right"] = "up_right";
    PathType["down_left"] = "down_left";
    PathType["down_right"] = "down_right";
    PathType["left_up"] = "left_up";
    PathType["left_down"] = "left_down";
    PathType["right_up"] = "right_up";
    PathType["right_down"] = "right_down";
})(PathType = exports.PathType || (exports.PathType = {}));
var NewClass = /** @class */ (function (_super) {
    __extends(NewClass, _super);
    function NewClass() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        // LIFE-CYCLE CALLBACKS:
        _this.UI = null;
        return _this;
        // update (dt) {}
    }
    NewClass.prototype.onLoad = function () {
        this.finishi = false;
        this.pos_Shifting = 0;
        this.pos = cc.v2(0, 0);
    };
    NewClass.prototype.start = function () {
    };
    //初始化地图块数据
    NewClass.prototype.initData = function (type, pos, max) {
        this.block_Type = type;
        this.pos = cc.v2(pos.x, pos.y);
        // if(this.pos.y%2 == 0) this.node.getChildByName("tip").active = true;
        if (type == cc.Enum(BlockType).Start) {
            var bg = this.node.getChildByName("sp");
            // this.node.getComponent(cc.Sprite).spriteFrame = null;
            bg.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"]["start"];
            if (cc.fx.GameConfig.GM_INFO.level > 3) {
                bg.getChildByName("start").y = 20;
                bg.getChildByName("end").y = 20;
            }
            this.rotateTarget(bg, "start", pos, max);
        }
        else if (type == cc.Enum(BlockType).End) {
            var bg = this.node.getChildByName("sp");
            // this.node.getComponent(cc.Sprite).spriteFrame = null;
            bg.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"]["end"];
            if (cc.fx.GameConfig.GM_INFO.level > 3) {
                bg.getChildByName("start").y = 20;
                bg.getChildByName("end").y = 20;
            }
            this.rotateTarget(bg, "end", pos, max);
        }
        else if (type == cc.Enum(BlockType).Nunja) {
            var random = Math.floor(Math.random() * 4);
            var rotationArr = [0, 90, 180, 270];
            var rotation = rotationArr[random];
            this.node.getChildByName("bg").getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"]["e5"];
            this.node.getChildByName("bg").angle = -rotation;
            this.node.getComponent(cc.Sprite).spriteFrame = null;
        }
        else if (type == cc.Enum(BlockType).Peak) {
            var random = Math.floor(Math.random() * 4 + 1);
            var name = "shan" + random;
            this.node.getChildByName("bg").getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"][name];
            this.node.getComponent(cc.Sprite).spriteFrame = null;
        }
        if (cc.fx.GameConfig.GM_INFO.level == 1) {
            this.node.getChildByName("tipWin").opacity = 220;
            this.node.getChildByName("tipLose").opacity = 220;
        }
        else if (cc.fx.GameConfig.GM_INFO.level == 2) {
            this.node.getChildByName("tipWin").opacity = 100;
            this.node.getChildByName("tipLose").opacity = 100;
        }
        else if (cc.fx.GameConfig.GM_INFO.level == 3) {
            this.node.getChildByName("tipWin").opacity = 50;
            this.node.getChildByName("tipLose").opacity = 50;
        }
        else if (cc.fx.GameConfig.GM_INFO.level > 3) {
            this.node.getChildByName("tipWin").opacity = 0;
            this.node.getChildByName("tipLose").opacity = 0;
        }
    };
    //旋转入海口和出海口的 图片以及文字角度
    NewClass.prototype.rotateTarget = function (bg, name, pos, max) {
        var target = bg.getChildByName(name);
        if (pos.y == max.y - 1) {
            bg.angle = 0;
            if (name == "end")
                target.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"]["end_x"];
            target.active = true;
            target.angle = 0;
            return;
        }
        else if (pos.y == 0) {
            bg.angle = -180;
            if (name == "end")
                target.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"]["end_x"];
            target.active = true;
            target.angle = -180;
            return;
        }
        else if (pos.x == max.x - 1) {
            bg.angle = 90;
            if (name == "start")
                target.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"]["start_y"];
            else
                target.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"]["end_y"];
            target.active = true;
            target.angle = -90;
        }
        else if (pos.x == 0) {
            bg.angle = -90;
            if (name == "start")
                target.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"]["start_y"];
            else
                target.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"]["end_y"];
            target.active = true;
            target.angle = 90;
        }
    };
    NewClass.prototype.setPath = function (type) {
        this.path_Type = type;
    };
    //设置息壤在起点
    NewClass.prototype.set_Xi_Soil = function (direction, type) {
        var sp = this.node.getChildByName("sp");
        var turn = this.node.getChildByName("turnStart");
        var water = this.node.getChildByName("waterStart");
        if (direction == "left" || direction == "right") {
            if (sp.angle == 0) {
                turn.active = true;
                water.active = true;
                water.opacity = 0;
                if (type) {
                    turn.angle = direction == "left" ? 90 : 0;
                    water.angle = direction == "left" ? 90 : 0;
                }
                else {
                    turn.angle = direction == "left" ? 0 : 90;
                    water.angle = direction == "left" ? 0 : 90;
                }
            }
            else if (sp.angle == -180) {
                turn.active = true;
                water.active = true;
                water.opacity = 0;
                if (type) {
                    turn.angle = direction == "left" ? -180 : -90;
                    water.angle = direction == "left" ? -180 : -90;
                }
                else {
                    turn.angle = direction == "left" ? 270 : -180;
                    water.angle = direction == "left" ? 270 : -180;
                }
            }
            else if (sp.angle == -90) {
                turn.active = true;
                turn.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"]["a1"];
                turn.angle = 90;
                if (type) {
                    water.active = true;
                    water.angle = 90;
                    water.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"]["block1"];
                    water.opacity = 0;
                }
            }
            else if (sp.angle == 90) {
                turn.active = true;
                turn.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"]["a1"];
                turn.angle = 90;
                if (type) {
                    water.active = true;
                    water.angle = 90;
                    water.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"]["block1"];
                    water.opacity = 0;
                }
            }
        }
        else if (direction == "up" || direction == "down") {
            var sp_1 = this.node.getChildByName("sp");
            if (sp_1.angle == -90) {
                turn.active = true;
                water.active = true;
                water.opacity = 0;
                if (type) {
                    turn.angle = direction == "up" ? 0 : -90;
                    water.angle = direction == "up" ? 0 : -90;
                }
                else {
                    turn.angle = direction == "up" ? -90 : 0;
                    water.angle = direction == "up" ? -90 : 0;
                }
            }
            else if (sp_1.angle == 90) {
                turn.active = true;
                water.active = true;
                water.opacity = 0;
                if (type) {
                    turn.angle = direction == "up" ? 90 : 180;
                    water.angle = direction == "up" ? 90 : 180;
                }
                else {
                    turn.angle = direction == "up" ? 180 : 90;
                    water.angle = direction == "up" ? 180 : 90;
                }
            }
            else if (sp_1.angle == 0) {
                turn.active = true;
                turn.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"]["a1"];
                turn.angle = 0;
                if (type) {
                    water.active = true;
                    water.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"]["block1"];
                    water.opacity = 0;
                }
            }
            else if (sp_1.angle == -180) {
                turn.active = true;
                turn.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"]["a1"];
                turn.angle = 0;
                if (type) {
                    water.active = true;
                    water.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"]["block1"];
                    water.opacity = 0;
                }
            }
        }
    };
    //息壤具体执行方法  外部可调用
    NewClass.prototype.set_Xi_SoilType = function (direction, end, name) {
        var _this = this;
        // console.log("息壤",direction,name,this.block_Type);
        var jg = this.repeatRoad(true, direction);
        console.log("息壤重复判断结果", jg);
        if (jg == true)
            return;
        if (this.block_Type == cc.Enum(BlockType).Start) {
            this.set_Xi_Soil(direction, false);
            return;
        }
        if (this.block_Type == cc.Enum(BlockType).Nunja) {
            this.block_Type = cc.Enum(BlockType).Nomal;
            this.node.getChildByName("bg").getComponent(cc.Sprite).spriteFrame = null;
            this.node.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"]["block_Bg"];
        }
        if (end != null) {
            if (this.block_Type == cc.Enum(BlockType).End) {
                this.finishi = true;
                setTimeout(function () {
                    _this.set_Xi_Soil(direction, true);
                }, 500);
            }
            setTimeout(function () {
                if (name == "water")
                    cc.fx.Notifications.emit(cc.fx.Message.nextWater, (end + 1));
                else
                    cc.fx.Notifications.emit(cc.fx.Message.next, (end + 1));
            }, 400);
        }
        if (this.block_Type != cc.Enum(BlockType).End && this.block_Type != cc.Enum(BlockType).Start) {
            this.block_Type = cc.Enum(BlockType).Xi_Soil;
        }
        else {
        }
        var target = this.node.getChildByName("Xi_Soil");
        this.path_Type = direction;
        target.active = true;
        target.opacity = 0;
        cc.tween(target)
            .to(0.1, { opacity: 255 })
            .to(0.1, { opacity: 0 })
            .call(function () {
            if (direction != null && end == null) {
                var data = {
                    order: 0,
                    time: cc.fx.GameConfig.TIME_INFO.waterSpeed[0],
                    type: 0,
                    circulate: false
                };
                if (name == "water") {
                    _this.runWater(data);
                }
                else
                    _this.runRoad(data);
            }
        })
            .start();
    };
    //判断重复路径 
    NewClass.prototype.repeatRoad = function (type, direction) {
        //如果双向都占用了还进来就算死了- 
        var jg = false;
        if (this.node.getChildByName("vertical2").active == true && this.node.getChildByName("horizontal2").active == true) {
            // alert("治水失败");
            jg = true;
            if (type) {
                cc.fx.Notifications.emit(cc.fx.Message.showResult, "lose");
                cc.fx.Notifications.emit(cc.fx.Message.setData, false);
            }
        }
        else if (this.node.getChildByName("turn2").active == true && this.block_Type != cc.Enum(BlockType).Xi_Soil) {
            // alert("治水失败");
            jg = true;
            if (type) {
                cc.fx.Notifications.emit(cc.fx.Message.showResult, "lose");
                cc.fx.Notifications.emit(cc.fx.Message.setData, false);
            }
        }
        if (direction) {
            if (this.node.getChildByName("vertical2").active == true && this.block_Type == cc.Enum(BlockType).Xi_Soil && (direction == "up" || direction == "down")) {
                // alert("治水失败");
                jg = true;
                if (type) {
                    cc.fx.Notifications.emit(cc.fx.Message.showResult, "lose");
                    cc.fx.Notifications.emit(cc.fx.Message.setData, false);
                }
            }
            else if (this.node.getChildByName("horizontal2").active == true && this.block_Type == cc.Enum(BlockType).Xi_Soil && (direction == "right" || direction == "left")) {
                // alert("治水失败");
                jg = true;
                if (type) {
                    cc.fx.Notifications.emit(cc.fx.Message.showResult, "lose");
                    cc.fx.Notifications.emit(cc.fx.Message.setData, false);
                }
            }
        }
        return jg;
    };
    //修筑路线执行
    NewClass.prototype.runRoad = function (data) {
        if (this.path_Type == "err") {
            setTimeout(function () {
                if (data.circulate)
                    cc.fx.Notifications.emit(cc.fx.Message.next, order);
            }, data.time);
            return;
        }
        var jg = this.repeatRoad(true, null);
        if (jg == true)
            return;
        var target = null;
        var progress = 1;
        var time = data.time;
        var order = data.order + 1;
        var random = Math.floor(Math.random() * 4 + 1);
        target = this.node.getChildByName("vertical2");
        if (target.name == "vertical") {
            var water1_1 = target.getChildByName("wave").getChildByName("water1");
            var water2_1 = target.getChildByName("wave").getChildByName("water2");
            var water3_1 = target.getChildByName("wave").getChildByName("water3");
            var timeDelay = 0.15;
            water1_1.runAction(cc.sequence(cc.moveTo(0.6, cc.v2(water1_1.x, 120)), cc.delayTime(timeDelay), cc.callFunc(function () {
                water1_1.y = -120;
            })).repeatForever());
            water2_1.runAction(cc.sequence(cc.moveTo(0.6, cc.v2(water2_1.x, 120)), cc.delayTime(timeDelay), cc.callFunc(function () {
                water2_1.y = -120;
            })).repeatForever());
            water3_1.runAction(cc.sequence(cc.moveTo(0.6, cc.v2(water3_1.x, 120)), cc.delayTime(timeDelay), cc.callFunc(function () {
                water3_1.y = -120;
            })).repeatForever());
        }
        var name = "a" + random;
        if (this.block_Type != cc.Enum(BlockType).Reinforce)
            target.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"][name];
        if (target.active == true) {
            target = this.node.getChildByName("horizontal2");
            name = "b" + random;
            if (this.block_Type != cc.Enum(BlockType).Reinforce)
                target.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"][name];
        }
        // console.log(this.path_Type,data.order);
        if (this.path_Type == cc.Enum(PathType).up) {
        }
        else if (this.path_Type == cc.Enum(PathType).down) {
            target.angle = 180;
        }
        else if (this.path_Type == cc.Enum(PathType).left) {
            target.angle = 90;
            name = "b" + random;
            if (this.block_Type != cc.Enum(BlockType).Reinforce)
                target.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"][name];
        }
        else if (this.path_Type == cc.Enum(PathType).right) {
            target.angle = 270;
            name = "b" + random;
            if (this.block_Type != cc.Enum(BlockType).Reinforce)
                target.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"][name];
        }
        else {
            target = this.node.getChildByName("turn2");
            if (target.name == "turn") {
                var water_1 = target.getChildByName("wave").getChildByName("water");
                water_1.opacity = 0;
                water_1.runAction(cc.sequence(cc.rotateTo(7.2, -1080), cc.delayTime(0)).repeatForever());
                setTimeout(function () {
                    water_1.opacity = 255;
                }, 200);
            }
            name = "c" + random;
            if (this.block_Type != cc.Enum(BlockType).Reinforce)
                target.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"][name];
            progress = 0.25;
            if (this.path_Type == cc.Enum(PathType).up_left) {
                target.setPosition(-this.pos_Shifting, -this.pos_Shifting);
            }
            else if (this.path_Type == cc.Enum(PathType).up_right) {
                target.scaleX = -1;
                target.setPosition(this.pos_Shifting, -this.pos_Shifting);
            }
            else if (this.path_Type == cc.Enum(PathType).down_left) {
                target.angle = 180;
                target.scaleX = -1;
                target.setPosition(-this.pos_Shifting, this.pos_Shifting);
            }
            else if (this.path_Type == cc.Enum(PathType).down_right) {
                target.angle = 180;
                target.setPosition(this.pos_Shifting, this.pos_Shifting);
            }
            else if (this.path_Type == cc.Enum(PathType).left_up) {
                target.angle = -90;
                target.scaleY = -1;
                target.setPosition(this.pos_Shifting, this.pos_Shifting);
            }
            else if (this.path_Type == cc.Enum(PathType).left_down) {
                target.angle = 90;
                target.setPosition(-this.pos_Shifting, -this.pos_Shifting);
            }
            else if (this.path_Type == cc.Enum(PathType).right_up) {
                target.angle = -90;
                target.setPosition(-this.pos_Shifting, this.pos_Shifting);
            }
            else if (this.path_Type == cc.Enum(PathType).right_down) {
                target.angle = -90;
                target.scaleX = -1;
                target.setPosition(-this.pos_Shifting, -this.pos_Shifting);
            }
        }
        if (this.path_Type == "Reinforce") {
            target = this.node.getChildByName("Reinforce");
            if (this.block_Type == cc.Enum(BlockType).Peak) {
                cc.fx.Notifications.emit(cc.fx.Message.showResult, "lose");
                cc.fx.Notifications.emit(cc.fx.Message.setData, false);
                return;
            }
            if (this.block_Type != cc.Enum(BlockType).End)
                this.block_Type = cc.Enum(BlockType).Reinforce;
            this.node.getChildByName("vertical2").getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"]["e1"];
            this.node.getChildByName("turn2").getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"]["e3"];
            this.node.getChildByName("horizontal2").getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"]["e2"];
            target.active = true;
            target.opacity = 0;
            progress = 1;
            cc.tween(target)
                .to(cc.fx.GameConfig.TIME_INFO.ReinforceSpeed, { opacity: 255 })
                .call(function () {
                if (data.circulate)
                    cc.fx.Notifications.emit(cc.fx.Message.changeMap, order);
                cc.fx.Notifications.emit(cc.fx.Message.next, order);
            })
                .start();
        }
        else if (this.path_Type == "Xi_Soil") {
            target.active = false;
            if (this.block_Type != cc.Enum(BlockType).End && this.block_Type != cc.Enum(BlockType).Start)
                this.block_Type = cc.Enum(BlockType).Xi_Soil;
            target = this.node.getChildByName("Xi_Soil");
            target.active = true;
            target.opacity = 0;
            cc.tween(target)
                .to(0.01, { opacity: 1 })
                .to(0.01, { opacity: 0 })
                .call(function () {
                if (data.circulate) {
                    cc.fx.Notifications.emit(cc.fx.Message.next, order);
                }
            })
                .start();
        }
        else if (this.path_Type == "End") {
            target.active = false;
            if (this.block_Type != cc.Enum(BlockType).End && this.block_Type != cc.Enum(BlockType).Start)
                this.block_Type = cc.Enum(BlockType).Xi_Soil;
            var posTemp = data.last;
            var direction = "up";
            if (this.pos.x - posTemp.x >= 1) {
                direction = "right";
            }
            else if (this.pos.x - posTemp.x <= -1) {
                direction = "left";
            }
            else if (this.pos.y - posTemp.y >= 1) {
                direction = "down";
            }
            console.log("结束方向:", direction);
            if (!this.finishi) {
                this.finishi = true;
                this.set_Xi_Soil(direction, true);
            }
        }
        else {
            target.active = true;
            if (this.block_Type != cc.Enum(BlockType).Xi_Soil) {
                target.getComponent(cc.Sprite).fillRange = 0;
                cc.tween(target.getComponent(cc.Sprite))
                    .to(time, { fillRange: progress })
                    .call(function () {
                    if (data.circulate)
                        cc.fx.Notifications.emit(cc.fx.Message.next, order);
                })
                    .start();
            }
            else {
                target.opacity = 0;
                target.getComponent(cc.Sprite).fillRange = 1;
                cc.tween(target)
                    .to(time, { opacity: 255 })
                    .call(function () {
                    if (data.circulate)
                        cc.fx.Notifications.emit(cc.fx.Message.next, order);
                })
                    .start();
            }
        }
    };
    //洪峰执行
    NewClass.prototype.runWater = function (data) {
        if (this.node.getChildByName("waterStart").active == true && this.block_Type == cc.Enum(BlockType).Start) {
            // sp.getChildByName("waterStart").opacity = 255;
            cc.tween(this.node.getChildByName("waterStart"))
                .to(0.2, { opacity: 255 })
                .start();
        }
        if (this.path_Type == "err") {
            setTimeout(function () {
                if (data.circulate)
                    cc.fx.Notifications.emit(cc.fx.Message.nextWater, order);
            }, data.time);
            return;
        }
        //如果双向都占用了还进来就算死了- 
        if (this.node.getChildByName("vertical").active == true && this.node.getChildByName("horizontal").active == true) {
            // alert("治水失败");
            cc.fx.Notifications.emit(cc.fx.Message.showResult, "lose");
            cc.fx.Notifications.emit(cc.fx.Message.setData, false);
            // cc.director.loadScene("GameScene");
            return;
        }
        else if (this.node.getChildByName("turn").active == true && this.block_Type != cc.Enum(BlockType).Xi_Soil) {
            // alert("治水失败");
            cc.fx.Notifications.emit(cc.fx.Message.showResult, "lose");
            cc.fx.Notifications.emit(cc.fx.Message.setData, false);
            // cc.director.loadScene("GameScene");
            return;
        }
        var target = null;
        var progress = 1;
        var time = data.time;
        var order = data.order + 1;
        var random = Math.floor(Math.random() * 4 + 1);
        target = this.node.getChildByName("vertical");
        if (target.name == "vertical") {
            var water1_2 = target.getChildByName("wave").getChildByName("water1");
            var water2_2 = target.getChildByName("wave").getChildByName("water2");
            var water3_2 = target.getChildByName("wave").getChildByName("water3");
            var timeDelay = 0.15;
            water1_2.runAction(cc.sequence(cc.moveTo(0.6, cc.v2(water1_2.x, 120)), cc.delayTime(timeDelay), cc.callFunc(function () {
                water1_2.y = -120;
            })).repeatForever());
            water2_2.runAction(cc.sequence(cc.moveTo(0.6, cc.v2(water2_2.x, 120)), cc.delayTime(timeDelay), cc.callFunc(function () {
                water2_2.y = -120;
            })).repeatForever());
            water3_2.runAction(cc.sequence(cc.moveTo(0.6, cc.v2(water3_2.x, 120)), cc.delayTime(timeDelay), cc.callFunc(function () {
                water3_2.y = -120;
            })).repeatForever());
        }
        var name = "a" + random;
        // if(this.block_Type != cc.Enum(BlockType).Reinforce)target.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"][name];
        if (target.active == true) {
            target = this.node.getChildByName("horizontal");
            var water1_3 = target.getChildByName("wave").getChildByName("water1");
            var water2_3 = target.getChildByName("wave").getChildByName("water2");
            var water3_3 = target.getChildByName("wave").getChildByName("water3");
            var timeDelay = 0.15;
            water1_3.runAction(cc.sequence(cc.moveTo(0.6, cc.v2(water1_3.x, 120)), cc.delayTime(timeDelay), cc.callFunc(function () {
                water1_3.y = -120;
            })).repeatForever());
            water2_3.runAction(cc.sequence(cc.moveTo(0.6, cc.v2(water2_3.x, 120)), cc.delayTime(timeDelay), cc.callFunc(function () {
                water2_3.y = -120;
            })).repeatForever());
            water3_3.runAction(cc.sequence(cc.moveTo(0.6, cc.v2(water3_3.x, 120)), cc.delayTime(timeDelay), cc.callFunc(function () {
                water3_3.y = -120;
            })).repeatForever());
            name = "b" + random;
            //if(this.block_Type != cc.Enum(BlockType).Reinforce) target.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"][name];
        }
        // console.log(this.path_Type,data.order);
        if (this.path_Type == cc.Enum(PathType).up) {
        }
        else if (this.path_Type == cc.Enum(PathType).down) {
            target.angle = 180;
        }
        else if (this.path_Type == cc.Enum(PathType).left) {
            target.angle = 90;
            name = "b" + random;
            //if(this.block_Type != cc.Enum(BlockType).Reinforce) target.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"][name];
        }
        else if (this.path_Type == cc.Enum(PathType).right) {
            target.angle = 270;
            name = "b" + random;
            //if(this.block_Type != cc.Enum(BlockType).Reinforce) target.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"][name];
        }
        else {
            target = this.node.getChildByName("turn");
            if (target.name == "turn") {
                var water_2 = target.getChildByName("wave").getChildByName("water");
                water_2.opacity = 0;
                water_2.runAction(cc.sequence(cc.rotateTo(7.2, -1080), cc.delayTime(0)).repeatForever());
                setTimeout(function () {
                    water_2.opacity = 255;
                }, 200);
            }
            name = "c" + random;
            //if(this.block_Type != cc.Enum(BlockType).Reinforce)target.getComponent(cc.Sprite).spriteFrame = this.UI["_spriteFrames"][name];
            progress = 0.25;
            if (this.path_Type == cc.Enum(PathType).up_left) {
                target.setPosition(-this.pos_Shifting, -this.pos_Shifting);
            }
            else if (this.path_Type == cc.Enum(PathType).up_right) {
                target.scaleX = -1;
                target.setPosition(this.pos_Shifting, -this.pos_Shifting);
            }
            else if (this.path_Type == cc.Enum(PathType).down_left) {
                target.angle = 180;
                target.scaleX = -1;
                target.setPosition(-this.pos_Shifting, this.pos_Shifting);
            }
            else if (this.path_Type == cc.Enum(PathType).down_right) {
                target.angle = 180;
                target.setPosition(this.pos_Shifting, this.pos_Shifting);
            }
            else if (this.path_Type == cc.Enum(PathType).left_up) {
                target.angle = -90;
                target.scaleY = -1;
                target.setPosition(this.pos_Shifting, this.pos_Shifting);
            }
            else if (this.path_Type == cc.Enum(PathType).left_down) {
                target.angle = 90;
                target.setPosition(-this.pos_Shifting, -this.pos_Shifting);
            }
            else if (this.path_Type == cc.Enum(PathType).right_up) {
                target.angle = -90;
                target.setPosition(-this.pos_Shifting, this.pos_Shifting);
            }
            else if (this.path_Type == cc.Enum(PathType).right_down) {
                target.angle = -90;
                target.scaleX = -1;
                target.setPosition(-this.pos_Shifting, -this.pos_Shifting);
            }
        }
        if (this.path_Type == "End") {
            target.active = false;
            if (this.block_Type == cc.Enum(BlockType).End) {
                if (this.node.getChildByName("waterStart").active == true && this.block_Type == cc.Enum(BlockType).End) {
                    cc.tween(this.node.getChildByName("waterStart"))
                        .to(0.2, { opacity: 255 })
                        .call(function () {
                        // alert("治水成功");
                        cc.fx.Notifications.emit(cc.fx.Message.showResult, "win");
                        cc.fx.Notifications.emit(cc.fx.Message.setData, true);
                        if (cc.fx.GameConfig.GM_INFO.level < 7) {
                            cc.fx.GameConfig.GM_INFO.level += 1;
                        }
                        setTimeout(function () {
                            // cc.director.loadScene("GameScene");
                        }, 500);
                    })
                        .start();
                }
            }
            else {
                target = this.node.getChildByName("End");
                target.active = true;
                target.opacity = 0;
                var posTemp = data.last;
                if (this.pos.x - posTemp.x >= 1) {
                    target.angle = -90;
                }
                else if (this.pos.x - posTemp.x <= -1) {
                    target.angle = 90;
                }
                else if (this.pos.y - posTemp.y >= 1) {
                    target.angle = 180;
                }
                cc.tween(target)
                    .to(0.5, { opacity: 255 })
                    .call(function () {
                    // alert("治水失败")
                    cc.fx.Notifications.emit(cc.fx.Message.showResult, "lose");
                    cc.fx.Notifications.emit(cc.fx.Message.setData, false);
                    // cc.director.loadScene("GameScene");
                })
                    .start();
            }
        }
        else {
            target.active = true;
            target.getComponent(cc.Sprite).fillRange = 0;
            cc.tween(target.getComponent(cc.Sprite))
                .to(time, { fillRange: progress })
                .call(function () {
                if (data.circulate)
                    cc.fx.Notifications.emit(cc.fx.Message.nextWater, order);
            })
                .start();
        }
    };
    __decorate([
        property(cc.SpriteAtlas)
    ], NewClass.prototype, "UI", void 0);
    NewClass = __decorate([
        ccclass
    ], NewClass);
    return NewClass;
}(cc.Component));
exports.default = NewClass;

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