e1f5944d-8945-4074-9c43-e07ab0fc197d.js 3.41 KB
"use strict";
cc._RF.push(module, 'e1f59RNiUVAdJxD4Hqw/Bl9', 'PatrolObj');
// scripts/kernel/battle/map/PatrolObj.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 __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.PatrolObj = void 0;
var GlobalNode_1 = require("../../GlobalNode");
var BattleConst_1 = require("../BattleConst");
var ObjData_1 = require("./ObjData");
var PatrolObj = /** @class */ (function (_super) {
    __extends(PatrolObj, _super);
    function PatrolObj() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this._patroltype = -1;
        _this._patrolIndex = 0;
        /**对应出口的位置,只有入口才有有效值 */
        _this.brotherIndex = -1;
        _this._hited = [];
        return _this;
    }
    Object.defineProperty(PatrolObj.prototype, "patrolType", {
        /**0为入口 1为出口 */
        get: function () { return this._patroltype; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PatrolObj.prototype, "patrolIndex", {
        get: function () { return this._patrolIndex; },
        enumerable: false,
        configurable: true
    });
    PatrolObj.prototype.initPatrolData = function ($index, $type, $brotherIndex) {
        this.canSlide = false; //XXX 传送门不可下落,因为是成对出现的,下落有可能导致销毁
        this._patroltype = $type;
        this._patrolIndex = $index;
        this.brotherIndex = $brotherIndex;
    };
    PatrolObj.prototype.onCollisonToBall = function (collider) {
        _super.prototype.onCollisonToBall.call(this, collider);
        if (this._patroltype == 0 && this.brotherIndex > -1 && !this._hited.includes(collider.node.uuid)) {
            this._hited.push(collider.node.uuid);
            var exitObj_1 = this.map.objData.get(this.brotherIndex);
            this.map.battle.addToRoundClear(this);
            this.map.battle.addToRoundClear(exitObj_1);
            collider.enabled = false; //先关闭碰撞,等当前物理步进结束后,再设置位置
            BattleConst_1.getGlobalNode().getComponent(GlobalNode_1.default).scheduleOnce(function () {
                collider.node.setPosition(exitObj_1.pixelPos.x, exitObj_1.pixelPos.y);
                collider.enabled = true;
            }, 0);
        }
        // else {
        //     cc.warn('patrol cannot find exit')
        // }
    };
    PatrolObj.prototype.clone = function () {
        return this.cloneValue(new PatrolObj());
    };
    PatrolObj.prototype.cloneValue = function (target) {
        _super.prototype.cloneValue.call(this, target);
        target._patroltype = this._patroltype;
        target._patrolIndex = this._patrolIndex;
        target.brotherIndex = this.brotherIndex;
        return target;
    };
    return PatrolObj;
}(ObjData_1.ObjData));
exports.PatrolObj = PatrolObj;

cc._RF.pop();