"use strict";
cc._RF.push(module, 'e35abcX5VRAoItO6mgFcYyX', 'ControlManager');
// Script/ControlManager.ts

"use strict";
// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var NewClass = /** @class */ (function (_super) {
    __extends(NewClass, _super);
    function NewClass() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.Map = null;
        _this.tip = null;
        _this.reinforce = null;
        _this.soil = null;
        return _this;
        // update (dt) {}
    }
    // LIFE-CYCLE CALLBACKS:
    // onLoad () {}
    NewClass.prototype.start = function () {
        this.tipArray = [];
        this.canTouch = true;
    };
    NewClass.prototype.setPosition = function (tip) {
        tip.setPosition(45, -35);
        if (this.tipArray.length > 0) {
            var length = this.tipArray.length + 1;
            var posY = Math.ceil(length / 5) - 1;
            var posX = length - Math.floor(posY) * 5 - 1;
            tip.setPosition(45 + 65 * posX, -35 - 60 * posY);
        }
    };
    NewClass.prototype.removeAllTip = function () {
        if (!this.canTouch)
            return;
        this.tipArray = [];
    };
    NewClass.prototype.back_Click = function () {
        if (!this.canTouch)
            return;
        if (this.tipArray.length > 0) {
            var tip = this.tipArray[this.tipArray.length - 1];
            tip.active = false;
            tip.removeFromParent(this.Map);
            tip = null;
            this.tipArray.pop();
        }
    };
    NewClass.prototype.btn_Click = function (target, data) {
        if (!this.canTouch)
            return;
        var prefab = this.tip;
        if (data == "reinforce" || data == "soil")
            prefab = this[data];
        var tip = cc.instantiate(prefab);
        if (data == "up")
            tip.angle = 180;
        if (data == "left")
            tip.angle = -90;
        if (data == "right")
            tip.angle = 90;
        tip.parent = this.Map;
        this.setPosition(tip);
        this.tipArray.push(tip);
        cc.fx.Notifications.emit(cc.fx.Message.control, data);
    };
    NewClass.prototype.start_Click = function () {
        if (!this.canTouch)
            return;
        this.canTouch = false;
        cc.fx.Notifications.emit(cc.fx.Message.startGame, null);
    };
    __decorate([
        property(cc.Node)
    ], NewClass.prototype, "Map", void 0);
    __decorate([
        property(cc.Prefab)
    ], NewClass.prototype, "tip", void 0);
    __decorate([
        property(cc.Prefab)
    ], NewClass.prototype, "reinforce", void 0);
    __decorate([
        property(cc.Prefab)
    ], NewClass.prototype, "soil", void 0);
    NewClass = __decorate([
        ccclass
    ], NewClass);
    return NewClass;
}(cc.Component));
exports.default = NewClass;

cc._RF.pop();