"use strict"; cc._RF.push(module, 'ee0dbKLiI9DVbrpvEAg/a+n', 'RectBlockData'); // scripts/kernel/battle/map/RectBlockData.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.RectBlockData = void 0; var BlockData_1 = require("./BlockData"); var ObjDataUtil_1 = require("./ObjDataUtil"); var RectBlockData = /** @class */ (function (_super) { __extends(RectBlockData, _super); function RectBlockData() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(RectBlockData.prototype, "widthGrid", { get: function () { return this._widthGrid; }, enumerable: false, configurable: true }); Object.defineProperty(RectBlockData.prototype, "widthPixel", { get: function () { return this._widthGrid * this.map.gridSize.x; }, enumerable: false, configurable: true }); Object.defineProperty(RectBlockData.prototype, "heightGrid", { get: function () { return this._heightGrid; }, enumerable: false, configurable: true }); Object.defineProperty(RectBlockData.prototype, "heightPixel", { get: function () { return this._heightGrid * this.map.gridSize.y; }, enumerable: false, configurable: true }); Object.defineProperty(RectBlockData.prototype, "viewPixelPosX", { get: function () { return this._pixelPos.x + (this._widthGrid) / 2 * this.map.gridSize.x - this.map.gridSize.x / 2; }, enumerable: false, configurable: true }); Object.defineProperty(RectBlockData.prototype, "viewPixelPosY", { get: function () { return this._pixelPos.y - (this._heightGrid) / 2 * this.map.gridSize.y + this.map.gridSize.y / 2; }, enumerable: false, configurable: true }); //#region life cycle RectBlockData.prototype.initBlock = function (map, type, hp, gridX, gridY, width, height) { if (width === void 0) { width = 1; } if (height === void 0) { height = 1; } this._widthGrid = width; this._heightGrid = height; _super.prototype.initBlock.call(this, map, type, hp, gridX, gridY); for (var i = this._gridPos.x; i < this._gridPos.x + this._widthGrid; ++i) { for (var j = this._gridPos.y; j < this._gridPos.y + this._heightGrid; ++j) { if (i == this._gridPos.x && j == this._gridPos.y) { continue; } var index = ObjDataUtil_1.ObjDataUtil.getIndex(i, j); this.map.objData.delete(index); //删除范围内的其他格子 this.map.blockData.delete(index); } } this._contentY = this._gridPos.y + this._heightGrid - 1; }; RectBlockData.prototype.clone = function () { return this.cloneValue(new RectBlockData()); }; RectBlockData.prototype.cloneValue = function (target) { _super.prototype.cloneValue.call(this, target); target._widthGrid = this._widthGrid; target._heightGrid = this._heightGrid; return target; }; //#endregion //#region public method RectBlockData.prototype.setGridPos = function (gridX, gridY) { // this.clearFromMap(); _super.prototype.setGridPos.call(this, gridX, gridY); this._contentY = this._gridPos.y + this._heightGrid - 1; // this.addToMap(); }; RectBlockData.prototype.isReachedDownBorder = function () { return !this._droped && (this._gridPos.y + this._heightGrid - 1 >= this.map.mapGridSize.y - 1); }; return RectBlockData; }(BlockData_1.BlockData)); exports.RectBlockData = RectBlockData; cc._RF.pop();