From 167ef03df6eaffb10fbe964bc9ea6e9abdb6f871 Mon Sep 17 00:00:00 2001 From: yhh <359807859@qq.com> Date: Wed, 12 Aug 2020 12:16:35 +0800 Subject: [PATCH] =?UTF-8?q?tiled=20=E5=9F=BA=E6=9C=AC=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/libs/framework/framework.d.ts | 334 ++++++++++++ demo/libs/framework/framework.js | 569 +++++++++++++++++++++ demo/libs/framework/framework.min.js | 2 +- demo/resource/default.res.json | 5 + demo/src/game/MainScene.ts | 1 - source/bin/framework.d.ts | 334 ++++++++++++ source/bin/framework.js | 569 +++++++++++++++++++++ source/bin/framework.min.js | 2 +- source/src/ECS/Components/TiledMapMover.ts | 131 +++++ source/src/Math/MathHelper.ts | 13 + source/src/Tiled/Group.ts | 16 + source/src/Tiled/ITmxLayer.ts | 9 + source/src/Tiled/ImageLayer.ts | 15 + source/src/Tiled/Layer.ts | 100 ++++ source/src/Tiled/Map.ts | 114 +++++ source/src/Tiled/ObjectGroup.ts | 77 +++ source/src/Tiled/TiledCore.ts | 58 +++ source/src/Tiled/Tileset.ts | 39 ++ source/src/Tiled/TilesetTile.ts | 79 +++ source/src/Utils/EdgeExt.ts | 32 ++ source/src/Utils/Enum.ts | 8 + source/src/Utils/Enumerable.ts | 16 + source/src/Utils/RectangleExt.ts | 78 +++ source/src/Utils/SubpixelNumber.ts | 27 + 24 files changed, 2625 insertions(+), 3 deletions(-) create mode 100644 source/src/ECS/Components/TiledMapMover.ts create mode 100644 source/src/Tiled/Group.ts create mode 100644 source/src/Tiled/ITmxLayer.ts create mode 100644 source/src/Tiled/ImageLayer.ts create mode 100644 source/src/Tiled/Layer.ts create mode 100644 source/src/Tiled/Map.ts create mode 100644 source/src/Tiled/ObjectGroup.ts create mode 100644 source/src/Tiled/TiledCore.ts create mode 100644 source/src/Tiled/Tileset.ts create mode 100644 source/src/Tiled/TilesetTile.ts create mode 100644 source/src/Utils/EdgeExt.ts create mode 100644 source/src/Utils/Enum.ts create mode 100644 source/src/Utils/Enumerable.ts create mode 100644 source/src/Utils/SubpixelNumber.ts diff --git a/demo/libs/framework/framework.d.ts b/demo/libs/framework/framework.d.ts index 30746054..35b7f9ef 100644 --- a/demo/libs/framework/framework.d.ts +++ b/demo/libs/framework/framework.d.ts @@ -699,6 +699,32 @@ declare module es { stop(): void; } } +declare module es { + class CollisionState { + right: boolean; + left: boolean; + above: boolean; + below: boolean; + becameGroundedThisFrame: boolean; + wasGroundedLastFrame: boolean; + isGroundedOnOnewayPlatform: boolean; + slopAngle: number; + readonly hasCollision: boolean; + _movementRemainderX: SubpixelNumber; + _movementRemainderY: SubpixelNumber; + reset(): void; + toString(): string; + } + class TiledMapMover extends Component { + colliderHorizontalInset: number; + colliderVerticalInset: number; + _boxColliderBounds: Rectangle; + constructor(); + testCollisions(motion: Vector2, boxColliderBounds: Rectangle, collisionState: CollisionState): void; + testMapCollision(collisionRect: Rectangle, direction: Edge, collisionState: CollisionState, collisionResponse: number): void; + collisionRectForSide(side: Edge, motion: number): Rectangle; + } +} declare module es { interface ITriggerListener { onTriggerEnter(other: Collider, local: Collider): any; @@ -1207,6 +1233,7 @@ declare module es { static isEven(value: number): boolean; static clamp01(value: number): number; static angleBetweenVectors(from: Vector2, to: Vector2): number; + static incrementWithWrap(t: number, length: number): number; } } declare module es { @@ -1488,6 +1515,281 @@ declare module es { reset(): void; } } +declare module es { + class TmxGroup implements ITmxLayer { + map: TmxMap; + offsetX: number; + offsetY: number; + opacity: number; + properties: Map; + visible: boolean; + name: string; + layers: TmxList; + tileLayers: TmxList; + objectGroups: TmxList; + imageLayers: TmxList; + groups: TmxList; + } +} +declare module es { + interface ITmxLayer { + offsetX: number; + offsetY: number; + opacity: number; + visible: boolean; + properties: Map; + } +} +declare module es { + class TmxImageLayer implements ITmxLayer { + map: TmxMap; + name: string; + offsetX: number; + offsetY: number; + opacity: number; + properties: Map; + visible: boolean; + width?: number; + height?: number; + image: TmxImage; + } +} +declare module es { + class TmxLayer implements ITmxLayer { + map: TmxMap; + name: string; + opacity: number; + offsetX: number; + offsetY: number; + properties: Map; + visible: boolean; + readonly offset: Vector2; + width: number; + height: number; + tiles: TmxLayerTile[]; + getTileWithGid(gid: number): TmxLayerTile; + } + class TmxLayerTile { + static readonly FLIPPED_HORIZONTALLY_FLAG: number; + static readonly FLIPPED_VERTICALLY_FLAG: number; + static readonly FLIPPED_DIAGONALLY_FLAG: number; + tileset: TmxTileset; + gid: number; + x: number; + y: number; + readonly position: Vector2; + horizontalFlip: boolean; + verticalFlip: boolean; + diagonalFlip: boolean; + _tilesetTileIndex?: number; + readonly tilesetTile: TmxTilesetTile; + constructor(map: TmxMap, id: number, x: number, y: number); + } +} +declare module es { + class TmxDocument { + TmxDirectory: string; + constructor(); + } + interface ITmxElement { + name: string; + } + class TmxList extends Map { + _nameCount: Map; + add(t: T): void; + protected getKeyForItem(item: T): string; + } + class TmxImage { + texture: egret.Texture; + source: string; + format: string; + data: any; + trans: number; + width: number; + height: number; + dispose(): void; + } +} +declare module es { + class TmxMap extends TmxDocument { + version: string; + tiledVersion: string; + width: number; + height: number; + readonly worldWidth: number; + readonly worldHeight: number; + tileWidth: number; + tileHeight: number; + hexSideLength?: number; + orientation: OrientationType; + staggerAxis: StaggerAxisType; + staggerIndex: StaggerIndexType; + renderOrder: RenderOrderType; + backgroundColor: number; + nextObjectID?: number; + layers: TmxList; + tilesets: TmxList; + tileLayers: TmxList; + objectGroups: TmxList; + imageLayers: TmxList; + groups: TmxList; + properties: Map; + maxTileWidth: number; + maxTileHeight: number; + readonly requiresLargeTileCulling: boolean; + getTilesetForTileGid(gid: number): TmxTileset; + update(): void; + _isDisposed: any; + dispose(disposing?: boolean): void; + } + enum OrientationType { + unknown = 0, + orthogonal = 1, + isometric = 2, + staggered = 3, + hexagonal = 4 + } + enum StaggerAxisType { + x = 0, + y = 1 + } + enum StaggerIndexType { + odd = 0, + even = 1 + } + enum RenderOrderType { + rightDown = 0, + rightUp = 1, + leftDown = 2, + leftUp = 3 + } +} +declare module es { + class TmxObjectGroup implements ITmxLayer { + map: TmxMap; + name: string; + opacity: number; + visible: boolean; + offsetX: number; + offsetY: number; + color: number; + drawOrder: DrawOrderType; + objects: TmxList; + properties: Map; + } + class TmxObject implements ITmxElement { + id: number; + name: string; + objectType: TmxObjectType; + type: string; + x: number; + y: number; + width: number; + height: number; + rotation: number; + tile: TmxLayerTile; + visible: boolean; + text: TmxText; + } + class TmxText { + fontFamily: string; + pixelSize: number; + wrap: boolean; + color: number; + bold: boolean; + italic: boolean; + underline: boolean; + strikeout: boolean; + kerning: boolean; + alignment: TmxAlignment; + value: string; + } + class TmxAlignment { + horizontal: TmxHorizontalAlignment; + vertical: TmxVerticalAlignment; + } + enum TmxObjectType { + basic = 0, + point = 1, + tile = 2, + ellipse = 3, + polygon = 4, + polyline = 5, + text = 6 + } + enum DrawOrderType { + unkownOrder = -1, + TopDown = 0, + IndexOrder = 1 + } + enum TmxHorizontalAlignment { + left = 0, + center = 1, + right = 2, + justify = 3 + } + enum TmxVerticalAlignment { + top = 0, + center = 1, + bottom = 2 + } +} +declare module es { + class TmxTileset extends TmxDocument implements ITmxElement { + map: TmxMap; + firstGid: number; + name: any; + tileWidth: number; + tileHeight: number; + spacing: number; + margin: number; + columns?: number; + tileCount?: number; + tiles: Map; + tileOffset: TmxTileOffset; + properties: Map; + image: TmxImage; + terrains: TmxList; + tileRegions: Map; + update(): void; + } + class TmxTileOffset { + x: number; + y: number; + } + class TmxTerrain implements ITmxElement { + name: any; + tile: number; + properties: Map; + } +} +declare module es { + class TmxTilesetTile { + tileset: TmxTileset; + id: number; + terrainEdges: TmxTerrain[]; + probability: number; + type: string; + properties: Map; + image: TmxImage; + objectGroups: TmxList; + animationFrames: TmxAnimationFrame[]; + readonly currentAnimationFrameGid: number; + _animationElapsedTime: number; + _animationCurrentFrame: number; + isDestructable: boolean; + isSlope: boolean; + isOneWayPlatform: boolean; + slopeTopLeft: number; + slopeTopRight: number; + processProperties(): void; + updateAnimatedTiles(): void; + } + class TmxAnimationFrame { + gid: number; + duration: number; + } +} declare class ArrayUtils { static bubbleSort(ary: number[]): void; static insertionSort(ary: number[]): void; @@ -1530,6 +1832,13 @@ declare module es { static getColorMatrix(color: number): egret.ColorMatrixFilter; } } +declare module es { + class EdgeExt { + static oppositeEdge(self: Edge): Edge; + static isHorizontal(self: Edge): boolean; + static isVertical(self: Edge): boolean; + } +} declare module es { class FuncPack { func: Function; @@ -1544,6 +1853,19 @@ declare module es { emit(eventType: T, data?: any): void; } } +declare module es { + enum Edge { + top = 0, + bottom = 1, + left = 2, + right = 3 + } +} +declare module es { + class Enumerable { + static repeat(element: T, count: number): any[]; + } +} declare module es { class GlobalManager { _enabled: boolean; @@ -1713,7 +2035,19 @@ declare class RandomUtils { } declare module es { class RectangleExt { + static getSide(rect: Rectangle, edge: Edge): number; static union(first: Rectangle, point: Vector2): Rectangle; + static getHalfRect(rect: Rectangle, edge: Edge): Rectangle; + static getRectEdgePortion(rect: Rectangle, edge: Edge, size?: number): Rectangle; + static expandSide(rect: Rectangle, edge: Edge, amount: number): void; + static contract(rect: Rectangle, horizontalAmount: any, verticalAmount: any): void; + } +} +declare module es { + class SubpixelNumber { + remainder: number; + update(amount: number): number; + reset(): void; } } declare module es { diff --git a/demo/libs/framework/framework.js b/demo/libs/framework/framework.js index f0620472..72f4fee8 100644 --- a/demo/libs/framework/framework.js +++ b/demo/libs/framework/framework.js @@ -3207,6 +3207,85 @@ var es; es.SpriteAnimator = SpriteAnimator; })(es || (es = {})); var es; +(function (es) { + var CollisionState = (function () { + function CollisionState() { + } + Object.defineProperty(CollisionState.prototype, "hasCollision", { + get: function () { + return this.below || this.right || this.left || this.above; + }, + enumerable: true, + configurable: true + }); + CollisionState.prototype.reset = function () { + this.becameGroundedThisFrame = this.isGroundedOnOnewayPlatform = this.right = this.left = this.above = this.below = false; + this.slopAngle = 0; + }; + CollisionState.prototype.toString = function () { + return "[CollisionState] r: " + this.right + ", l: " + this.left + ", a: " + this.above + ", b: " + this.below + ", angle: " + this.slopAngle + ", wasGroundedLastFrame: " + this.wasGroundedLastFrame + ", becameGroundedThisFrame: " + this.becameGroundedThisFrame; + }; + return CollisionState; + }()); + es.CollisionState = CollisionState; + var TiledMapMover = (function (_super) { + __extends(TiledMapMover, _super); + function TiledMapMover() { + var _this = _super.call(this) || this; + _this.colliderHorizontalInset = 2; + _this.colliderVerticalInset = 6; + return _this; + } + TiledMapMover.prototype.testCollisions = function (motion, boxColliderBounds, collisionState) { + this._boxColliderBounds = boxColliderBounds; + collisionState.wasGroundedLastFrame = collisionState.below; + collisionState.reset(); + var motionX = motion.x; + var motionY = motion.y; + if (motionX != 0) { + var direction = motionX > 0 ? es.Edge.right : es.Edge.left; + var sweptBounds = this.collisionRectForSide(direction, motionX); + var collisionResponse = 0; + if (this.testMapCollision(sweptBounds, direction, collisionState, collisionResponse)) { + motion.x = collisionResponse - es.RectangleExt.getSide(boxColliderBounds, direction); + collisionState.left = direction == es.Edge.left; + collisionState.right = direction == es.Edge.right; + collisionState._movementRemainderX.reset(); + } + else { + collisionState.left = false; + collisionState.right = false; + } + } + }; + TiledMapMover.prototype.testMapCollision = function (collisionRect, direction, collisionState, collisionResponse) { + var side = es.EdgeExt.oppositeEdge(direction); + var perpindicularPosition = es.EdgeExt.isVertical(side) ? collisionRect.center.x : collisionRect.center.y; + var leadingPosition = es.RectangleExt.getSide(collisionRect, direction); + var shouldTestSlopes = es.EdgeExt.isVertical(side); + }; + TiledMapMover.prototype.collisionRectForSide = function (side, motion) { + var bounds; + if (es.EdgeExt.isHorizontal(side)) { + bounds = es.RectangleExt.getRectEdgePortion(this._boxColliderBounds, side); + } + else { + bounds = es.RectangleExt.getHalfRect(this._boxColliderBounds, side); + } + if (es.EdgeExt.isVertical(side)) { + es.RectangleExt.contract(bounds, this.colliderHorizontalInset, 0); + } + else { + es.RectangleExt.contract(bounds, 0, this.colliderVerticalInset); + } + es.RectangleExt.expandSide(bounds, side, motion); + return bounds; + }; + return TiledMapMover; + }(es.Component)); + es.TiledMapMover = TiledMapMover; +})(es || (es = {})); +var es; (function (es) { var Mover = (function (_super) { __extends(Mover, _super); @@ -5631,6 +5710,12 @@ var es; MathHelper.angleBetweenVectors = function (from, to) { return Math.atan2(to.y - from.y, to.x - from.x); }; + MathHelper.incrementWithWrap = function (t, length) { + t++; + if (t == length) + return 0; + return t; + }; MathHelper.Epsilon = 0.00001; MathHelper.Rad2Deg = 57.29578; MathHelper.Deg2Rad = 0.0174532924; @@ -7259,6 +7344,357 @@ var es; }()); es.RaycastResultParser = RaycastResultParser; })(es || (es = {})); +var es; +(function (es) { + var TmxGroup = (function () { + function TmxGroup() { + } + return TmxGroup; + }()); + es.TmxGroup = TmxGroup; +})(es || (es = {})); +var es; +(function (es) { + var TmxImageLayer = (function () { + function TmxImageLayer() { + } + return TmxImageLayer; + }()); + es.TmxImageLayer = TmxImageLayer; +})(es || (es = {})); +var es; +(function (es) { + var TmxLayer = (function () { + function TmxLayer() { + } + Object.defineProperty(TmxLayer.prototype, "offset", { + get: function () { + return new es.Vector2(this.offsetX, this.offsetY); + }, + enumerable: true, + configurable: true + }); + TmxLayer.prototype.getTileWithGid = function (gid) { + for (var i = 0; i < this.tiles.length; i++) { + if (this.tiles[i] && this.tiles[i].gid == gid) + return this.tiles[i]; + } + return null; + }; + return TmxLayer; + }()); + es.TmxLayer = TmxLayer; + var TmxLayerTile = (function () { + function TmxLayerTile(map, id, x, y) { + this.x = x; + this.y = y; + var rawGid = id; + var flip; + flip = (rawGid & TmxLayerTile.FLIPPED_HORIZONTALLY_FLAG) != 0; + this.horizontalFlip = flip; + flip = (rawGid & TmxLayerTile.FLIPPED_VERTICALLY_FLAG) != 0; + this.verticalFlip = flip; + flip = (rawGid & TmxLayerTile.FLIPPED_DIAGONALLY_FLAG) != 0; + this.diagonalFlip = flip; + rawGid &= ~(TmxLayerTile.FLIPPED_HORIZONTALLY_FLAG | TmxLayerTile.FLIPPED_VERTICALLY_FLAG | TmxLayerTile.FLIPPED_DIAGONALLY_FLAG); + this.gid = rawGid; + this.tileset = map.getTilesetForTileGid(this.gid); + } + Object.defineProperty(TmxLayerTile.prototype, "position", { + get: function () { + return new es.Vector2(this.x, this.y); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TmxLayerTile.prototype, "tilesetTile", { + get: function () { + if (this._tilesetTileIndex == undefined) { + this._tilesetTileIndex = -1; + if (this.tileset.firstGid <= this.gid) { + var tilesetTile = this.tileset.tiles.get(this.gid - this.tileset.firstGid); + if (tilesetTile) { + this._tilesetTileIndex = this.gid - this.tileset.firstGid; + } + } + } + if (this._tilesetTileIndex < 0) + return null; + return this.tileset.tiles.get(this._tilesetTileIndex); + }, + enumerable: true, + configurable: true + }); + TmxLayerTile.FLIPPED_HORIZONTALLY_FLAG = 0x80000000; + TmxLayerTile.FLIPPED_VERTICALLY_FLAG = 0x40000000; + TmxLayerTile.FLIPPED_DIAGONALLY_FLAG = 0x20000000; + return TmxLayerTile; + }()); + es.TmxLayerTile = TmxLayerTile; +})(es || (es = {})); +var es; +(function (es) { + var TmxDocument = (function () { + function TmxDocument() { + this.TmxDirectory = ""; + } + return TmxDocument; + }()); + es.TmxDocument = TmxDocument; + var TmxList = (function (_super) { + __extends(TmxList, _super); + function TmxList() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._nameCount = new Map(); + return _this; + } + TmxList.prototype.add = function (t) { + var tName = t.name; + if (this.has(tName)) + this._nameCount.set(tName, this._nameCount.get(tName) + 1); + else + this._nameCount.set(tName, 0); + }; + TmxList.prototype.getKeyForItem = function (item) { + var name = item.name; + var count = this._nameCount.get(name); + var dupes = 0; + while (this.has(name)) { + name = name + es.Enumerable.repeat("_", dupes).toString() + count.toString(); + dupes++; + } + return name; + }; + return TmxList; + }(Map)); + es.TmxList = TmxList; + var TmxImage = (function () { + function TmxImage() { + } + TmxImage.prototype.dispose = function () { + if (this.texture) { + this.texture.dispose(); + this.texture = null; + } + }; + return TmxImage; + }()); + es.TmxImage = TmxImage; +})(es || (es = {})); +var es; +(function (es) { + var TmxMap = (function (_super) { + __extends(TmxMap, _super); + function TmxMap() { + return _super !== null && _super.apply(this, arguments) || this; + } + Object.defineProperty(TmxMap.prototype, "worldWidth", { + get: function () { + return this.width * this.tileWidth; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TmxMap.prototype, "worldHeight", { + get: function () { + return this.height * this.tileHeight; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TmxMap.prototype, "requiresLargeTileCulling", { + get: function () { + return this.maxTileHeight > this.tileHeight || this.maxTileWidth > this.tileWidth; + }, + enumerable: true, + configurable: true + }); + TmxMap.prototype.getTilesetForTileGid = function (gid) { + if (gid == 0) + return null; + for (var i = this.tilesets.size - 1; i >= 0; i--) { + if (this.tilesets.get(i.toString()).firstGid <= gid) + return this.tilesets.get(i.toString()); + } + console.error("tile gid" + gid + "\u672A\u5728\u4EFB\u4F55tileset\u4E2D\u627E\u5230"); + }; + TmxMap.prototype.update = function () { + this.tilesets.forEach(function (tileset) { tileset.update(); }); + }; + TmxMap.prototype.dispose = function (disposing) { + if (disposing === void 0) { disposing = true; } + if (!this._isDisposed) { + if (disposing) { + this.tilesets.forEach(function (tileset) { if (tileset.image) + tileset.image.dispose(); }); + this.imageLayers.forEach(function (layer) { if (layer.image) + layer.image.dispose(); }); + } + this._isDisposed = true; + } + }; + return TmxMap; + }(es.TmxDocument)); + es.TmxMap = TmxMap; + var OrientationType; + (function (OrientationType) { + OrientationType[OrientationType["unknown"] = 0] = "unknown"; + OrientationType[OrientationType["orthogonal"] = 1] = "orthogonal"; + OrientationType[OrientationType["isometric"] = 2] = "isometric"; + OrientationType[OrientationType["staggered"] = 3] = "staggered"; + OrientationType[OrientationType["hexagonal"] = 4] = "hexagonal"; + })(OrientationType = es.OrientationType || (es.OrientationType = {})); + var StaggerAxisType; + (function (StaggerAxisType) { + StaggerAxisType[StaggerAxisType["x"] = 0] = "x"; + StaggerAxisType[StaggerAxisType["y"] = 1] = "y"; + })(StaggerAxisType = es.StaggerAxisType || (es.StaggerAxisType = {})); + var StaggerIndexType; + (function (StaggerIndexType) { + StaggerIndexType[StaggerIndexType["odd"] = 0] = "odd"; + StaggerIndexType[StaggerIndexType["even"] = 1] = "even"; + })(StaggerIndexType = es.StaggerIndexType || (es.StaggerIndexType = {})); + var RenderOrderType; + (function (RenderOrderType) { + RenderOrderType[RenderOrderType["rightDown"] = 0] = "rightDown"; + RenderOrderType[RenderOrderType["rightUp"] = 1] = "rightUp"; + RenderOrderType[RenderOrderType["leftDown"] = 2] = "leftDown"; + RenderOrderType[RenderOrderType["leftUp"] = 3] = "leftUp"; + })(RenderOrderType = es.RenderOrderType || (es.RenderOrderType = {})); +})(es || (es = {})); +var es; +(function (es) { + var TmxObjectGroup = (function () { + function TmxObjectGroup() { + } + return TmxObjectGroup; + }()); + es.TmxObjectGroup = TmxObjectGroup; + var TmxObject = (function () { + function TmxObject() { + } + return TmxObject; + }()); + es.TmxObject = TmxObject; + var TmxText = (function () { + function TmxText() { + } + return TmxText; + }()); + es.TmxText = TmxText; + var TmxAlignment = (function () { + function TmxAlignment() { + } + return TmxAlignment; + }()); + es.TmxAlignment = TmxAlignment; + var TmxObjectType; + (function (TmxObjectType) { + TmxObjectType[TmxObjectType["basic"] = 0] = "basic"; + TmxObjectType[TmxObjectType["point"] = 1] = "point"; + TmxObjectType[TmxObjectType["tile"] = 2] = "tile"; + TmxObjectType[TmxObjectType["ellipse"] = 3] = "ellipse"; + TmxObjectType[TmxObjectType["polygon"] = 4] = "polygon"; + TmxObjectType[TmxObjectType["polyline"] = 5] = "polyline"; + TmxObjectType[TmxObjectType["text"] = 6] = "text"; + })(TmxObjectType = es.TmxObjectType || (es.TmxObjectType = {})); + var DrawOrderType; + (function (DrawOrderType) { + DrawOrderType[DrawOrderType["unkownOrder"] = -1] = "unkownOrder"; + DrawOrderType[DrawOrderType["TopDown"] = 0] = "TopDown"; + DrawOrderType[DrawOrderType["IndexOrder"] = 1] = "IndexOrder"; + })(DrawOrderType = es.DrawOrderType || (es.DrawOrderType = {})); + var TmxHorizontalAlignment; + (function (TmxHorizontalAlignment) { + TmxHorizontalAlignment[TmxHorizontalAlignment["left"] = 0] = "left"; + TmxHorizontalAlignment[TmxHorizontalAlignment["center"] = 1] = "center"; + TmxHorizontalAlignment[TmxHorizontalAlignment["right"] = 2] = "right"; + TmxHorizontalAlignment[TmxHorizontalAlignment["justify"] = 3] = "justify"; + })(TmxHorizontalAlignment = es.TmxHorizontalAlignment || (es.TmxHorizontalAlignment = {})); + var TmxVerticalAlignment; + (function (TmxVerticalAlignment) { + TmxVerticalAlignment[TmxVerticalAlignment["top"] = 0] = "top"; + TmxVerticalAlignment[TmxVerticalAlignment["center"] = 1] = "center"; + TmxVerticalAlignment[TmxVerticalAlignment["bottom"] = 2] = "bottom"; + })(TmxVerticalAlignment = es.TmxVerticalAlignment || (es.TmxVerticalAlignment = {})); +})(es || (es = {})); +var es; +(function (es) { + var TmxTileset = (function (_super) { + __extends(TmxTileset, _super); + function TmxTileset() { + return _super !== null && _super.apply(this, arguments) || this; + } + TmxTileset.prototype.update = function () { + this.tiles.forEach(function (value) { + value.updateAnimatedTiles(); + }); + }; + return TmxTileset; + }(es.TmxDocument)); + es.TmxTileset = TmxTileset; + var TmxTileOffset = (function () { + function TmxTileOffset() { + } + return TmxTileOffset; + }()); + es.TmxTileOffset = TmxTileOffset; + var TmxTerrain = (function () { + function TmxTerrain() { + } + return TmxTerrain; + }()); + es.TmxTerrain = TmxTerrain; +})(es || (es = {})); +var es; +(function (es) { + var TmxTilesetTile = (function () { + function TmxTilesetTile() { + } + Object.defineProperty(TmxTilesetTile.prototype, "currentAnimationFrameGid", { + get: function () { + return this.animationFrames[this._animationCurrentFrame].gid + this.tileset.firstGid; + }, + enumerable: true, + configurable: true + }); + TmxTilesetTile.prototype.processProperties = function () { + var value; + value = this.properties.get("engine.isDestructable"); + if (value) + this.isDestructable = Boolean(value); + value = this.properties.get("engine:isSlope"); + if (value) + this.isSlope = Boolean(value); + value = this.properties.get("engine:isOneWayPlatform"); + if (value) + this.isOneWayPlatform = Boolean(value); + value = this.properties.get("engine:slopeTopLeft"); + if (value) + this.slopeTopLeft = Number(value); + value = this.properties.get("engine:slopeTopRight"); + if (value) + this.slopeTopRight = Number(value); + }; + TmxTilesetTile.prototype.updateAnimatedTiles = function () { + if (this.animationFrames.length == 0) + return; + this._animationElapsedTime += es.Time.deltaTime; + if (this._animationElapsedTime > this.animationFrames[this._animationCurrentFrame].duration) { + this._animationCurrentFrame = es.MathHelper.incrementWithWrap(this._animationCurrentFrame, this.animationFrames.length); + this._animationElapsedTime = 0; + } + }; + return TmxTilesetTile; + }()); + es.TmxTilesetTile = TmxTilesetTile; + var TmxAnimationFrame = (function () { + function TmxAnimationFrame() { + } + return TmxAnimationFrame; + }()); + es.TmxAnimationFrame = TmxAnimationFrame; +})(es || (es = {})); var ArrayUtils = (function () { function ArrayUtils() { } @@ -7654,6 +8090,33 @@ var es; es.DrawUtils = DrawUtils; })(es || (es = {})); var es; +(function (es) { + var EdgeExt = (function () { + function EdgeExt() { + } + EdgeExt.oppositeEdge = function (self) { + switch (self) { + case es.Edge.bottom: + return es.Edge.top; + case es.Edge.top: + return es.Edge.bottom; + case es.Edge.left: + return es.Edge.right; + case es.Edge.right: + return es.Edge.left; + } + }; + EdgeExt.isHorizontal = function (self) { + return self == es.Edge.right || self == es.Edge.left; + }; + EdgeExt.isVertical = function (self) { + return self == es.Edge.top || self == es.Edge.bottom; + }; + return EdgeExt; + }()); + es.EdgeExt = EdgeExt; +})(es || (es = {})); +var es; (function (es) { var FuncPack = (function () { function FuncPack(func, context) { @@ -7695,6 +8158,32 @@ var es; es.Emitter = Emitter; })(es || (es = {})); var es; +(function (es) { + var Edge; + (function (Edge) { + Edge[Edge["top"] = 0] = "top"; + Edge[Edge["bottom"] = 1] = "bottom"; + Edge[Edge["left"] = 2] = "left"; + Edge[Edge["right"] = 3] = "right"; + })(Edge = es.Edge || (es.Edge = {})); +})(es || (es = {})); +var es; +(function (es) { + var Enumerable = (function () { + function Enumerable() { + } + Enumerable.repeat = function (element, count) { + var result = []; + while (count--) { + result.push(element); + } + return result; + }; + return Enumerable; + }()); + es.Enumerable = Enumerable; +})(es || (es = {})); +var es; (function (es) { var GlobalManager = (function () { function GlobalManager() { @@ -8252,6 +8741,18 @@ var es; var RectangleExt = (function () { function RectangleExt() { } + RectangleExt.getSide = function (rect, edge) { + switch (edge) { + case es.Edge.top: + return rect.top; + case es.Edge.bottom: + return rect.bottom; + case es.Edge.left: + return rect.left; + case es.Edge.right: + return rect.right; + } + }; RectangleExt.union = function (first, point) { var rect = new es.Rectangle(point.x, point.y, 0, 0); var result = new es.Rectangle(); @@ -8261,11 +8762,79 @@ var es; result.height = Math.max(first.bottom, result.bottom) - result.y; return result; }; + RectangleExt.getHalfRect = function (rect, edge) { + switch (edge) { + case es.Edge.top: + return new es.Rectangle(rect.x, rect.y, rect.width, rect.height / 2); + case es.Edge.bottom: + return new es.Rectangle(rect.x, rect.y + rect.height / 2, rect.width, rect.height / 2); + case es.Edge.left: + return new es.Rectangle(rect.x, rect.y, rect.width / 2, rect.height); + case es.Edge.right: + return new es.Rectangle(rect.x + rect.width / 2, rect.y, rect.width / 2, rect.height); + } + }; + RectangleExt.getRectEdgePortion = function (rect, edge, size) { + if (size === void 0) { size = 1; } + switch (edge) { + case es.Edge.top: + return new es.Rectangle(rect.x, rect.y, rect.width, size); + case es.Edge.bottom: + return new es.Rectangle(rect.x, rect.y + rect.height - size, rect.width, size); + case es.Edge.left: + return new es.Rectangle(rect.x, rect.y, size, rect.height); + case es.Edge.right: + return new es.Rectangle(rect.x + rect.width - size, rect.y, size, rect.height); + } + }; + RectangleExt.expandSide = function (rect, edge, amount) { + amount = Math.abs(amount); + switch (edge) { + case es.Edge.top: + rect.y -= amount; + rect.height += amount; + break; + case es.Edge.bottom: + rect.height += amount; + break; + case es.Edge.left: + rect.x -= amount; + rect.width += amount; + break; + case es.Edge.right: + rect.width += amount; + break; + } + }; + RectangleExt.contract = function (rect, horizontalAmount, verticalAmount) { + rect.x += horizontalAmount; + rect.y += verticalAmount; + rect.width -= horizontalAmount * 2; + rect.height -= verticalAmount * 2; + }; return RectangleExt; }()); es.RectangleExt = RectangleExt; })(es || (es = {})); var es; +(function (es) { + var SubpixelNumber = (function () { + function SubpixelNumber() { + } + SubpixelNumber.prototype.update = function (amount) { + this.remainder += amount; + var motion = Math.trunc(this.remainder); + this.remainder -= motion; + return motion; + }; + SubpixelNumber.prototype.reset = function () { + this.remainder = 0; + }; + return SubpixelNumber; + }()); + es.SubpixelNumber = SubpixelNumber; +})(es || (es = {})); +var es; (function (es) { var Triangulator = (function () { function Triangulator() { diff --git a/demo/libs/framework/framework.min.js b/demo/libs/framework/framework.min.js index 91a7edf2..0b6d4509 100644 --- a/demo/libs/framework/framework.min.js +++ b/demo/libs/framework/framework.min.js @@ -1 +1 @@ -window.es={},window.__extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}();var transform,__awaiter=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{c(i.next(t))}catch(t){o(t)}}function a(t){try{c(i.throw(t))}catch(t){o(t)}}function c(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}c((i=i.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=(r=s.trys).length>0&&r[r.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]-1}(this,t)},Array.prototype.firstOrDefault=function(t){return function(t,e){var n=t.findIndex(e);return-1==n?null:t[n]}(this,t)},Array.prototype.find=function(t){return function(t,e){return t.firstOrDefault(e)}(this,t)},Array.prototype.where=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(n,i,r){return e.call(arguments[2],i,r,t)&&n.push(i),n},[]);for(var n=[],i=0,r=t.length;i=0&&t.splice(n,1)}while(n>=0)}(this,t)},Array.prototype.remove=function(t){return function(t,e){var n=t.findIndex(function(t){return t===e});return n>=0&&(t.splice(n,1),!0)}(this,t)},Array.prototype.removeAt=function(t){return function(t,e){t.splice(e,1)}(this,t)},Array.prototype.removeRange=function(t,e){return function(t,e,n){t.splice(e,n)}(this,t,e)},Array.prototype.select=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(n,i,r){return n.push(e.call(arguments[2],i,r,t)),n},[]);for(var n=[],i=0,r=t.length;io?1:-1}),t}(this,t,e)},Array.prototype.orderByDescending=function(t,e){return function(t,e,n){return t.sort(function(t,i){var r=e(t),o=e(i);return n?-n(r,o):r0;){if("break"===u())break}return s?this.recontructPath(a,i,r):null},e.recontructPath=function(t,e,n){var i=[],r=n;for(i.push(n);r!=e;)r=this.getKey(t,r),i.push(r);return i.reverse(),i},e.hasKey=function(t,e){for(var n,i=t.keys();!(n=i.next()).done;)if(JSON.stringify(n.value)==JSON.stringify(e))return!0;return!1},e.getKey=function(t,e){for(var n,i,r=t.keys(),o=t.values();n=r.next(),i=o.next(),!n.done;)if(JSON.stringify(n.value)==JSON.stringify(e))return i.value;return null},e}();t.AStarPathfinder=e;var n=function(t){function e(e){var n=t.call(this)||this;return n.data=e,n}return __extends(e,t),e}(t.PriorityQueueNode);t.AStarNode=n}(es||(es={})),function(t){var e=function(){function e(e,n){this.dirs=[new t.Vector2(1,0),new t.Vector2(0,-1),new t.Vector2(-1,0),new t.Vector2(0,1)],this.walls=[],this.weightedNodes=[],this.defaultWeight=1,this.weightedNodeWeight=5,this._neighbors=new Array(4),this._width=e,this._height=n}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x=this._nodes.length?(console.error("node.QueueIndex has been corrupted. Did you change it manually? Or add this node to another queue?"),!1):this._nodes[t.queueIndex]==t:(console.error("node cannot be null"),!1)},t.prototype.enqueue=function(t,e){t.priority=e,this._numNodes++,this._nodes[this._numNodes]=t,t.queueIndex=this._numNodes,t.insertionIndex=this._numNodesEverEnqueued++,this.cascadeUp(this._nodes[this._numNodes])},t.prototype.dequeue=function(){var t=this._nodes[1];return this.remove(t),t},t.prototype.remove=function(t){if(t.queueIndex==this._numNodes)return this._nodes[this._numNodes]=null,void this._numNodes--;var e=this._nodes[this._numNodes];this.swap(t,e),delete this._nodes[this._numNodes],this._numNodes--,this.onNodeUpdated(e)},t.prototype.isValidQueue=function(){for(var t=1;t0&&this.hasHigherPriority(t,n)?this.cascadeUp(t):this.cascadeDown(t)},t.prototype.cascadeDown=function(t){for(var e,n=t.queueIndex;;){e=t;var i=2*n;if(i>this._numNodes){t.queueIndex=n,this._nodes[n]=t;break}var r=this._nodes[i];this.hasHigherPriority(r,e)&&(e=r);var o=i+1;if(o<=this._numNodes){var s=this._nodes[o];this.hasHigherPriority(s,e)&&(e=s)}if(e==t){t.queueIndex=n,this._nodes[n]=t;break}this._nodes[n]=e;var a=e.queueIndex;e.queueIndex=n,n=a}},t.prototype.cascadeUp=function(t){for(var e=Math.floor(t.queueIndex/2);e>=1;){var n=this._nodes[e];if(this.hasHigherPriority(n,t))break;this.swap(t,n),e=Math.floor(t.queueIndex/2)}},t.prototype.swap=function(t,e){this._nodes[t.queueIndex]=e,this._nodes[e.queueIndex]=t;var n=t.queueIndex;t.queueIndex=e.queueIndex,e.queueIndex=n},t.prototype.hasHigherPriority=function(t,e){return t.priority0;){if("break"===c())break}return o?t.AStarPathfinder.recontructPath(a,n,i):null},e.hasKey=function(t,e){for(var n,i=t.keys();!(n=i.next()).done;)if(JSON.stringify(n.value)==JSON.stringify(e))return!0;return!1},e}();t.BreadthFirstPathfinder=e}(es||(es={})),function(t){var e=function(){function t(){this.edges=new Map}return t.prototype.addEdgesForNode=function(t,e){return this.edges.set(t,e),this},t.prototype.getNeighbors=function(t){return this.edges.get(t)},t}();t.UnweightedGraph=e}(es||(es={})),function(t){var e=function(){function e(t,e){this.x=0,this.y=0,this.x=t||0,this.y=null!=e?e:this.x}return Object.defineProperty(e,"zero",{get:function(){return e.zeroVector2},enumerable:!0,configurable:!0}),Object.defineProperty(e,"one",{get:function(){return e.unitVector2},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitX",{get:function(){return e.unitXVector},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitY",{get:function(){return e.unitYVector},enumerable:!0,configurable:!0}),e.add=function(t,n){var i=new e(0,0);return i.x=t.x+n.x,i.y=t.y+n.y,i},e.divide=function(t,n){var i=new e(0,0);return i.x=t.x/n.x,i.y=t.y/n.y,i},e.multiply=function(t,n){var i=new e(0,0);return i.x=t.x*n.x,i.y=t.y*n.y,i},e.subtract=function(t,n){var i=new e(0,0);return i.x=t.x-n.x,i.y=t.y-n.y,i},e.normalize=function(t){var e=1/Math.sqrt(t.x*t.x+t.y*t.y);return t.x*=e,t.y*=e,t},e.dot=function(t,e){return t.x*e.x+t.y*e.y},e.distanceSquared=function(t,e){var n=t.x-e.x,i=t.y-e.y;return n*n+i*i},e.clamp=function(n,i,r){return new e(t.MathHelper.clamp(n.x,i.x,r.x),t.MathHelper.clamp(n.y,i.y,r.y))},e.lerp=function(n,i,r){return new e(t.MathHelper.lerp(n.x,i.x,r),t.MathHelper.lerp(n.y,i.y,r))},e.transform=function(t,n){return new e(t.x*n.m11+t.y*n.m21+n.m31,t.x*n.m12+t.y*n.m22+n.m32)},e.distance=function(t,e){var n=t.x-e.x,i=t.y-e.y;return Math.sqrt(n*n+i*i)},e.angle=function(n,i){return n=e.normalize(n),i=e.normalize(i),Math.acos(t.MathHelper.clamp(e.dot(n,i),-1,1))*t.MathHelper.Rad2Deg},e.negate=function(t){var n=new e;return n.x=-t.x,n.y=-t.y,n},e.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this},e.prototype.divide=function(t){return this.x/=t.x,this.y/=t.y,this},e.prototype.multiply=function(t){return this.x*=t.x,this.y*=t.y,this},e.prototype.subtract=function(t){return this.x-=t.x,this.y-=t.y,this},e.prototype.normalize=function(){var t=1/Math.sqrt(this.x*this.x+this.y*this.y);return this.x*=t,this.y*=t,this},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},e.prototype.round=function(){return new e(Math.round(this.x),Math.round(this.y))},e.prototype.equals=function(t){return t.x==this.x&&t.y==this.y},e.unitYVector=new e(0,1),e.unitXVector=new e(1,0),e.unitVector2=new e(1,1),e.zeroVector2=new e(0,0),e}();t.Vector2=e}(es||(es={})),function(t){var e=function(){function e(t,n,i){void 0===i&&(i=!1),this.walls=[],this._neighbors=new Array(4),this._width=t,this._hegiht=n,this._dirs=i?e.COMPASS_DIRS:e.CARDINAL_DIRS}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x0;){if("break"===u())break}return s?this.recontructPath(a,i,r):null},n.recontructPath=function(t,e,n){var i=[],r=n;for(i.push(n);r!=e;)r=this.getKey(t,r),i.push(r);return i.reverse(),i},n.hasKey=function(t,e){for(var n,i=t.keys();!(n=i.next()).done;)if(JSON.stringify(n.value)==JSON.stringify(e))return!0;return!1},n.getKey=function(t,e){for(var n,i,r=t.keys(),o=t.values();n=r.next(),i=o.next(),!n.done;)if(JSON.stringify(n.value)==JSON.stringify(e))return i.value;return null},n}();t.WeightedPathfinder=n}(es||(es={})),function(t){var e=function(){function e(){}return e.drawHollowRect=function(e,n,i){void 0===i&&(i=0),this._debugDrawItems.push(new t.DebugDrawItem(e,n,i))},e.render=function(){if(this._debugDrawItems.length>0){var e=new egret.Shape;t.Core.scene&&t.Core.scene.addChild(e);for(var n=this._debugDrawItems.length-1;n>=0;n--){this._debugDrawItems[n].draw(e)&&this._debugDrawItems.removeAt(n)}}},e._debugDrawItems=[],e}();t.Debug=e}(es||(es={})),function(t){var e=function(){function t(){}return t.verletParticle=14431326,t.verletConstraintEdge=4406838,t}();t.DebugDefaults=e}(es||(es={})),function(t){var e;!function(t){t[t.line=0]="line",t[t.hollowRectangle=1]="hollowRectangle",t[t.pixel=2]="pixel",t[t.text=3]="text"}(e=t.DebugDrawType||(t.DebugDrawType={}));var n=function(){function n(t,n,i){this.rectangle=t,this.color=n,this.duration=i,this.drawType=e.hollowRectangle}return n.prototype.draw=function(n){switch(this.drawType){case e.line:t.DrawUtils.drawLine(n,this.start,this.end,this.color);break;case e.hollowRectangle:t.DrawUtils.drawHollowRect(n,this.rectangle,this.color);break;case e.pixel:t.DrawUtils.drawPixel(n,new t.Vector2(this.x,this.y),this.color,this.size);break;case e.text:}return this.duration-=t.Time.deltaTime,this.duration<0},n}();t.DebugDrawItem=n}(es||(es={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateInterval=1,e._enabled=!0,e._updateOrder=0,e}return __extends(e,t),Object.defineProperty(e.prototype,"transform",{get:function(){return this.entity.transform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this.entity?this.entity.enabled&&this._enabled:this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"updateOrder",{get:function(){return this._updateOrder},set:function(t){this.setUpdateOrder(t)},enumerable:!0,configurable:!0}),e.prototype.initialize=function(){},e.prototype.onAddedToEntity=function(){},e.prototype.onRemovedFromEntity=function(){},e.prototype.onEntityTransformChanged=function(t){},e.prototype.debugRender=function(){},e.prototype.onEnabled=function(){},e.prototype.onDisabled=function(){},e.prototype.update=function(){},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled()),this},e.prototype.setUpdateOrder=function(t){return this._updateOrder!=t&&(this._updateOrder=t),this},e.prototype.clone=function(){var t=ObjectUtils.clone(this);return t.entity=null,t},e}(egret.HashObject);t.Component=e}(es||(es={})),function(t){var e=function(e){function n(){var i=e.call(this)||this;return i._globalManagers=[],n._instance=i,n.emitter=new t.Emitter,n.content=new t.ContentManager,i.addEventListener(egret.Event.ADDED_TO_STAGE,i.onAddToStage,i),i}return __extends(n,e),Object.defineProperty(n,"Instance",{get:function(){return this._instance},enumerable:!0,configurable:!0}),Object.defineProperty(n,"scene",{get:function(){return this._instance?this._instance._scene:null},set:function(t){t?null==this._instance._scene?(this._instance._scene=t,this._instance.addChild(t),this._instance._scene.begin(),n.Instance.onSceneChanged()):this._instance._nextScene=t:console.error("场景不能为空")},enumerable:!0,configurable:!0}),n.startSceneTransition=function(t){if(!this._instance._sceneTransition)return this._instance._sceneTransition=t,t;console.warn("在前一个场景完成之前,不能开始一个新的场景转换。")},n.registerGlobalManager=function(t){this._instance._globalManagers.push(t),t.enabled=!0},n.unregisterGlobalManager=function(t){this._instance._globalManagers.remove(t),t.enabled=!1},n.getGlobalManager=function(t){for(var e=0;e=0;e--)this._globalManagers[e].enabled&&this._globalManagers[e].update();return this._sceneTransition&&(!this._sceneTransition||this._sceneTransition.loadsNewScene&&!this._sceneTransition.isNewSceneLoaded)||this._scene.update(),this._nextScene?(this.removeChild(this._scene),this._scene.end(),this._scene=this._nextScene,this._nextScene=null,this.onSceneChanged(),this.addChild(this._scene),[4,this._scene.begin()]):[3,2];case 1:n.sent(),n.label=2;case 2:return[4,this.draw()];case 3:return n.sent(),[2]}})})},n.prototype.onAddToStage=function(){n.graphicsDevice=new t.GraphicsDevice,this.addEventListener(egret.Event.RESIZE,this.onGraphicsDeviceReset,this),this.addEventListener(egret.StageOrientationEvent.ORIENTATION_CHANGE,this.onOrientationChanged,this),this.addEventListener(egret.Event.ENTER_FRAME,this.update,this),t.Input.initialize(),this.initialize()},n}(egret.DisplayObjectContainer);t.Core=e}(es||(es={})),function(t){!function(t){t[t.GraphicsDeviceReset=0]="GraphicsDeviceReset",t[t.SceneChanged=1]="SceneChanged",t[t.OrientationChanged=2]="OrientationChanged"}(t.CoreEvents||(t.CoreEvents={}))}(es||(es={})),function(t){var e=function(){function e(n){this.updateInterval=1,this._tag=0,this._enabled=!0,this._updateOrder=0,this.components=new t.ComponentList(this),this.transform=new t.Transform(this),this.name=n,this.id=e._idGenerator++,this.componentBits=new t.BitSet}return Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this._isDestroyed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tag",{get:function(){return this._tag},set:function(t){this.setTag(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"updateOrder",{get:function(){return this._updateOrder},set:function(t){this.setUpdateOrder(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this.transform.parent},set:function(t){this.transform.setParent(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"childCount",{get:function(){return this.transform.childCount},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this.transform.position},set:function(t){this.transform.setPosition(t.x,t.y)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localPosition",{get:function(){return this.transform.localPosition},set:function(t){this.transform.setLocalPosition(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotation",{get:function(){return this.transform.rotation},set:function(t){this.transform.setRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotationDegrees",{get:function(){return this.transform.rotationDegrees},set:function(t){this.transform.setRotationDegrees(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localRotation",{get:function(){return this.transform.localRotation},set:function(t){this.transform.setLocalRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localRotationDegrees",{get:function(){return this.transform.localRotationDegrees},set:function(t){this.transform.setLocalRotationDegrees(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scale",{get:function(){return this.transform.scale},set:function(t){this.transform.setScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localScale",{get:function(){return this.transform.localScale},set:function(t){this.transform.setLocalScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"worldInverseTransform",{get:function(){return this.transform.worldInverseTransform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localToWorldTransform",{get:function(){return this.transform.localToWorldTransform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"worldToLocalTransform",{get:function(){return this.transform.worldToLocalTransform},enumerable:!0,configurable:!0}),e.prototype.onTransformChanged=function(t){this.components.onEntityTransformChanged(t)},e.prototype.setTag=function(t){return this._tag!=t&&(this.scene&&this.scene.entities.removeFromTagList(this),this._tag=t,this.scene&&this.scene.entities.addToTagList(this)),this},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.components.onEntityEnabled():this.components.onEntityDisabled()),this},e.prototype.setUpdateOrder=function(t){if(this._updateOrder!=t)return this._updateOrder=t,this.scene&&(this.scene.entities.markEntityListUnsorted(),this.scene.entities.markTagUnsorted(this.tag)),this},e.prototype.destroy=function(){this._isDestroyed=!0,this.scene.entities.remove(this),this.transform.parent=null;for(var t=this.transform.childCount-1;t>=0;t--){this.transform.getChild(t).entity.destroy()}},e.prototype.detachFromScene=function(){this.scene.entities.remove(this),this.components.deregisterAllComponents();for(var t=0;t=0;t--)this._sceneComponents[t].enabled&&this._sceneComponents[t].update();this.entityProcessors&&this.entityProcessors.update(),this.entities.update(),this.entityProcessors&&this.entityProcessors.lateUpdate(),this.renderableComponents.updateList()},n.prototype.render=function(){if(0!=this._renderers.length)for(var t=0;te.x?-1:1,i=t.Vector2.normalize(t.Vector2.subtract(this.position,e));this.rotation=n*Math.acos(t.Vector2.dot(i,t.Vector2.unitY))},i.prototype.setLocalRotation=function(t){return this._localRotation=t,this._localDirty=this._positionDirty=this._localPositionDirty=this._localRotationDirty=this._localScaleDirty=!0,this.setDirty(e.rotationDirty),this},i.prototype.setLocalRotationDegrees=function(e){return this.setLocalRotation(t.MathHelper.toRadians(e))},i.prototype.setScale=function(e){return this._scale=e,this.parent?this.localScale=t.Vector2.divide(e,this.parent._scale):this.localScale=e,this},i.prototype.setLocalScale=function(t){return this._localScale=t,this._localDirty=this._positionDirty=this._localScaleDirty=!0,this.setDirty(e.scaleDirty),this},i.prototype.roundPosition=function(){this.position=this._position.round()},i.prototype.updateTransform=function(){this.hierarchyDirty!=e.clean&&(this.parent&&this.parent.updateTransform(),this._localDirty&&(this._localPositionDirty&&(this._translationMatrix=t.Matrix2D.create().translate(this._localPosition.x,this._localPosition.y),this._localPositionDirty=!1),this._localRotationDirty&&(this._rotationMatrix=t.Matrix2D.create().rotate(this._localRotation),this._localRotationDirty=!1),this._localScaleDirty&&(this._scaleMatrix=t.Matrix2D.create().scale(this._localScale.x,this._localScale.y),this._localScaleDirty=!1),this._localTransform=this._scaleMatrix.multiply(this._rotationMatrix),this._localTransform=this._localTransform.multiply(this._translationMatrix),this.parent||(this._worldTransform=this._localTransform,this._rotation=this._localRotation,this._scale=this._localScale,this._worldInverseDirty=!0),this._localDirty=!1),this.parent&&(this._worldTransform=this._localTransform.multiply(this.parent._worldTransform),this._rotation=this._localRotation+this.parent._rotation,this._scale=t.Vector2.multiply(this.parent._scale,this._localScale),this._worldInverseDirty=!0),this._worldToLocalDirty=!0,this._positionDirty=!0,this.hierarchyDirty=e.clean)},i.prototype.setDirty=function(e){if(0==(this.hierarchyDirty&e)){switch(this.hierarchyDirty|=e,e){case t.DirtyType.positionDirty:this.entity.onTransformChanged(transform.Component.position);break;case t.DirtyType.rotationDirty:this.entity.onTransformChanged(transform.Component.rotation);break;case t.DirtyType.scaleDirty:this.entity.onTransformChanged(transform.Component.scale)}this._children||(this._children=[]);for(var n=0;nt&&(this._zoom=t),this._maximumZoom=t,this;console.error("maximumZoom must be greater than zero")},r.prototype.onEntityTransformChanged=function(t){this._areMatrixedDirty=!0},r.prototype.zoomIn=function(t){this.zoom+=t},r.prototype.zoomOut=function(t){this.zoom-=t},r.prototype.worldToScreenPoint=function(e){return this.updateMatrixes(),e=t.Vector2.transform(e,this._transformMatrix)},r.prototype.screenToWorldPoint=function(e){return this.updateMatrixes(),e=t.Vector2.transform(e,this._inverseTransformMatrix)},r.prototype.mouseToWorldPoint=function(){return this.screenToWorldPoint(t.Input.touchPosition)},r.prototype.onAddedToEntity=function(){this.follow(this._targetEntity,this._cameraStyle)},r.prototype.update=function(){var e=t.Vector2.multiply(new t.Vector2(this.bounds.width,this.bounds.height),new t.Vector2(.5));this._worldSpaceDeadZone.x=this.position.x-e.x*t.Core.scene.scaleX+this.deadzone.x+this.focusOffset.x,this._worldSpaceDeadZone.y=this.position.y-e.y*t.Core.scene.scaleY+this.deadzone.y+this.focusOffset.y,this._worldSpaceDeadZone.width=this.deadzone.width,this._worldSpaceDeadZone.height=this.deadzone.height,this._targetEntity&&this.updateFollow(),this.position=t.Vector2.lerp(this.position,t.Vector2.add(this.position,this._desiredPositionDelta),this.followLerp),this.entity.transform.roundPosition(),this.mapLockEnabled&&(this.position=this.clampToMapSize(this.position),this.entity.transform.roundPosition())},r.prototype.clampToMapSize=function(e){var n=t.Vector2.multiply(new t.Vector2(this.bounds.width,this.bounds.height),new t.Vector2(.5)).add(new t.Vector2(this.mapSize.x,this.mapSize.y)),i=new t.Vector2(this.mapSize.width-n.x,this.mapSize.height-n.y);return t.Vector2.clamp(e,n,i)},r.prototype.updateFollow=function(){if(this._desiredPositionDelta.x=this._desiredPositionDelta.y=0,this._cameraStyle==e.lockOn){var n=this._targetEntity.transform.position.x,i=this._targetEntity.transform.position.y;this._worldSpaceDeadZone.x>n?this._desiredPositionDelta.x=n-this._worldSpaceDeadZone.x:this._worldSpaceDeadZone.xi&&(this._desiredPositionDelta.y=i-this._worldSpaceDeadZone.y)}else{if(!this._targetCollider&&(this._targetCollider=this._targetEntity.getComponent(t.Collider),!this._targetCollider))return;var r=this._targetEntity.getComponent(t.Collider).bounds;this._worldSpaceDeadZone.containsRect(r)||(this._worldSpaceDeadZone.left>r.left?this._desiredPositionDelta.x=r.left-this._worldSpaceDeadZone.left:this._worldSpaceDeadZone.rightr.top&&(this._desiredPositionDelta.y=r.top-this._worldSpaceDeadZone.top))}},r.prototype.follow=function(n,i){switch(void 0===i&&(i=e.cameraWindow),this._targetEntity=n,this._cameraStyle=i,this._cameraStyle){case e.cameraWindow:var r=this.bounds.width/6,o=this.bounds.height/3;this.deadzone=new t.Rectangle((this.bounds.width-r)/2,(this.bounds.height-o)/2,r,o);break;case e.lockOn:this.deadzone=new t.Rectangle(this.bounds.width/2,this.bounds.height/2,10,10)}},r.prototype.setCenteredDeadzone=function(e,n){this.deadzone=new t.Rectangle((this.bounds.width-e)/2,(this.bounds.height-n)/2,e,n)},r.prototype.updateMatrixes=function(){var e;this._areMatrixedDirty&&(this._transformMatrix=t.Matrix2D.create().translate(-this.entity.transform.position.x,-this.entity.transform.position.y),1!=this._zoom&&(e=t.Matrix2D.create().scale(this._zoom,this._zoom),this._transformMatrix=this._transformMatrix.multiply(e)),0!=this.entity.transform.rotation&&(e=t.Matrix2D.create().rotate(this.entity.transform.rotation),this._transformMatrix=this._transformMatrix.multiply(e)),e=t.Matrix2D.create().translate(this._origin.x,this._origin.y),this._transformMatrix=this._transformMatrix.multiply(e),this._inverseTransformMatrix=this._transformMatrix.invert(),this._areBoundsDirty=!0,this._areMatrixedDirty=!1)},r}(t.Component);t.Camera=i}(es||(es={})),function(t){var e=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n._shakeDirection=t.Vector2.zero,n._shakeOffset=t.Vector2.zero,n._shakeIntensity=0,n._shakeDegredation=.95,n}return __extends(n,e),n.prototype.shake=function(e,n,i){void 0===e&&(e=15),void 0===n&&(n=.9),void 0===i&&(i=t.Vector2.zero),this.enabled=!0,this._shakeIntensity=1)&&(n=.95),this._shakeDegredation=n)},n.prototype.update=function(){Math.abs(this._shakeIntensity)>0&&(this._shakeOffset=this._shakeDirection,0!=this._shakeOffset.x||0!=this._shakeOffset.y?this._shakeOffset.normalize():(this._shakeOffset.x=this._shakeOffset.x+Math.random()-.5,this._shakeOffset.y=this._shakeOffset.y+Math.random()-.5),this._shakeOffset.multiply(new t.Vector2(this._shakeIntensity)),this._shakeIntensity*=-this._shakeDegredation,Math.abs(this._shakeIntensity)<=.01&&(this._shakeIntensity=0,this.enabled=!1)),this.entity.scene.camera.position.add(this._shakeOffset)},n}(t.Component);t.CameraShake=e}(es||(es={})),function(t){var e=function(){function t(t){this._type=t,this._cache=[]}return t.prototype.obtain=function(){try{return this._cache.length>0?this._cache.shift():new this._type}catch(t){throw new Error(this._type+t)}},t.prototype.free=function(t){t.reset(),this._cache.push(t)},t}();t.ComponentPool=e}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.compare=function(t,e){return t.updateOrder-e.updateOrder},t}();t.IUpdatableComparer=e}(es||(es={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(t.Component);t.PooledComponent=e}(es||(es={})),function(t){var e=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n.displayObject=new egret.DisplayObject,n.color=0,n._areBoundsDirty=!0,n._localOffset=t.Vector2.zero,n._renderLayer=0,n._bounds=new t.Rectangle,n}return __extends(n,e),Object.defineProperty(n.prototype,"width",{get:function(){return this.bounds.width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return this.bounds.height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"localOffset",{get:function(){return this._localOffset},set:function(t){this.setLocalOffset(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"renderLayer",{get:function(){return this._renderLayer},set:function(t){this.setRenderLayer(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"bounds",{get:function(){return this._areBoundsDirty&&(this._bounds.calculateBounds(this.entity.transform.position,this._localOffset,t.Vector2.zero,this.entity.transform.scale,this.entity.transform.rotation,this.width,this.height),this._areBoundsDirty=!1),this._bounds},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isVisible",{get:function(){return this._isVisible},set:function(t){this._isVisible!=t&&(this._isVisible=t,this._isVisible?this.onBecameVisible():this.onBecameInvisible())},enumerable:!0,configurable:!0}),n.prototype.onEntityTransformChanged=function(t){this._areBoundsDirty=!0},n.prototype.isVisibleFromCamera=function(t){return this.isVisible=t.bounds.intersects(this.bounds),this.isVisible},n.prototype.setRenderLayer=function(t){if(t!=this._renderLayer){var e=this._renderLayer;this._renderLayer=t,this.entity&&this.entity.scene&&this.entity.scene.renderableComponents.updateRenderableRenderLayer(this,e,this._renderLayer)}return this},n.prototype.setColor=function(t){return this.color=t,this},n.prototype.setLocalOffset=function(t){return this._localOffset!=t&&(this._localOffset=t),this},n.prototype.sync=function(t){this.displayObject.x=this.entity.position.x+this.localOffset.x-t.position.x+t.origin.x,this.displayObject.y=this.entity.position.y+this.localOffset.y-t.position.y+t.origin.y,this.displayObject.scaleX=this.entity.scale.x,this.displayObject.scaleY=this.entity.scale.y,this.displayObject.rotation=this.entity.rotation},n.prototype.toString=function(){return"[RenderableComponent] renderLayer: "+this.renderLayer},n.prototype.onBecameVisible=function(){this.displayObject.visible=this.isVisible},n.prototype.onBecameInvisible=function(){this.displayObject.visible=this.isVisible},n}(t.Component);t.RenderableComponent=e}(es||(es={})),function(t){var e=function(){function e(){this.updateOrder=0,this._enabled=!0}return Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),e.prototype.onEnabled=function(){},e.prototype.onDisabled=function(){},e.prototype.onRemovedFromScene=function(){},e.prototype.update=function(){},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled),this},e.prototype.setUpdateOrder=function(e){return this.updateOrder!=e&&(this.updateOrder=e,t.Core.scene._sceneComponents.sort(this.compareTo)),this},e.prototype.compareTo=function(t){return this.updateOrder-t.updateOrder},e}();t.SceneComponent=e}(es||(es={})),function(t){var e=egret.Bitmap,n=function(n){function i(e){void 0===e&&(e=null);var i=n.call(this)||this;return e instanceof t.Sprite?i.setSprite(e):e instanceof egret.Texture&&i.setSprite(new t.Sprite(e)),i}return __extends(i,n),Object.defineProperty(i.prototype,"bounds",{get:function(){return this._areBoundsDirty&&this._sprite&&(this._bounds.calculateBounds(this.entity.transform.position,this._localOffset,this._origin,this.entity.transform.scale,this.entity.transform.rotation,this._sprite.sourceRect.width,this._sprite.sourceRect.height),this._areBoundsDirty=!1),this._bounds},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"originNormalized",{get:function(){return new t.Vector2(this._origin.x/this.width*this.entity.transform.scale.x,this._origin.y/this.height*this.entity.transform.scale.y)},set:function(e){this.setOrigin(new t.Vector2(e.x*this.width/this.entity.transform.scale.x,e.y*this.height/this.entity.transform.scale.y))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"origin",{get:function(){return this._origin},set:function(t){this.setOrigin(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"sprite",{get:function(){return this._sprite},set:function(t){this.setSprite(t)},enumerable:!0,configurable:!0}),i.prototype.setSprite=function(t){return this._sprite=t,this._sprite&&(this._origin=this._sprite.origin,this.displayObject.anchorOffsetX=this._origin.x,this.displayObject.anchorOffsetY=this._origin.y),this.displayObject=new e(t.texture2D),this},i.prototype.setOrigin=function(t){return this._origin!=t&&(this._origin=t,this.displayObject.anchorOffsetX=this._origin.x,this.displayObject.anchorOffsetY=this._origin.y,this._areBoundsDirty=!0),this},i.prototype.setOriginNormalized=function(e){return this.setOrigin(new t.Vector2(e.x*this.width/this.entity.transform.scale.x,e.y*this.height/this.entity.transform.scale.y)),this},i.prototype.render=function(t){this.sync(t),this.displayObject.x=this.entity.position.x+this.localOffset.x-t.position.x+t.origin.x,this.displayObject.y=this.entity.position.y+this.localOffset.y-t.position.y+t.origin.y},i}(t.RenderableComponent);t.SpriteRenderer=n}(es||(es={})),function(t){var e=egret.Bitmap,n=egret.RenderTexture,i=function(i){function r(e){var n=i.call(this,e)||this;return n._textureScale=t.Vector2.one,n._inverseTexScale=t.Vector2.one,n._gapX=0,n._gapY=0,n._sourceRect=e.sourceRect,n.displayObject.$fillMode=egret.BitmapFillMode.REPEAT,n}return __extends(r,i),Object.defineProperty(r.prototype,"bounds",{get:function(){return this._areBoundsDirty&&this._sprite&&(this._bounds.calculateBounds(this.entity.transform.position,this._localOffset,this._origin,this.entity.transform.scale,this.entity.transform.rotation,this.width,this.height),this._areBoundsDirty=!1),this._bounds},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scrollX",{get:function(){return this._sourceRect.x},set:function(t){this._sourceRect.x=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scrollY",{get:function(){return this._sourceRect.y},set:function(t){this._sourceRect.y=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"textureScale",{get:function(){return this._textureScale},set:function(e){this._textureScale=e,this._inverseTexScale=new t.Vector2(1/this._textureScale.x,1/this._textureScale.y),this._sourceRect.width=this._sprite.sourceRect.width*this._inverseTexScale.x,this._sourceRect.height=this._sprite.sourceRect.height*this._inverseTexScale.y},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"width",{get:function(){return this._sourceRect.width},set:function(t){this._areBoundsDirty=!0,this._sourceRect.width=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"height",{get:function(){return this._sourceRect.height},set:function(t){this._areBoundsDirty=!0,this._sourceRect.height=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"gapXY",{get:function(){return new t.Vector2(this._gapX,this._gapY)},set:function(t){this._gapX=t.x,this._gapY=t.y;var i=new n,r=this.sprite.sourceRect;r.x=0,r.y=0,r.width+=this._gapX,r.height+=this._gapY,i.drawToTexture(this.displayObject,r),this.displayObject?this.displayObject.texture=i:this.displayObject=new e(i)},enumerable:!0,configurable:!0}),r.prototype.setGapXY=function(t){return this.gapXY=t,this},r.prototype.render=function(t){i.prototype.render.call(this,t);var e=this.displayObject;e.width=this.width,e.height=this.height,e.scrollRect=this._sourceRect},r}(t.SpriteRenderer);t.TiledSpriteRenderer=i}(es||(es={})),function(t){var e=function(e){function n(t){var n=e.call(this,t)||this;return n.scrollSpeedX=15,n.scroolSpeedY=0,n._scrollX=0,n._scrollY=0,n._scrollWidth=0,n._scrollHeight=0,n._scrollWidth=n.width,n._scrollHeight=n.height,n}return __extends(n,e),Object.defineProperty(n.prototype,"textureScale",{get:function(){return this._textureScale},set:function(e){this._textureScale=e,this._inverseTexScale=new t.Vector2(1/this._textureScale.x,1/this._textureScale.y)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scrollWidth",{get:function(){return this._scrollWidth},set:function(t){this._scrollWidth=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scrollHeight",{get:function(){return this._scrollHeight},set:function(t){this._scrollHeight=t},enumerable:!0,configurable:!0}),n.prototype.update=function(){this.sprite&&(this._scrollX+=this.scrollSpeedX*t.Time.deltaTime,this._scrollY+=this.scroolSpeedY*t.Time.deltaTime,this._sourceRect.x=this._scrollX,this._sourceRect.y=this._scrollY,this._sourceRect.width=this._scrollWidth+Math.abs(this._scrollX),this._sourceRect.height=this._scrollHeight+Math.abs(this._scrollY))},n}(t.TiledSpriteRenderer);t.ScrollingSpriteRenderer=e}(es||(es={})),function(t){var e=function(){return function(e,n,i){void 0===n&&(n=new t.Rectangle(0,0,e.textureWidth,e.textureHeight)),void 0===i&&(i=n.getHalfSize()),this.uvs=new t.Rectangle,this.texture2D=e,this.sourceRect=n,this.center=new t.Vector2(.5*n.width,.5*n.height),this.origin=i;var r=1/e.textureWidth,o=1/e.textureHeight;this.uvs.x=n.x*r,this.uvs.y=n.y*o,this.uvs.width=n.width*r,this.uvs.height=n.height*o}}();t.Sprite=e}(es||(es={})),function(t){var e=function(){return function(t,e){this.sprites=t,this.frameRate=e}}();t.SpriteAnimation=e}(es||(es={})),function(t){var e,n;!function(t){t[t.loop=0]="loop",t[t.once=1]="once",t[t.clampForever=2]="clampForever",t[t.pingPong=3]="pingPong",t[t.pingPongOnce=4]="pingPongOnce"}(e=t.LoopMode||(t.LoopMode={})),function(t){t[t.none=0]="none",t[t.running=1]="running",t[t.paused=2]="paused",t[t.completed=3]="completed"}(n=t.State||(t.State={}));var i=function(i){function r(t){var e=i.call(this,t)||this;return e.speed=1,e.animationState=n.none,e._elapsedTime=0,e._animations=new Map,e}return __extends(r,i),Object.defineProperty(r.prototype,"isRunning",{get:function(){return this.animationState==n.running},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"animations",{get:function(){return this._animations},enumerable:!0,configurable:!0}),r.prototype.update=function(){if(this.animationState==n.running&&this.currentAnimation){var i=this.currentAnimation,r=1/(i.frameRate*this.speed),o=r*i.sprites.length;this._elapsedTime+=t.Time.deltaTime;var s=Math.abs(this._elapsedTime);if(this._loopMode==e.once&&s>o||this._loopMode==e.pingPongOnce&&s>2*o)return this.animationState=n.completed,this._elapsedTime=0,this.currentFrame=0,void(this.sprite=i.sprites[this.currentFrame]);var a=Math.floor(s/r),c=i.sprites.length;if(c>2&&(this._loopMode==e.pingPong||this._loopMode==e.pingPongOnce)){var h=c-1;this.currentFrame=h-Math.abs(h-a%(2*h))}else this.currentFrame=a%c;this.sprite=i.sprites[this.currentFrame]}},r.prototype.addAnimation=function(t,e){return!this.sprite&&e.sprites.length>0&&this.setSprite(e.sprites[0]),this._animations[t]=e,this},r.prototype.play=function(t,i){void 0===i&&(i=null),this.currentAnimation=this._animations[t],this.currentAnimationName=t,this.currentFrame=0,this.animationState=n.running,this.sprite=this.currentAnimation.sprites[0],this._elapsedTime=0,this._loopMode=i||e.loop},r.prototype.isAnimationActive=function(t){return this.currentAnimation&&this.currentAnimationName==t},r.prototype.pause=function(){this.animationState=n.paused},r.prototype.unPause=function(){this.animationState=n.running},r.prototype.stop=function(){this.currentAnimation=null,this.currentAnimationName=null,this.currentFrame=0,this.animationState=n.none},r}(t.SpriteRenderer);t.SpriteAnimator=i}(es||(es={})),function(t){var e=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.onAddedToEntity=function(){this._triggerHelper=new t.ColliderTriggerHelper(this.entity)},n.prototype.calculateMovement=function(e,n){if(!this.entity.getComponent(t.Collider)||!this._triggerHelper)return!1;for(var i=this.entity.getComponents(t.Collider),r=0;r>6;0!=(e&t.LONG_MASK)&&n++,this._bits=new Array(n)}return t.prototype.and=function(t){for(var e,n=Math.min(this._bits.length,t._bits.length),i=0;i=0;)this._bits[e]&=~t._bits[e]},t.prototype.cardinality=function(){for(var t=0,e=this._bits.length-1;e>=0;e--){var n=this._bits[e];if(0!=n)if(-1!=n){var i=((n=((n=(n>>1&0x5555555555555400)+(0x5555555555555400&n))>>2&0x3333333333333400)+(0x3333333333333400&n))>>32)+n;t+=((i=((i=(i>>4&252645135)+(252645135&i))>>8&16711935)+(16711935&i))>>16&65535)+(65535&i)}else t+=64}return t},t.prototype.clear=function(t){if(null!=t){var e=t>>6;this.ensure(e),this._bits[e]&=~(1<>6;return!(e>=this._bits.length)&&0!=(this._bits[e]&1<=0;)if(0!=(this._bits[e]&t._bits[e]))return!0;return!1},t.prototype.isEmpty=function(){for(var t=this._bits.length-1;t>=0;t--)if(this._bits[t])return!1;return!0},t.prototype.nextSetBit=function(t){for(var e=t>>6,n=1<>6;this.ensure(n),this._bits[n]|=1<=this._bits.length){var e=new Number[t+1];e=this._bits.copyWithin(0,0,this._bits.length),this._bits=e}},t.LONG_MASK=63,t}();t.BitSet=e}(es||(es={})),function(t){var e=function(){function e(t){this._components=[],this._componentsToAdd=[],this._componentsToRemove=[],this._tempBufferList=[],this._entity=t}return Object.defineProperty(e.prototype,"count",{get:function(){return this._components.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buffer",{get:function(){return this._components},enumerable:!0,configurable:!0}),e.prototype.markEntityListUnsorted=function(){this._isComponentListUnsorted=!0},e.prototype.add=function(t){this._componentsToAdd.push(t)},e.prototype.remove=function(t){this._componentsToRemove.contains(t)&&console.warn("You are trying to remove a Component ("+t+") that you already removed"),this._componentsToAdd.contains(t)?this._componentsToAdd.remove(t):this._componentsToRemove.push(t)},e.prototype.removeAllComponents=function(){for(var t=0;t0){for(var n=0;n0){n=0;for(var i=this._componentsToAdd.length;n0){var e=this._entitiesToRemove;this._entitiesToRemove=this._tempEntityList,this._tempEntityList=e,this._tempEntityList.forEach(function(e){t.removeFromTagList(e),t._entities.remove(e),e.onRemovedFromScene(),e.scene=null,t.scene.entityProcessors.onEntityRemoved(e)}),this._tempEntityList.length=0}if(this._entitiesToAdded.length>0){e=this._entitiesToAdded;this._entitiesToAdded=this._tempEntityList,this._tempEntityList=e,this._tempEntityList.forEach(function(e){t._entities.contains(e)||(t._entities.push(e),e.scene=t.scene,t.addToTagList(e),t.scene.entityProcessors.onEntityAdded(e))}),this._tempEntityList.forEach(function(t){return t.onAddedToScene()}),this._tempEntityList.length=0,this._isEntityListUnsorted=!0}this._isEntityListUnsorted&&(this._entities.sort(),this._isEntityListUnsorted=!1),this._unsortedTags.length>0&&(this._unsortedTags.forEach(function(e){t._entityDict.get(e).sort()}),this._unsortedTags.length=0)},e.prototype.findEntity=function(t){for(var e=0;e=0;e=this.allSet.nextSetBit(e+1))if(!t.componentBits.get(e))return!1;return!(!this.exclusionSet.isEmpty()&&this.exclusionSet.intersects(t.componentBits))&&!(!this.oneSet.isEmpty()&&!this.oneSet.intersects(t.componentBits))},e.prototype.all=function(){for(var e=this,n=[],i=0;i0){for(var t=0,n=this._unsortedRenderLayers.length;t=e)return t;var i=!1;"-"==t.substr(0,1)&&(i=!0,t=t.substr(1));for(var r=e-n,o=0;o1?this.reverse(t.substring(1))+t.substring(0,1):t},t.cutOff=function(t,e,n,i){void 0===i&&(i=!0),e=Math.floor(e),n=Math.floor(n);var r=t.length;e>r&&(e=r);var o,s=e,a=e+n;return i?o=t.substring(0,s)+t.substr(a,r):(a=(s=r-1-e-n)+n,o=t.substring(0,s+1)+t.substr(a+1,r)),o},t.strReplace=function(t,e){for(var n=0,i=e.length;n",">",'"',""","'","'","®","®","©","©","™","™"],t}();!function(t){var e=function(){function e(){}return e.convertImageToCanvas=function(e,n){this.sharedCanvas||(this.sharedCanvas=egret.sys.createCanvas(),this.sharedContext=this.sharedCanvas.getContext("2d"));var i=e.$getTextureWidth(),r=e.$getTextureHeight();n||((n=egret.$TempRectangle).x=0,n.y=0,n.width=i,n.height=r),n.x=Math.min(n.x,i-1),n.y=Math.min(n.y,r-1),n.width=Math.min(n.width,i-n.x),n.height=Math.min(n.height,r-n.y);var o=Math.floor(n.width),s=Math.floor(n.height),a=this.sharedCanvas;if(a.style.width=o+"px",a.style.height=s+"px",this.sharedCanvas.width=o,this.sharedCanvas.height=s,"webgl"==egret.Capabilities.renderMode){var c=void 0;e.$renderBuffer?c=e:(egret.sys.systemRenderer.renderClear&&egret.sys.systemRenderer.renderClear(),(c=new egret.RenderTexture).drawToTexture(new egret.Bitmap(e)));for(var h=c.$renderBuffer.getPixels(n.x,n.y,o,s),u=0,l=0,p=0;p=0?"png":"jpg"});return wx.getFileSystemManager().saveFile({tempFilePath:o,filePath:wx.env.USER_DATA_PATH+"/"+n,success:function(t){}}),o},e.getPixel32=function(t,e,n){return egret.$warn(1041,"getPixel32","getPixels"),t.getPixels(e,n)},e.getPixels=function(t,e,n,i,r){if(void 0===i&&(i=1),void 0===r&&(r=1),"webgl"==egret.Capabilities.renderMode){var o=void 0;return t.$renderBuffer?o=t:(o=new egret.RenderTexture).drawToTexture(new egret.Bitmap(t)),o.$renderBuffer.getPixels(e,n,i,r)}try{this.convertImageToCanvas(t);return this.sharedContext.getImageData(e,n,i,r).data}catch(t){egret.$error(1039)}},e}();t.TextureUtils=e}(es||(es={})),function(t){var e=function(){function t(){}return t.update=function(t){var e=(t-this._lastTime)/1e3;this.deltaTime=e*this.timeScale,this.unscaledDeltaTime=e,this._timeSinceSceneLoad+=e,this.frameCount++,this._lastTime=t},t.sceneChanged=function(){this._timeSinceSceneLoad=0},t.checkEvery=function(t){return this._timeSinceSceneLoad/t>(this._timeSinceSceneLoad-this.deltaTime)/t},t.deltaTime=0,t.timeScale=1,t.frameCount=0,t._lastTime=0,t}();t.Time=e}(es||(es={}));var TimeUtils=function(){function t(){}return t.monthId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getFullYear(),n=t.getMonth()+1;return parseInt(e+(n<10?"0":"")+n)},t.dateId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getMonth()+1,n=e<10?"0":"",i=t.getDate(),r=i<10?"0":"";return parseInt(t.getFullYear()+n+e+r+i)},t.weekId=function(t,e){void 0===t&&(t=null),void 0===e&&(e=!0),t=t||new Date;var n=new Date;n.setTime(t.getTime()),n.setDate(1),n.setMonth(0);var i=n.getFullYear(),r=n.getDay();0==r&&(r=7);var o=!1;r<=4?(o=r>1,n.setDate(n.getDate()-(r-1))):n.setDate(n.getDate()+7-r+1);var s=this.diffDay(t,n,!1);if(s<0)return n.setDate(1),n.setMonth(0),n.setDate(n.getDate()-1),this.weekId(n,!1);var a=s/7,c=Math.floor(a)+1;if(53==c){n.setTime(t.getTime()),n.setDate(n.getDate()-1);var h=n.getDay();if(0==h&&(h=7),e&&(!o||h<4))return n.setFullYear(n.getFullYear()+1),n.setDate(1),n.setMonth(0),this.weekId(n,!1)}return parseInt(i+"00"+(c>9?"":"0")+c)},t.diffDay=function(t,e,n){void 0===n&&(n=!1);var i=(t.getTime()-e.getTime())/864e5;return n?Math.ceil(i):Math.floor(i)},t.getFirstDayOfWeek=function(t){var e=(t=t||new Date).getDay()||7;return new Date(t.getFullYear(),t.getMonth(),t.getDate()+1-e,0,0,0,0)},t.getFirstOfDay=function(t){return(t=t||new Date).setHours(0,0,0,0),t},t.getNextFirstOfDay=function(t){return new Date(this.getFirstOfDay(t).getTime()+864e5)},t.formatDate=function(t){var e=t.getFullYear(),n=t.getMonth()+1;n=n<10?"0"+n:n;var i=t.getDate();return e+"-"+n+"-"+(i=i<10?"0"+i:i)},t.formatDateTime=function(t){var e=t.getFullYear(),n=t.getMonth()+1;n=n<10?"0"+n:n;var i=t.getDate();i=i<10?"0"+i:i;var r=t.getHours(),o=t.getMinutes();o=o<10?"0"+o:o;var s=t.getSeconds();return e+"-"+n+"-"+i+" "+r+":"+o+":"+(s=s<10?"0"+s:s)},t.parseDate=function(t){var e=Date.parse(t);return isNaN(e)?new Date:new Date(Date.parse(t.replace(/-/g,"/")))},t.secondToTime=function(t,e,n){void 0===t&&(t=0),void 0===e&&(e=":"),void 0===n&&(n=!0);var i=Math.floor(t/3600),r=Math.floor(t%3600/60),o=Math.floor(t%3600%60),s=i.toString(),a=r.toString(),c=o.toString();return i<10&&(s="0"+s),r<10&&(a="0"+a),o<10&&(c="0"+c),n?s+e+a+e+c:a+e+c},t.timeToMillisecond=function(t,e){void 0===e&&(e=":");for(var n=t.split(e),i=0,r=n.length,o=0;o-1?this.os="iOS":i.indexOf("android")>-1&&(this.os="Android");var r=n.language;r=r.indexOf("zh")>-1?"zh-CN":"en-US",this.language=r}},e}(egret.Capabilities);t.GraphicsCapabilities=e}(es||(es={})),function(t){var e=function(){function e(){this.setup(),this.graphicsCapabilities=new t.GraphicsCapabilities,this.graphicsCapabilities.initialize(this)}return Object.defineProperty(e.prototype,"viewport",{get:function(){return this._viewport},enumerable:!0,configurable:!0}),e.prototype.setup=function(){this._viewport=new t.Viewport(0,0,t.Core._instance.stage.stageWidth,t.Core._instance.stage.stageHeight)},e}();t.GraphicsDevice=e}(es||(es={})),function(t){var e=function(){function e(t,e,n,i){this._x=t,this._y=e,this._width=n,this._height=i,this._minDepth=0,this._maxDepth=1}return Object.defineProperty(e.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"aspectRatio",{get:function(){return 0!=this._height&&0!=this._width?this._width/this._height:0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bounds",{get:function(){return new t.Rectangle(this._x,this._y,this._width,this._height)},set:function(t){this._x=t.x,this._y=t.y,this._width=t.width,this._height=t.height},enumerable:!0,configurable:!0}),e}();t.Viewport=e}(es||(es={})),function(t){var e=function(e){function n(){return e.call(this,t.PostProcessor.default_vert,n.blur_frag,{screenWidth:t.Core.graphicsDevice.viewport.width,screenHeight:t.Core.graphicsDevice.viewport.height})||this}return __extends(n,e),n.blur_frag="precision mediump float;\nuniform sampler2D uSampler;\nuniform float screenWidth;\nuniform float screenHeight;\nfloat normpdf(in float x, in float sigma)\n{\nreturn 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;\n}\nvoid main()\n{\nvec3 c = texture2D(uSampler, gl_FragCoord.xy / vec2(screenWidth, screenHeight).xy).rgb;\nconst int mSize = 11;\nconst int kSize = (mSize - 1)/2;\nfloat kernel[mSize];\nvec3 final_colour = vec3(0.0);\nfloat sigma = 7.0;\nfloat z = 0.0;\nfor (int j = 0; j <= kSize; ++j)\n{\nkernel[kSize+j] = kernel[kSize-j] = normpdf(float(j),sigma);\n}\nfor (int j = 0; j < mSize; ++j)\n{\nz += kernel[j];\n}\nfor (int i = -kSize; i <= kSize; ++i)\n{\nfor (int j = -kSize; j <= kSize; ++j)\n{\nfinal_colour += kernel[kSize+j]*kernel[kSize+i]*texture2D(uSampler, (gl_FragCoord.xy+vec2(float(i),float(j))) / vec2(screenWidth, screenHeight).xy).rgb;\n}\n}\ngl_FragColor = vec4(final_colour/(z*z), 1.0);\n}",n}(egret.CustomFilter);t.GaussianBlurEffect=e}(es||(es={})),function(t){var e=function(t){function e(){return t.call(this,e.vertSrc,e.fragmentSrc)||this}return __extends(e,t),e.vertSrc="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nuniform vec2 projectionVector;\nvarying vec2 vTextureCoord;\nconst vec2 center = vec2(-1.0, 1.0);\nvoid main(void) {\n gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",e.fragmentSrc="precision lowp float;\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n#define SAMPLE_COUNT 15\nuniform vec2 _sampleOffsets[SAMPLE_COUNT];\nuniform float _sampleWeights[SAMPLE_COUNT];\nvoid main(void) {\nvec4 c = vec4(0, 0, 0, 0);\nfor( int i = 0; i < SAMPLE_COUNT; i++ )\n c += texture2D( uSampler, vTextureCoord + _sampleOffsets[i] ) * _sampleWeights[i];\ngl_FragColor = c;\n}",e}(egret.CustomFilter);t.PolygonLightEffect=e}(es||(es={})),function(t){var e=function(){function e(t){void 0===t&&(t=null),this.enabled=!0,this.effect=t}return e.prototype.onAddedToScene=function(e){this.scene=e,this.shape=new egret.Shape,this.shape.graphics.beginFill(16777215,1),this.shape.graphics.drawRect(0,0,t.Core.graphicsDevice.viewport.width,t.Core.graphicsDevice.viewport.height),this.shape.graphics.endFill(),e.addChild(this.shape)},e.prototype.process=function(){this.drawFullscreenQuad()},e.prototype.onSceneBackBufferSizeChanged=function(t,e){},e.prototype.unload=function(){this.effect&&(this.effect=null),this.scene.removeChild(this.shape),this.scene=null},e.prototype.drawFullscreenQuad=function(){this.scene.filters=[this.effect]},e.default_vert="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec2 aColor;\nuniform vec2 projectionVector;\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nconst vec2 center = vec2(-1.0, 1.0);\nvoid main(void) {\ngl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\nvTextureCoord = aTextureCoord;\nvColor = vec4(aColor.x, aColor.x, aColor.x, aColor.x);\n}",e}();t.PostProcessor=e}(es||(es={})),function(t){var e=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.onAddedToScene=function(n){e.prototype.onAddedToScene.call(this,n),this.effect=new t.GaussianBlurEffect},n}(t.PostProcessor);t.GaussianBlurPostProcessor=e}(es||(es={})),function(t){var e=function(){function t(t,e){void 0===e&&(e=null),this.renderOrder=0,this.camera=e,this.renderOrder=t}return t.prototype.onAddedToScene=function(t){},t.prototype.unload=function(){},t.prototype.onSceneBackBufferSizeChanged=function(t,e){},t.prototype.compareTo=function(t){return this.renderOrder-t.renderOrder},t.prototype.beginRender=function(t){},t.prototype.renderAfterStateCheck=function(t,e){t.render(e)},t}();t.Renderer=e}(es||(es={})),function(t){var e=function(t){function e(){return t.call(this,0,null)||this}return __extends(e,t),e.prototype.render=function(t){var e=this.camera?this.camera:t.camera;this.beginRender(e);for(var n=0;nn?n:t},e.pointOnCirlce=function(n,i,r){var o=e.toRadians(r);return new t.Vector2(Math.cos(o)*o+n.x,Math.sin(o)*o+n.y)},e.isEven=function(t){return t%2==0},e.clamp01=function(t){return t<0?0:t>1?1:t},e.angleBetweenVectors=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)},e.Epsilon=1e-5,e.Rad2Deg=57.29578,e.Deg2Rad=.0174532924,e}();t.MathHelper=e}(es||(es={})),function(t){t.matrixPool=[];var e=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),Object.defineProperty(n.prototype,"m11",{get:function(){return this.a},set:function(t){this.a=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"m12",{get:function(){return this.b},set:function(t){this.b=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"m21",{get:function(){return this.c},set:function(t){this.c=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"m22",{get:function(){return this.d},set:function(t){this.d=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"m31",{get:function(){return this.tx},set:function(t){this.tx=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"m32",{get:function(){return this.ty},set:function(t){this.ty=t},enumerable:!0,configurable:!0}),n.create=function(){var e=t.matrixPool.pop();return e||(e=new n),e},n.prototype.identity=function(){return this.a=this.d=1,this.b=this.c=this.tx=this.ty=0,this},n.prototype.translate=function(t,e){return this.tx+=t,this.ty+=e,this},n.prototype.scale=function(t,e){return 1!==t&&(this.a*=t,this.c*=t,this.tx*=t),1!==e&&(this.b*=e,this.d*=e,this.ty*=e),this},n.prototype.rotate=function(t){if(0!==(t=+t)){t/=DEG_TO_RAD;var e=Math.cos(t),n=Math.sin(t),i=this.a,r=this.b,o=this.c,s=this.d,a=this.tx,c=this.ty;this.a=i*e-r*n,this.b=i*n+r*e,this.c=o*e-s*n,this.d=o*n+s*e,this.tx=a*e-c*n,this.ty=a*n+c*e}return this},n.prototype.invert=function(){return this.$invertInto(this),this},n.prototype.add=function(t){return this.m11+=t.m11,this.m12+=t.m12,this.m21+=t.m21,this.m22+=t.m22,this.m31+=t.m31,this.m32+=t.m32,this},n.prototype.substract=function(t){return this.m11-=t.m11,this.m12-=t.m12,this.m21-=t.m21,this.m22-=t.m22,this.m31-=t.m31,this.m32-=t.m32,this},n.prototype.divide=function(t){return this.m11/=t.m11,this.m12/=t.m12,this.m21/=t.m21,this.m22/=t.m22,this.m31/=t.m31,this.m32/=t.m32,this},n.prototype.multiply=function(t){var e=this.m11*t.m11+this.m12*t.m21,n=this.m11*t.m12+this.m12*t.m22,i=this.m21*t.m11+this.m22*t.m21,r=this.m21*t.m12+this.m22*t.m22,o=this.m31*t.m11+this.m32*t.m21+t.m31,s=this.m31*t.m12+this.m32*t.m22+t.m32;return this.m11=e,this.m12=n,this.m21=i,this.m22=r,this.m31=o,this.m32=s,this},n.prototype.determinant=function(){return this.m11*this.m22-this.m12*this.m21},n.prototype.release=function(e){e&&t.matrixPool.push(e)},n}(egret.Matrix);t.Matrix2D=e}(es||(es={})),function(t){var e=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),Object.defineProperty(n.prototype,"max",{get:function(){return new t.Vector2(this.right,this.bottom)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"center",{get:function(){return new t.Vector2(this.x+this.width/2,this.y+this.height/2)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"location",{get:function(){return new t.Vector2(this.x,this.y)},set:function(t){this.x=t.x,this.y=t.y},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"size",{get:function(){return new t.Vector2(this.width,this.height)},set:function(t){this.width=t.x,this.height=t.y},enumerable:!0,configurable:!0}),n.fromMinMax=function(t,e,i,r){return new n(t,e,i-t,r-e)},n.rectEncompassingPoints=function(t){for(var e=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=0;oi&&(i=s.x),s.yr&&(r=s.y)}return this.fromMinMax(e,n,i,r)},n.prototype.intersects=function(t){return t.leftthis.x+this.width)return e}else{var i=1/t.direction.x,r=(this.x-t.start.x)*i,o=(this.x+this.width-t.start.x)*i;if(r>o){var s=r;r=o,o=s}if((e=Math.max(r,e))>(n=Math.min(o,n)))return e}if(Math.abs(t.direction.y)<1e-6){if(t.start.ythis.y+this.height)return e}else{var a=1/t.direction.y,c=(this.y-t.start.y)*a,h=(this.y+this.height-t.start.y)*a;if(c>h){var u=c;c=h,h=u}if((e=Math.max(c,e))>(n=Math.max(h,n)))return e}return e},n.prototype.containsRect=function(t){return this.x<=t.x&&t.x1)return!1;var u=(c.x*o.y-c.y*o.x)/a;return!(u<0||u>1)},n.lineToLineIntersection=function(e,n,i,r){var o=new t.Vector2(0,0),s=t.Vector2.subtract(n,e),a=t.Vector2.subtract(r,i),c=s.x*a.y-s.y*a.x;if(0==c)return o;var h=t.Vector2.subtract(i,e),u=(h.x*a.y-h.y*a.x)/c;if(u<0||u>1)return o;var l=(h.x*s.y-h.y*s.x)/c;return l<0||l>1?o:o=t.Vector2.add(e,new t.Vector2(u*s.x,u*s.y))},n.closestPointOnLine=function(e,n,i){var r=t.Vector2.subtract(n,e),o=t.Vector2.subtract(i,e),s=t.Vector2.dot(o,r)/t.Vector2.dot(r,r);return s=t.MathHelper.clamp(s,0,1),t.Vector2.add(e,new t.Vector2(r.x*s,r.y*s))},n.isCircleToCircle=function(e,n,i,r){return t.Vector2.distanceSquared(e,i)<(n+r)*(n+r)},n.isCircleToLine=function(e,n,i,r){return t.Vector2.distanceSquared(e,this.closestPointOnLine(i,r,e))=t&&r.y>=e&&r.x=t+i&&(s|=e.right),o.y=n+r&&(s|=e.bottom),s},n}();t.Collisions=n}(es||(es={})),function(t){var e=function(){function e(){}return e.reset=function(){this._spatialHash=new t.SpatialHash(this.spatialHashCellSize)},e.clear=function(){this._spatialHash.clear()},e.overlapCircleAll=function(t,e,n,i){if(void 0===i&&(i=-1),0!=n.length)return this._spatialHash.overlapCircle(t,e,n,i);console.error("An empty results array was passed in. No results will ever be returned.")},e.boxcastBroadphase=function(t,e){return void 0===e&&(e=this.allLayers),this._spatialHash.aabbBroadphase(t,null,e)},e.boxcastBroadphaseExcludingSelf=function(t,e,n){return void 0===n&&(n=this.allLayers),this._spatialHash.aabbBroadphase(e,t,n)},e.addCollider=function(t){e._spatialHash.register(t)},e.removeCollider=function(t){e._spatialHash.remove(t)},e.updateCollider=function(t){this._spatialHash.remove(t),this._spatialHash.register(t)},e.debugDraw=function(t){this._spatialHash.debugDraw(t,2)},e.spatialHashCellSize=100,e.allLayers=-1,e.raycastsHitTriggers=!1,e.raycastsStartInColliders=!1,e}();t.Physics=e}(es||(es={})),function(t){var e=function(){return function(e,n){this.start=e,this.end=n,this.direction=t.Vector2.subtract(this.end,this.start)}}();t.Ray2D=e}(es||(es={})),function(t){var e=function(){function e(e,n,i,r,o){this.fraction=0,this.distance=0,this.point=t.Vector2.zero,this.normal=t.Vector2.zero,this.collider=e,this.fraction=n,this.distance=i,this.point=r,this.centroid=t.Vector2.zero}return e.prototype.setValues=function(t,e,n,i){this.collider=t,this.fraction=e,this.distance=n,this.point=i},e.prototype.setValuesNonCollider=function(t,e,n,i){this.fraction=t,this.distance=e,this.point=n,this.normal=i},e.prototype.reset=function(){this.collider=null,this.fraction=this.distance=0},e.prototype.toString=function(){return"[RaycastHit] fraction: "+this.fraction+", distance: "+this.distance+", normal: "+this.normal+", centroid: "+this.centroid+", point: "+this.point},e}();t.RaycastHit=e}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.clone=function(){return ObjectUtils.clone(this)},t}();t.Shape=e}(es||(es={})),function(t){var e=function(e){function n(t,n){var i=e.call(this)||this;return i._areEdgeNormalsDirty=!0,i.isUnrotated=!0,i.setPoints(t),i.isBox=n,i}return __extends(n,e),Object.defineProperty(n.prototype,"edgeNormals",{get:function(){return this._areEdgeNormalsDirty&&this.buildEdgeNormals(),this._edgeNormals},enumerable:!0,configurable:!0}),n.prototype.setPoints=function(t){this.points=t,this.recalculateCenterAndEdgeNormals(),this._originalPoints=[];for(var e=0;e=this.points.length?this.points[0]:this.points[i+1];var o=t.Vector2Ext.perpendicular(r,e);o=t.Vector2.normalize(o),this._edgeNormals[i]=o}},n.buildSymmetricalPolygon=function(e,n){for(var i=new Array(e),r=0;rr&&(r=s,i=o)}return e[i]},n.getClosestPointOnPolygonToPoint=function(e,n,i,r){i=Number.MAX_VALUE,r=new t.Vector2(0,0);for(var o,s=new t.Vector2(0,0),a=0;ae.y!=this.points[r].y>e.y&&e.x<(this.points[r].x-this.points[i].x)*(e.y-this.points[i].y)/(this.points[r].y-this.points[i].y)+this.points[i].x&&(n=!n);return n},n.prototype.pointCollidesWithShape=function(e,n){return t.ShapeCollisions.pointToPoly(e,this,n)},n}(t.Shape);t.Polygon=e}(es||(es={})),function(t){var e=function(e){function n(t,i){var r=e.call(this,n.buildBox(t,i),!0)||this;return r.width=t,r.height=i,r}return __extends(n,e),n.buildBox=function(e,n){var i=e/2,r=n/2,o=new Array(4);return o[0]=new t.Vector2(-i,-r),o[1]=new t.Vector2(i,-r),o[2]=new t.Vector2(i,r),o[3]=new t.Vector2(-i,r),o},n.prototype.updateBox=function(e,n){this.width=e,this.height=n;var i=e/2,r=n/2;this.points[0]=new t.Vector2(-i,-r),this.points[1]=new t.Vector2(i,-r),this.points[2]=new t.Vector2(i,r),this.points[3]=new t.Vector2(-i,r);for(var o=0;o1)return s;var a,c=t.Vector2.add(o.start,t.Vector2.add(o.direction,new t.Vector2(s))),h=0;c.xn.bounds.right&&(h|=1),c.yn.bounds.bottom&&(h|=2);var u=a+h;return 3==u&&console.log("m == 3. corner "+t.Time.frameCount),s},e}();t.RealtimeCollisions=e}(es||(es={})),function(t){var e=function(){function e(){}return e.polygonToPolygon=function(e,n,i){for(var r,o=!0,s=e.edgeNormals,a=n.edgeNormals,c=Number.POSITIVE_INFINITY,h=new t.Vector2,u=t.Vector2.subtract(e.position,n.position),l=0;l0&&(o=!1),!o)return!1;(m=Math.abs(m))r&&(r=o);return{min:i,max:r}},e.circleToPolygon=function(e,n,i){var r,o=t.Vector2.subtract(e.position,n.position),s=t.Polygon.getClosestPointOnPolygonToPoint(n.points,o,0,i.normal),a=n.containsPoint(e.position);if(0>e.radius*e.radius&&!a)return!1;a?r=t.Vector2.multiply(i.normal,new t.Vector2(Math.sqrt(0)-e.radius)):r=t.Vector2.multiply(i.normal,new t.Vector2(e.radius));return i.minimumTranslationVector=r,i.point=t.Vector2.add(s,n.position),!0},e.circleToBox=function(e,n,i){var r=n.bounds.getClosestPointOnRectangleBorderToPoint(e.position,i.normal);if(n.containsPoint(e.position)){i.point=r;var o=t.Vector2.add(r,t.Vector2.multiply(i.normal,new t.Vector2(e.radius)));return i.minimumTranslationVector=t.Vector2.subtract(e.position,o),!0}var s=t.Vector2.distanceSquared(r,e.position);if(0==s)i.minimumTranslationVector=t.Vector2.multiply(i.normal,new t.Vector2(e.radius));else if(s<=e.radius*e.radius){i.normal=t.Vector2.subtract(e.position,r);var a=i.normal.length()-e.radius;return i.point=r,i.normal=t.Vector2Ext.normalize(i.normal),i.minimumTranslationVector=t.Vector2.multiply(new t.Vector2(a),i.normal),!0}return!1},e.pointToCircle=function(e,n,i){var r=t.Vector2.distanceSquared(e,n.position),o=1+n.radius;if(r1)return!1;var l=(h.x*s.y-h.y*s.x)/c;return!(l<0||l>1)&&(o=o.add(e).add(t.Vector2.multiply(new t.Vector2(u),s)),!0)},e.lineToCircle=function(e,n,i,r){var o=t.Vector2.distance(e,n),s=t.Vector2.divide(t.Vector2.subtract(n,e),new t.Vector2(o)),a=t.Vector2.subtract(e,i.position),c=t.Vector2.dot(a,s),h=t.Vector2.dot(a,a)-i.radius*i.radius;if(h>0&&c>0)return!1;var u=c*c-h;return!(u<0)&&(r.fraction=-c-Math.sqrt(u),r.fraction<0&&(r.fraction=0),r.point=t.Vector2.add(e,t.Vector2.multiply(new t.Vector2(r.fraction),s)),r.distance=t.Vector2.distance(e,r.point),r.normal=t.Vector2.normalize(t.Vector2.subtract(r.point,i.position)),r.fraction=r.distance/o,!0)},e.boxToBoxCast=function(e,n,i,r){var o=this.minkowskiDifference(e,n);if(o.contains(0,0)){var s=o.getClosestPointOnBoundsToOrigin();return!s.equals(t.Vector2.zero)&&(r.normal=new t.Vector2(-s.x),r.normal=r.normal.normalize(),r.distance=0,r.fraction=0,!0)}var a=new t.Ray2D(t.Vector2.zero,new t.Vector2(-i.x)),c=o.rayIntersects(a);return c<=1&&(r.fraction=c,r.distance=i.length()*c,r.normal=new t.Vector2(-i.x),r.normal=r.normal.normalize(),r.centroid=t.Vector2.add(e.bounds.center,t.Vector2.multiply(i,new t.Vector2(c))),!0)},e}();t.ShapeCollisions=e}(es||(es={})),function(t){var e=function(){function e(e){void 0===e&&(e=100),this.gridBounds=new t.Rectangle,this._overlapTestCircle=new t.Circle(0),this._cellDict=new n,this._tempHashSet=[],this._cellSize=e,this._inverseCellSize=1/this._cellSize,this._raycastParser=new i}return e.prototype.register=function(e){var n=e.bounds;e.registeredPhysicsBounds=n;var i=this.cellCoords(n.x,n.y),r=this.cellCoords(n.right,n.bottom);this.gridBounds.contains(i.x,i.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,i)),this.gridBounds.contains(r.x,r.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,r));for(var o=i.x;o<=r.x;o++)for(var s=i.y;s<=r.y;s++){var a=this.cellAtPosition(o,s,!0);a.firstOrDefault(function(t){return t.hashCode==e.hashCode})||a.push(e)}},e.prototype.remove=function(t){for(var e=t.registeredPhysicsBounds,n=this.cellCoords(e.x,e.y),i=this.cellCoords(e.right,e.bottom),r=n.x;r<=i.x;r++)for(var o=n.y;o<=i.y;o++){var s=this.cellAtPosition(r,o);s?s.remove(t):console.log("从不存在碰撞器的单元格中移除碰撞器: ["+t+"]")}},e.prototype.removeWithBruteForce=function(t){this._cellDict.remove(t)},e.prototype.clear=function(){this._cellDict.clear()},e.prototype.debugDraw=function(t,e){void 0===e&&(e=1);for(var n=this.gridBounds.x;n<=this.gridBounds.right;n++)for(var i=this.gridBounds.y;i<=this.gridBounds.bottom;i++){var r=this.cellAtPosition(n,i);r&&r.length>0&&this.debugDrawCellDetails(n,i,r.length,t,e)}},e.prototype.aabbBroadphase=function(e,n,i){this._tempHashSet.length=0;for(var r=this.cellCoords(e.x,e.y),o=this.cellCoords(e.right,e.bottom),s=r.x;s<=o.x;s++)for(var a=r.y;a<=o.y;a++){var c=this.cellAtPosition(s,a);if(c)for(var h=function(r){var o=c[r];if(o==n||!t.Flags.isFlagSet(i,o.physicsLayer))return"continue";e.intersects(o.bounds)&&(u._tempHashSet.firstOrDefault(function(t){return t.hashCode==o.hashCode})||u._tempHashSet.push(o))},u=this,l=0;ln;i--)if(t[i]0&&t[r-1]>i;r--)t[r]=t[r-1];t[r]=i}},t.binarySearch=function(t,e){for(var n=0,i=t.length,r=n+i>>1;n=t[r]&&(n=r+1),r=n+i>>1;return t[n]==e?n:-1},t.findElementIndex=function(t,e){for(var n=t.length,i=0;it[e]&&(e=i);return e},t.getMinElementIndex=function(t){for(var e=0,n=t.length,i=1;i=0;--r)n.unshift(e[r]);return n},t.getDifferAry=function(t,e){t=this.getUniqueAry(t),e=this.getUniqueAry(e);for(var n=t.concat(e),i={},r=[],o=n.length,s=0;s=0;e-=1)t.splice(e,1)},t.cloneList=function(t){return t?t.slice(0,t.length):null},t.equals=function(t,e){if(t==e)return!0;var n=t.length;if(n!=e.length)return!1;for(;n--;)if(t[n]!=e[n])return!1;return!0},t.insert=function(t,e,n){if(!t)return null;var i=t.length;if(e>i&&(e=i),e<0&&(e=0),e==i)t.push(n);else if(0==e)t.unshift(n);else{for(var r=i-1;r>=e;r-=1)t[r+1]=t[r];t[e]=n}return n},t}(),Base64Utils=function(){function t(){}return t.decode=function(t,e){void 0===e&&(e=!0);var n,i,r,o,s,a,c="",h=0;for(t=(t=this.getConfKey(t)).replace(/[^A-Za-z0-9\+\/\=]/g,"");h>4,i=(15&o)<<4|(s=this._keyAll.indexOf(t.charAt(h++)))>>2,r=(3&s)<<6|(a=this._keyAll.indexOf(t.charAt(h++))),c+=String.fromCharCode(n),64!=s&&(0==i?e&&(c+=String.fromCharCode(i)):c+=String.fromCharCode(i)),64!=a&&(0==r?e&&(c+=String.fromCharCode(r)):c+=String.fromCharCode(r));return c=this._utf8_decode(c)},t._utf8_encode=function(t){t=t.replace(/\r\n/g,"\n");for(var e="",n=0;n127&&i<2048?(e+=String.fromCharCode(i>>6|192),e+=String.fromCharCode(63&i|128)):(e+=String.fromCharCode(i>>12|224),e+=String.fromCharCode(i>>6&63|128),e+=String.fromCharCode(63&i|128))}return e},t._utf8_decode=function(t){for(var e="",n=0,i=0,r=0,o=0;n191&&i<224?(r=t.charCodeAt(n+1),e+=String.fromCharCode((31&i)<<6|63&r),n+=2):(r=t.charCodeAt(n+1),o=t.charCodeAt(n+2),e+=String.fromCharCode((15&i)<<12|(63&r)<<6|63&o),n+=3);return e},t.getConfKey=function(t){return t.slice(1,t.length)},t._keyNum="0123456789+/",t._keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",t._keyAll=t._keyNum+t._keyStr,t.encode=function(t){var e,n,i,r,o,s,a,c="",h=0;for(t=this._utf8_encode(t);h>2,o=(3&e)<<4|(n=t.charCodeAt(h++))>>4,s=(15&n)<<2|(i=t.charCodeAt(h++))>>6,a=63&i,isNaN(n)?s=a=64:isNaN(i)&&(a=64),c=c+this._keyAll.charAt(r)+this._keyAll.charAt(o)+this._keyAll.charAt(s)+this._keyAll.charAt(a);return this._keyStr.charAt(Math.floor(Math.random()*this._keyStr.length))+c},t}();!function(t){var e=function(){function t(){this.loadedAssets=new Map}return t.prototype.loadRes=function(t,e){var n=this;return void 0===e&&(e=!0),new Promise(function(i,r){var o=n.loadedAssets.get(t);o?i(o):e?RES.getResAsync(t).then(function(e){n.loadedAssets.set(t,e),i(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)}):RES.getResByUrl(t).then(function(e){n.loadedAssets.set(t,e),i(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)})})},t.prototype.dispose=function(){this.loadedAssets.forEach(function(t){t.dispose()}),this.loadedAssets.clear()},t}();t.ContentManager=e}(es||(es={})),function(t){var e=function(){function e(){}return e.drawLine=function(e,n,i,r,o){void 0===o&&(o=1),this.drawLineAngle(e,n,t.MathHelper.angleBetweenVectors(n,i),t.Vector2.distance(n,i),r,o)},e.drawLineAngle=function(t,e,n,i,r,o){void 0===o&&(o=1),t.graphics.beginFill(r),t.graphics.drawRect(e.x,e.y,1,1),t.graphics.endFill(),t.scaleX=i,t.scaleY=o,t.$anchorOffsetX=0,t.$anchorOffsetY=0,t.rotation=n},e.drawHollowRect=function(t,e,n,i){void 0===i&&(i=1),this.drawHollowRectR(t,e.x,e.y,e.width,e.height,n,i)},e.drawHollowRectR=function(e,n,i,r,o,s,a){void 0===a&&(a=1);var c=new t.Vector2(n,i).round(),h=new t.Vector2(n+r,i).round(),u=new t.Vector2(n+r,i+o).round(),l=new t.Vector2(n,i+o).round();this.drawLine(e,c,h,s,a),this.drawLine(e,h,u,s,a),this.drawLine(e,u,l,s,a),this.drawLine(e,l,c,s,a)},e.drawPixel=function(e,n,i,r){void 0===r&&(r=1);var o=new t.Rectangle(n.x,n.y,r,r);1!=r&&(o.x-=.5*r,o.y-=.5*r),e.graphics.beginFill(i),e.graphics.drawRect(o.x,o.y,o.width,o.height),e.graphics.endFill()},e.getColorMatrix=function(t){var e=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];return e[0]=Math.floor(t/256/256)/255,e[6]=Math.floor(t/256%256)/255,e[12]=t%256/255,new egret.ColorMatrixFilter(e)},e}();t.DrawUtils=e}(es||(es={})),function(t){var e=function(){return function(t,e){this.func=t,this.context=e}}();t.FuncPack=e;var n=function(){function t(){this._messageTable=new Map}return t.prototype.addObserver=function(t,n,i){var r=this._messageTable.get(t);r||(r=[],this._messageTable.set(t,r)),-1!=r.findIndex(function(t){return t.func==n})&&console.warn("您试图添加相同的观察者两次"),r.push(new e(n,i))},t.prototype.removeObserver=function(t,e){var n=this._messageTable.get(t),i=n.findIndex(function(t){return t.func==e});-1!=i&&n.removeAt(i)},t.prototype.emit=function(t,e){var n=this._messageTable.get(t);if(n)for(var i=n.length-1;i>=0;i--)n[i].func.call(n[i].context,e)},t}();t.Emitter=n}(es||(es={})),function(t){var e=function(){function t(){}return Object.defineProperty(t.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),t.prototype.setEnabled=function(t){this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled())},t.prototype.onEnabled=function(){},t.prototype.onDisabled=function(){},t.prototype.update=function(){},t}();t.GlobalManager=e}(es||(es={})),function(t){var e=function(){function e(){this.x=0,this.y=0,this.touchPoint=-1,this.touchDown=!1}return Object.defineProperty(e.prototype,"position",{get:function(){return new t.Vector2(this.x,this.y)},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this.x=0,this.y=0,this.touchDown=!1,this.touchPoint=-1},e}();t.TouchState=e;var n=function(){function n(){}return Object.defineProperty(n,"gameTouchs",{get:function(){return this._gameTouchs},enumerable:!0,configurable:!0}),Object.defineProperty(n,"resolutionScale",{get:function(){return this._resolutionScale},enumerable:!0,configurable:!0}),Object.defineProperty(n,"totalTouchCount",{get:function(){return this._totalTouchCount},enumerable:!0,configurable:!0}),Object.defineProperty(n,"touchPosition",{get:function(){return this._gameTouchs[0]?this._gameTouchs[0].position:t.Vector2.zero},enumerable:!0,configurable:!0}),Object.defineProperty(n,"maxSupportedTouch",{get:function(){return t.Core._instance.stage.maxTouches},set:function(e){t.Core._instance.stage.maxTouches=e,this.initTouchCache()},enumerable:!0,configurable:!0}),Object.defineProperty(n,"touchPositionDelta",{get:function(){var e=t.Vector2.subtract(this.touchPosition,this._previousTouchState.position);return e.length()>0&&this.setpreviousTouchState(this._gameTouchs[0]),e},enumerable:!0,configurable:!0}),n.initialize=function(){this._init||(this._init=!0,t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.touchBegin,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.touchMove,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_END,this.touchEnd,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL,this.touchEnd,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE,this.touchEnd,this),this.initTouchCache())},n.scaledPosition=function(e){var n=new t.Vector2(e.x-this._resolutionOffset.x,e.y-this._resolutionOffset.y);return t.Vector2.multiply(n,this.resolutionScale)},n.initTouchCache=function(){this._totalTouchCount=0,this._touchIndex=0,this._gameTouchs.length=0;for(var t=0;t0)for(var e=0;ethis._objectQueue.length;)this._objectQueue.shift()},t.clearCache=function(){this._objectQueue.length=0},t.obtain=function(){return this._objectQueue.length>0?this._objectQueue.shift():[]},t.free=function(t){this._objectQueue.unshift(t),t.length=0},t._objectQueue=[],t}();t.ListPool=e}(es||(es={}));var THREAD_ID=Math.floor(1e3*Math.random())+"-"+Date.now(),nextTick=function(t){setTimeout(t,0)},LockUtils=function(){function t(t){this._keyX="mutex_key_"+t+"_X",this._keyY="mutex_key_"+t+"_Y",this.setItem=egret.localStorage.setItem.bind(localStorage),this.getItem=egret.localStorage.getItem.bind(localStorage),this.removeItem=egret.localStorage.removeItem.bind(localStorage)}return t.prototype.lock=function(){var t=this;return new Promise(function(e,n){var i=function(){t.setItem(t._keyX,THREAD_ID),null===!t.getItem(t._keyY)&&nextTick(i),t.setItem(t._keyY,THREAD_ID),t.getItem(t._keyX)!==THREAD_ID?setTimeout(function(){t.getItem(t._keyY)===THREAD_ID?(e(),t.removeItem(t._keyY)):nextTick(i)},10):(e(),t.removeItem(t._keyY))};i()})},t}();!function(t){var e=function(){function t(t,e){this.first=t,this.second=e}return t.prototype.clear=function(){this.first=this.second=null},t.prototype.equals=function(t){return this.first==t.first&&this.second==t.second},t}();t.Pair=e}(es||(es={}));var RandomUtils=function(){function t(){}return t.randrange=function(t,e,n){if(void 0===n&&(n=1),0==n)throw new Error("step 不能为 0");var i=e-t;if(0==i)throw new Error("没有可用的范围("+t+","+e+")");i<0&&(i=t-e);var r=Math.floor((i+n-1)/n);return Math.floor(this.random()*r)*n+Math.min(t,e)},t.randint=function(t,e){return(t=Math.floor(t))>(e=Math.floor(e))?t++:e++,this.randrange(t,e)},t.randnum=function(t,e){return this.random()*(e-t)+t},t.shuffle=function(t){return t.sort(this._randomCompare),t},t.choice=function(t){if(!t.hasOwnProperty("length"))throw new Error("无法对此对象执行此操作");var e=Math.floor(this.random()*t.length);return t instanceof String?String(t).charAt(e):t[e]},t.sample=function(t,e){var n=t.length;if(e<=0||n=0;)s=Math.floor(this.random()*n);i.push(t[s]),r.push(s)}return i},t.random=function(){return Math.random()},t.boolean=function(t){return void 0===t&&(t=.5),this.random().5?1:-1},t}();!function(t){var e=function(){function e(){}return e.union=function(e,n){var i=new t.Rectangle(n.x,n.y,0,0),r=new t.Rectangle;return r.x=Math.min(e.x,i.x),r.y=Math.min(e.y,i.y),r.width=Math.max(e.right,i.right)-r.x,r.height=Math.max(e.bottom,r.bottom)-r.y,r},e}();t.RectangleExt=e}(es||(es={})),function(t){var e=function(){function e(){this.triangleIndices=[],this._triPrev=new Array(12),this._triNext=new Array(12)}return e.testPointTriangle=function(e,n,i,r){return!(t.Vector2Ext.cross(t.Vector2.subtract(e,n),t.Vector2.subtract(i,n))<0)&&(!(t.Vector2Ext.cross(t.Vector2.subtract(e,i),t.Vector2.subtract(r,i))<0)&&!(t.Vector2Ext.cross(t.Vector2.subtract(e,r),t.Vector2.subtract(n,r))<0))},e.prototype.triangulate=function(n,i){void 0===i&&(i=!0);var r=n.length;this.initialize(r);for(var o=0,s=0;r>3&&o<500;){o++;var a=!0,c=n[this._triPrev[s]],h=n[s],u=n[this._triNext[s]];if(t.Vector2Ext.isTriangleCCW(c,h,u)){var l=this._triNext[this._triNext[s]];do{if(e.testPointTriangle(n[l],c,h,u)){a=!1;break}l=this._triNext[l]}while(l!=this._triPrev[s])}else a=!1;a?(this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),this._triNext[this._triPrev[s]]=this._triNext[s],this._triPrev[this._triNext[s]]=this._triPrev[s],r--,s=this._triPrev[s]):s=this._triNext[s]}this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),i||this.triangleIndices.reverse()},e.prototype.initialize=function(t){this.triangleIndices.length=0,this._triNext.lengtht.MathHelper.Epsilon?e=t.Vector2.divide(e,new t.Vector2(n)):e.x=e.y=0,e},e.transformA=function(t,e,n,i,r,o){for(var s=0;sthis.safeArea.right&&(s.x=this.safeArea.right-s.width),s.topthis.safeArea.bottom&&(s.y=this.safeArea.bottom-s.height),s},n}();t.Layout=n,function(t){t[t.none=0]="none",t[t.left=1]="left",t[t.right=2]="right",t[t.horizontalCenter=4]="horizontalCenter",t[t.top=8]="top",t[t.bottom=16]="bottom",t[t.verticalCenter=32]="verticalCenter",t[t.topLeft=9]="topLeft",t[t.topRight=10]="topRight",t[t.topCenter=12]="topCenter",t[t.bottomLeft=17]="bottomLeft",t[t.bottomRight=18]="bottomRight",t[t.bottomCenter=20]="bottomCenter",t[t.centerLeft=33]="centerLeft",t[t.centerRight=34]="centerRight",t[t.center=36]="center"}(e=t.Alignment||(t.Alignment={}))}(es||(es={})),function(t){var e,n=function(){function t(t){void 0===t&&(t=i),this.getSystemTime=t,this._stopDuration=0,this._completeSlices=[]}return t.prototype.getState=function(){return void 0===this._startSystemTime?e.IDLE:void 0===this._stopSystemTime?e.RUNNING:e.STOPPED},t.prototype.isIdle=function(){return this.getState()===e.IDLE},t.prototype.isRunning=function(){return this.getState()===e.RUNNING},t.prototype.isStopped=function(){return this.getState()===e.STOPPED},t.prototype.slice=function(){return this.recordPendingSlice()},t.prototype.getCompletedSlices=function(){return Array.from(this._completeSlices)},t.prototype.getCompletedAndPendingSlices=function(){return this._completeSlices.concat([this.getPendingSlice()])},t.prototype.getPendingSlice=function(){return this.calculatePendingSlice()},t.prototype.getTime=function(){return this.caculateStopwatchTime()},t.prototype.reset=function(){this._startSystemTime=this._pendingSliceStartStopwatchTime=this._stopSystemTime=void 0,this._stopDuration=0,this._completeSlices=[]},t.prototype.start=function(t){if(void 0===t&&(t=!1),t&&this.reset(),void 0!==this._stopSystemTime){var e=(n=this.getSystemTime())-this._stopSystemTime;this._stopDuration+=e,this._stopSystemTime=void 0}else if(void 0===this._startSystemTime){var n=this.getSystemTime();this._startSystemTime=n,this._pendingSliceStartStopwatchTime=0}},t.prototype.stop=function(t){if(void 0===t&&(t=!1),void 0===this._startSystemTime)return 0;var e=this.getSystemTimeOfCurrentStopwatchTime();return t&&this.recordPendingSlice(this.caculateStopwatchTime(e)),this._stopSystemTime=e,this.getTime()},t.prototype.calculatePendingSlice=function(t){return void 0===this._pendingSliceStartStopwatchTime?Object.freeze({startTime:0,endTime:0,duration:0}):(void 0===t&&(t=this.getTime()),Object.freeze({startTime:this._pendingSliceStartStopwatchTime,endTime:t,duration:t-this._pendingSliceStartStopwatchTime}))},t.prototype.caculateStopwatchTime=function(t){return void 0===this._startSystemTime?0:(void 0===t&&(t=this.getSystemTimeOfCurrentStopwatchTime()),t-this._startSystemTime-this._stopDuration)},t.prototype.getSystemTimeOfCurrentStopwatchTime=function(){return void 0===this._stopSystemTime?this.getSystemTime():this._stopSystemTime},t.prototype.recordPendingSlice=function(t){if(void 0!==this._pendingSliceStartStopwatchTime){void 0===t&&(t=this.getTime());var e=this.calculatePendingSlice(t);return this._pendingSliceStartStopwatchTime=e.endTime,this._completeSlices.push(e),e}return this.calculatePendingSlice()},t}();t.Stopwatch=n,function(t){t.IDLE="IDLE",t.RUNNING="RUNNING",t.STOPPED="STOPPED"}(e||(e={})),t.setDefaultSystemTimeGetter=function(t){void 0===t&&(t=Date.now),i=t};var i=Date.now}(stopwatch||(stopwatch={})),function(t){var e=function(){function e(){this.showLog=!1,this._frameKey="frame",this._logKey="log",this.markers=[],this.stopwacth=new stopwatch.Stopwatch,this._markerNameToIdMap=new Map,this._logs=new Array(2);for(var e=0;e=e.logSnapDuration&&(l.logs[r].snapMin=l.logs[r].min,l.logs[r].snapMax=l.logs[r].max,l.logs[r].snapAvg=l.logs[r].avg,l.logs[r].samples=0)):(l.logs[r].min=h,l.logs[r].max=h,l.logs[r].avg=h,l.logs[r].initialized=!0)}s.markCount=o.nestCount,s.nestCount=o.nestCount}t.stopwacth.reset(),t.stopwacth.start()}})},e.prototype.beginMark=function(t,n,i){var r=this;void 0===i&&(i=0),new LockUtils(this._frameKey).lock().then(function(){if(i<0||i>=e.maxBars)throw new Error("barIndex argument out of range");var o=r._curLog.bars[i];if(o.markCount>=e.maxSamples)throw new Error("exceeded sample count. either set larger number to timeruler.maxsaple or lower sample count");if(o.nestCount>=e.maxNestCall)throw new Error("exceeded nest count. either set larger number to timeruler.maxnestcall or lower nest calls");var s=r._markerNameToIdMap.get(t);isNaN(s)&&(s=r.markers.length,r._markerNameToIdMap.set(t,s)),o.markerNests[o.nestCount++]=o.markCount,o.markers[o.markCount].markerId=s,o.markers[o.markCount].color=n,o.markers[o.markCount].beginTime=r.stopwacth.getTime(),o.markers[o.markCount].endTime=-1})},e.prototype.endMark=function(t,n){var i=this;void 0===n&&(n=0),new LockUtils(this._frameKey).lock().then(function(){if(n<0||n>=e.maxBars)throw new Error("barIndex argument out of range");var r=i._curLog.bars[n];if(r.nestCount<=0)throw new Error("call beginMark method before calling endMark method");var o=i._markerNameToIdMap.get(t);if(isNaN(o))throw new Error("Marker "+t+" is not registered. Make sure you specifed same name as you used for beginMark method");var s=r.markerNests[--r.nestCount];if(r.markers[s].markerId!=o)throw new Error("Incorrect call order of beginMark/endMark method. beginMark(A), beginMark(B), endMark(B), endMark(A) But you can't called it like beginMark(A), beginMark(B), endMark(A), endMark(B).");r.markers[s].endTime=i.stopwacth.getTime()})},e.prototype.getAverageTime=function(t,n){if(t<0||t>=e.maxBars)throw new Error("barIndex argument out of range");var i=0,r=this._markerNameToIdMap.get(n);return r&&(i=this.markers[r].logs[t].avg),i},e.prototype.resetLog=function(){var t=this;new LockUtils(this._logKey).lock().then(function(){var e=parseInt(egret.localStorage.getItem(t._logKey),10);e+=1,egret.localStorage.setItem(t._logKey,e.toString()),t.markers.forEach(function(t){for(var e=0;e0&&(i+=e.barHeight+2*e.barPadding,r=Math.max(r,t.markers[t.markCount-1].endTime))});var o=this.sampleFrames*(1/60*1e3);this._frameAdjust=r>o?Math.max(0,this._frameAdjust)+1:Math.min(0,this._frameAdjust)-1,Math.max(this._frameAdjust)>e.autoAdjustDelay&&(this.sampleFrames=Math.min(e.maxSampleFrames,this.sampleFrames),this.sampleFrames=Math.max(this.targetSampleFrames,r/(1/60*1e3)+1),this._frameAdjust=0);t.y,e.barHeight}},e.prototype.onGraphicsDeviceReset=function(){var n=new t.Layout;this._position=n.place(new t.Vector2(this.width,e.barHeight),0,.01,t.Alignment.bottomCenter).location},e.maxBars=8,e.maxSamples=256,e.maxNestCall=32,e.barHeight=8,e.maxSampleFrames=4,e.logSnapDuration=120,e.barPadding=2,e.autoAdjustDelay=30,e}();t.TimeRuler=e;var n=function(){return function(){this.bars=new Array(e.maxBars),this.bars.fill(new i,0,e.maxBars)}}();t.FrameLog=n;var i=function(){return function(){this.markers=new Array(e.maxSamples),this.markCount=0,this.markerNests=new Array(e.maxNestCall),this.nestCount=0,this.markers.fill(new r,0,e.maxSamples),this.markerNests.fill(0,0,e.maxNestCall)}}();t.MarkerCollection=i;var r=function(){return function(){this.markerId=0,this.beginTime=0,this.endTime=0,this.color=0}}();t.Marker=r;var o=function(){return function(t){this.logs=new Array(e.maxBars),this.name=t,this.logs.fill(new s,0,e.maxBars)}}();t.MarkerInfo=o;var s=function(){return function(){this.snapMin=0,this.snapMax=0,this.snapAvg=0,this.min=0,this.max=0,this.avg=0,this.samples=0,this.color=0,this.initialized=!1}}();t.MarkerLog=s}(es||(es={})); \ No newline at end of file +window.es={},window.__extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}();var transform,__awaiter=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{c(i.next(t))}catch(t){o(t)}}function a(t){try{c(i.throw(t))}catch(t){o(t)}}function c(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}c((i=i.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=(r=s.trys).length>0&&r[r.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]-1}(this,t)},Array.prototype.firstOrDefault=function(t){return function(t,e){var n=t.findIndex(e);return-1==n?null:t[n]}(this,t)},Array.prototype.find=function(t){return function(t,e){return t.firstOrDefault(e)}(this,t)},Array.prototype.where=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(n,i,r){return e.call(arguments[2],i,r,t)&&n.push(i),n},[]);for(var n=[],i=0,r=t.length;i=0&&t.splice(n,1)}while(n>=0)}(this,t)},Array.prototype.remove=function(t){return function(t,e){var n=t.findIndex(function(t){return t===e});return n>=0&&(t.splice(n,1),!0)}(this,t)},Array.prototype.removeAt=function(t){return function(t,e){t.splice(e,1)}(this,t)},Array.prototype.removeRange=function(t,e){return function(t,e,n){t.splice(e,n)}(this,t,e)},Array.prototype.select=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(n,i,r){return n.push(e.call(arguments[2],i,r,t)),n},[]);for(var n=[],i=0,r=t.length;io?1:-1}),t}(this,t,e)},Array.prototype.orderByDescending=function(t,e){return function(t,e,n){return t.sort(function(t,i){var r=e(t),o=e(i);return n?-n(r,o):r0;){if("break"===u())break}return s?this.recontructPath(a,i,r):null},e.recontructPath=function(t,e,n){var i=[],r=n;for(i.push(n);r!=e;)r=this.getKey(t,r),i.push(r);return i.reverse(),i},e.hasKey=function(t,e){for(var n,i=t.keys();!(n=i.next()).done;)if(JSON.stringify(n.value)==JSON.stringify(e))return!0;return!1},e.getKey=function(t,e){for(var n,i,r=t.keys(),o=t.values();n=r.next(),i=o.next(),!n.done;)if(JSON.stringify(n.value)==JSON.stringify(e))return i.value;return null},e}();t.AStarPathfinder=e;var n=function(t){function e(e){var n=t.call(this)||this;return n.data=e,n}return __extends(e,t),e}(t.PriorityQueueNode);t.AStarNode=n}(es||(es={})),function(t){var e=function(){function e(e,n){this.dirs=[new t.Vector2(1,0),new t.Vector2(0,-1),new t.Vector2(-1,0),new t.Vector2(0,1)],this.walls=[],this.weightedNodes=[],this.defaultWeight=1,this.weightedNodeWeight=5,this._neighbors=new Array(4),this._width=e,this._height=n}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x=this._nodes.length?(console.error("node.QueueIndex has been corrupted. Did you change it manually? Or add this node to another queue?"),!1):this._nodes[t.queueIndex]==t:(console.error("node cannot be null"),!1)},t.prototype.enqueue=function(t,e){t.priority=e,this._numNodes++,this._nodes[this._numNodes]=t,t.queueIndex=this._numNodes,t.insertionIndex=this._numNodesEverEnqueued++,this.cascadeUp(this._nodes[this._numNodes])},t.prototype.dequeue=function(){var t=this._nodes[1];return this.remove(t),t},t.prototype.remove=function(t){if(t.queueIndex==this._numNodes)return this._nodes[this._numNodes]=null,void this._numNodes--;var e=this._nodes[this._numNodes];this.swap(t,e),delete this._nodes[this._numNodes],this._numNodes--,this.onNodeUpdated(e)},t.prototype.isValidQueue=function(){for(var t=1;t0&&this.hasHigherPriority(t,n)?this.cascadeUp(t):this.cascadeDown(t)},t.prototype.cascadeDown=function(t){for(var e,n=t.queueIndex;;){e=t;var i=2*n;if(i>this._numNodes){t.queueIndex=n,this._nodes[n]=t;break}var r=this._nodes[i];this.hasHigherPriority(r,e)&&(e=r);var o=i+1;if(o<=this._numNodes){var s=this._nodes[o];this.hasHigherPriority(s,e)&&(e=s)}if(e==t){t.queueIndex=n,this._nodes[n]=t;break}this._nodes[n]=e;var a=e.queueIndex;e.queueIndex=n,n=a}},t.prototype.cascadeUp=function(t){for(var e=Math.floor(t.queueIndex/2);e>=1;){var n=this._nodes[e];if(this.hasHigherPriority(n,t))break;this.swap(t,n),e=Math.floor(t.queueIndex/2)}},t.prototype.swap=function(t,e){this._nodes[t.queueIndex]=e,this._nodes[e.queueIndex]=t;var n=t.queueIndex;t.queueIndex=e.queueIndex,e.queueIndex=n},t.prototype.hasHigherPriority=function(t,e){return t.priority0;){if("break"===c())break}return o?t.AStarPathfinder.recontructPath(a,n,i):null},e.hasKey=function(t,e){for(var n,i=t.keys();!(n=i.next()).done;)if(JSON.stringify(n.value)==JSON.stringify(e))return!0;return!1},e}();t.BreadthFirstPathfinder=e}(es||(es={})),function(t){var e=function(){function t(){this.edges=new Map}return t.prototype.addEdgesForNode=function(t,e){return this.edges.set(t,e),this},t.prototype.getNeighbors=function(t){return this.edges.get(t)},t}();t.UnweightedGraph=e}(es||(es={})),function(t){var e=function(){function e(t,e){this.x=0,this.y=0,this.x=t||0,this.y=null!=e?e:this.x}return Object.defineProperty(e,"zero",{get:function(){return e.zeroVector2},enumerable:!0,configurable:!0}),Object.defineProperty(e,"one",{get:function(){return e.unitVector2},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitX",{get:function(){return e.unitXVector},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitY",{get:function(){return e.unitYVector},enumerable:!0,configurable:!0}),e.add=function(t,n){var i=new e(0,0);return i.x=t.x+n.x,i.y=t.y+n.y,i},e.divide=function(t,n){var i=new e(0,0);return i.x=t.x/n.x,i.y=t.y/n.y,i},e.multiply=function(t,n){var i=new e(0,0);return i.x=t.x*n.x,i.y=t.y*n.y,i},e.subtract=function(t,n){var i=new e(0,0);return i.x=t.x-n.x,i.y=t.y-n.y,i},e.normalize=function(t){var e=1/Math.sqrt(t.x*t.x+t.y*t.y);return t.x*=e,t.y*=e,t},e.dot=function(t,e){return t.x*e.x+t.y*e.y},e.distanceSquared=function(t,e){var n=t.x-e.x,i=t.y-e.y;return n*n+i*i},e.clamp=function(n,i,r){return new e(t.MathHelper.clamp(n.x,i.x,r.x),t.MathHelper.clamp(n.y,i.y,r.y))},e.lerp=function(n,i,r){return new e(t.MathHelper.lerp(n.x,i.x,r),t.MathHelper.lerp(n.y,i.y,r))},e.transform=function(t,n){return new e(t.x*n.m11+t.y*n.m21+n.m31,t.x*n.m12+t.y*n.m22+n.m32)},e.distance=function(t,e){var n=t.x-e.x,i=t.y-e.y;return Math.sqrt(n*n+i*i)},e.angle=function(n,i){return n=e.normalize(n),i=e.normalize(i),Math.acos(t.MathHelper.clamp(e.dot(n,i),-1,1))*t.MathHelper.Rad2Deg},e.negate=function(t){var n=new e;return n.x=-t.x,n.y=-t.y,n},e.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this},e.prototype.divide=function(t){return this.x/=t.x,this.y/=t.y,this},e.prototype.multiply=function(t){return this.x*=t.x,this.y*=t.y,this},e.prototype.subtract=function(t){return this.x-=t.x,this.y-=t.y,this},e.prototype.normalize=function(){var t=1/Math.sqrt(this.x*this.x+this.y*this.y);return this.x*=t,this.y*=t,this},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},e.prototype.round=function(){return new e(Math.round(this.x),Math.round(this.y))},e.prototype.equals=function(t){return t.x==this.x&&t.y==this.y},e.unitYVector=new e(0,1),e.unitXVector=new e(1,0),e.unitVector2=new e(1,1),e.zeroVector2=new e(0,0),e}();t.Vector2=e}(es||(es={})),function(t){var e=function(){function e(t,n,i){void 0===i&&(i=!1),this.walls=[],this._neighbors=new Array(4),this._width=t,this._hegiht=n,this._dirs=i?e.COMPASS_DIRS:e.CARDINAL_DIRS}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x0;){if("break"===u())break}return s?this.recontructPath(a,i,r):null},n.recontructPath=function(t,e,n){var i=[],r=n;for(i.push(n);r!=e;)r=this.getKey(t,r),i.push(r);return i.reverse(),i},n.hasKey=function(t,e){for(var n,i=t.keys();!(n=i.next()).done;)if(JSON.stringify(n.value)==JSON.stringify(e))return!0;return!1},n.getKey=function(t,e){for(var n,i,r=t.keys(),o=t.values();n=r.next(),i=o.next(),!n.done;)if(JSON.stringify(n.value)==JSON.stringify(e))return i.value;return null},n}();t.WeightedPathfinder=n}(es||(es={})),function(t){var e=function(){function e(){}return e.drawHollowRect=function(e,n,i){void 0===i&&(i=0),this._debugDrawItems.push(new t.DebugDrawItem(e,n,i))},e.render=function(){if(this._debugDrawItems.length>0){var e=new egret.Shape;t.Core.scene&&t.Core.scene.addChild(e);for(var n=this._debugDrawItems.length-1;n>=0;n--){this._debugDrawItems[n].draw(e)&&this._debugDrawItems.removeAt(n)}}},e._debugDrawItems=[],e}();t.Debug=e}(es||(es={})),function(t){var e=function(){function t(){}return t.verletParticle=14431326,t.verletConstraintEdge=4406838,t}();t.DebugDefaults=e}(es||(es={})),function(t){var e;!function(t){t[t.line=0]="line",t[t.hollowRectangle=1]="hollowRectangle",t[t.pixel=2]="pixel",t[t.text=3]="text"}(e=t.DebugDrawType||(t.DebugDrawType={}));var n=function(){function n(t,n,i){this.rectangle=t,this.color=n,this.duration=i,this.drawType=e.hollowRectangle}return n.prototype.draw=function(n){switch(this.drawType){case e.line:t.DrawUtils.drawLine(n,this.start,this.end,this.color);break;case e.hollowRectangle:t.DrawUtils.drawHollowRect(n,this.rectangle,this.color);break;case e.pixel:t.DrawUtils.drawPixel(n,new t.Vector2(this.x,this.y),this.color,this.size);break;case e.text:}return this.duration-=t.Time.deltaTime,this.duration<0},n}();t.DebugDrawItem=n}(es||(es={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateInterval=1,e._enabled=!0,e._updateOrder=0,e}return __extends(e,t),Object.defineProperty(e.prototype,"transform",{get:function(){return this.entity.transform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this.entity?this.entity.enabled&&this._enabled:this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"updateOrder",{get:function(){return this._updateOrder},set:function(t){this.setUpdateOrder(t)},enumerable:!0,configurable:!0}),e.prototype.initialize=function(){},e.prototype.onAddedToEntity=function(){},e.prototype.onRemovedFromEntity=function(){},e.prototype.onEntityTransformChanged=function(t){},e.prototype.debugRender=function(){},e.prototype.onEnabled=function(){},e.prototype.onDisabled=function(){},e.prototype.update=function(){},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled()),this},e.prototype.setUpdateOrder=function(t){return this._updateOrder!=t&&(this._updateOrder=t),this},e.prototype.clone=function(){var t=ObjectUtils.clone(this);return t.entity=null,t},e}(egret.HashObject);t.Component=e}(es||(es={})),function(t){var e=function(e){function n(){var i=e.call(this)||this;return i._globalManagers=[],n._instance=i,n.emitter=new t.Emitter,n.content=new t.ContentManager,i.addEventListener(egret.Event.ADDED_TO_STAGE,i.onAddToStage,i),i}return __extends(n,e),Object.defineProperty(n,"Instance",{get:function(){return this._instance},enumerable:!0,configurable:!0}),Object.defineProperty(n,"scene",{get:function(){return this._instance?this._instance._scene:null},set:function(t){t?null==this._instance._scene?(this._instance._scene=t,this._instance.addChild(t),this._instance._scene.begin(),n.Instance.onSceneChanged()):this._instance._nextScene=t:console.error("场景不能为空")},enumerable:!0,configurable:!0}),n.startSceneTransition=function(t){if(!this._instance._sceneTransition)return this._instance._sceneTransition=t,t;console.warn("在前一个场景完成之前,不能开始一个新的场景转换。")},n.registerGlobalManager=function(t){this._instance._globalManagers.push(t),t.enabled=!0},n.unregisterGlobalManager=function(t){this._instance._globalManagers.remove(t),t.enabled=!1},n.getGlobalManager=function(t){for(var e=0;e=0;e--)this._globalManagers[e].enabled&&this._globalManagers[e].update();return this._sceneTransition&&(!this._sceneTransition||this._sceneTransition.loadsNewScene&&!this._sceneTransition.isNewSceneLoaded)||this._scene.update(),this._nextScene?(this.removeChild(this._scene),this._scene.end(),this._scene=this._nextScene,this._nextScene=null,this.onSceneChanged(),this.addChild(this._scene),[4,this._scene.begin()]):[3,2];case 1:n.sent(),n.label=2;case 2:return[4,this.draw()];case 3:return n.sent(),[2]}})})},n.prototype.onAddToStage=function(){n.graphicsDevice=new t.GraphicsDevice,this.addEventListener(egret.Event.RESIZE,this.onGraphicsDeviceReset,this),this.addEventListener(egret.StageOrientationEvent.ORIENTATION_CHANGE,this.onOrientationChanged,this),this.addEventListener(egret.Event.ENTER_FRAME,this.update,this),t.Input.initialize(),this.initialize()},n}(egret.DisplayObjectContainer);t.Core=e}(es||(es={})),function(t){!function(t){t[t.GraphicsDeviceReset=0]="GraphicsDeviceReset",t[t.SceneChanged=1]="SceneChanged",t[t.OrientationChanged=2]="OrientationChanged"}(t.CoreEvents||(t.CoreEvents={}))}(es||(es={})),function(t){var e=function(){function e(n){this.updateInterval=1,this._tag=0,this._enabled=!0,this._updateOrder=0,this.components=new t.ComponentList(this),this.transform=new t.Transform(this),this.name=n,this.id=e._idGenerator++,this.componentBits=new t.BitSet}return Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this._isDestroyed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tag",{get:function(){return this._tag},set:function(t){this.setTag(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"updateOrder",{get:function(){return this._updateOrder},set:function(t){this.setUpdateOrder(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this.transform.parent},set:function(t){this.transform.setParent(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"childCount",{get:function(){return this.transform.childCount},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this.transform.position},set:function(t){this.transform.setPosition(t.x,t.y)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localPosition",{get:function(){return this.transform.localPosition},set:function(t){this.transform.setLocalPosition(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotation",{get:function(){return this.transform.rotation},set:function(t){this.transform.setRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotationDegrees",{get:function(){return this.transform.rotationDegrees},set:function(t){this.transform.setRotationDegrees(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localRotation",{get:function(){return this.transform.localRotation},set:function(t){this.transform.setLocalRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localRotationDegrees",{get:function(){return this.transform.localRotationDegrees},set:function(t){this.transform.setLocalRotationDegrees(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scale",{get:function(){return this.transform.scale},set:function(t){this.transform.setScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localScale",{get:function(){return this.transform.localScale},set:function(t){this.transform.setLocalScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"worldInverseTransform",{get:function(){return this.transform.worldInverseTransform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localToWorldTransform",{get:function(){return this.transform.localToWorldTransform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"worldToLocalTransform",{get:function(){return this.transform.worldToLocalTransform},enumerable:!0,configurable:!0}),e.prototype.onTransformChanged=function(t){this.components.onEntityTransformChanged(t)},e.prototype.setTag=function(t){return this._tag!=t&&(this.scene&&this.scene.entities.removeFromTagList(this),this._tag=t,this.scene&&this.scene.entities.addToTagList(this)),this},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.components.onEntityEnabled():this.components.onEntityDisabled()),this},e.prototype.setUpdateOrder=function(t){if(this._updateOrder!=t)return this._updateOrder=t,this.scene&&(this.scene.entities.markEntityListUnsorted(),this.scene.entities.markTagUnsorted(this.tag)),this},e.prototype.destroy=function(){this._isDestroyed=!0,this.scene.entities.remove(this),this.transform.parent=null;for(var t=this.transform.childCount-1;t>=0;t--){this.transform.getChild(t).entity.destroy()}},e.prototype.detachFromScene=function(){this.scene.entities.remove(this),this.components.deregisterAllComponents();for(var t=0;t=0;t--)this._sceneComponents[t].enabled&&this._sceneComponents[t].update();this.entityProcessors&&this.entityProcessors.update(),this.entities.update(),this.entityProcessors&&this.entityProcessors.lateUpdate(),this.renderableComponents.updateList()},n.prototype.render=function(){if(0!=this._renderers.length)for(var t=0;te.x?-1:1,i=t.Vector2.normalize(t.Vector2.subtract(this.position,e));this.rotation=n*Math.acos(t.Vector2.dot(i,t.Vector2.unitY))},i.prototype.setLocalRotation=function(t){return this._localRotation=t,this._localDirty=this._positionDirty=this._localPositionDirty=this._localRotationDirty=this._localScaleDirty=!0,this.setDirty(e.rotationDirty),this},i.prototype.setLocalRotationDegrees=function(e){return this.setLocalRotation(t.MathHelper.toRadians(e))},i.prototype.setScale=function(e){return this._scale=e,this.parent?this.localScale=t.Vector2.divide(e,this.parent._scale):this.localScale=e,this},i.prototype.setLocalScale=function(t){return this._localScale=t,this._localDirty=this._positionDirty=this._localScaleDirty=!0,this.setDirty(e.scaleDirty),this},i.prototype.roundPosition=function(){this.position=this._position.round()},i.prototype.updateTransform=function(){this.hierarchyDirty!=e.clean&&(this.parent&&this.parent.updateTransform(),this._localDirty&&(this._localPositionDirty&&(this._translationMatrix=t.Matrix2D.create().translate(this._localPosition.x,this._localPosition.y),this._localPositionDirty=!1),this._localRotationDirty&&(this._rotationMatrix=t.Matrix2D.create().rotate(this._localRotation),this._localRotationDirty=!1),this._localScaleDirty&&(this._scaleMatrix=t.Matrix2D.create().scale(this._localScale.x,this._localScale.y),this._localScaleDirty=!1),this._localTransform=this._scaleMatrix.multiply(this._rotationMatrix),this._localTransform=this._localTransform.multiply(this._translationMatrix),this.parent||(this._worldTransform=this._localTransform,this._rotation=this._localRotation,this._scale=this._localScale,this._worldInverseDirty=!0),this._localDirty=!1),this.parent&&(this._worldTransform=this._localTransform.multiply(this.parent._worldTransform),this._rotation=this._localRotation+this.parent._rotation,this._scale=t.Vector2.multiply(this.parent._scale,this._localScale),this._worldInverseDirty=!0),this._worldToLocalDirty=!0,this._positionDirty=!0,this.hierarchyDirty=e.clean)},i.prototype.setDirty=function(e){if(0==(this.hierarchyDirty&e)){switch(this.hierarchyDirty|=e,e){case t.DirtyType.positionDirty:this.entity.onTransformChanged(transform.Component.position);break;case t.DirtyType.rotationDirty:this.entity.onTransformChanged(transform.Component.rotation);break;case t.DirtyType.scaleDirty:this.entity.onTransformChanged(transform.Component.scale)}this._children||(this._children=[]);for(var n=0;nt&&(this._zoom=t),this._maximumZoom=t,this;console.error("maximumZoom must be greater than zero")},r.prototype.onEntityTransformChanged=function(t){this._areMatrixedDirty=!0},r.prototype.zoomIn=function(t){this.zoom+=t},r.prototype.zoomOut=function(t){this.zoom-=t},r.prototype.worldToScreenPoint=function(e){return this.updateMatrixes(),e=t.Vector2.transform(e,this._transformMatrix)},r.prototype.screenToWorldPoint=function(e){return this.updateMatrixes(),e=t.Vector2.transform(e,this._inverseTransformMatrix)},r.prototype.mouseToWorldPoint=function(){return this.screenToWorldPoint(t.Input.touchPosition)},r.prototype.onAddedToEntity=function(){this.follow(this._targetEntity,this._cameraStyle)},r.prototype.update=function(){var e=t.Vector2.multiply(new t.Vector2(this.bounds.width,this.bounds.height),new t.Vector2(.5));this._worldSpaceDeadZone.x=this.position.x-e.x*t.Core.scene.scaleX+this.deadzone.x+this.focusOffset.x,this._worldSpaceDeadZone.y=this.position.y-e.y*t.Core.scene.scaleY+this.deadzone.y+this.focusOffset.y,this._worldSpaceDeadZone.width=this.deadzone.width,this._worldSpaceDeadZone.height=this.deadzone.height,this._targetEntity&&this.updateFollow(),this.position=t.Vector2.lerp(this.position,t.Vector2.add(this.position,this._desiredPositionDelta),this.followLerp),this.entity.transform.roundPosition(),this.mapLockEnabled&&(this.position=this.clampToMapSize(this.position),this.entity.transform.roundPosition())},r.prototype.clampToMapSize=function(e){var n=t.Vector2.multiply(new t.Vector2(this.bounds.width,this.bounds.height),new t.Vector2(.5)).add(new t.Vector2(this.mapSize.x,this.mapSize.y)),i=new t.Vector2(this.mapSize.width-n.x,this.mapSize.height-n.y);return t.Vector2.clamp(e,n,i)},r.prototype.updateFollow=function(){if(this._desiredPositionDelta.x=this._desiredPositionDelta.y=0,this._cameraStyle==e.lockOn){var n=this._targetEntity.transform.position.x,i=this._targetEntity.transform.position.y;this._worldSpaceDeadZone.x>n?this._desiredPositionDelta.x=n-this._worldSpaceDeadZone.x:this._worldSpaceDeadZone.xi&&(this._desiredPositionDelta.y=i-this._worldSpaceDeadZone.y)}else{if(!this._targetCollider&&(this._targetCollider=this._targetEntity.getComponent(t.Collider),!this._targetCollider))return;var r=this._targetEntity.getComponent(t.Collider).bounds;this._worldSpaceDeadZone.containsRect(r)||(this._worldSpaceDeadZone.left>r.left?this._desiredPositionDelta.x=r.left-this._worldSpaceDeadZone.left:this._worldSpaceDeadZone.rightr.top&&(this._desiredPositionDelta.y=r.top-this._worldSpaceDeadZone.top))}},r.prototype.follow=function(n,i){switch(void 0===i&&(i=e.cameraWindow),this._targetEntity=n,this._cameraStyle=i,this._cameraStyle){case e.cameraWindow:var r=this.bounds.width/6,o=this.bounds.height/3;this.deadzone=new t.Rectangle((this.bounds.width-r)/2,(this.bounds.height-o)/2,r,o);break;case e.lockOn:this.deadzone=new t.Rectangle(this.bounds.width/2,this.bounds.height/2,10,10)}},r.prototype.setCenteredDeadzone=function(e,n){this.deadzone=new t.Rectangle((this.bounds.width-e)/2,(this.bounds.height-n)/2,e,n)},r.prototype.updateMatrixes=function(){var e;this._areMatrixedDirty&&(this._transformMatrix=t.Matrix2D.create().translate(-this.entity.transform.position.x,-this.entity.transform.position.y),1!=this._zoom&&(e=t.Matrix2D.create().scale(this._zoom,this._zoom),this._transformMatrix=this._transformMatrix.multiply(e)),0!=this.entity.transform.rotation&&(e=t.Matrix2D.create().rotate(this.entity.transform.rotation),this._transformMatrix=this._transformMatrix.multiply(e)),e=t.Matrix2D.create().translate(this._origin.x,this._origin.y),this._transformMatrix=this._transformMatrix.multiply(e),this._inverseTransformMatrix=this._transformMatrix.invert(),this._areBoundsDirty=!0,this._areMatrixedDirty=!1)},r}(t.Component);t.Camera=i}(es||(es={})),function(t){var e=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n._shakeDirection=t.Vector2.zero,n._shakeOffset=t.Vector2.zero,n._shakeIntensity=0,n._shakeDegredation=.95,n}return __extends(n,e),n.prototype.shake=function(e,n,i){void 0===e&&(e=15),void 0===n&&(n=.9),void 0===i&&(i=t.Vector2.zero),this.enabled=!0,this._shakeIntensity=1)&&(n=.95),this._shakeDegredation=n)},n.prototype.update=function(){Math.abs(this._shakeIntensity)>0&&(this._shakeOffset=this._shakeDirection,0!=this._shakeOffset.x||0!=this._shakeOffset.y?this._shakeOffset.normalize():(this._shakeOffset.x=this._shakeOffset.x+Math.random()-.5,this._shakeOffset.y=this._shakeOffset.y+Math.random()-.5),this._shakeOffset.multiply(new t.Vector2(this._shakeIntensity)),this._shakeIntensity*=-this._shakeDegredation,Math.abs(this._shakeIntensity)<=.01&&(this._shakeIntensity=0,this.enabled=!1)),this.entity.scene.camera.position.add(this._shakeOffset)},n}(t.Component);t.CameraShake=e}(es||(es={})),function(t){var e=function(){function t(t){this._type=t,this._cache=[]}return t.prototype.obtain=function(){try{return this._cache.length>0?this._cache.shift():new this._type}catch(t){throw new Error(this._type+t)}},t.prototype.free=function(t){t.reset(),this._cache.push(t)},t}();t.ComponentPool=e}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.compare=function(t,e){return t.updateOrder-e.updateOrder},t}();t.IUpdatableComparer=e}(es||(es={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(t.Component);t.PooledComponent=e}(es||(es={})),function(t){var e=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n.displayObject=new egret.DisplayObject,n.color=0,n._areBoundsDirty=!0,n._localOffset=t.Vector2.zero,n._renderLayer=0,n._bounds=new t.Rectangle,n}return __extends(n,e),Object.defineProperty(n.prototype,"width",{get:function(){return this.bounds.width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return this.bounds.height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"localOffset",{get:function(){return this._localOffset},set:function(t){this.setLocalOffset(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"renderLayer",{get:function(){return this._renderLayer},set:function(t){this.setRenderLayer(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"bounds",{get:function(){return this._areBoundsDirty&&(this._bounds.calculateBounds(this.entity.transform.position,this._localOffset,t.Vector2.zero,this.entity.transform.scale,this.entity.transform.rotation,this.width,this.height),this._areBoundsDirty=!1),this._bounds},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isVisible",{get:function(){return this._isVisible},set:function(t){this._isVisible!=t&&(this._isVisible=t,this._isVisible?this.onBecameVisible():this.onBecameInvisible())},enumerable:!0,configurable:!0}),n.prototype.onEntityTransformChanged=function(t){this._areBoundsDirty=!0},n.prototype.isVisibleFromCamera=function(t){return this.isVisible=t.bounds.intersects(this.bounds),this.isVisible},n.prototype.setRenderLayer=function(t){if(t!=this._renderLayer){var e=this._renderLayer;this._renderLayer=t,this.entity&&this.entity.scene&&this.entity.scene.renderableComponents.updateRenderableRenderLayer(this,e,this._renderLayer)}return this},n.prototype.setColor=function(t){return this.color=t,this},n.prototype.setLocalOffset=function(t){return this._localOffset!=t&&(this._localOffset=t),this},n.prototype.sync=function(t){this.displayObject.x=this.entity.position.x+this.localOffset.x-t.position.x+t.origin.x,this.displayObject.y=this.entity.position.y+this.localOffset.y-t.position.y+t.origin.y,this.displayObject.scaleX=this.entity.scale.x,this.displayObject.scaleY=this.entity.scale.y,this.displayObject.rotation=this.entity.rotation},n.prototype.toString=function(){return"[RenderableComponent] renderLayer: "+this.renderLayer},n.prototype.onBecameVisible=function(){this.displayObject.visible=this.isVisible},n.prototype.onBecameInvisible=function(){this.displayObject.visible=this.isVisible},n}(t.Component);t.RenderableComponent=e}(es||(es={})),function(t){var e=function(){function e(){this.updateOrder=0,this._enabled=!0}return Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),e.prototype.onEnabled=function(){},e.prototype.onDisabled=function(){},e.prototype.onRemovedFromScene=function(){},e.prototype.update=function(){},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled),this},e.prototype.setUpdateOrder=function(e){return this.updateOrder!=e&&(this.updateOrder=e,t.Core.scene._sceneComponents.sort(this.compareTo)),this},e.prototype.compareTo=function(t){return this.updateOrder-t.updateOrder},e}();t.SceneComponent=e}(es||(es={})),function(t){var e=egret.Bitmap,n=function(n){function i(e){void 0===e&&(e=null);var i=n.call(this)||this;return e instanceof t.Sprite?i.setSprite(e):e instanceof egret.Texture&&i.setSprite(new t.Sprite(e)),i}return __extends(i,n),Object.defineProperty(i.prototype,"bounds",{get:function(){return this._areBoundsDirty&&this._sprite&&(this._bounds.calculateBounds(this.entity.transform.position,this._localOffset,this._origin,this.entity.transform.scale,this.entity.transform.rotation,this._sprite.sourceRect.width,this._sprite.sourceRect.height),this._areBoundsDirty=!1),this._bounds},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"originNormalized",{get:function(){return new t.Vector2(this._origin.x/this.width*this.entity.transform.scale.x,this._origin.y/this.height*this.entity.transform.scale.y)},set:function(e){this.setOrigin(new t.Vector2(e.x*this.width/this.entity.transform.scale.x,e.y*this.height/this.entity.transform.scale.y))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"origin",{get:function(){return this._origin},set:function(t){this.setOrigin(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"sprite",{get:function(){return this._sprite},set:function(t){this.setSprite(t)},enumerable:!0,configurable:!0}),i.prototype.setSprite=function(t){return this._sprite=t,this._sprite&&(this._origin=this._sprite.origin,this.displayObject.anchorOffsetX=this._origin.x,this.displayObject.anchorOffsetY=this._origin.y),this.displayObject=new e(t.texture2D),this},i.prototype.setOrigin=function(t){return this._origin!=t&&(this._origin=t,this.displayObject.anchorOffsetX=this._origin.x,this.displayObject.anchorOffsetY=this._origin.y,this._areBoundsDirty=!0),this},i.prototype.setOriginNormalized=function(e){return this.setOrigin(new t.Vector2(e.x*this.width/this.entity.transform.scale.x,e.y*this.height/this.entity.transform.scale.y)),this},i.prototype.render=function(t){this.sync(t),this.displayObject.x=this.entity.position.x+this.localOffset.x-t.position.x+t.origin.x,this.displayObject.y=this.entity.position.y+this.localOffset.y-t.position.y+t.origin.y},i}(t.RenderableComponent);t.SpriteRenderer=n}(es||(es={})),function(t){var e=egret.Bitmap,n=egret.RenderTexture,i=function(i){function r(e){var n=i.call(this,e)||this;return n._textureScale=t.Vector2.one,n._inverseTexScale=t.Vector2.one,n._gapX=0,n._gapY=0,n._sourceRect=e.sourceRect,n.displayObject.$fillMode=egret.BitmapFillMode.REPEAT,n}return __extends(r,i),Object.defineProperty(r.prototype,"bounds",{get:function(){return this._areBoundsDirty&&this._sprite&&(this._bounds.calculateBounds(this.entity.transform.position,this._localOffset,this._origin,this.entity.transform.scale,this.entity.transform.rotation,this.width,this.height),this._areBoundsDirty=!1),this._bounds},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scrollX",{get:function(){return this._sourceRect.x},set:function(t){this._sourceRect.x=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scrollY",{get:function(){return this._sourceRect.y},set:function(t){this._sourceRect.y=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"textureScale",{get:function(){return this._textureScale},set:function(e){this._textureScale=e,this._inverseTexScale=new t.Vector2(1/this._textureScale.x,1/this._textureScale.y),this._sourceRect.width=this._sprite.sourceRect.width*this._inverseTexScale.x,this._sourceRect.height=this._sprite.sourceRect.height*this._inverseTexScale.y},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"width",{get:function(){return this._sourceRect.width},set:function(t){this._areBoundsDirty=!0,this._sourceRect.width=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"height",{get:function(){return this._sourceRect.height},set:function(t){this._areBoundsDirty=!0,this._sourceRect.height=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"gapXY",{get:function(){return new t.Vector2(this._gapX,this._gapY)},set:function(t){this._gapX=t.x,this._gapY=t.y;var i=new n,r=this.sprite.sourceRect;r.x=0,r.y=0,r.width+=this._gapX,r.height+=this._gapY,i.drawToTexture(this.displayObject,r),this.displayObject?this.displayObject.texture=i:this.displayObject=new e(i)},enumerable:!0,configurable:!0}),r.prototype.setGapXY=function(t){return this.gapXY=t,this},r.prototype.render=function(t){i.prototype.render.call(this,t);var e=this.displayObject;e.width=this.width,e.height=this.height,e.scrollRect=this._sourceRect},r}(t.SpriteRenderer);t.TiledSpriteRenderer=i}(es||(es={})),function(t){var e=function(e){function n(t){var n=e.call(this,t)||this;return n.scrollSpeedX=15,n.scroolSpeedY=0,n._scrollX=0,n._scrollY=0,n._scrollWidth=0,n._scrollHeight=0,n._scrollWidth=n.width,n._scrollHeight=n.height,n}return __extends(n,e),Object.defineProperty(n.prototype,"textureScale",{get:function(){return this._textureScale},set:function(e){this._textureScale=e,this._inverseTexScale=new t.Vector2(1/this._textureScale.x,1/this._textureScale.y)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scrollWidth",{get:function(){return this._scrollWidth},set:function(t){this._scrollWidth=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scrollHeight",{get:function(){return this._scrollHeight},set:function(t){this._scrollHeight=t},enumerable:!0,configurable:!0}),n.prototype.update=function(){this.sprite&&(this._scrollX+=this.scrollSpeedX*t.Time.deltaTime,this._scrollY+=this.scroolSpeedY*t.Time.deltaTime,this._sourceRect.x=this._scrollX,this._sourceRect.y=this._scrollY,this._sourceRect.width=this._scrollWidth+Math.abs(this._scrollX),this._sourceRect.height=this._scrollHeight+Math.abs(this._scrollY))},n}(t.TiledSpriteRenderer);t.ScrollingSpriteRenderer=e}(es||(es={})),function(t){var e=function(){return function(e,n,i){void 0===n&&(n=new t.Rectangle(0,0,e.textureWidth,e.textureHeight)),void 0===i&&(i=n.getHalfSize()),this.uvs=new t.Rectangle,this.texture2D=e,this.sourceRect=n,this.center=new t.Vector2(.5*n.width,.5*n.height),this.origin=i;var r=1/e.textureWidth,o=1/e.textureHeight;this.uvs.x=n.x*r,this.uvs.y=n.y*o,this.uvs.width=n.width*r,this.uvs.height=n.height*o}}();t.Sprite=e}(es||(es={})),function(t){var e=function(){return function(t,e){this.sprites=t,this.frameRate=e}}();t.SpriteAnimation=e}(es||(es={})),function(t){var e,n;!function(t){t[t.loop=0]="loop",t[t.once=1]="once",t[t.clampForever=2]="clampForever",t[t.pingPong=3]="pingPong",t[t.pingPongOnce=4]="pingPongOnce"}(e=t.LoopMode||(t.LoopMode={})),function(t){t[t.none=0]="none",t[t.running=1]="running",t[t.paused=2]="paused",t[t.completed=3]="completed"}(n=t.State||(t.State={}));var i=function(i){function r(t){var e=i.call(this,t)||this;return e.speed=1,e.animationState=n.none,e._elapsedTime=0,e._animations=new Map,e}return __extends(r,i),Object.defineProperty(r.prototype,"isRunning",{get:function(){return this.animationState==n.running},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"animations",{get:function(){return this._animations},enumerable:!0,configurable:!0}),r.prototype.update=function(){if(this.animationState==n.running&&this.currentAnimation){var i=this.currentAnimation,r=1/(i.frameRate*this.speed),o=r*i.sprites.length;this._elapsedTime+=t.Time.deltaTime;var s=Math.abs(this._elapsedTime);if(this._loopMode==e.once&&s>o||this._loopMode==e.pingPongOnce&&s>2*o)return this.animationState=n.completed,this._elapsedTime=0,this.currentFrame=0,void(this.sprite=i.sprites[this.currentFrame]);var a=Math.floor(s/r),c=i.sprites.length;if(c>2&&(this._loopMode==e.pingPong||this._loopMode==e.pingPongOnce)){var h=c-1;this.currentFrame=h-Math.abs(h-a%(2*h))}else this.currentFrame=a%c;this.sprite=i.sprites[this.currentFrame]}},r.prototype.addAnimation=function(t,e){return!this.sprite&&e.sprites.length>0&&this.setSprite(e.sprites[0]),this._animations[t]=e,this},r.prototype.play=function(t,i){void 0===i&&(i=null),this.currentAnimation=this._animations[t],this.currentAnimationName=t,this.currentFrame=0,this.animationState=n.running,this.sprite=this.currentAnimation.sprites[0],this._elapsedTime=0,this._loopMode=i||e.loop},r.prototype.isAnimationActive=function(t){return this.currentAnimation&&this.currentAnimationName==t},r.prototype.pause=function(){this.animationState=n.paused},r.prototype.unPause=function(){this.animationState=n.running},r.prototype.stop=function(){this.currentAnimation=null,this.currentAnimationName=null,this.currentFrame=0,this.animationState=n.none},r}(t.SpriteRenderer);t.SpriteAnimator=i}(es||(es={})),function(t){var e=function(){function t(){}return Object.defineProperty(t.prototype,"hasCollision",{get:function(){return this.below||this.right||this.left||this.above},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this.becameGroundedThisFrame=this.isGroundedOnOnewayPlatform=this.right=this.left=this.above=this.below=!1,this.slopAngle=0},t.prototype.toString=function(){return"[CollisionState] r: "+this.right+", l: "+this.left+", a: "+this.above+", b: "+this.below+", angle: "+this.slopAngle+", wasGroundedLastFrame: "+this.wasGroundedLastFrame+", becameGroundedThisFrame: "+this.becameGroundedThisFrame},t}();t.CollisionState=e;var n=function(e){function n(){var t=e.call(this)||this;return t.colliderHorizontalInset=2,t.colliderVerticalInset=6,t}return __extends(n,e),n.prototype.testCollisions=function(e,n,i){this._boxColliderBounds=n,i.wasGroundedLastFrame=i.below,i.reset();var r=e.x;e.y;if(0!=r){var o=r>0?t.Edge.right:t.Edge.left,s=this.collisionRectForSide(o,r);this.testMapCollision(s,o,i,0)?(e.x=0-t.RectangleExt.getSide(n,o),i.left=o==t.Edge.left,i.right=o==t.Edge.right,i._movementRemainderX.reset()):(i.left=!1,i.right=!1)}},n.prototype.testMapCollision=function(e,n,i,r){var o=t.EdgeExt.oppositeEdge(n);t.EdgeExt.isVertical(o)?e.center.x:e.center.y,t.RectangleExt.getSide(e,n),t.EdgeExt.isVertical(o)},n.prototype.collisionRectForSide=function(e,n){var i;return i=t.EdgeExt.isHorizontal(e)?t.RectangleExt.getRectEdgePortion(this._boxColliderBounds,e):t.RectangleExt.getHalfRect(this._boxColliderBounds,e),t.EdgeExt.isVertical(e)?t.RectangleExt.contract(i,this.colliderHorizontalInset,0):t.RectangleExt.contract(i,0,this.colliderVerticalInset),t.RectangleExt.expandSide(i,e,n),i},n}(t.Component);t.TiledMapMover=n}(es||(es={})),function(t){var e=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.onAddedToEntity=function(){this._triggerHelper=new t.ColliderTriggerHelper(this.entity)},n.prototype.calculateMovement=function(e,n){if(!this.entity.getComponent(t.Collider)||!this._triggerHelper)return!1;for(var i=this.entity.getComponents(t.Collider),r=0;r>6;0!=(e&t.LONG_MASK)&&n++,this._bits=new Array(n)}return t.prototype.and=function(t){for(var e,n=Math.min(this._bits.length,t._bits.length),i=0;i=0;)this._bits[e]&=~t._bits[e]},t.prototype.cardinality=function(){for(var t=0,e=this._bits.length-1;e>=0;e--){var n=this._bits[e];if(0!=n)if(-1!=n){var i=((n=((n=(n>>1&0x5555555555555400)+(0x5555555555555400&n))>>2&0x3333333333333400)+(0x3333333333333400&n))>>32)+n;t+=((i=((i=(i>>4&252645135)+(252645135&i))>>8&16711935)+(16711935&i))>>16&65535)+(65535&i)}else t+=64}return t},t.prototype.clear=function(t){if(null!=t){var e=t>>6;this.ensure(e),this._bits[e]&=~(1<>6;return!(e>=this._bits.length)&&0!=(this._bits[e]&1<=0;)if(0!=(this._bits[e]&t._bits[e]))return!0;return!1},t.prototype.isEmpty=function(){for(var t=this._bits.length-1;t>=0;t--)if(this._bits[t])return!1;return!0},t.prototype.nextSetBit=function(t){for(var e=t>>6,n=1<>6;this.ensure(n),this._bits[n]|=1<=this._bits.length){var e=new Number[t+1];e=this._bits.copyWithin(0,0,this._bits.length),this._bits=e}},t.LONG_MASK=63,t}();t.BitSet=e}(es||(es={})),function(t){var e=function(){function e(t){this._components=[],this._componentsToAdd=[],this._componentsToRemove=[],this._tempBufferList=[],this._entity=t}return Object.defineProperty(e.prototype,"count",{get:function(){return this._components.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buffer",{get:function(){return this._components},enumerable:!0,configurable:!0}),e.prototype.markEntityListUnsorted=function(){this._isComponentListUnsorted=!0},e.prototype.add=function(t){this._componentsToAdd.push(t)},e.prototype.remove=function(t){this._componentsToRemove.contains(t)&&console.warn("You are trying to remove a Component ("+t+") that you already removed"),this._componentsToAdd.contains(t)?this._componentsToAdd.remove(t):this._componentsToRemove.push(t)},e.prototype.removeAllComponents=function(){for(var t=0;t0){for(var n=0;n0){n=0;for(var i=this._componentsToAdd.length;n0){var e=this._entitiesToRemove;this._entitiesToRemove=this._tempEntityList,this._tempEntityList=e,this._tempEntityList.forEach(function(e){t.removeFromTagList(e),t._entities.remove(e),e.onRemovedFromScene(),e.scene=null,t.scene.entityProcessors.onEntityRemoved(e)}),this._tempEntityList.length=0}if(this._entitiesToAdded.length>0){e=this._entitiesToAdded;this._entitiesToAdded=this._tempEntityList,this._tempEntityList=e,this._tempEntityList.forEach(function(e){t._entities.contains(e)||(t._entities.push(e),e.scene=t.scene,t.addToTagList(e),t.scene.entityProcessors.onEntityAdded(e))}),this._tempEntityList.forEach(function(t){return t.onAddedToScene()}),this._tempEntityList.length=0,this._isEntityListUnsorted=!0}this._isEntityListUnsorted&&(this._entities.sort(),this._isEntityListUnsorted=!1),this._unsortedTags.length>0&&(this._unsortedTags.forEach(function(e){t._entityDict.get(e).sort()}),this._unsortedTags.length=0)},e.prototype.findEntity=function(t){for(var e=0;e=0;e=this.allSet.nextSetBit(e+1))if(!t.componentBits.get(e))return!1;return!(!this.exclusionSet.isEmpty()&&this.exclusionSet.intersects(t.componentBits))&&!(!this.oneSet.isEmpty()&&!this.oneSet.intersects(t.componentBits))},e.prototype.all=function(){for(var e=this,n=[],i=0;i0){for(var t=0,n=this._unsortedRenderLayers.length;t=e)return t;var i=!1;"-"==t.substr(0,1)&&(i=!0,t=t.substr(1));for(var r=e-n,o=0;o1?this.reverse(t.substring(1))+t.substring(0,1):t},t.cutOff=function(t,e,n,i){void 0===i&&(i=!0),e=Math.floor(e),n=Math.floor(n);var r=t.length;e>r&&(e=r);var o,s=e,a=e+n;return i?o=t.substring(0,s)+t.substr(a,r):(a=(s=r-1-e-n)+n,o=t.substring(0,s+1)+t.substr(a+1,r)),o},t.strReplace=function(t,e){for(var n=0,i=e.length;n",">",'"',""","'","'","®","®","©","©","™","™"],t}();!function(t){var e=function(){function e(){}return e.convertImageToCanvas=function(e,n){this.sharedCanvas||(this.sharedCanvas=egret.sys.createCanvas(),this.sharedContext=this.sharedCanvas.getContext("2d"));var i=e.$getTextureWidth(),r=e.$getTextureHeight();n||((n=egret.$TempRectangle).x=0,n.y=0,n.width=i,n.height=r),n.x=Math.min(n.x,i-1),n.y=Math.min(n.y,r-1),n.width=Math.min(n.width,i-n.x),n.height=Math.min(n.height,r-n.y);var o=Math.floor(n.width),s=Math.floor(n.height),a=this.sharedCanvas;if(a.style.width=o+"px",a.style.height=s+"px",this.sharedCanvas.width=o,this.sharedCanvas.height=s,"webgl"==egret.Capabilities.renderMode){var c=void 0;e.$renderBuffer?c=e:(egret.sys.systemRenderer.renderClear&&egret.sys.systemRenderer.renderClear(),(c=new egret.RenderTexture).drawToTexture(new egret.Bitmap(e)));for(var h=c.$renderBuffer.getPixels(n.x,n.y,o,s),u=0,l=0,p=0;p=0?"png":"jpg"});return wx.getFileSystemManager().saveFile({tempFilePath:o,filePath:wx.env.USER_DATA_PATH+"/"+n,success:function(t){}}),o},e.getPixel32=function(t,e,n){return egret.$warn(1041,"getPixel32","getPixels"),t.getPixels(e,n)},e.getPixels=function(t,e,n,i,r){if(void 0===i&&(i=1),void 0===r&&(r=1),"webgl"==egret.Capabilities.renderMode){var o=void 0;return t.$renderBuffer?o=t:(o=new egret.RenderTexture).drawToTexture(new egret.Bitmap(t)),o.$renderBuffer.getPixels(e,n,i,r)}try{this.convertImageToCanvas(t);return this.sharedContext.getImageData(e,n,i,r).data}catch(t){egret.$error(1039)}},e}();t.TextureUtils=e}(es||(es={})),function(t){var e=function(){function t(){}return t.update=function(t){var e=(t-this._lastTime)/1e3;this.deltaTime=e*this.timeScale,this.unscaledDeltaTime=e,this._timeSinceSceneLoad+=e,this.frameCount++,this._lastTime=t},t.sceneChanged=function(){this._timeSinceSceneLoad=0},t.checkEvery=function(t){return this._timeSinceSceneLoad/t>(this._timeSinceSceneLoad-this.deltaTime)/t},t.deltaTime=0,t.timeScale=1,t.frameCount=0,t._lastTime=0,t}();t.Time=e}(es||(es={}));var TimeUtils=function(){function t(){}return t.monthId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getFullYear(),n=t.getMonth()+1;return parseInt(e+(n<10?"0":"")+n)},t.dateId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getMonth()+1,n=e<10?"0":"",i=t.getDate(),r=i<10?"0":"";return parseInt(t.getFullYear()+n+e+r+i)},t.weekId=function(t,e){void 0===t&&(t=null),void 0===e&&(e=!0),t=t||new Date;var n=new Date;n.setTime(t.getTime()),n.setDate(1),n.setMonth(0);var i=n.getFullYear(),r=n.getDay();0==r&&(r=7);var o=!1;r<=4?(o=r>1,n.setDate(n.getDate()-(r-1))):n.setDate(n.getDate()+7-r+1);var s=this.diffDay(t,n,!1);if(s<0)return n.setDate(1),n.setMonth(0),n.setDate(n.getDate()-1),this.weekId(n,!1);var a=s/7,c=Math.floor(a)+1;if(53==c){n.setTime(t.getTime()),n.setDate(n.getDate()-1);var h=n.getDay();if(0==h&&(h=7),e&&(!o||h<4))return n.setFullYear(n.getFullYear()+1),n.setDate(1),n.setMonth(0),this.weekId(n,!1)}return parseInt(i+"00"+(c>9?"":"0")+c)},t.diffDay=function(t,e,n){void 0===n&&(n=!1);var i=(t.getTime()-e.getTime())/864e5;return n?Math.ceil(i):Math.floor(i)},t.getFirstDayOfWeek=function(t){var e=(t=t||new Date).getDay()||7;return new Date(t.getFullYear(),t.getMonth(),t.getDate()+1-e,0,0,0,0)},t.getFirstOfDay=function(t){return(t=t||new Date).setHours(0,0,0,0),t},t.getNextFirstOfDay=function(t){return new Date(this.getFirstOfDay(t).getTime()+864e5)},t.formatDate=function(t){var e=t.getFullYear(),n=t.getMonth()+1;n=n<10?"0"+n:n;var i=t.getDate();return e+"-"+n+"-"+(i=i<10?"0"+i:i)},t.formatDateTime=function(t){var e=t.getFullYear(),n=t.getMonth()+1;n=n<10?"0"+n:n;var i=t.getDate();i=i<10?"0"+i:i;var r=t.getHours(),o=t.getMinutes();o=o<10?"0"+o:o;var s=t.getSeconds();return e+"-"+n+"-"+i+" "+r+":"+o+":"+(s=s<10?"0"+s:s)},t.parseDate=function(t){var e=Date.parse(t);return isNaN(e)?new Date:new Date(Date.parse(t.replace(/-/g,"/")))},t.secondToTime=function(t,e,n){void 0===t&&(t=0),void 0===e&&(e=":"),void 0===n&&(n=!0);var i=Math.floor(t/3600),r=Math.floor(t%3600/60),o=Math.floor(t%3600%60),s=i.toString(),a=r.toString(),c=o.toString();return i<10&&(s="0"+s),r<10&&(a="0"+a),o<10&&(c="0"+c),n?s+e+a+e+c:a+e+c},t.timeToMillisecond=function(t,e){void 0===e&&(e=":");for(var n=t.split(e),i=0,r=n.length,o=0;o-1?this.os="iOS":i.indexOf("android")>-1&&(this.os="Android");var r=n.language;r=r.indexOf("zh")>-1?"zh-CN":"en-US",this.language=r}},e}(egret.Capabilities);t.GraphicsCapabilities=e}(es||(es={})),function(t){var e=function(){function e(){this.setup(),this.graphicsCapabilities=new t.GraphicsCapabilities,this.graphicsCapabilities.initialize(this)}return Object.defineProperty(e.prototype,"viewport",{get:function(){return this._viewport},enumerable:!0,configurable:!0}),e.prototype.setup=function(){this._viewport=new t.Viewport(0,0,t.Core._instance.stage.stageWidth,t.Core._instance.stage.stageHeight)},e}();t.GraphicsDevice=e}(es||(es={})),function(t){var e=function(){function e(t,e,n,i){this._x=t,this._y=e,this._width=n,this._height=i,this._minDepth=0,this._maxDepth=1}return Object.defineProperty(e.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"aspectRatio",{get:function(){return 0!=this._height&&0!=this._width?this._width/this._height:0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bounds",{get:function(){return new t.Rectangle(this._x,this._y,this._width,this._height)},set:function(t){this._x=t.x,this._y=t.y,this._width=t.width,this._height=t.height},enumerable:!0,configurable:!0}),e}();t.Viewport=e}(es||(es={})),function(t){var e=function(e){function n(){return e.call(this,t.PostProcessor.default_vert,n.blur_frag,{screenWidth:t.Core.graphicsDevice.viewport.width,screenHeight:t.Core.graphicsDevice.viewport.height})||this}return __extends(n,e),n.blur_frag="precision mediump float;\nuniform sampler2D uSampler;\nuniform float screenWidth;\nuniform float screenHeight;\nfloat normpdf(in float x, in float sigma)\n{\nreturn 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;\n}\nvoid main()\n{\nvec3 c = texture2D(uSampler, gl_FragCoord.xy / vec2(screenWidth, screenHeight).xy).rgb;\nconst int mSize = 11;\nconst int kSize = (mSize - 1)/2;\nfloat kernel[mSize];\nvec3 final_colour = vec3(0.0);\nfloat sigma = 7.0;\nfloat z = 0.0;\nfor (int j = 0; j <= kSize; ++j)\n{\nkernel[kSize+j] = kernel[kSize-j] = normpdf(float(j),sigma);\n}\nfor (int j = 0; j < mSize; ++j)\n{\nz += kernel[j];\n}\nfor (int i = -kSize; i <= kSize; ++i)\n{\nfor (int j = -kSize; j <= kSize; ++j)\n{\nfinal_colour += kernel[kSize+j]*kernel[kSize+i]*texture2D(uSampler, (gl_FragCoord.xy+vec2(float(i),float(j))) / vec2(screenWidth, screenHeight).xy).rgb;\n}\n}\ngl_FragColor = vec4(final_colour/(z*z), 1.0);\n}",n}(egret.CustomFilter);t.GaussianBlurEffect=e}(es||(es={})),function(t){var e=function(t){function e(){return t.call(this,e.vertSrc,e.fragmentSrc)||this}return __extends(e,t),e.vertSrc="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nuniform vec2 projectionVector;\nvarying vec2 vTextureCoord;\nconst vec2 center = vec2(-1.0, 1.0);\nvoid main(void) {\n gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",e.fragmentSrc="precision lowp float;\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n#define SAMPLE_COUNT 15\nuniform vec2 _sampleOffsets[SAMPLE_COUNT];\nuniform float _sampleWeights[SAMPLE_COUNT];\nvoid main(void) {\nvec4 c = vec4(0, 0, 0, 0);\nfor( int i = 0; i < SAMPLE_COUNT; i++ )\n c += texture2D( uSampler, vTextureCoord + _sampleOffsets[i] ) * _sampleWeights[i];\ngl_FragColor = c;\n}",e}(egret.CustomFilter);t.PolygonLightEffect=e}(es||(es={})),function(t){var e=function(){function e(t){void 0===t&&(t=null),this.enabled=!0,this.effect=t}return e.prototype.onAddedToScene=function(e){this.scene=e,this.shape=new egret.Shape,this.shape.graphics.beginFill(16777215,1),this.shape.graphics.drawRect(0,0,t.Core.graphicsDevice.viewport.width,t.Core.graphicsDevice.viewport.height),this.shape.graphics.endFill(),e.addChild(this.shape)},e.prototype.process=function(){this.drawFullscreenQuad()},e.prototype.onSceneBackBufferSizeChanged=function(t,e){},e.prototype.unload=function(){this.effect&&(this.effect=null),this.scene.removeChild(this.shape),this.scene=null},e.prototype.drawFullscreenQuad=function(){this.scene.filters=[this.effect]},e.default_vert="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec2 aColor;\nuniform vec2 projectionVector;\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nconst vec2 center = vec2(-1.0, 1.0);\nvoid main(void) {\ngl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\nvTextureCoord = aTextureCoord;\nvColor = vec4(aColor.x, aColor.x, aColor.x, aColor.x);\n}",e}();t.PostProcessor=e}(es||(es={})),function(t){var e=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.onAddedToScene=function(n){e.prototype.onAddedToScene.call(this,n),this.effect=new t.GaussianBlurEffect},n}(t.PostProcessor);t.GaussianBlurPostProcessor=e}(es||(es={})),function(t){var e=function(){function t(t,e){void 0===e&&(e=null),this.renderOrder=0,this.camera=e,this.renderOrder=t}return t.prototype.onAddedToScene=function(t){},t.prototype.unload=function(){},t.prototype.onSceneBackBufferSizeChanged=function(t,e){},t.prototype.compareTo=function(t){return this.renderOrder-t.renderOrder},t.prototype.beginRender=function(t){},t.prototype.renderAfterStateCheck=function(t,e){t.render(e)},t}();t.Renderer=e}(es||(es={})),function(t){var e=function(t){function e(){return t.call(this,0,null)||this}return __extends(e,t),e.prototype.render=function(t){var e=this.camera?this.camera:t.camera;this.beginRender(e);for(var n=0;nn?n:t},e.pointOnCirlce=function(n,i,r){var o=e.toRadians(r);return new t.Vector2(Math.cos(o)*o+n.x,Math.sin(o)*o+n.y)},e.isEven=function(t){return t%2==0},e.clamp01=function(t){return t<0?0:t>1?1:t},e.angleBetweenVectors=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)},e.incrementWithWrap=function(t,e){return++t==e?0:t},e.Epsilon=1e-5,e.Rad2Deg=57.29578,e.Deg2Rad=.0174532924,e}();t.MathHelper=e}(es||(es={})),function(t){t.matrixPool=[];var e=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),Object.defineProperty(n.prototype,"m11",{get:function(){return this.a},set:function(t){this.a=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"m12",{get:function(){return this.b},set:function(t){this.b=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"m21",{get:function(){return this.c},set:function(t){this.c=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"m22",{get:function(){return this.d},set:function(t){this.d=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"m31",{get:function(){return this.tx},set:function(t){this.tx=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"m32",{get:function(){return this.ty},set:function(t){this.ty=t},enumerable:!0,configurable:!0}),n.create=function(){var e=t.matrixPool.pop();return e||(e=new n),e},n.prototype.identity=function(){return this.a=this.d=1,this.b=this.c=this.tx=this.ty=0,this},n.prototype.translate=function(t,e){return this.tx+=t,this.ty+=e,this},n.prototype.scale=function(t,e){return 1!==t&&(this.a*=t,this.c*=t,this.tx*=t),1!==e&&(this.b*=e,this.d*=e,this.ty*=e),this},n.prototype.rotate=function(t){if(0!==(t=+t)){t/=DEG_TO_RAD;var e=Math.cos(t),n=Math.sin(t),i=this.a,r=this.b,o=this.c,s=this.d,a=this.tx,c=this.ty;this.a=i*e-r*n,this.b=i*n+r*e,this.c=o*e-s*n,this.d=o*n+s*e,this.tx=a*e-c*n,this.ty=a*n+c*e}return this},n.prototype.invert=function(){return this.$invertInto(this),this},n.prototype.add=function(t){return this.m11+=t.m11,this.m12+=t.m12,this.m21+=t.m21,this.m22+=t.m22,this.m31+=t.m31,this.m32+=t.m32,this},n.prototype.substract=function(t){return this.m11-=t.m11,this.m12-=t.m12,this.m21-=t.m21,this.m22-=t.m22,this.m31-=t.m31,this.m32-=t.m32,this},n.prototype.divide=function(t){return this.m11/=t.m11,this.m12/=t.m12,this.m21/=t.m21,this.m22/=t.m22,this.m31/=t.m31,this.m32/=t.m32,this},n.prototype.multiply=function(t){var e=this.m11*t.m11+this.m12*t.m21,n=this.m11*t.m12+this.m12*t.m22,i=this.m21*t.m11+this.m22*t.m21,r=this.m21*t.m12+this.m22*t.m22,o=this.m31*t.m11+this.m32*t.m21+t.m31,s=this.m31*t.m12+this.m32*t.m22+t.m32;return this.m11=e,this.m12=n,this.m21=i,this.m22=r,this.m31=o,this.m32=s,this},n.prototype.determinant=function(){return this.m11*this.m22-this.m12*this.m21},n.prototype.release=function(e){e&&t.matrixPool.push(e)},n}(egret.Matrix);t.Matrix2D=e}(es||(es={})),function(t){var e=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),Object.defineProperty(n.prototype,"max",{get:function(){return new t.Vector2(this.right,this.bottom)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"center",{get:function(){return new t.Vector2(this.x+this.width/2,this.y+this.height/2)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"location",{get:function(){return new t.Vector2(this.x,this.y)},set:function(t){this.x=t.x,this.y=t.y},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"size",{get:function(){return new t.Vector2(this.width,this.height)},set:function(t){this.width=t.x,this.height=t.y},enumerable:!0,configurable:!0}),n.fromMinMax=function(t,e,i,r){return new n(t,e,i-t,r-e)},n.rectEncompassingPoints=function(t){for(var e=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=0;oi&&(i=s.x),s.yr&&(r=s.y)}return this.fromMinMax(e,n,i,r)},n.prototype.intersects=function(t){return t.leftthis.x+this.width)return e}else{var i=1/t.direction.x,r=(this.x-t.start.x)*i,o=(this.x+this.width-t.start.x)*i;if(r>o){var s=r;r=o,o=s}if((e=Math.max(r,e))>(n=Math.min(o,n)))return e}if(Math.abs(t.direction.y)<1e-6){if(t.start.ythis.y+this.height)return e}else{var a=1/t.direction.y,c=(this.y-t.start.y)*a,h=(this.y+this.height-t.start.y)*a;if(c>h){var u=c;c=h,h=u}if((e=Math.max(c,e))>(n=Math.max(h,n)))return e}return e},n.prototype.containsRect=function(t){return this.x<=t.x&&t.x1)return!1;var u=(c.x*o.y-c.y*o.x)/a;return!(u<0||u>1)},n.lineToLineIntersection=function(e,n,i,r){var o=new t.Vector2(0,0),s=t.Vector2.subtract(n,e),a=t.Vector2.subtract(r,i),c=s.x*a.y-s.y*a.x;if(0==c)return o;var h=t.Vector2.subtract(i,e),u=(h.x*a.y-h.y*a.x)/c;if(u<0||u>1)return o;var l=(h.x*s.y-h.y*s.x)/c;return l<0||l>1?o:o=t.Vector2.add(e,new t.Vector2(u*s.x,u*s.y))},n.closestPointOnLine=function(e,n,i){var r=t.Vector2.subtract(n,e),o=t.Vector2.subtract(i,e),s=t.Vector2.dot(o,r)/t.Vector2.dot(r,r);return s=t.MathHelper.clamp(s,0,1),t.Vector2.add(e,new t.Vector2(r.x*s,r.y*s))},n.isCircleToCircle=function(e,n,i,r){return t.Vector2.distanceSquared(e,i)<(n+r)*(n+r)},n.isCircleToLine=function(e,n,i,r){return t.Vector2.distanceSquared(e,this.closestPointOnLine(i,r,e))=t&&r.y>=e&&r.x=t+i&&(s|=e.right),o.y=n+r&&(s|=e.bottom),s},n}();t.Collisions=n}(es||(es={})),function(t){var e=function(){function e(){}return e.reset=function(){this._spatialHash=new t.SpatialHash(this.spatialHashCellSize)},e.clear=function(){this._spatialHash.clear()},e.overlapCircleAll=function(t,e,n,i){if(void 0===i&&(i=-1),0!=n.length)return this._spatialHash.overlapCircle(t,e,n,i);console.error("An empty results array was passed in. No results will ever be returned.")},e.boxcastBroadphase=function(t,e){return void 0===e&&(e=this.allLayers),this._spatialHash.aabbBroadphase(t,null,e)},e.boxcastBroadphaseExcludingSelf=function(t,e,n){return void 0===n&&(n=this.allLayers),this._spatialHash.aabbBroadphase(e,t,n)},e.addCollider=function(t){e._spatialHash.register(t)},e.removeCollider=function(t){e._spatialHash.remove(t)},e.updateCollider=function(t){this._spatialHash.remove(t),this._spatialHash.register(t)},e.debugDraw=function(t){this._spatialHash.debugDraw(t,2)},e.spatialHashCellSize=100,e.allLayers=-1,e.raycastsHitTriggers=!1,e.raycastsStartInColliders=!1,e}();t.Physics=e}(es||(es={})),function(t){var e=function(){return function(e,n){this.start=e,this.end=n,this.direction=t.Vector2.subtract(this.end,this.start)}}();t.Ray2D=e}(es||(es={})),function(t){var e=function(){function e(e,n,i,r,o){this.fraction=0,this.distance=0,this.point=t.Vector2.zero,this.normal=t.Vector2.zero,this.collider=e,this.fraction=n,this.distance=i,this.point=r,this.centroid=t.Vector2.zero}return e.prototype.setValues=function(t,e,n,i){this.collider=t,this.fraction=e,this.distance=n,this.point=i},e.prototype.setValuesNonCollider=function(t,e,n,i){this.fraction=t,this.distance=e,this.point=n,this.normal=i},e.prototype.reset=function(){this.collider=null,this.fraction=this.distance=0},e.prototype.toString=function(){return"[RaycastHit] fraction: "+this.fraction+", distance: "+this.distance+", normal: "+this.normal+", centroid: "+this.centroid+", point: "+this.point},e}();t.RaycastHit=e}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.clone=function(){return ObjectUtils.clone(this)},t}();t.Shape=e}(es||(es={})),function(t){var e=function(e){function n(t,n){var i=e.call(this)||this;return i._areEdgeNormalsDirty=!0,i.isUnrotated=!0,i.setPoints(t),i.isBox=n,i}return __extends(n,e),Object.defineProperty(n.prototype,"edgeNormals",{get:function(){return this._areEdgeNormalsDirty&&this.buildEdgeNormals(),this._edgeNormals},enumerable:!0,configurable:!0}),n.prototype.setPoints=function(t){this.points=t,this.recalculateCenterAndEdgeNormals(),this._originalPoints=[];for(var e=0;e=this.points.length?this.points[0]:this.points[i+1];var o=t.Vector2Ext.perpendicular(r,e);o=t.Vector2.normalize(o),this._edgeNormals[i]=o}},n.buildSymmetricalPolygon=function(e,n){for(var i=new Array(e),r=0;rr&&(r=s,i=o)}return e[i]},n.getClosestPointOnPolygonToPoint=function(e,n,i,r){i=Number.MAX_VALUE,r=new t.Vector2(0,0);for(var o,s=new t.Vector2(0,0),a=0;ae.y!=this.points[r].y>e.y&&e.x<(this.points[r].x-this.points[i].x)*(e.y-this.points[i].y)/(this.points[r].y-this.points[i].y)+this.points[i].x&&(n=!n);return n},n.prototype.pointCollidesWithShape=function(e,n){return t.ShapeCollisions.pointToPoly(e,this,n)},n}(t.Shape);t.Polygon=e}(es||(es={})),function(t){var e=function(e){function n(t,i){var r=e.call(this,n.buildBox(t,i),!0)||this;return r.width=t,r.height=i,r}return __extends(n,e),n.buildBox=function(e,n){var i=e/2,r=n/2,o=new Array(4);return o[0]=new t.Vector2(-i,-r),o[1]=new t.Vector2(i,-r),o[2]=new t.Vector2(i,r),o[3]=new t.Vector2(-i,r),o},n.prototype.updateBox=function(e,n){this.width=e,this.height=n;var i=e/2,r=n/2;this.points[0]=new t.Vector2(-i,-r),this.points[1]=new t.Vector2(i,-r),this.points[2]=new t.Vector2(i,r),this.points[3]=new t.Vector2(-i,r);for(var o=0;o1)return s;var a,c=t.Vector2.add(o.start,t.Vector2.add(o.direction,new t.Vector2(s))),h=0;c.xn.bounds.right&&(h|=1),c.yn.bounds.bottom&&(h|=2);var u=a+h;return 3==u&&console.log("m == 3. corner "+t.Time.frameCount),s},e}();t.RealtimeCollisions=e}(es||(es={})),function(t){var e=function(){function e(){}return e.polygonToPolygon=function(e,n,i){for(var r,o=!0,s=e.edgeNormals,a=n.edgeNormals,c=Number.POSITIVE_INFINITY,h=new t.Vector2,u=t.Vector2.subtract(e.position,n.position),l=0;l0&&(o=!1),!o)return!1;(g=Math.abs(g))r&&(r=o);return{min:i,max:r}},e.circleToPolygon=function(e,n,i){var r,o=t.Vector2.subtract(e.position,n.position),s=t.Polygon.getClosestPointOnPolygonToPoint(n.points,o,0,i.normal),a=n.containsPoint(e.position);if(0>e.radius*e.radius&&!a)return!1;a?r=t.Vector2.multiply(i.normal,new t.Vector2(Math.sqrt(0)-e.radius)):r=t.Vector2.multiply(i.normal,new t.Vector2(e.radius));return i.minimumTranslationVector=r,i.point=t.Vector2.add(s,n.position),!0},e.circleToBox=function(e,n,i){var r=n.bounds.getClosestPointOnRectangleBorderToPoint(e.position,i.normal);if(n.containsPoint(e.position)){i.point=r;var o=t.Vector2.add(r,t.Vector2.multiply(i.normal,new t.Vector2(e.radius)));return i.minimumTranslationVector=t.Vector2.subtract(e.position,o),!0}var s=t.Vector2.distanceSquared(r,e.position);if(0==s)i.minimumTranslationVector=t.Vector2.multiply(i.normal,new t.Vector2(e.radius));else if(s<=e.radius*e.radius){i.normal=t.Vector2.subtract(e.position,r);var a=i.normal.length()-e.radius;return i.point=r,i.normal=t.Vector2Ext.normalize(i.normal),i.minimumTranslationVector=t.Vector2.multiply(new t.Vector2(a),i.normal),!0}return!1},e.pointToCircle=function(e,n,i){var r=t.Vector2.distanceSquared(e,n.position),o=1+n.radius;if(r1)return!1;var l=(h.x*s.y-h.y*s.x)/c;return!(l<0||l>1)&&(o=o.add(e).add(t.Vector2.multiply(new t.Vector2(u),s)),!0)},e.lineToCircle=function(e,n,i,r){var o=t.Vector2.distance(e,n),s=t.Vector2.divide(t.Vector2.subtract(n,e),new t.Vector2(o)),a=t.Vector2.subtract(e,i.position),c=t.Vector2.dot(a,s),h=t.Vector2.dot(a,a)-i.radius*i.radius;if(h>0&&c>0)return!1;var u=c*c-h;return!(u<0)&&(r.fraction=-c-Math.sqrt(u),r.fraction<0&&(r.fraction=0),r.point=t.Vector2.add(e,t.Vector2.multiply(new t.Vector2(r.fraction),s)),r.distance=t.Vector2.distance(e,r.point),r.normal=t.Vector2.normalize(t.Vector2.subtract(r.point,i.position)),r.fraction=r.distance/o,!0)},e.boxToBoxCast=function(e,n,i,r){var o=this.minkowskiDifference(e,n);if(o.contains(0,0)){var s=o.getClosestPointOnBoundsToOrigin();return!s.equals(t.Vector2.zero)&&(r.normal=new t.Vector2(-s.x),r.normal=r.normal.normalize(),r.distance=0,r.fraction=0,!0)}var a=new t.Ray2D(t.Vector2.zero,new t.Vector2(-i.x)),c=o.rayIntersects(a);return c<=1&&(r.fraction=c,r.distance=i.length()*c,r.normal=new t.Vector2(-i.x),r.normal=r.normal.normalize(),r.centroid=t.Vector2.add(e.bounds.center,t.Vector2.multiply(i,new t.Vector2(c))),!0)},e}();t.ShapeCollisions=e}(es||(es={})),function(t){var e=function(){function e(e){void 0===e&&(e=100),this.gridBounds=new t.Rectangle,this._overlapTestCircle=new t.Circle(0),this._cellDict=new n,this._tempHashSet=[],this._cellSize=e,this._inverseCellSize=1/this._cellSize,this._raycastParser=new i}return e.prototype.register=function(e){var n=e.bounds;e.registeredPhysicsBounds=n;var i=this.cellCoords(n.x,n.y),r=this.cellCoords(n.right,n.bottom);this.gridBounds.contains(i.x,i.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,i)),this.gridBounds.contains(r.x,r.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,r));for(var o=i.x;o<=r.x;o++)for(var s=i.y;s<=r.y;s++){var a=this.cellAtPosition(o,s,!0);a.firstOrDefault(function(t){return t.hashCode==e.hashCode})||a.push(e)}},e.prototype.remove=function(t){for(var e=t.registeredPhysicsBounds,n=this.cellCoords(e.x,e.y),i=this.cellCoords(e.right,e.bottom),r=n.x;r<=i.x;r++)for(var o=n.y;o<=i.y;o++){var s=this.cellAtPosition(r,o);s?s.remove(t):console.log("从不存在碰撞器的单元格中移除碰撞器: ["+t+"]")}},e.prototype.removeWithBruteForce=function(t){this._cellDict.remove(t)},e.prototype.clear=function(){this._cellDict.clear()},e.prototype.debugDraw=function(t,e){void 0===e&&(e=1);for(var n=this.gridBounds.x;n<=this.gridBounds.right;n++)for(var i=this.gridBounds.y;i<=this.gridBounds.bottom;i++){var r=this.cellAtPosition(n,i);r&&r.length>0&&this.debugDrawCellDetails(n,i,r.length,t,e)}},e.prototype.aabbBroadphase=function(e,n,i){this._tempHashSet.length=0;for(var r=this.cellCoords(e.x,e.y),o=this.cellCoords(e.right,e.bottom),s=r.x;s<=o.x;s++)for(var a=r.y;a<=o.y;a++){var c=this.cellAtPosition(s,a);if(c)for(var h=function(r){var o=c[r];if(o==n||!t.Flags.isFlagSet(i,o.physicsLayer))return"continue";e.intersects(o.bounds)&&(u._tempHashSet.firstOrDefault(function(t){return t.hashCode==o.hashCode})||u._tempHashSet.push(o))},u=this,l=0;lthis.tileHeight||this.maxTileWidth>this.tileWidth},enumerable:!0,configurable:!0}),e.prototype.getTilesetForTileGid=function(t){if(0==t)return null;for(var e=this.tilesets.size-1;e>=0;e--)if(this.tilesets.get(e.toString()).firstGid<=t)return this.tilesets.get(e.toString());console.error("tile gid"+t+"未在任何tileset中找到")},e.prototype.update=function(){this.tilesets.forEach(function(t){t.update()})},e.prototype.dispose=function(t){void 0===t&&(t=!0),this._isDisposed||(t&&(this.tilesets.forEach(function(t){t.image&&t.image.dispose()}),this.imageLayers.forEach(function(t){t.image&&t.image.dispose()})),this._isDisposed=!0)},e}(t.TmxDocument);t.TmxMap=e,function(t){t[t.unknown=0]="unknown",t[t.orthogonal=1]="orthogonal",t[t.isometric=2]="isometric",t[t.staggered=3]="staggered",t[t.hexagonal=4]="hexagonal"}(t.OrientationType||(t.OrientationType={})),function(t){t[t.x=0]="x",t[t.y=1]="y"}(t.StaggerAxisType||(t.StaggerAxisType={})),function(t){t[t.odd=0]="odd",t[t.even=1]="even"}(t.StaggerIndexType||(t.StaggerIndexType={})),function(t){t[t.rightDown=0]="rightDown",t[t.rightUp=1]="rightUp",t[t.leftDown=2]="leftDown",t[t.leftUp=3]="leftUp"}(t.RenderOrderType||(t.RenderOrderType={}))}(es||(es={})),function(t){var e=function(){return function(){}}();t.TmxObjectGroup=e;var n=function(){return function(){}}();t.TmxObject=n;var i=function(){return function(){}}();t.TmxText=i;var r=function(){return function(){}}();t.TmxAlignment=r,function(t){t[t.basic=0]="basic",t[t.point=1]="point",t[t.tile=2]="tile",t[t.ellipse=3]="ellipse",t[t.polygon=4]="polygon",t[t.polyline=5]="polyline",t[t.text=6]="text"}(t.TmxObjectType||(t.TmxObjectType={})),function(t){t[t.unkownOrder=-1]="unkownOrder",t[t.TopDown=0]="TopDown",t[t.IndexOrder=1]="IndexOrder"}(t.DrawOrderType||(t.DrawOrderType={})),function(t){t[t.left=0]="left",t[t.center=1]="center",t[t.right=2]="right",t[t.justify=3]="justify"}(t.TmxHorizontalAlignment||(t.TmxHorizontalAlignment={})),function(t){t[t.top=0]="top",t[t.center=1]="center",t[t.bottom=2]="bottom"}(t.TmxVerticalAlignment||(t.TmxVerticalAlignment={}))}(es||(es={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.update=function(){this.tiles.forEach(function(t){t.updateAnimatedTiles()})},e}(t.TmxDocument);t.TmxTileset=e;var n=function(){return function(){}}();t.TmxTileOffset=n;var i=function(){return function(){}}();t.TmxTerrain=i}(es||(es={})),function(t){var e=function(){function e(){}return Object.defineProperty(e.prototype,"currentAnimationFrameGid",{get:function(){return this.animationFrames[this._animationCurrentFrame].gid+this.tileset.firstGid},enumerable:!0,configurable:!0}),e.prototype.processProperties=function(){var t;(t=this.properties.get("engine.isDestructable"))&&(this.isDestructable=Boolean(t)),(t=this.properties.get("engine:isSlope"))&&(this.isSlope=Boolean(t)),(t=this.properties.get("engine:isOneWayPlatform"))&&(this.isOneWayPlatform=Boolean(t)),(t=this.properties.get("engine:slopeTopLeft"))&&(this.slopeTopLeft=Number(t)),(t=this.properties.get("engine:slopeTopRight"))&&(this.slopeTopRight=Number(t))},e.prototype.updateAnimatedTiles=function(){0!=this.animationFrames.length&&(this._animationElapsedTime+=t.Time.deltaTime,this._animationElapsedTime>this.animationFrames[this._animationCurrentFrame].duration&&(this._animationCurrentFrame=t.MathHelper.incrementWithWrap(this._animationCurrentFrame,this.animationFrames.length),this._animationElapsedTime=0))},e}();t.TmxTilesetTile=e;var n=function(){return function(){}}();t.TmxAnimationFrame=n}(es||(es={}));var ArrayUtils=function(){function t(){}return t.bubbleSort=function(t){for(var e=!1,n=0;nn;i--)if(t[i]0&&t[r-1]>i;r--)t[r]=t[r-1];t[r]=i}},t.binarySearch=function(t,e){for(var n=0,i=t.length,r=n+i>>1;n=t[r]&&(n=r+1),r=n+i>>1;return t[n]==e?n:-1},t.findElementIndex=function(t,e){for(var n=t.length,i=0;it[e]&&(e=i);return e},t.getMinElementIndex=function(t){for(var e=0,n=t.length,i=1;i=0;--r)n.unshift(e[r]);return n},t.getDifferAry=function(t,e){t=this.getUniqueAry(t),e=this.getUniqueAry(e);for(var n=t.concat(e),i={},r=[],o=n.length,s=0;s=0;e-=1)t.splice(e,1)},t.cloneList=function(t){return t?t.slice(0,t.length):null},t.equals=function(t,e){if(t==e)return!0;var n=t.length;if(n!=e.length)return!1;for(;n--;)if(t[n]!=e[n])return!1;return!0},t.insert=function(t,e,n){if(!t)return null;var i=t.length;if(e>i&&(e=i),e<0&&(e=0),e==i)t.push(n);else if(0==e)t.unshift(n);else{for(var r=i-1;r>=e;r-=1)t[r+1]=t[r];t[e]=n}return n},t}(),Base64Utils=function(){function t(){}return t.decode=function(t,e){void 0===e&&(e=!0);var n,i,r,o,s,a,c="",h=0;for(t=(t=this.getConfKey(t)).replace(/[^A-Za-z0-9\+\/\=]/g,"");h>4,i=(15&o)<<4|(s=this._keyAll.indexOf(t.charAt(h++)))>>2,r=(3&s)<<6|(a=this._keyAll.indexOf(t.charAt(h++))),c+=String.fromCharCode(n),64!=s&&(0==i?e&&(c+=String.fromCharCode(i)):c+=String.fromCharCode(i)),64!=a&&(0==r?e&&(c+=String.fromCharCode(r)):c+=String.fromCharCode(r));return c=this._utf8_decode(c)},t._utf8_encode=function(t){t=t.replace(/\r\n/g,"\n");for(var e="",n=0;n127&&i<2048?(e+=String.fromCharCode(i>>6|192),e+=String.fromCharCode(63&i|128)):(e+=String.fromCharCode(i>>12|224),e+=String.fromCharCode(i>>6&63|128),e+=String.fromCharCode(63&i|128))}return e},t._utf8_decode=function(t){for(var e="",n=0,i=0,r=0,o=0;n191&&i<224?(r=t.charCodeAt(n+1),e+=String.fromCharCode((31&i)<<6|63&r),n+=2):(r=t.charCodeAt(n+1),o=t.charCodeAt(n+2),e+=String.fromCharCode((15&i)<<12|(63&r)<<6|63&o),n+=3);return e},t.getConfKey=function(t){return t.slice(1,t.length)},t._keyNum="0123456789+/",t._keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",t._keyAll=t._keyNum+t._keyStr,t.encode=function(t){var e,n,i,r,o,s,a,c="",h=0;for(t=this._utf8_encode(t);h>2,o=(3&e)<<4|(n=t.charCodeAt(h++))>>4,s=(15&n)<<2|(i=t.charCodeAt(h++))>>6,a=63&i,isNaN(n)?s=a=64:isNaN(i)&&(a=64),c=c+this._keyAll.charAt(r)+this._keyAll.charAt(o)+this._keyAll.charAt(s)+this._keyAll.charAt(a);return this._keyStr.charAt(Math.floor(Math.random()*this._keyStr.length))+c},t}();!function(t){var e=function(){function t(){this.loadedAssets=new Map}return t.prototype.loadRes=function(t,e){var n=this;return void 0===e&&(e=!0),new Promise(function(i,r){var o=n.loadedAssets.get(t);o?i(o):e?RES.getResAsync(t).then(function(e){n.loadedAssets.set(t,e),i(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)}):RES.getResByUrl(t).then(function(e){n.loadedAssets.set(t,e),i(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)})})},t.prototype.dispose=function(){this.loadedAssets.forEach(function(t){t.dispose()}),this.loadedAssets.clear()},t}();t.ContentManager=e}(es||(es={})),function(t){var e=function(){function e(){}return e.drawLine=function(e,n,i,r,o){void 0===o&&(o=1),this.drawLineAngle(e,n,t.MathHelper.angleBetweenVectors(n,i),t.Vector2.distance(n,i),r,o)},e.drawLineAngle=function(t,e,n,i,r,o){void 0===o&&(o=1),t.graphics.beginFill(r),t.graphics.drawRect(e.x,e.y,1,1),t.graphics.endFill(),t.scaleX=i,t.scaleY=o,t.$anchorOffsetX=0,t.$anchorOffsetY=0,t.rotation=n},e.drawHollowRect=function(t,e,n,i){void 0===i&&(i=1),this.drawHollowRectR(t,e.x,e.y,e.width,e.height,n,i)},e.drawHollowRectR=function(e,n,i,r,o,s,a){void 0===a&&(a=1);var c=new t.Vector2(n,i).round(),h=new t.Vector2(n+r,i).round(),u=new t.Vector2(n+r,i+o).round(),l=new t.Vector2(n,i+o).round();this.drawLine(e,c,h,s,a),this.drawLine(e,h,u,s,a),this.drawLine(e,u,l,s,a),this.drawLine(e,l,c,s,a)},e.drawPixel=function(e,n,i,r){void 0===r&&(r=1);var o=new t.Rectangle(n.x,n.y,r,r);1!=r&&(o.x-=.5*r,o.y-=.5*r),e.graphics.beginFill(i),e.graphics.drawRect(o.x,o.y,o.width,o.height),e.graphics.endFill()},e.getColorMatrix=function(t){var e=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];return e[0]=Math.floor(t/256/256)/255,e[6]=Math.floor(t/256%256)/255,e[12]=t%256/255,new egret.ColorMatrixFilter(e)},e}();t.DrawUtils=e}(es||(es={})),function(t){var e=function(){function e(){}return e.oppositeEdge=function(e){switch(e){case t.Edge.bottom:return t.Edge.top;case t.Edge.top:return t.Edge.bottom;case t.Edge.left:return t.Edge.right;case t.Edge.right:return t.Edge.left}},e.isHorizontal=function(e){return e==t.Edge.right||e==t.Edge.left},e.isVertical=function(e){return e==t.Edge.top||e==t.Edge.bottom},e}();t.EdgeExt=e}(es||(es={})),function(t){var e=function(){return function(t,e){this.func=t,this.context=e}}();t.FuncPack=e;var n=function(){function t(){this._messageTable=new Map}return t.prototype.addObserver=function(t,n,i){var r=this._messageTable.get(t);r||(r=[],this._messageTable.set(t,r)),-1!=r.findIndex(function(t){return t.func==n})&&console.warn("您试图添加相同的观察者两次"),r.push(new e(n,i))},t.prototype.removeObserver=function(t,e){var n=this._messageTable.get(t),i=n.findIndex(function(t){return t.func==e});-1!=i&&n.removeAt(i)},t.prototype.emit=function(t,e){var n=this._messageTable.get(t);if(n)for(var i=n.length-1;i>=0;i--)n[i].func.call(n[i].context,e)},t}();t.Emitter=n}(es||(es={})),function(t){!function(t){t[t.top=0]="top",t[t.bottom=1]="bottom",t[t.left=2]="left",t[t.right=3]="right"}(t.Edge||(t.Edge={}))}(es||(es={})),function(t){var e=function(){function t(){}return t.repeat=function(t,e){for(var n=[];e--;)n.push(t);return n},t}();t.Enumerable=e}(es||(es={})),function(t){var e=function(){function t(){}return Object.defineProperty(t.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),t.prototype.setEnabled=function(t){this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled())},t.prototype.onEnabled=function(){},t.prototype.onDisabled=function(){},t.prototype.update=function(){},t}();t.GlobalManager=e}(es||(es={})),function(t){var e=function(){function e(){this.x=0,this.y=0,this.touchPoint=-1,this.touchDown=!1}return Object.defineProperty(e.prototype,"position",{get:function(){return new t.Vector2(this.x,this.y)},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this.x=0,this.y=0,this.touchDown=!1,this.touchPoint=-1},e}();t.TouchState=e;var n=function(){function n(){}return Object.defineProperty(n,"gameTouchs",{get:function(){return this._gameTouchs},enumerable:!0,configurable:!0}),Object.defineProperty(n,"resolutionScale",{get:function(){return this._resolutionScale},enumerable:!0,configurable:!0}),Object.defineProperty(n,"totalTouchCount",{get:function(){return this._totalTouchCount},enumerable:!0,configurable:!0}),Object.defineProperty(n,"touchPosition",{get:function(){return this._gameTouchs[0]?this._gameTouchs[0].position:t.Vector2.zero},enumerable:!0,configurable:!0}),Object.defineProperty(n,"maxSupportedTouch",{get:function(){return t.Core._instance.stage.maxTouches},set:function(e){t.Core._instance.stage.maxTouches=e,this.initTouchCache()},enumerable:!0,configurable:!0}),Object.defineProperty(n,"touchPositionDelta",{get:function(){var e=t.Vector2.subtract(this.touchPosition,this._previousTouchState.position);return e.length()>0&&this.setpreviousTouchState(this._gameTouchs[0]),e},enumerable:!0,configurable:!0}),n.initialize=function(){this._init||(this._init=!0,t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.touchBegin,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.touchMove,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_END,this.touchEnd,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL,this.touchEnd,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE,this.touchEnd,this),this.initTouchCache())},n.scaledPosition=function(e){var n=new t.Vector2(e.x-this._resolutionOffset.x,e.y-this._resolutionOffset.y);return t.Vector2.multiply(n,this.resolutionScale)},n.initTouchCache=function(){this._totalTouchCount=0,this._touchIndex=0,this._gameTouchs.length=0;for(var t=0;t0)for(var e=0;ethis._objectQueue.length;)this._objectQueue.shift()},t.clearCache=function(){this._objectQueue.length=0},t.obtain=function(){return this._objectQueue.length>0?this._objectQueue.shift():[]},t.free=function(t){this._objectQueue.unshift(t),t.length=0},t._objectQueue=[],t}();t.ListPool=e}(es||(es={}));var THREAD_ID=Math.floor(1e3*Math.random())+"-"+Date.now(),nextTick=function(t){setTimeout(t,0)},LockUtils=function(){function t(t){this._keyX="mutex_key_"+t+"_X",this._keyY="mutex_key_"+t+"_Y",this.setItem=egret.localStorage.setItem.bind(localStorage),this.getItem=egret.localStorage.getItem.bind(localStorage),this.removeItem=egret.localStorage.removeItem.bind(localStorage)}return t.prototype.lock=function(){var t=this;return new Promise(function(e,n){var i=function(){t.setItem(t._keyX,THREAD_ID),null===!t.getItem(t._keyY)&&nextTick(i),t.setItem(t._keyY,THREAD_ID),t.getItem(t._keyX)!==THREAD_ID?setTimeout(function(){t.getItem(t._keyY)===THREAD_ID?(e(),t.removeItem(t._keyY)):nextTick(i)},10):(e(),t.removeItem(t._keyY))};i()})},t}();!function(t){var e=function(){function t(t,e){this.first=t,this.second=e}return t.prototype.clear=function(){this.first=this.second=null},t.prototype.equals=function(t){return this.first==t.first&&this.second==t.second},t}();t.Pair=e}(es||(es={}));var RandomUtils=function(){function t(){}return t.randrange=function(t,e,n){if(void 0===n&&(n=1),0==n)throw new Error("step 不能为 0");var i=e-t;if(0==i)throw new Error("没有可用的范围("+t+","+e+")");i<0&&(i=t-e);var r=Math.floor((i+n-1)/n);return Math.floor(this.random()*r)*n+Math.min(t,e)},t.randint=function(t,e){return(t=Math.floor(t))>(e=Math.floor(e))?t++:e++,this.randrange(t,e)},t.randnum=function(t,e){return this.random()*(e-t)+t},t.shuffle=function(t){return t.sort(this._randomCompare),t},t.choice=function(t){if(!t.hasOwnProperty("length"))throw new Error("无法对此对象执行此操作");var e=Math.floor(this.random()*t.length);return t instanceof String?String(t).charAt(e):t[e]},t.sample=function(t,e){var n=t.length;if(e<=0||n=0;)s=Math.floor(this.random()*n);i.push(t[s]),r.push(s)}return i},t.random=function(){return Math.random()},t.boolean=function(t){return void 0===t&&(t=.5),this.random().5?1:-1},t}();!function(t){var e=function(){function e(){}return e.getSide=function(e,n){switch(n){case t.Edge.top:return e.top;case t.Edge.bottom:return e.bottom;case t.Edge.left:return e.left;case t.Edge.right:return e.right}},e.union=function(e,n){var i=new t.Rectangle(n.x,n.y,0,0),r=new t.Rectangle;return r.x=Math.min(e.x,i.x),r.y=Math.min(e.y,i.y),r.width=Math.max(e.right,i.right)-r.x,r.height=Math.max(e.bottom,r.bottom)-r.y,r},e.getHalfRect=function(e,n){switch(n){case t.Edge.top:return new t.Rectangle(e.x,e.y,e.width,e.height/2);case t.Edge.bottom:return new t.Rectangle(e.x,e.y+e.height/2,e.width,e.height/2);case t.Edge.left:return new t.Rectangle(e.x,e.y,e.width/2,e.height);case t.Edge.right:return new t.Rectangle(e.x+e.width/2,e.y,e.width/2,e.height)}},e.getRectEdgePortion=function(e,n,i){switch(void 0===i&&(i=1),n){case t.Edge.top:return new t.Rectangle(e.x,e.y,e.width,i);case t.Edge.bottom:return new t.Rectangle(e.x,e.y+e.height-i,e.width,i);case t.Edge.left:return new t.Rectangle(e.x,e.y,i,e.height);case t.Edge.right:return new t.Rectangle(e.x+e.width-i,e.y,i,e.height)}},e.expandSide=function(e,n,i){switch(i=Math.abs(i),n){case t.Edge.top:e.y-=i,e.height+=i;break;case t.Edge.bottom:e.height+=i;break;case t.Edge.left:e.x-=i,e.width+=i;break;case t.Edge.right:e.width+=i}},e.contract=function(t,e,n){t.x+=e,t.y+=n,t.width-=2*e,t.height-=2*n},e}();t.RectangleExt=e}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.update=function(t){this.remainder+=t;var e=Math.trunc(this.remainder);return this.remainder-=e,e},t.prototype.reset=function(){this.remainder=0},t}();t.SubpixelNumber=e}(es||(es={})),function(t){var e=function(){function e(){this.triangleIndices=[],this._triPrev=new Array(12),this._triNext=new Array(12)}return e.testPointTriangle=function(e,n,i,r){return!(t.Vector2Ext.cross(t.Vector2.subtract(e,n),t.Vector2.subtract(i,n))<0)&&(!(t.Vector2Ext.cross(t.Vector2.subtract(e,i),t.Vector2.subtract(r,i))<0)&&!(t.Vector2Ext.cross(t.Vector2.subtract(e,r),t.Vector2.subtract(n,r))<0))},e.prototype.triangulate=function(n,i){void 0===i&&(i=!0);var r=n.length;this.initialize(r);for(var o=0,s=0;r>3&&o<500;){o++;var a=!0,c=n[this._triPrev[s]],h=n[s],u=n[this._triNext[s]];if(t.Vector2Ext.isTriangleCCW(c,h,u)){var l=this._triNext[this._triNext[s]];do{if(e.testPointTriangle(n[l],c,h,u)){a=!1;break}l=this._triNext[l]}while(l!=this._triPrev[s])}else a=!1;a?(this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),this._triNext[this._triPrev[s]]=this._triNext[s],this._triPrev[this._triNext[s]]=this._triPrev[s],r--,s=this._triPrev[s]):s=this._triNext[s]}this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),i||this.triangleIndices.reverse()},e.prototype.initialize=function(t){this.triangleIndices.length=0,this._triNext.lengtht.MathHelper.Epsilon?e=t.Vector2.divide(e,new t.Vector2(n)):e.x=e.y=0,e},e.transformA=function(t,e,n,i,r,o){for(var s=0;sthis.safeArea.right&&(s.x=this.safeArea.right-s.width),s.topthis.safeArea.bottom&&(s.y=this.safeArea.bottom-s.height),s},n}();t.Layout=n,function(t){t[t.none=0]="none",t[t.left=1]="left",t[t.right=2]="right",t[t.horizontalCenter=4]="horizontalCenter",t[t.top=8]="top",t[t.bottom=16]="bottom",t[t.verticalCenter=32]="verticalCenter",t[t.topLeft=9]="topLeft",t[t.topRight=10]="topRight",t[t.topCenter=12]="topCenter",t[t.bottomLeft=17]="bottomLeft",t[t.bottomRight=18]="bottomRight",t[t.bottomCenter=20]="bottomCenter",t[t.centerLeft=33]="centerLeft",t[t.centerRight=34]="centerRight",t[t.center=36]="center"}(e=t.Alignment||(t.Alignment={}))}(es||(es={})),function(t){var e,n=function(){function t(t){void 0===t&&(t=i),this.getSystemTime=t,this._stopDuration=0,this._completeSlices=[]}return t.prototype.getState=function(){return void 0===this._startSystemTime?e.IDLE:void 0===this._stopSystemTime?e.RUNNING:e.STOPPED},t.prototype.isIdle=function(){return this.getState()===e.IDLE},t.prototype.isRunning=function(){return this.getState()===e.RUNNING},t.prototype.isStopped=function(){return this.getState()===e.STOPPED},t.prototype.slice=function(){return this.recordPendingSlice()},t.prototype.getCompletedSlices=function(){return Array.from(this._completeSlices)},t.prototype.getCompletedAndPendingSlices=function(){return this._completeSlices.concat([this.getPendingSlice()])},t.prototype.getPendingSlice=function(){return this.calculatePendingSlice()},t.prototype.getTime=function(){return this.caculateStopwatchTime()},t.prototype.reset=function(){this._startSystemTime=this._pendingSliceStartStopwatchTime=this._stopSystemTime=void 0,this._stopDuration=0,this._completeSlices=[]},t.prototype.start=function(t){if(void 0===t&&(t=!1),t&&this.reset(),void 0!==this._stopSystemTime){var e=(n=this.getSystemTime())-this._stopSystemTime;this._stopDuration+=e,this._stopSystemTime=void 0}else if(void 0===this._startSystemTime){var n=this.getSystemTime();this._startSystemTime=n,this._pendingSliceStartStopwatchTime=0}},t.prototype.stop=function(t){if(void 0===t&&(t=!1),void 0===this._startSystemTime)return 0;var e=this.getSystemTimeOfCurrentStopwatchTime();return t&&this.recordPendingSlice(this.caculateStopwatchTime(e)),this._stopSystemTime=e,this.getTime()},t.prototype.calculatePendingSlice=function(t){return void 0===this._pendingSliceStartStopwatchTime?Object.freeze({startTime:0,endTime:0,duration:0}):(void 0===t&&(t=this.getTime()),Object.freeze({startTime:this._pendingSliceStartStopwatchTime,endTime:t,duration:t-this._pendingSliceStartStopwatchTime}))},t.prototype.caculateStopwatchTime=function(t){return void 0===this._startSystemTime?0:(void 0===t&&(t=this.getSystemTimeOfCurrentStopwatchTime()),t-this._startSystemTime-this._stopDuration)},t.prototype.getSystemTimeOfCurrentStopwatchTime=function(){return void 0===this._stopSystemTime?this.getSystemTime():this._stopSystemTime},t.prototype.recordPendingSlice=function(t){if(void 0!==this._pendingSliceStartStopwatchTime){void 0===t&&(t=this.getTime());var e=this.calculatePendingSlice(t);return this._pendingSliceStartStopwatchTime=e.endTime,this._completeSlices.push(e),e}return this.calculatePendingSlice()},t}();t.Stopwatch=n,function(t){t.IDLE="IDLE",t.RUNNING="RUNNING",t.STOPPED="STOPPED"}(e||(e={})),t.setDefaultSystemTimeGetter=function(t){void 0===t&&(t=Date.now),i=t};var i=Date.now}(stopwatch||(stopwatch={})),function(t){var e=function(){function e(){this.showLog=!1,this._frameKey="frame",this._logKey="log",this.markers=[],this.stopwacth=new stopwatch.Stopwatch,this._markerNameToIdMap=new Map,this._logs=new Array(2);for(var e=0;e=e.logSnapDuration&&(l.logs[r].snapMin=l.logs[r].min,l.logs[r].snapMax=l.logs[r].max,l.logs[r].snapAvg=l.logs[r].avg,l.logs[r].samples=0)):(l.logs[r].min=h,l.logs[r].max=h,l.logs[r].avg=h,l.logs[r].initialized=!0)}s.markCount=o.nestCount,s.nestCount=o.nestCount}t.stopwacth.reset(),t.stopwacth.start()}})},e.prototype.beginMark=function(t,n,i){var r=this;void 0===i&&(i=0),new LockUtils(this._frameKey).lock().then(function(){if(i<0||i>=e.maxBars)throw new Error("barIndex argument out of range");var o=r._curLog.bars[i];if(o.markCount>=e.maxSamples)throw new Error("exceeded sample count. either set larger number to timeruler.maxsaple or lower sample count");if(o.nestCount>=e.maxNestCall)throw new Error("exceeded nest count. either set larger number to timeruler.maxnestcall or lower nest calls");var s=r._markerNameToIdMap.get(t);isNaN(s)&&(s=r.markers.length,r._markerNameToIdMap.set(t,s)),o.markerNests[o.nestCount++]=o.markCount,o.markers[o.markCount].markerId=s,o.markers[o.markCount].color=n,o.markers[o.markCount].beginTime=r.stopwacth.getTime(),o.markers[o.markCount].endTime=-1})},e.prototype.endMark=function(t,n){var i=this;void 0===n&&(n=0),new LockUtils(this._frameKey).lock().then(function(){if(n<0||n>=e.maxBars)throw new Error("barIndex argument out of range");var r=i._curLog.bars[n];if(r.nestCount<=0)throw new Error("call beginMark method before calling endMark method");var o=i._markerNameToIdMap.get(t);if(isNaN(o))throw new Error("Marker "+t+" is not registered. Make sure you specifed same name as you used for beginMark method");var s=r.markerNests[--r.nestCount];if(r.markers[s].markerId!=o)throw new Error("Incorrect call order of beginMark/endMark method. beginMark(A), beginMark(B), endMark(B), endMark(A) But you can't called it like beginMark(A), beginMark(B), endMark(A), endMark(B).");r.markers[s].endTime=i.stopwacth.getTime()})},e.prototype.getAverageTime=function(t,n){if(t<0||t>=e.maxBars)throw new Error("barIndex argument out of range");var i=0,r=this._markerNameToIdMap.get(n);return r&&(i=this.markers[r].logs[t].avg),i},e.prototype.resetLog=function(){var t=this;new LockUtils(this._logKey).lock().then(function(){var e=parseInt(egret.localStorage.getItem(t._logKey),10);e+=1,egret.localStorage.setItem(t._logKey,e.toString()),t.markers.forEach(function(t){for(var e=0;e0&&(i+=e.barHeight+2*e.barPadding,r=Math.max(r,t.markers[t.markCount-1].endTime))});var o=this.sampleFrames*(1/60*1e3);this._frameAdjust=r>o?Math.max(0,this._frameAdjust)+1:Math.min(0,this._frameAdjust)-1,Math.max(this._frameAdjust)>e.autoAdjustDelay&&(this.sampleFrames=Math.min(e.maxSampleFrames,this.sampleFrames),this.sampleFrames=Math.max(this.targetSampleFrames,r/(1/60*1e3)+1),this._frameAdjust=0);t.y,e.barHeight}},e.prototype.onGraphicsDeviceReset=function(){var n=new t.Layout;this._position=n.place(new t.Vector2(this.width,e.barHeight),0,.01,t.Alignment.bottomCenter).location},e.maxBars=8,e.maxSamples=256,e.maxNestCall=32,e.barHeight=8,e.maxSampleFrames=4,e.logSnapDuration=120,e.barPadding=2,e.autoAdjustDelay=30,e}();t.TimeRuler=e;var n=function(){return function(){this.bars=new Array(e.maxBars),this.bars.fill(new i,0,e.maxBars)}}();t.FrameLog=n;var i=function(){return function(){this.markers=new Array(e.maxSamples),this.markCount=0,this.markerNests=new Array(e.maxNestCall),this.nestCount=0,this.markers.fill(new r,0,e.maxSamples),this.markerNests.fill(0,0,e.maxNestCall)}}();t.MarkerCollection=i;var r=function(){return function(){this.markerId=0,this.beginTime=0,this.endTime=0,this.color=0}}();t.Marker=r;var o=function(){return function(t){this.logs=new Array(e.maxBars),this.name=t,this.logs.fill(new s,0,e.maxBars)}}();t.MarkerInfo=o;var s=function(){return function(){this.snapMin=0,this.snapMax=0,this.snapAvg=0,this.min=0,this.max=0,this.avg=0,this.samples=0,this.color=0,this.initialized=!1}}();t.MarkerLog=s}(es||(es={})); \ No newline at end of file diff --git a/demo/resource/default.res.json b/demo/resource/default.res.json index 44a2354c..7faab154 100644 --- a/demo/resource/default.res.json +++ b/demo/resource/default.res.json @@ -145,6 +145,11 @@ "url": "assets/isometric_grass_and_water.png", "type": "image", "name": "isometric_grass_and_water_png" + }, + { + "url": "assets/000010000.img.json", + "type": "json", + "name": "000010000.img_json" } ] } \ No newline at end of file diff --git a/demo/src/game/MainScene.ts b/demo/src/game/MainScene.ts index f1afc386..9730d05d 100644 --- a/demo/src/game/MainScene.ts +++ b/demo/src/game/MainScene.ts @@ -22,7 +22,6 @@ module scene { this.camera.follow(bg, es.CameraStyle.lockOn); }); // // bg.addComponent(new es.SpriteRenderer()).setSprite(sprite).setColor(0xff0000); - for (let i = 0; i < 20; i++) { let sprite = new es.Sprite(RES.getRes("checkbox_select_disabled_png")); diff --git a/source/bin/framework.d.ts b/source/bin/framework.d.ts index 30746054..35b7f9ef 100644 --- a/source/bin/framework.d.ts +++ b/source/bin/framework.d.ts @@ -699,6 +699,32 @@ declare module es { stop(): void; } } +declare module es { + class CollisionState { + right: boolean; + left: boolean; + above: boolean; + below: boolean; + becameGroundedThisFrame: boolean; + wasGroundedLastFrame: boolean; + isGroundedOnOnewayPlatform: boolean; + slopAngle: number; + readonly hasCollision: boolean; + _movementRemainderX: SubpixelNumber; + _movementRemainderY: SubpixelNumber; + reset(): void; + toString(): string; + } + class TiledMapMover extends Component { + colliderHorizontalInset: number; + colliderVerticalInset: number; + _boxColliderBounds: Rectangle; + constructor(); + testCollisions(motion: Vector2, boxColliderBounds: Rectangle, collisionState: CollisionState): void; + testMapCollision(collisionRect: Rectangle, direction: Edge, collisionState: CollisionState, collisionResponse: number): void; + collisionRectForSide(side: Edge, motion: number): Rectangle; + } +} declare module es { interface ITriggerListener { onTriggerEnter(other: Collider, local: Collider): any; @@ -1207,6 +1233,7 @@ declare module es { static isEven(value: number): boolean; static clamp01(value: number): number; static angleBetweenVectors(from: Vector2, to: Vector2): number; + static incrementWithWrap(t: number, length: number): number; } } declare module es { @@ -1488,6 +1515,281 @@ declare module es { reset(): void; } } +declare module es { + class TmxGroup implements ITmxLayer { + map: TmxMap; + offsetX: number; + offsetY: number; + opacity: number; + properties: Map; + visible: boolean; + name: string; + layers: TmxList; + tileLayers: TmxList; + objectGroups: TmxList; + imageLayers: TmxList; + groups: TmxList; + } +} +declare module es { + interface ITmxLayer { + offsetX: number; + offsetY: number; + opacity: number; + visible: boolean; + properties: Map; + } +} +declare module es { + class TmxImageLayer implements ITmxLayer { + map: TmxMap; + name: string; + offsetX: number; + offsetY: number; + opacity: number; + properties: Map; + visible: boolean; + width?: number; + height?: number; + image: TmxImage; + } +} +declare module es { + class TmxLayer implements ITmxLayer { + map: TmxMap; + name: string; + opacity: number; + offsetX: number; + offsetY: number; + properties: Map; + visible: boolean; + readonly offset: Vector2; + width: number; + height: number; + tiles: TmxLayerTile[]; + getTileWithGid(gid: number): TmxLayerTile; + } + class TmxLayerTile { + static readonly FLIPPED_HORIZONTALLY_FLAG: number; + static readonly FLIPPED_VERTICALLY_FLAG: number; + static readonly FLIPPED_DIAGONALLY_FLAG: number; + tileset: TmxTileset; + gid: number; + x: number; + y: number; + readonly position: Vector2; + horizontalFlip: boolean; + verticalFlip: boolean; + diagonalFlip: boolean; + _tilesetTileIndex?: number; + readonly tilesetTile: TmxTilesetTile; + constructor(map: TmxMap, id: number, x: number, y: number); + } +} +declare module es { + class TmxDocument { + TmxDirectory: string; + constructor(); + } + interface ITmxElement { + name: string; + } + class TmxList extends Map { + _nameCount: Map; + add(t: T): void; + protected getKeyForItem(item: T): string; + } + class TmxImage { + texture: egret.Texture; + source: string; + format: string; + data: any; + trans: number; + width: number; + height: number; + dispose(): void; + } +} +declare module es { + class TmxMap extends TmxDocument { + version: string; + tiledVersion: string; + width: number; + height: number; + readonly worldWidth: number; + readonly worldHeight: number; + tileWidth: number; + tileHeight: number; + hexSideLength?: number; + orientation: OrientationType; + staggerAxis: StaggerAxisType; + staggerIndex: StaggerIndexType; + renderOrder: RenderOrderType; + backgroundColor: number; + nextObjectID?: number; + layers: TmxList; + tilesets: TmxList; + tileLayers: TmxList; + objectGroups: TmxList; + imageLayers: TmxList; + groups: TmxList; + properties: Map; + maxTileWidth: number; + maxTileHeight: number; + readonly requiresLargeTileCulling: boolean; + getTilesetForTileGid(gid: number): TmxTileset; + update(): void; + _isDisposed: any; + dispose(disposing?: boolean): void; + } + enum OrientationType { + unknown = 0, + orthogonal = 1, + isometric = 2, + staggered = 3, + hexagonal = 4 + } + enum StaggerAxisType { + x = 0, + y = 1 + } + enum StaggerIndexType { + odd = 0, + even = 1 + } + enum RenderOrderType { + rightDown = 0, + rightUp = 1, + leftDown = 2, + leftUp = 3 + } +} +declare module es { + class TmxObjectGroup implements ITmxLayer { + map: TmxMap; + name: string; + opacity: number; + visible: boolean; + offsetX: number; + offsetY: number; + color: number; + drawOrder: DrawOrderType; + objects: TmxList; + properties: Map; + } + class TmxObject implements ITmxElement { + id: number; + name: string; + objectType: TmxObjectType; + type: string; + x: number; + y: number; + width: number; + height: number; + rotation: number; + tile: TmxLayerTile; + visible: boolean; + text: TmxText; + } + class TmxText { + fontFamily: string; + pixelSize: number; + wrap: boolean; + color: number; + bold: boolean; + italic: boolean; + underline: boolean; + strikeout: boolean; + kerning: boolean; + alignment: TmxAlignment; + value: string; + } + class TmxAlignment { + horizontal: TmxHorizontalAlignment; + vertical: TmxVerticalAlignment; + } + enum TmxObjectType { + basic = 0, + point = 1, + tile = 2, + ellipse = 3, + polygon = 4, + polyline = 5, + text = 6 + } + enum DrawOrderType { + unkownOrder = -1, + TopDown = 0, + IndexOrder = 1 + } + enum TmxHorizontalAlignment { + left = 0, + center = 1, + right = 2, + justify = 3 + } + enum TmxVerticalAlignment { + top = 0, + center = 1, + bottom = 2 + } +} +declare module es { + class TmxTileset extends TmxDocument implements ITmxElement { + map: TmxMap; + firstGid: number; + name: any; + tileWidth: number; + tileHeight: number; + spacing: number; + margin: number; + columns?: number; + tileCount?: number; + tiles: Map; + tileOffset: TmxTileOffset; + properties: Map; + image: TmxImage; + terrains: TmxList; + tileRegions: Map; + update(): void; + } + class TmxTileOffset { + x: number; + y: number; + } + class TmxTerrain implements ITmxElement { + name: any; + tile: number; + properties: Map; + } +} +declare module es { + class TmxTilesetTile { + tileset: TmxTileset; + id: number; + terrainEdges: TmxTerrain[]; + probability: number; + type: string; + properties: Map; + image: TmxImage; + objectGroups: TmxList; + animationFrames: TmxAnimationFrame[]; + readonly currentAnimationFrameGid: number; + _animationElapsedTime: number; + _animationCurrentFrame: number; + isDestructable: boolean; + isSlope: boolean; + isOneWayPlatform: boolean; + slopeTopLeft: number; + slopeTopRight: number; + processProperties(): void; + updateAnimatedTiles(): void; + } + class TmxAnimationFrame { + gid: number; + duration: number; + } +} declare class ArrayUtils { static bubbleSort(ary: number[]): void; static insertionSort(ary: number[]): void; @@ -1530,6 +1832,13 @@ declare module es { static getColorMatrix(color: number): egret.ColorMatrixFilter; } } +declare module es { + class EdgeExt { + static oppositeEdge(self: Edge): Edge; + static isHorizontal(self: Edge): boolean; + static isVertical(self: Edge): boolean; + } +} declare module es { class FuncPack { func: Function; @@ -1544,6 +1853,19 @@ declare module es { emit(eventType: T, data?: any): void; } } +declare module es { + enum Edge { + top = 0, + bottom = 1, + left = 2, + right = 3 + } +} +declare module es { + class Enumerable { + static repeat(element: T, count: number): any[]; + } +} declare module es { class GlobalManager { _enabled: boolean; @@ -1713,7 +2035,19 @@ declare class RandomUtils { } declare module es { class RectangleExt { + static getSide(rect: Rectangle, edge: Edge): number; static union(first: Rectangle, point: Vector2): Rectangle; + static getHalfRect(rect: Rectangle, edge: Edge): Rectangle; + static getRectEdgePortion(rect: Rectangle, edge: Edge, size?: number): Rectangle; + static expandSide(rect: Rectangle, edge: Edge, amount: number): void; + static contract(rect: Rectangle, horizontalAmount: any, verticalAmount: any): void; + } +} +declare module es { + class SubpixelNumber { + remainder: number; + update(amount: number): number; + reset(): void; } } declare module es { diff --git a/source/bin/framework.js b/source/bin/framework.js index f0620472..72f4fee8 100644 --- a/source/bin/framework.js +++ b/source/bin/framework.js @@ -3207,6 +3207,85 @@ var es; es.SpriteAnimator = SpriteAnimator; })(es || (es = {})); var es; +(function (es) { + var CollisionState = (function () { + function CollisionState() { + } + Object.defineProperty(CollisionState.prototype, "hasCollision", { + get: function () { + return this.below || this.right || this.left || this.above; + }, + enumerable: true, + configurable: true + }); + CollisionState.prototype.reset = function () { + this.becameGroundedThisFrame = this.isGroundedOnOnewayPlatform = this.right = this.left = this.above = this.below = false; + this.slopAngle = 0; + }; + CollisionState.prototype.toString = function () { + return "[CollisionState] r: " + this.right + ", l: " + this.left + ", a: " + this.above + ", b: " + this.below + ", angle: " + this.slopAngle + ", wasGroundedLastFrame: " + this.wasGroundedLastFrame + ", becameGroundedThisFrame: " + this.becameGroundedThisFrame; + }; + return CollisionState; + }()); + es.CollisionState = CollisionState; + var TiledMapMover = (function (_super) { + __extends(TiledMapMover, _super); + function TiledMapMover() { + var _this = _super.call(this) || this; + _this.colliderHorizontalInset = 2; + _this.colliderVerticalInset = 6; + return _this; + } + TiledMapMover.prototype.testCollisions = function (motion, boxColliderBounds, collisionState) { + this._boxColliderBounds = boxColliderBounds; + collisionState.wasGroundedLastFrame = collisionState.below; + collisionState.reset(); + var motionX = motion.x; + var motionY = motion.y; + if (motionX != 0) { + var direction = motionX > 0 ? es.Edge.right : es.Edge.left; + var sweptBounds = this.collisionRectForSide(direction, motionX); + var collisionResponse = 0; + if (this.testMapCollision(sweptBounds, direction, collisionState, collisionResponse)) { + motion.x = collisionResponse - es.RectangleExt.getSide(boxColliderBounds, direction); + collisionState.left = direction == es.Edge.left; + collisionState.right = direction == es.Edge.right; + collisionState._movementRemainderX.reset(); + } + else { + collisionState.left = false; + collisionState.right = false; + } + } + }; + TiledMapMover.prototype.testMapCollision = function (collisionRect, direction, collisionState, collisionResponse) { + var side = es.EdgeExt.oppositeEdge(direction); + var perpindicularPosition = es.EdgeExt.isVertical(side) ? collisionRect.center.x : collisionRect.center.y; + var leadingPosition = es.RectangleExt.getSide(collisionRect, direction); + var shouldTestSlopes = es.EdgeExt.isVertical(side); + }; + TiledMapMover.prototype.collisionRectForSide = function (side, motion) { + var bounds; + if (es.EdgeExt.isHorizontal(side)) { + bounds = es.RectangleExt.getRectEdgePortion(this._boxColliderBounds, side); + } + else { + bounds = es.RectangleExt.getHalfRect(this._boxColliderBounds, side); + } + if (es.EdgeExt.isVertical(side)) { + es.RectangleExt.contract(bounds, this.colliderHorizontalInset, 0); + } + else { + es.RectangleExt.contract(bounds, 0, this.colliderVerticalInset); + } + es.RectangleExt.expandSide(bounds, side, motion); + return bounds; + }; + return TiledMapMover; + }(es.Component)); + es.TiledMapMover = TiledMapMover; +})(es || (es = {})); +var es; (function (es) { var Mover = (function (_super) { __extends(Mover, _super); @@ -5631,6 +5710,12 @@ var es; MathHelper.angleBetweenVectors = function (from, to) { return Math.atan2(to.y - from.y, to.x - from.x); }; + MathHelper.incrementWithWrap = function (t, length) { + t++; + if (t == length) + return 0; + return t; + }; MathHelper.Epsilon = 0.00001; MathHelper.Rad2Deg = 57.29578; MathHelper.Deg2Rad = 0.0174532924; @@ -7259,6 +7344,357 @@ var es; }()); es.RaycastResultParser = RaycastResultParser; })(es || (es = {})); +var es; +(function (es) { + var TmxGroup = (function () { + function TmxGroup() { + } + return TmxGroup; + }()); + es.TmxGroup = TmxGroup; +})(es || (es = {})); +var es; +(function (es) { + var TmxImageLayer = (function () { + function TmxImageLayer() { + } + return TmxImageLayer; + }()); + es.TmxImageLayer = TmxImageLayer; +})(es || (es = {})); +var es; +(function (es) { + var TmxLayer = (function () { + function TmxLayer() { + } + Object.defineProperty(TmxLayer.prototype, "offset", { + get: function () { + return new es.Vector2(this.offsetX, this.offsetY); + }, + enumerable: true, + configurable: true + }); + TmxLayer.prototype.getTileWithGid = function (gid) { + for (var i = 0; i < this.tiles.length; i++) { + if (this.tiles[i] && this.tiles[i].gid == gid) + return this.tiles[i]; + } + return null; + }; + return TmxLayer; + }()); + es.TmxLayer = TmxLayer; + var TmxLayerTile = (function () { + function TmxLayerTile(map, id, x, y) { + this.x = x; + this.y = y; + var rawGid = id; + var flip; + flip = (rawGid & TmxLayerTile.FLIPPED_HORIZONTALLY_FLAG) != 0; + this.horizontalFlip = flip; + flip = (rawGid & TmxLayerTile.FLIPPED_VERTICALLY_FLAG) != 0; + this.verticalFlip = flip; + flip = (rawGid & TmxLayerTile.FLIPPED_DIAGONALLY_FLAG) != 0; + this.diagonalFlip = flip; + rawGid &= ~(TmxLayerTile.FLIPPED_HORIZONTALLY_FLAG | TmxLayerTile.FLIPPED_VERTICALLY_FLAG | TmxLayerTile.FLIPPED_DIAGONALLY_FLAG); + this.gid = rawGid; + this.tileset = map.getTilesetForTileGid(this.gid); + } + Object.defineProperty(TmxLayerTile.prototype, "position", { + get: function () { + return new es.Vector2(this.x, this.y); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TmxLayerTile.prototype, "tilesetTile", { + get: function () { + if (this._tilesetTileIndex == undefined) { + this._tilesetTileIndex = -1; + if (this.tileset.firstGid <= this.gid) { + var tilesetTile = this.tileset.tiles.get(this.gid - this.tileset.firstGid); + if (tilesetTile) { + this._tilesetTileIndex = this.gid - this.tileset.firstGid; + } + } + } + if (this._tilesetTileIndex < 0) + return null; + return this.tileset.tiles.get(this._tilesetTileIndex); + }, + enumerable: true, + configurable: true + }); + TmxLayerTile.FLIPPED_HORIZONTALLY_FLAG = 0x80000000; + TmxLayerTile.FLIPPED_VERTICALLY_FLAG = 0x40000000; + TmxLayerTile.FLIPPED_DIAGONALLY_FLAG = 0x20000000; + return TmxLayerTile; + }()); + es.TmxLayerTile = TmxLayerTile; +})(es || (es = {})); +var es; +(function (es) { + var TmxDocument = (function () { + function TmxDocument() { + this.TmxDirectory = ""; + } + return TmxDocument; + }()); + es.TmxDocument = TmxDocument; + var TmxList = (function (_super) { + __extends(TmxList, _super); + function TmxList() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._nameCount = new Map(); + return _this; + } + TmxList.prototype.add = function (t) { + var tName = t.name; + if (this.has(tName)) + this._nameCount.set(tName, this._nameCount.get(tName) + 1); + else + this._nameCount.set(tName, 0); + }; + TmxList.prototype.getKeyForItem = function (item) { + var name = item.name; + var count = this._nameCount.get(name); + var dupes = 0; + while (this.has(name)) { + name = name + es.Enumerable.repeat("_", dupes).toString() + count.toString(); + dupes++; + } + return name; + }; + return TmxList; + }(Map)); + es.TmxList = TmxList; + var TmxImage = (function () { + function TmxImage() { + } + TmxImage.prototype.dispose = function () { + if (this.texture) { + this.texture.dispose(); + this.texture = null; + } + }; + return TmxImage; + }()); + es.TmxImage = TmxImage; +})(es || (es = {})); +var es; +(function (es) { + var TmxMap = (function (_super) { + __extends(TmxMap, _super); + function TmxMap() { + return _super !== null && _super.apply(this, arguments) || this; + } + Object.defineProperty(TmxMap.prototype, "worldWidth", { + get: function () { + return this.width * this.tileWidth; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TmxMap.prototype, "worldHeight", { + get: function () { + return this.height * this.tileHeight; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TmxMap.prototype, "requiresLargeTileCulling", { + get: function () { + return this.maxTileHeight > this.tileHeight || this.maxTileWidth > this.tileWidth; + }, + enumerable: true, + configurable: true + }); + TmxMap.prototype.getTilesetForTileGid = function (gid) { + if (gid == 0) + return null; + for (var i = this.tilesets.size - 1; i >= 0; i--) { + if (this.tilesets.get(i.toString()).firstGid <= gid) + return this.tilesets.get(i.toString()); + } + console.error("tile gid" + gid + "\u672A\u5728\u4EFB\u4F55tileset\u4E2D\u627E\u5230"); + }; + TmxMap.prototype.update = function () { + this.tilesets.forEach(function (tileset) { tileset.update(); }); + }; + TmxMap.prototype.dispose = function (disposing) { + if (disposing === void 0) { disposing = true; } + if (!this._isDisposed) { + if (disposing) { + this.tilesets.forEach(function (tileset) { if (tileset.image) + tileset.image.dispose(); }); + this.imageLayers.forEach(function (layer) { if (layer.image) + layer.image.dispose(); }); + } + this._isDisposed = true; + } + }; + return TmxMap; + }(es.TmxDocument)); + es.TmxMap = TmxMap; + var OrientationType; + (function (OrientationType) { + OrientationType[OrientationType["unknown"] = 0] = "unknown"; + OrientationType[OrientationType["orthogonal"] = 1] = "orthogonal"; + OrientationType[OrientationType["isometric"] = 2] = "isometric"; + OrientationType[OrientationType["staggered"] = 3] = "staggered"; + OrientationType[OrientationType["hexagonal"] = 4] = "hexagonal"; + })(OrientationType = es.OrientationType || (es.OrientationType = {})); + var StaggerAxisType; + (function (StaggerAxisType) { + StaggerAxisType[StaggerAxisType["x"] = 0] = "x"; + StaggerAxisType[StaggerAxisType["y"] = 1] = "y"; + })(StaggerAxisType = es.StaggerAxisType || (es.StaggerAxisType = {})); + var StaggerIndexType; + (function (StaggerIndexType) { + StaggerIndexType[StaggerIndexType["odd"] = 0] = "odd"; + StaggerIndexType[StaggerIndexType["even"] = 1] = "even"; + })(StaggerIndexType = es.StaggerIndexType || (es.StaggerIndexType = {})); + var RenderOrderType; + (function (RenderOrderType) { + RenderOrderType[RenderOrderType["rightDown"] = 0] = "rightDown"; + RenderOrderType[RenderOrderType["rightUp"] = 1] = "rightUp"; + RenderOrderType[RenderOrderType["leftDown"] = 2] = "leftDown"; + RenderOrderType[RenderOrderType["leftUp"] = 3] = "leftUp"; + })(RenderOrderType = es.RenderOrderType || (es.RenderOrderType = {})); +})(es || (es = {})); +var es; +(function (es) { + var TmxObjectGroup = (function () { + function TmxObjectGroup() { + } + return TmxObjectGroup; + }()); + es.TmxObjectGroup = TmxObjectGroup; + var TmxObject = (function () { + function TmxObject() { + } + return TmxObject; + }()); + es.TmxObject = TmxObject; + var TmxText = (function () { + function TmxText() { + } + return TmxText; + }()); + es.TmxText = TmxText; + var TmxAlignment = (function () { + function TmxAlignment() { + } + return TmxAlignment; + }()); + es.TmxAlignment = TmxAlignment; + var TmxObjectType; + (function (TmxObjectType) { + TmxObjectType[TmxObjectType["basic"] = 0] = "basic"; + TmxObjectType[TmxObjectType["point"] = 1] = "point"; + TmxObjectType[TmxObjectType["tile"] = 2] = "tile"; + TmxObjectType[TmxObjectType["ellipse"] = 3] = "ellipse"; + TmxObjectType[TmxObjectType["polygon"] = 4] = "polygon"; + TmxObjectType[TmxObjectType["polyline"] = 5] = "polyline"; + TmxObjectType[TmxObjectType["text"] = 6] = "text"; + })(TmxObjectType = es.TmxObjectType || (es.TmxObjectType = {})); + var DrawOrderType; + (function (DrawOrderType) { + DrawOrderType[DrawOrderType["unkownOrder"] = -1] = "unkownOrder"; + DrawOrderType[DrawOrderType["TopDown"] = 0] = "TopDown"; + DrawOrderType[DrawOrderType["IndexOrder"] = 1] = "IndexOrder"; + })(DrawOrderType = es.DrawOrderType || (es.DrawOrderType = {})); + var TmxHorizontalAlignment; + (function (TmxHorizontalAlignment) { + TmxHorizontalAlignment[TmxHorizontalAlignment["left"] = 0] = "left"; + TmxHorizontalAlignment[TmxHorizontalAlignment["center"] = 1] = "center"; + TmxHorizontalAlignment[TmxHorizontalAlignment["right"] = 2] = "right"; + TmxHorizontalAlignment[TmxHorizontalAlignment["justify"] = 3] = "justify"; + })(TmxHorizontalAlignment = es.TmxHorizontalAlignment || (es.TmxHorizontalAlignment = {})); + var TmxVerticalAlignment; + (function (TmxVerticalAlignment) { + TmxVerticalAlignment[TmxVerticalAlignment["top"] = 0] = "top"; + TmxVerticalAlignment[TmxVerticalAlignment["center"] = 1] = "center"; + TmxVerticalAlignment[TmxVerticalAlignment["bottom"] = 2] = "bottom"; + })(TmxVerticalAlignment = es.TmxVerticalAlignment || (es.TmxVerticalAlignment = {})); +})(es || (es = {})); +var es; +(function (es) { + var TmxTileset = (function (_super) { + __extends(TmxTileset, _super); + function TmxTileset() { + return _super !== null && _super.apply(this, arguments) || this; + } + TmxTileset.prototype.update = function () { + this.tiles.forEach(function (value) { + value.updateAnimatedTiles(); + }); + }; + return TmxTileset; + }(es.TmxDocument)); + es.TmxTileset = TmxTileset; + var TmxTileOffset = (function () { + function TmxTileOffset() { + } + return TmxTileOffset; + }()); + es.TmxTileOffset = TmxTileOffset; + var TmxTerrain = (function () { + function TmxTerrain() { + } + return TmxTerrain; + }()); + es.TmxTerrain = TmxTerrain; +})(es || (es = {})); +var es; +(function (es) { + var TmxTilesetTile = (function () { + function TmxTilesetTile() { + } + Object.defineProperty(TmxTilesetTile.prototype, "currentAnimationFrameGid", { + get: function () { + return this.animationFrames[this._animationCurrentFrame].gid + this.tileset.firstGid; + }, + enumerable: true, + configurable: true + }); + TmxTilesetTile.prototype.processProperties = function () { + var value; + value = this.properties.get("engine.isDestructable"); + if (value) + this.isDestructable = Boolean(value); + value = this.properties.get("engine:isSlope"); + if (value) + this.isSlope = Boolean(value); + value = this.properties.get("engine:isOneWayPlatform"); + if (value) + this.isOneWayPlatform = Boolean(value); + value = this.properties.get("engine:slopeTopLeft"); + if (value) + this.slopeTopLeft = Number(value); + value = this.properties.get("engine:slopeTopRight"); + if (value) + this.slopeTopRight = Number(value); + }; + TmxTilesetTile.prototype.updateAnimatedTiles = function () { + if (this.animationFrames.length == 0) + return; + this._animationElapsedTime += es.Time.deltaTime; + if (this._animationElapsedTime > this.animationFrames[this._animationCurrentFrame].duration) { + this._animationCurrentFrame = es.MathHelper.incrementWithWrap(this._animationCurrentFrame, this.animationFrames.length); + this._animationElapsedTime = 0; + } + }; + return TmxTilesetTile; + }()); + es.TmxTilesetTile = TmxTilesetTile; + var TmxAnimationFrame = (function () { + function TmxAnimationFrame() { + } + return TmxAnimationFrame; + }()); + es.TmxAnimationFrame = TmxAnimationFrame; +})(es || (es = {})); var ArrayUtils = (function () { function ArrayUtils() { } @@ -7654,6 +8090,33 @@ var es; es.DrawUtils = DrawUtils; })(es || (es = {})); var es; +(function (es) { + var EdgeExt = (function () { + function EdgeExt() { + } + EdgeExt.oppositeEdge = function (self) { + switch (self) { + case es.Edge.bottom: + return es.Edge.top; + case es.Edge.top: + return es.Edge.bottom; + case es.Edge.left: + return es.Edge.right; + case es.Edge.right: + return es.Edge.left; + } + }; + EdgeExt.isHorizontal = function (self) { + return self == es.Edge.right || self == es.Edge.left; + }; + EdgeExt.isVertical = function (self) { + return self == es.Edge.top || self == es.Edge.bottom; + }; + return EdgeExt; + }()); + es.EdgeExt = EdgeExt; +})(es || (es = {})); +var es; (function (es) { var FuncPack = (function () { function FuncPack(func, context) { @@ -7695,6 +8158,32 @@ var es; es.Emitter = Emitter; })(es || (es = {})); var es; +(function (es) { + var Edge; + (function (Edge) { + Edge[Edge["top"] = 0] = "top"; + Edge[Edge["bottom"] = 1] = "bottom"; + Edge[Edge["left"] = 2] = "left"; + Edge[Edge["right"] = 3] = "right"; + })(Edge = es.Edge || (es.Edge = {})); +})(es || (es = {})); +var es; +(function (es) { + var Enumerable = (function () { + function Enumerable() { + } + Enumerable.repeat = function (element, count) { + var result = []; + while (count--) { + result.push(element); + } + return result; + }; + return Enumerable; + }()); + es.Enumerable = Enumerable; +})(es || (es = {})); +var es; (function (es) { var GlobalManager = (function () { function GlobalManager() { @@ -8252,6 +8741,18 @@ var es; var RectangleExt = (function () { function RectangleExt() { } + RectangleExt.getSide = function (rect, edge) { + switch (edge) { + case es.Edge.top: + return rect.top; + case es.Edge.bottom: + return rect.bottom; + case es.Edge.left: + return rect.left; + case es.Edge.right: + return rect.right; + } + }; RectangleExt.union = function (first, point) { var rect = new es.Rectangle(point.x, point.y, 0, 0); var result = new es.Rectangle(); @@ -8261,11 +8762,79 @@ var es; result.height = Math.max(first.bottom, result.bottom) - result.y; return result; }; + RectangleExt.getHalfRect = function (rect, edge) { + switch (edge) { + case es.Edge.top: + return new es.Rectangle(rect.x, rect.y, rect.width, rect.height / 2); + case es.Edge.bottom: + return new es.Rectangle(rect.x, rect.y + rect.height / 2, rect.width, rect.height / 2); + case es.Edge.left: + return new es.Rectangle(rect.x, rect.y, rect.width / 2, rect.height); + case es.Edge.right: + return new es.Rectangle(rect.x + rect.width / 2, rect.y, rect.width / 2, rect.height); + } + }; + RectangleExt.getRectEdgePortion = function (rect, edge, size) { + if (size === void 0) { size = 1; } + switch (edge) { + case es.Edge.top: + return new es.Rectangle(rect.x, rect.y, rect.width, size); + case es.Edge.bottom: + return new es.Rectangle(rect.x, rect.y + rect.height - size, rect.width, size); + case es.Edge.left: + return new es.Rectangle(rect.x, rect.y, size, rect.height); + case es.Edge.right: + return new es.Rectangle(rect.x + rect.width - size, rect.y, size, rect.height); + } + }; + RectangleExt.expandSide = function (rect, edge, amount) { + amount = Math.abs(amount); + switch (edge) { + case es.Edge.top: + rect.y -= amount; + rect.height += amount; + break; + case es.Edge.bottom: + rect.height += amount; + break; + case es.Edge.left: + rect.x -= amount; + rect.width += amount; + break; + case es.Edge.right: + rect.width += amount; + break; + } + }; + RectangleExt.contract = function (rect, horizontalAmount, verticalAmount) { + rect.x += horizontalAmount; + rect.y += verticalAmount; + rect.width -= horizontalAmount * 2; + rect.height -= verticalAmount * 2; + }; return RectangleExt; }()); es.RectangleExt = RectangleExt; })(es || (es = {})); var es; +(function (es) { + var SubpixelNumber = (function () { + function SubpixelNumber() { + } + SubpixelNumber.prototype.update = function (amount) { + this.remainder += amount; + var motion = Math.trunc(this.remainder); + this.remainder -= motion; + return motion; + }; + SubpixelNumber.prototype.reset = function () { + this.remainder = 0; + }; + return SubpixelNumber; + }()); + es.SubpixelNumber = SubpixelNumber; +})(es || (es = {})); +var es; (function (es) { var Triangulator = (function () { function Triangulator() { diff --git a/source/bin/framework.min.js b/source/bin/framework.min.js index 91a7edf2..0b6d4509 100644 --- a/source/bin/framework.min.js +++ b/source/bin/framework.min.js @@ -1 +1 @@ -window.es={},window.__extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}();var transform,__awaiter=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{c(i.next(t))}catch(t){o(t)}}function a(t){try{c(i.throw(t))}catch(t){o(t)}}function c(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}c((i=i.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=(r=s.trys).length>0&&r[r.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]-1}(this,t)},Array.prototype.firstOrDefault=function(t){return function(t,e){var n=t.findIndex(e);return-1==n?null:t[n]}(this,t)},Array.prototype.find=function(t){return function(t,e){return t.firstOrDefault(e)}(this,t)},Array.prototype.where=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(n,i,r){return e.call(arguments[2],i,r,t)&&n.push(i),n},[]);for(var n=[],i=0,r=t.length;i=0&&t.splice(n,1)}while(n>=0)}(this,t)},Array.prototype.remove=function(t){return function(t,e){var n=t.findIndex(function(t){return t===e});return n>=0&&(t.splice(n,1),!0)}(this,t)},Array.prototype.removeAt=function(t){return function(t,e){t.splice(e,1)}(this,t)},Array.prototype.removeRange=function(t,e){return function(t,e,n){t.splice(e,n)}(this,t,e)},Array.prototype.select=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(n,i,r){return n.push(e.call(arguments[2],i,r,t)),n},[]);for(var n=[],i=0,r=t.length;io?1:-1}),t}(this,t,e)},Array.prototype.orderByDescending=function(t,e){return function(t,e,n){return t.sort(function(t,i){var r=e(t),o=e(i);return n?-n(r,o):r0;){if("break"===u())break}return s?this.recontructPath(a,i,r):null},e.recontructPath=function(t,e,n){var i=[],r=n;for(i.push(n);r!=e;)r=this.getKey(t,r),i.push(r);return i.reverse(),i},e.hasKey=function(t,e){for(var n,i=t.keys();!(n=i.next()).done;)if(JSON.stringify(n.value)==JSON.stringify(e))return!0;return!1},e.getKey=function(t,e){for(var n,i,r=t.keys(),o=t.values();n=r.next(),i=o.next(),!n.done;)if(JSON.stringify(n.value)==JSON.stringify(e))return i.value;return null},e}();t.AStarPathfinder=e;var n=function(t){function e(e){var n=t.call(this)||this;return n.data=e,n}return __extends(e,t),e}(t.PriorityQueueNode);t.AStarNode=n}(es||(es={})),function(t){var e=function(){function e(e,n){this.dirs=[new t.Vector2(1,0),new t.Vector2(0,-1),new t.Vector2(-1,0),new t.Vector2(0,1)],this.walls=[],this.weightedNodes=[],this.defaultWeight=1,this.weightedNodeWeight=5,this._neighbors=new Array(4),this._width=e,this._height=n}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x=this._nodes.length?(console.error("node.QueueIndex has been corrupted. Did you change it manually? Or add this node to another queue?"),!1):this._nodes[t.queueIndex]==t:(console.error("node cannot be null"),!1)},t.prototype.enqueue=function(t,e){t.priority=e,this._numNodes++,this._nodes[this._numNodes]=t,t.queueIndex=this._numNodes,t.insertionIndex=this._numNodesEverEnqueued++,this.cascadeUp(this._nodes[this._numNodes])},t.prototype.dequeue=function(){var t=this._nodes[1];return this.remove(t),t},t.prototype.remove=function(t){if(t.queueIndex==this._numNodes)return this._nodes[this._numNodes]=null,void this._numNodes--;var e=this._nodes[this._numNodes];this.swap(t,e),delete this._nodes[this._numNodes],this._numNodes--,this.onNodeUpdated(e)},t.prototype.isValidQueue=function(){for(var t=1;t0&&this.hasHigherPriority(t,n)?this.cascadeUp(t):this.cascadeDown(t)},t.prototype.cascadeDown=function(t){for(var e,n=t.queueIndex;;){e=t;var i=2*n;if(i>this._numNodes){t.queueIndex=n,this._nodes[n]=t;break}var r=this._nodes[i];this.hasHigherPriority(r,e)&&(e=r);var o=i+1;if(o<=this._numNodes){var s=this._nodes[o];this.hasHigherPriority(s,e)&&(e=s)}if(e==t){t.queueIndex=n,this._nodes[n]=t;break}this._nodes[n]=e;var a=e.queueIndex;e.queueIndex=n,n=a}},t.prototype.cascadeUp=function(t){for(var e=Math.floor(t.queueIndex/2);e>=1;){var n=this._nodes[e];if(this.hasHigherPriority(n,t))break;this.swap(t,n),e=Math.floor(t.queueIndex/2)}},t.prototype.swap=function(t,e){this._nodes[t.queueIndex]=e,this._nodes[e.queueIndex]=t;var n=t.queueIndex;t.queueIndex=e.queueIndex,e.queueIndex=n},t.prototype.hasHigherPriority=function(t,e){return t.priority0;){if("break"===c())break}return o?t.AStarPathfinder.recontructPath(a,n,i):null},e.hasKey=function(t,e){for(var n,i=t.keys();!(n=i.next()).done;)if(JSON.stringify(n.value)==JSON.stringify(e))return!0;return!1},e}();t.BreadthFirstPathfinder=e}(es||(es={})),function(t){var e=function(){function t(){this.edges=new Map}return t.prototype.addEdgesForNode=function(t,e){return this.edges.set(t,e),this},t.prototype.getNeighbors=function(t){return this.edges.get(t)},t}();t.UnweightedGraph=e}(es||(es={})),function(t){var e=function(){function e(t,e){this.x=0,this.y=0,this.x=t||0,this.y=null!=e?e:this.x}return Object.defineProperty(e,"zero",{get:function(){return e.zeroVector2},enumerable:!0,configurable:!0}),Object.defineProperty(e,"one",{get:function(){return e.unitVector2},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitX",{get:function(){return e.unitXVector},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitY",{get:function(){return e.unitYVector},enumerable:!0,configurable:!0}),e.add=function(t,n){var i=new e(0,0);return i.x=t.x+n.x,i.y=t.y+n.y,i},e.divide=function(t,n){var i=new e(0,0);return i.x=t.x/n.x,i.y=t.y/n.y,i},e.multiply=function(t,n){var i=new e(0,0);return i.x=t.x*n.x,i.y=t.y*n.y,i},e.subtract=function(t,n){var i=new e(0,0);return i.x=t.x-n.x,i.y=t.y-n.y,i},e.normalize=function(t){var e=1/Math.sqrt(t.x*t.x+t.y*t.y);return t.x*=e,t.y*=e,t},e.dot=function(t,e){return t.x*e.x+t.y*e.y},e.distanceSquared=function(t,e){var n=t.x-e.x,i=t.y-e.y;return n*n+i*i},e.clamp=function(n,i,r){return new e(t.MathHelper.clamp(n.x,i.x,r.x),t.MathHelper.clamp(n.y,i.y,r.y))},e.lerp=function(n,i,r){return new e(t.MathHelper.lerp(n.x,i.x,r),t.MathHelper.lerp(n.y,i.y,r))},e.transform=function(t,n){return new e(t.x*n.m11+t.y*n.m21+n.m31,t.x*n.m12+t.y*n.m22+n.m32)},e.distance=function(t,e){var n=t.x-e.x,i=t.y-e.y;return Math.sqrt(n*n+i*i)},e.angle=function(n,i){return n=e.normalize(n),i=e.normalize(i),Math.acos(t.MathHelper.clamp(e.dot(n,i),-1,1))*t.MathHelper.Rad2Deg},e.negate=function(t){var n=new e;return n.x=-t.x,n.y=-t.y,n},e.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this},e.prototype.divide=function(t){return this.x/=t.x,this.y/=t.y,this},e.prototype.multiply=function(t){return this.x*=t.x,this.y*=t.y,this},e.prototype.subtract=function(t){return this.x-=t.x,this.y-=t.y,this},e.prototype.normalize=function(){var t=1/Math.sqrt(this.x*this.x+this.y*this.y);return this.x*=t,this.y*=t,this},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},e.prototype.round=function(){return new e(Math.round(this.x),Math.round(this.y))},e.prototype.equals=function(t){return t.x==this.x&&t.y==this.y},e.unitYVector=new e(0,1),e.unitXVector=new e(1,0),e.unitVector2=new e(1,1),e.zeroVector2=new e(0,0),e}();t.Vector2=e}(es||(es={})),function(t){var e=function(){function e(t,n,i){void 0===i&&(i=!1),this.walls=[],this._neighbors=new Array(4),this._width=t,this._hegiht=n,this._dirs=i?e.COMPASS_DIRS:e.CARDINAL_DIRS}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x0;){if("break"===u())break}return s?this.recontructPath(a,i,r):null},n.recontructPath=function(t,e,n){var i=[],r=n;for(i.push(n);r!=e;)r=this.getKey(t,r),i.push(r);return i.reverse(),i},n.hasKey=function(t,e){for(var n,i=t.keys();!(n=i.next()).done;)if(JSON.stringify(n.value)==JSON.stringify(e))return!0;return!1},n.getKey=function(t,e){for(var n,i,r=t.keys(),o=t.values();n=r.next(),i=o.next(),!n.done;)if(JSON.stringify(n.value)==JSON.stringify(e))return i.value;return null},n}();t.WeightedPathfinder=n}(es||(es={})),function(t){var e=function(){function e(){}return e.drawHollowRect=function(e,n,i){void 0===i&&(i=0),this._debugDrawItems.push(new t.DebugDrawItem(e,n,i))},e.render=function(){if(this._debugDrawItems.length>0){var e=new egret.Shape;t.Core.scene&&t.Core.scene.addChild(e);for(var n=this._debugDrawItems.length-1;n>=0;n--){this._debugDrawItems[n].draw(e)&&this._debugDrawItems.removeAt(n)}}},e._debugDrawItems=[],e}();t.Debug=e}(es||(es={})),function(t){var e=function(){function t(){}return t.verletParticle=14431326,t.verletConstraintEdge=4406838,t}();t.DebugDefaults=e}(es||(es={})),function(t){var e;!function(t){t[t.line=0]="line",t[t.hollowRectangle=1]="hollowRectangle",t[t.pixel=2]="pixel",t[t.text=3]="text"}(e=t.DebugDrawType||(t.DebugDrawType={}));var n=function(){function n(t,n,i){this.rectangle=t,this.color=n,this.duration=i,this.drawType=e.hollowRectangle}return n.prototype.draw=function(n){switch(this.drawType){case e.line:t.DrawUtils.drawLine(n,this.start,this.end,this.color);break;case e.hollowRectangle:t.DrawUtils.drawHollowRect(n,this.rectangle,this.color);break;case e.pixel:t.DrawUtils.drawPixel(n,new t.Vector2(this.x,this.y),this.color,this.size);break;case e.text:}return this.duration-=t.Time.deltaTime,this.duration<0},n}();t.DebugDrawItem=n}(es||(es={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateInterval=1,e._enabled=!0,e._updateOrder=0,e}return __extends(e,t),Object.defineProperty(e.prototype,"transform",{get:function(){return this.entity.transform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this.entity?this.entity.enabled&&this._enabled:this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"updateOrder",{get:function(){return this._updateOrder},set:function(t){this.setUpdateOrder(t)},enumerable:!0,configurable:!0}),e.prototype.initialize=function(){},e.prototype.onAddedToEntity=function(){},e.prototype.onRemovedFromEntity=function(){},e.prototype.onEntityTransformChanged=function(t){},e.prototype.debugRender=function(){},e.prototype.onEnabled=function(){},e.prototype.onDisabled=function(){},e.prototype.update=function(){},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled()),this},e.prototype.setUpdateOrder=function(t){return this._updateOrder!=t&&(this._updateOrder=t),this},e.prototype.clone=function(){var t=ObjectUtils.clone(this);return t.entity=null,t},e}(egret.HashObject);t.Component=e}(es||(es={})),function(t){var e=function(e){function n(){var i=e.call(this)||this;return i._globalManagers=[],n._instance=i,n.emitter=new t.Emitter,n.content=new t.ContentManager,i.addEventListener(egret.Event.ADDED_TO_STAGE,i.onAddToStage,i),i}return __extends(n,e),Object.defineProperty(n,"Instance",{get:function(){return this._instance},enumerable:!0,configurable:!0}),Object.defineProperty(n,"scene",{get:function(){return this._instance?this._instance._scene:null},set:function(t){t?null==this._instance._scene?(this._instance._scene=t,this._instance.addChild(t),this._instance._scene.begin(),n.Instance.onSceneChanged()):this._instance._nextScene=t:console.error("场景不能为空")},enumerable:!0,configurable:!0}),n.startSceneTransition=function(t){if(!this._instance._sceneTransition)return this._instance._sceneTransition=t,t;console.warn("在前一个场景完成之前,不能开始一个新的场景转换。")},n.registerGlobalManager=function(t){this._instance._globalManagers.push(t),t.enabled=!0},n.unregisterGlobalManager=function(t){this._instance._globalManagers.remove(t),t.enabled=!1},n.getGlobalManager=function(t){for(var e=0;e=0;e--)this._globalManagers[e].enabled&&this._globalManagers[e].update();return this._sceneTransition&&(!this._sceneTransition||this._sceneTransition.loadsNewScene&&!this._sceneTransition.isNewSceneLoaded)||this._scene.update(),this._nextScene?(this.removeChild(this._scene),this._scene.end(),this._scene=this._nextScene,this._nextScene=null,this.onSceneChanged(),this.addChild(this._scene),[4,this._scene.begin()]):[3,2];case 1:n.sent(),n.label=2;case 2:return[4,this.draw()];case 3:return n.sent(),[2]}})})},n.prototype.onAddToStage=function(){n.graphicsDevice=new t.GraphicsDevice,this.addEventListener(egret.Event.RESIZE,this.onGraphicsDeviceReset,this),this.addEventListener(egret.StageOrientationEvent.ORIENTATION_CHANGE,this.onOrientationChanged,this),this.addEventListener(egret.Event.ENTER_FRAME,this.update,this),t.Input.initialize(),this.initialize()},n}(egret.DisplayObjectContainer);t.Core=e}(es||(es={})),function(t){!function(t){t[t.GraphicsDeviceReset=0]="GraphicsDeviceReset",t[t.SceneChanged=1]="SceneChanged",t[t.OrientationChanged=2]="OrientationChanged"}(t.CoreEvents||(t.CoreEvents={}))}(es||(es={})),function(t){var e=function(){function e(n){this.updateInterval=1,this._tag=0,this._enabled=!0,this._updateOrder=0,this.components=new t.ComponentList(this),this.transform=new t.Transform(this),this.name=n,this.id=e._idGenerator++,this.componentBits=new t.BitSet}return Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this._isDestroyed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tag",{get:function(){return this._tag},set:function(t){this.setTag(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"updateOrder",{get:function(){return this._updateOrder},set:function(t){this.setUpdateOrder(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this.transform.parent},set:function(t){this.transform.setParent(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"childCount",{get:function(){return this.transform.childCount},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this.transform.position},set:function(t){this.transform.setPosition(t.x,t.y)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localPosition",{get:function(){return this.transform.localPosition},set:function(t){this.transform.setLocalPosition(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotation",{get:function(){return this.transform.rotation},set:function(t){this.transform.setRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotationDegrees",{get:function(){return this.transform.rotationDegrees},set:function(t){this.transform.setRotationDegrees(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localRotation",{get:function(){return this.transform.localRotation},set:function(t){this.transform.setLocalRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localRotationDegrees",{get:function(){return this.transform.localRotationDegrees},set:function(t){this.transform.setLocalRotationDegrees(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scale",{get:function(){return this.transform.scale},set:function(t){this.transform.setScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localScale",{get:function(){return this.transform.localScale},set:function(t){this.transform.setLocalScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"worldInverseTransform",{get:function(){return this.transform.worldInverseTransform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localToWorldTransform",{get:function(){return this.transform.localToWorldTransform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"worldToLocalTransform",{get:function(){return this.transform.worldToLocalTransform},enumerable:!0,configurable:!0}),e.prototype.onTransformChanged=function(t){this.components.onEntityTransformChanged(t)},e.prototype.setTag=function(t){return this._tag!=t&&(this.scene&&this.scene.entities.removeFromTagList(this),this._tag=t,this.scene&&this.scene.entities.addToTagList(this)),this},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.components.onEntityEnabled():this.components.onEntityDisabled()),this},e.prototype.setUpdateOrder=function(t){if(this._updateOrder!=t)return this._updateOrder=t,this.scene&&(this.scene.entities.markEntityListUnsorted(),this.scene.entities.markTagUnsorted(this.tag)),this},e.prototype.destroy=function(){this._isDestroyed=!0,this.scene.entities.remove(this),this.transform.parent=null;for(var t=this.transform.childCount-1;t>=0;t--){this.transform.getChild(t).entity.destroy()}},e.prototype.detachFromScene=function(){this.scene.entities.remove(this),this.components.deregisterAllComponents();for(var t=0;t=0;t--)this._sceneComponents[t].enabled&&this._sceneComponents[t].update();this.entityProcessors&&this.entityProcessors.update(),this.entities.update(),this.entityProcessors&&this.entityProcessors.lateUpdate(),this.renderableComponents.updateList()},n.prototype.render=function(){if(0!=this._renderers.length)for(var t=0;te.x?-1:1,i=t.Vector2.normalize(t.Vector2.subtract(this.position,e));this.rotation=n*Math.acos(t.Vector2.dot(i,t.Vector2.unitY))},i.prototype.setLocalRotation=function(t){return this._localRotation=t,this._localDirty=this._positionDirty=this._localPositionDirty=this._localRotationDirty=this._localScaleDirty=!0,this.setDirty(e.rotationDirty),this},i.prototype.setLocalRotationDegrees=function(e){return this.setLocalRotation(t.MathHelper.toRadians(e))},i.prototype.setScale=function(e){return this._scale=e,this.parent?this.localScale=t.Vector2.divide(e,this.parent._scale):this.localScale=e,this},i.prototype.setLocalScale=function(t){return this._localScale=t,this._localDirty=this._positionDirty=this._localScaleDirty=!0,this.setDirty(e.scaleDirty),this},i.prototype.roundPosition=function(){this.position=this._position.round()},i.prototype.updateTransform=function(){this.hierarchyDirty!=e.clean&&(this.parent&&this.parent.updateTransform(),this._localDirty&&(this._localPositionDirty&&(this._translationMatrix=t.Matrix2D.create().translate(this._localPosition.x,this._localPosition.y),this._localPositionDirty=!1),this._localRotationDirty&&(this._rotationMatrix=t.Matrix2D.create().rotate(this._localRotation),this._localRotationDirty=!1),this._localScaleDirty&&(this._scaleMatrix=t.Matrix2D.create().scale(this._localScale.x,this._localScale.y),this._localScaleDirty=!1),this._localTransform=this._scaleMatrix.multiply(this._rotationMatrix),this._localTransform=this._localTransform.multiply(this._translationMatrix),this.parent||(this._worldTransform=this._localTransform,this._rotation=this._localRotation,this._scale=this._localScale,this._worldInverseDirty=!0),this._localDirty=!1),this.parent&&(this._worldTransform=this._localTransform.multiply(this.parent._worldTransform),this._rotation=this._localRotation+this.parent._rotation,this._scale=t.Vector2.multiply(this.parent._scale,this._localScale),this._worldInverseDirty=!0),this._worldToLocalDirty=!0,this._positionDirty=!0,this.hierarchyDirty=e.clean)},i.prototype.setDirty=function(e){if(0==(this.hierarchyDirty&e)){switch(this.hierarchyDirty|=e,e){case t.DirtyType.positionDirty:this.entity.onTransformChanged(transform.Component.position);break;case t.DirtyType.rotationDirty:this.entity.onTransformChanged(transform.Component.rotation);break;case t.DirtyType.scaleDirty:this.entity.onTransformChanged(transform.Component.scale)}this._children||(this._children=[]);for(var n=0;nt&&(this._zoom=t),this._maximumZoom=t,this;console.error("maximumZoom must be greater than zero")},r.prototype.onEntityTransformChanged=function(t){this._areMatrixedDirty=!0},r.prototype.zoomIn=function(t){this.zoom+=t},r.prototype.zoomOut=function(t){this.zoom-=t},r.prototype.worldToScreenPoint=function(e){return this.updateMatrixes(),e=t.Vector2.transform(e,this._transformMatrix)},r.prototype.screenToWorldPoint=function(e){return this.updateMatrixes(),e=t.Vector2.transform(e,this._inverseTransformMatrix)},r.prototype.mouseToWorldPoint=function(){return this.screenToWorldPoint(t.Input.touchPosition)},r.prototype.onAddedToEntity=function(){this.follow(this._targetEntity,this._cameraStyle)},r.prototype.update=function(){var e=t.Vector2.multiply(new t.Vector2(this.bounds.width,this.bounds.height),new t.Vector2(.5));this._worldSpaceDeadZone.x=this.position.x-e.x*t.Core.scene.scaleX+this.deadzone.x+this.focusOffset.x,this._worldSpaceDeadZone.y=this.position.y-e.y*t.Core.scene.scaleY+this.deadzone.y+this.focusOffset.y,this._worldSpaceDeadZone.width=this.deadzone.width,this._worldSpaceDeadZone.height=this.deadzone.height,this._targetEntity&&this.updateFollow(),this.position=t.Vector2.lerp(this.position,t.Vector2.add(this.position,this._desiredPositionDelta),this.followLerp),this.entity.transform.roundPosition(),this.mapLockEnabled&&(this.position=this.clampToMapSize(this.position),this.entity.transform.roundPosition())},r.prototype.clampToMapSize=function(e){var n=t.Vector2.multiply(new t.Vector2(this.bounds.width,this.bounds.height),new t.Vector2(.5)).add(new t.Vector2(this.mapSize.x,this.mapSize.y)),i=new t.Vector2(this.mapSize.width-n.x,this.mapSize.height-n.y);return t.Vector2.clamp(e,n,i)},r.prototype.updateFollow=function(){if(this._desiredPositionDelta.x=this._desiredPositionDelta.y=0,this._cameraStyle==e.lockOn){var n=this._targetEntity.transform.position.x,i=this._targetEntity.transform.position.y;this._worldSpaceDeadZone.x>n?this._desiredPositionDelta.x=n-this._worldSpaceDeadZone.x:this._worldSpaceDeadZone.xi&&(this._desiredPositionDelta.y=i-this._worldSpaceDeadZone.y)}else{if(!this._targetCollider&&(this._targetCollider=this._targetEntity.getComponent(t.Collider),!this._targetCollider))return;var r=this._targetEntity.getComponent(t.Collider).bounds;this._worldSpaceDeadZone.containsRect(r)||(this._worldSpaceDeadZone.left>r.left?this._desiredPositionDelta.x=r.left-this._worldSpaceDeadZone.left:this._worldSpaceDeadZone.rightr.top&&(this._desiredPositionDelta.y=r.top-this._worldSpaceDeadZone.top))}},r.prototype.follow=function(n,i){switch(void 0===i&&(i=e.cameraWindow),this._targetEntity=n,this._cameraStyle=i,this._cameraStyle){case e.cameraWindow:var r=this.bounds.width/6,o=this.bounds.height/3;this.deadzone=new t.Rectangle((this.bounds.width-r)/2,(this.bounds.height-o)/2,r,o);break;case e.lockOn:this.deadzone=new t.Rectangle(this.bounds.width/2,this.bounds.height/2,10,10)}},r.prototype.setCenteredDeadzone=function(e,n){this.deadzone=new t.Rectangle((this.bounds.width-e)/2,(this.bounds.height-n)/2,e,n)},r.prototype.updateMatrixes=function(){var e;this._areMatrixedDirty&&(this._transformMatrix=t.Matrix2D.create().translate(-this.entity.transform.position.x,-this.entity.transform.position.y),1!=this._zoom&&(e=t.Matrix2D.create().scale(this._zoom,this._zoom),this._transformMatrix=this._transformMatrix.multiply(e)),0!=this.entity.transform.rotation&&(e=t.Matrix2D.create().rotate(this.entity.transform.rotation),this._transformMatrix=this._transformMatrix.multiply(e)),e=t.Matrix2D.create().translate(this._origin.x,this._origin.y),this._transformMatrix=this._transformMatrix.multiply(e),this._inverseTransformMatrix=this._transformMatrix.invert(),this._areBoundsDirty=!0,this._areMatrixedDirty=!1)},r}(t.Component);t.Camera=i}(es||(es={})),function(t){var e=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n._shakeDirection=t.Vector2.zero,n._shakeOffset=t.Vector2.zero,n._shakeIntensity=0,n._shakeDegredation=.95,n}return __extends(n,e),n.prototype.shake=function(e,n,i){void 0===e&&(e=15),void 0===n&&(n=.9),void 0===i&&(i=t.Vector2.zero),this.enabled=!0,this._shakeIntensity=1)&&(n=.95),this._shakeDegredation=n)},n.prototype.update=function(){Math.abs(this._shakeIntensity)>0&&(this._shakeOffset=this._shakeDirection,0!=this._shakeOffset.x||0!=this._shakeOffset.y?this._shakeOffset.normalize():(this._shakeOffset.x=this._shakeOffset.x+Math.random()-.5,this._shakeOffset.y=this._shakeOffset.y+Math.random()-.5),this._shakeOffset.multiply(new t.Vector2(this._shakeIntensity)),this._shakeIntensity*=-this._shakeDegredation,Math.abs(this._shakeIntensity)<=.01&&(this._shakeIntensity=0,this.enabled=!1)),this.entity.scene.camera.position.add(this._shakeOffset)},n}(t.Component);t.CameraShake=e}(es||(es={})),function(t){var e=function(){function t(t){this._type=t,this._cache=[]}return t.prototype.obtain=function(){try{return this._cache.length>0?this._cache.shift():new this._type}catch(t){throw new Error(this._type+t)}},t.prototype.free=function(t){t.reset(),this._cache.push(t)},t}();t.ComponentPool=e}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.compare=function(t,e){return t.updateOrder-e.updateOrder},t}();t.IUpdatableComparer=e}(es||(es={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(t.Component);t.PooledComponent=e}(es||(es={})),function(t){var e=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n.displayObject=new egret.DisplayObject,n.color=0,n._areBoundsDirty=!0,n._localOffset=t.Vector2.zero,n._renderLayer=0,n._bounds=new t.Rectangle,n}return __extends(n,e),Object.defineProperty(n.prototype,"width",{get:function(){return this.bounds.width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return this.bounds.height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"localOffset",{get:function(){return this._localOffset},set:function(t){this.setLocalOffset(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"renderLayer",{get:function(){return this._renderLayer},set:function(t){this.setRenderLayer(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"bounds",{get:function(){return this._areBoundsDirty&&(this._bounds.calculateBounds(this.entity.transform.position,this._localOffset,t.Vector2.zero,this.entity.transform.scale,this.entity.transform.rotation,this.width,this.height),this._areBoundsDirty=!1),this._bounds},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isVisible",{get:function(){return this._isVisible},set:function(t){this._isVisible!=t&&(this._isVisible=t,this._isVisible?this.onBecameVisible():this.onBecameInvisible())},enumerable:!0,configurable:!0}),n.prototype.onEntityTransformChanged=function(t){this._areBoundsDirty=!0},n.prototype.isVisibleFromCamera=function(t){return this.isVisible=t.bounds.intersects(this.bounds),this.isVisible},n.prototype.setRenderLayer=function(t){if(t!=this._renderLayer){var e=this._renderLayer;this._renderLayer=t,this.entity&&this.entity.scene&&this.entity.scene.renderableComponents.updateRenderableRenderLayer(this,e,this._renderLayer)}return this},n.prototype.setColor=function(t){return this.color=t,this},n.prototype.setLocalOffset=function(t){return this._localOffset!=t&&(this._localOffset=t),this},n.prototype.sync=function(t){this.displayObject.x=this.entity.position.x+this.localOffset.x-t.position.x+t.origin.x,this.displayObject.y=this.entity.position.y+this.localOffset.y-t.position.y+t.origin.y,this.displayObject.scaleX=this.entity.scale.x,this.displayObject.scaleY=this.entity.scale.y,this.displayObject.rotation=this.entity.rotation},n.prototype.toString=function(){return"[RenderableComponent] renderLayer: "+this.renderLayer},n.prototype.onBecameVisible=function(){this.displayObject.visible=this.isVisible},n.prototype.onBecameInvisible=function(){this.displayObject.visible=this.isVisible},n}(t.Component);t.RenderableComponent=e}(es||(es={})),function(t){var e=function(){function e(){this.updateOrder=0,this._enabled=!0}return Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),e.prototype.onEnabled=function(){},e.prototype.onDisabled=function(){},e.prototype.onRemovedFromScene=function(){},e.prototype.update=function(){},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled),this},e.prototype.setUpdateOrder=function(e){return this.updateOrder!=e&&(this.updateOrder=e,t.Core.scene._sceneComponents.sort(this.compareTo)),this},e.prototype.compareTo=function(t){return this.updateOrder-t.updateOrder},e}();t.SceneComponent=e}(es||(es={})),function(t){var e=egret.Bitmap,n=function(n){function i(e){void 0===e&&(e=null);var i=n.call(this)||this;return e instanceof t.Sprite?i.setSprite(e):e instanceof egret.Texture&&i.setSprite(new t.Sprite(e)),i}return __extends(i,n),Object.defineProperty(i.prototype,"bounds",{get:function(){return this._areBoundsDirty&&this._sprite&&(this._bounds.calculateBounds(this.entity.transform.position,this._localOffset,this._origin,this.entity.transform.scale,this.entity.transform.rotation,this._sprite.sourceRect.width,this._sprite.sourceRect.height),this._areBoundsDirty=!1),this._bounds},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"originNormalized",{get:function(){return new t.Vector2(this._origin.x/this.width*this.entity.transform.scale.x,this._origin.y/this.height*this.entity.transform.scale.y)},set:function(e){this.setOrigin(new t.Vector2(e.x*this.width/this.entity.transform.scale.x,e.y*this.height/this.entity.transform.scale.y))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"origin",{get:function(){return this._origin},set:function(t){this.setOrigin(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"sprite",{get:function(){return this._sprite},set:function(t){this.setSprite(t)},enumerable:!0,configurable:!0}),i.prototype.setSprite=function(t){return this._sprite=t,this._sprite&&(this._origin=this._sprite.origin,this.displayObject.anchorOffsetX=this._origin.x,this.displayObject.anchorOffsetY=this._origin.y),this.displayObject=new e(t.texture2D),this},i.prototype.setOrigin=function(t){return this._origin!=t&&(this._origin=t,this.displayObject.anchorOffsetX=this._origin.x,this.displayObject.anchorOffsetY=this._origin.y,this._areBoundsDirty=!0),this},i.prototype.setOriginNormalized=function(e){return this.setOrigin(new t.Vector2(e.x*this.width/this.entity.transform.scale.x,e.y*this.height/this.entity.transform.scale.y)),this},i.prototype.render=function(t){this.sync(t),this.displayObject.x=this.entity.position.x+this.localOffset.x-t.position.x+t.origin.x,this.displayObject.y=this.entity.position.y+this.localOffset.y-t.position.y+t.origin.y},i}(t.RenderableComponent);t.SpriteRenderer=n}(es||(es={})),function(t){var e=egret.Bitmap,n=egret.RenderTexture,i=function(i){function r(e){var n=i.call(this,e)||this;return n._textureScale=t.Vector2.one,n._inverseTexScale=t.Vector2.one,n._gapX=0,n._gapY=0,n._sourceRect=e.sourceRect,n.displayObject.$fillMode=egret.BitmapFillMode.REPEAT,n}return __extends(r,i),Object.defineProperty(r.prototype,"bounds",{get:function(){return this._areBoundsDirty&&this._sprite&&(this._bounds.calculateBounds(this.entity.transform.position,this._localOffset,this._origin,this.entity.transform.scale,this.entity.transform.rotation,this.width,this.height),this._areBoundsDirty=!1),this._bounds},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scrollX",{get:function(){return this._sourceRect.x},set:function(t){this._sourceRect.x=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scrollY",{get:function(){return this._sourceRect.y},set:function(t){this._sourceRect.y=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"textureScale",{get:function(){return this._textureScale},set:function(e){this._textureScale=e,this._inverseTexScale=new t.Vector2(1/this._textureScale.x,1/this._textureScale.y),this._sourceRect.width=this._sprite.sourceRect.width*this._inverseTexScale.x,this._sourceRect.height=this._sprite.sourceRect.height*this._inverseTexScale.y},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"width",{get:function(){return this._sourceRect.width},set:function(t){this._areBoundsDirty=!0,this._sourceRect.width=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"height",{get:function(){return this._sourceRect.height},set:function(t){this._areBoundsDirty=!0,this._sourceRect.height=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"gapXY",{get:function(){return new t.Vector2(this._gapX,this._gapY)},set:function(t){this._gapX=t.x,this._gapY=t.y;var i=new n,r=this.sprite.sourceRect;r.x=0,r.y=0,r.width+=this._gapX,r.height+=this._gapY,i.drawToTexture(this.displayObject,r),this.displayObject?this.displayObject.texture=i:this.displayObject=new e(i)},enumerable:!0,configurable:!0}),r.prototype.setGapXY=function(t){return this.gapXY=t,this},r.prototype.render=function(t){i.prototype.render.call(this,t);var e=this.displayObject;e.width=this.width,e.height=this.height,e.scrollRect=this._sourceRect},r}(t.SpriteRenderer);t.TiledSpriteRenderer=i}(es||(es={})),function(t){var e=function(e){function n(t){var n=e.call(this,t)||this;return n.scrollSpeedX=15,n.scroolSpeedY=0,n._scrollX=0,n._scrollY=0,n._scrollWidth=0,n._scrollHeight=0,n._scrollWidth=n.width,n._scrollHeight=n.height,n}return __extends(n,e),Object.defineProperty(n.prototype,"textureScale",{get:function(){return this._textureScale},set:function(e){this._textureScale=e,this._inverseTexScale=new t.Vector2(1/this._textureScale.x,1/this._textureScale.y)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scrollWidth",{get:function(){return this._scrollWidth},set:function(t){this._scrollWidth=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scrollHeight",{get:function(){return this._scrollHeight},set:function(t){this._scrollHeight=t},enumerable:!0,configurable:!0}),n.prototype.update=function(){this.sprite&&(this._scrollX+=this.scrollSpeedX*t.Time.deltaTime,this._scrollY+=this.scroolSpeedY*t.Time.deltaTime,this._sourceRect.x=this._scrollX,this._sourceRect.y=this._scrollY,this._sourceRect.width=this._scrollWidth+Math.abs(this._scrollX),this._sourceRect.height=this._scrollHeight+Math.abs(this._scrollY))},n}(t.TiledSpriteRenderer);t.ScrollingSpriteRenderer=e}(es||(es={})),function(t){var e=function(){return function(e,n,i){void 0===n&&(n=new t.Rectangle(0,0,e.textureWidth,e.textureHeight)),void 0===i&&(i=n.getHalfSize()),this.uvs=new t.Rectangle,this.texture2D=e,this.sourceRect=n,this.center=new t.Vector2(.5*n.width,.5*n.height),this.origin=i;var r=1/e.textureWidth,o=1/e.textureHeight;this.uvs.x=n.x*r,this.uvs.y=n.y*o,this.uvs.width=n.width*r,this.uvs.height=n.height*o}}();t.Sprite=e}(es||(es={})),function(t){var e=function(){return function(t,e){this.sprites=t,this.frameRate=e}}();t.SpriteAnimation=e}(es||(es={})),function(t){var e,n;!function(t){t[t.loop=0]="loop",t[t.once=1]="once",t[t.clampForever=2]="clampForever",t[t.pingPong=3]="pingPong",t[t.pingPongOnce=4]="pingPongOnce"}(e=t.LoopMode||(t.LoopMode={})),function(t){t[t.none=0]="none",t[t.running=1]="running",t[t.paused=2]="paused",t[t.completed=3]="completed"}(n=t.State||(t.State={}));var i=function(i){function r(t){var e=i.call(this,t)||this;return e.speed=1,e.animationState=n.none,e._elapsedTime=0,e._animations=new Map,e}return __extends(r,i),Object.defineProperty(r.prototype,"isRunning",{get:function(){return this.animationState==n.running},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"animations",{get:function(){return this._animations},enumerable:!0,configurable:!0}),r.prototype.update=function(){if(this.animationState==n.running&&this.currentAnimation){var i=this.currentAnimation,r=1/(i.frameRate*this.speed),o=r*i.sprites.length;this._elapsedTime+=t.Time.deltaTime;var s=Math.abs(this._elapsedTime);if(this._loopMode==e.once&&s>o||this._loopMode==e.pingPongOnce&&s>2*o)return this.animationState=n.completed,this._elapsedTime=0,this.currentFrame=0,void(this.sprite=i.sprites[this.currentFrame]);var a=Math.floor(s/r),c=i.sprites.length;if(c>2&&(this._loopMode==e.pingPong||this._loopMode==e.pingPongOnce)){var h=c-1;this.currentFrame=h-Math.abs(h-a%(2*h))}else this.currentFrame=a%c;this.sprite=i.sprites[this.currentFrame]}},r.prototype.addAnimation=function(t,e){return!this.sprite&&e.sprites.length>0&&this.setSprite(e.sprites[0]),this._animations[t]=e,this},r.prototype.play=function(t,i){void 0===i&&(i=null),this.currentAnimation=this._animations[t],this.currentAnimationName=t,this.currentFrame=0,this.animationState=n.running,this.sprite=this.currentAnimation.sprites[0],this._elapsedTime=0,this._loopMode=i||e.loop},r.prototype.isAnimationActive=function(t){return this.currentAnimation&&this.currentAnimationName==t},r.prototype.pause=function(){this.animationState=n.paused},r.prototype.unPause=function(){this.animationState=n.running},r.prototype.stop=function(){this.currentAnimation=null,this.currentAnimationName=null,this.currentFrame=0,this.animationState=n.none},r}(t.SpriteRenderer);t.SpriteAnimator=i}(es||(es={})),function(t){var e=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.onAddedToEntity=function(){this._triggerHelper=new t.ColliderTriggerHelper(this.entity)},n.prototype.calculateMovement=function(e,n){if(!this.entity.getComponent(t.Collider)||!this._triggerHelper)return!1;for(var i=this.entity.getComponents(t.Collider),r=0;r>6;0!=(e&t.LONG_MASK)&&n++,this._bits=new Array(n)}return t.prototype.and=function(t){for(var e,n=Math.min(this._bits.length,t._bits.length),i=0;i=0;)this._bits[e]&=~t._bits[e]},t.prototype.cardinality=function(){for(var t=0,e=this._bits.length-1;e>=0;e--){var n=this._bits[e];if(0!=n)if(-1!=n){var i=((n=((n=(n>>1&0x5555555555555400)+(0x5555555555555400&n))>>2&0x3333333333333400)+(0x3333333333333400&n))>>32)+n;t+=((i=((i=(i>>4&252645135)+(252645135&i))>>8&16711935)+(16711935&i))>>16&65535)+(65535&i)}else t+=64}return t},t.prototype.clear=function(t){if(null!=t){var e=t>>6;this.ensure(e),this._bits[e]&=~(1<>6;return!(e>=this._bits.length)&&0!=(this._bits[e]&1<=0;)if(0!=(this._bits[e]&t._bits[e]))return!0;return!1},t.prototype.isEmpty=function(){for(var t=this._bits.length-1;t>=0;t--)if(this._bits[t])return!1;return!0},t.prototype.nextSetBit=function(t){for(var e=t>>6,n=1<>6;this.ensure(n),this._bits[n]|=1<=this._bits.length){var e=new Number[t+1];e=this._bits.copyWithin(0,0,this._bits.length),this._bits=e}},t.LONG_MASK=63,t}();t.BitSet=e}(es||(es={})),function(t){var e=function(){function e(t){this._components=[],this._componentsToAdd=[],this._componentsToRemove=[],this._tempBufferList=[],this._entity=t}return Object.defineProperty(e.prototype,"count",{get:function(){return this._components.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buffer",{get:function(){return this._components},enumerable:!0,configurable:!0}),e.prototype.markEntityListUnsorted=function(){this._isComponentListUnsorted=!0},e.prototype.add=function(t){this._componentsToAdd.push(t)},e.prototype.remove=function(t){this._componentsToRemove.contains(t)&&console.warn("You are trying to remove a Component ("+t+") that you already removed"),this._componentsToAdd.contains(t)?this._componentsToAdd.remove(t):this._componentsToRemove.push(t)},e.prototype.removeAllComponents=function(){for(var t=0;t0){for(var n=0;n0){n=0;for(var i=this._componentsToAdd.length;n0){var e=this._entitiesToRemove;this._entitiesToRemove=this._tempEntityList,this._tempEntityList=e,this._tempEntityList.forEach(function(e){t.removeFromTagList(e),t._entities.remove(e),e.onRemovedFromScene(),e.scene=null,t.scene.entityProcessors.onEntityRemoved(e)}),this._tempEntityList.length=0}if(this._entitiesToAdded.length>0){e=this._entitiesToAdded;this._entitiesToAdded=this._tempEntityList,this._tempEntityList=e,this._tempEntityList.forEach(function(e){t._entities.contains(e)||(t._entities.push(e),e.scene=t.scene,t.addToTagList(e),t.scene.entityProcessors.onEntityAdded(e))}),this._tempEntityList.forEach(function(t){return t.onAddedToScene()}),this._tempEntityList.length=0,this._isEntityListUnsorted=!0}this._isEntityListUnsorted&&(this._entities.sort(),this._isEntityListUnsorted=!1),this._unsortedTags.length>0&&(this._unsortedTags.forEach(function(e){t._entityDict.get(e).sort()}),this._unsortedTags.length=0)},e.prototype.findEntity=function(t){for(var e=0;e=0;e=this.allSet.nextSetBit(e+1))if(!t.componentBits.get(e))return!1;return!(!this.exclusionSet.isEmpty()&&this.exclusionSet.intersects(t.componentBits))&&!(!this.oneSet.isEmpty()&&!this.oneSet.intersects(t.componentBits))},e.prototype.all=function(){for(var e=this,n=[],i=0;i0){for(var t=0,n=this._unsortedRenderLayers.length;t=e)return t;var i=!1;"-"==t.substr(0,1)&&(i=!0,t=t.substr(1));for(var r=e-n,o=0;o1?this.reverse(t.substring(1))+t.substring(0,1):t},t.cutOff=function(t,e,n,i){void 0===i&&(i=!0),e=Math.floor(e),n=Math.floor(n);var r=t.length;e>r&&(e=r);var o,s=e,a=e+n;return i?o=t.substring(0,s)+t.substr(a,r):(a=(s=r-1-e-n)+n,o=t.substring(0,s+1)+t.substr(a+1,r)),o},t.strReplace=function(t,e){for(var n=0,i=e.length;n",">",'"',""","'","'","®","®","©","©","™","™"],t}();!function(t){var e=function(){function e(){}return e.convertImageToCanvas=function(e,n){this.sharedCanvas||(this.sharedCanvas=egret.sys.createCanvas(),this.sharedContext=this.sharedCanvas.getContext("2d"));var i=e.$getTextureWidth(),r=e.$getTextureHeight();n||((n=egret.$TempRectangle).x=0,n.y=0,n.width=i,n.height=r),n.x=Math.min(n.x,i-1),n.y=Math.min(n.y,r-1),n.width=Math.min(n.width,i-n.x),n.height=Math.min(n.height,r-n.y);var o=Math.floor(n.width),s=Math.floor(n.height),a=this.sharedCanvas;if(a.style.width=o+"px",a.style.height=s+"px",this.sharedCanvas.width=o,this.sharedCanvas.height=s,"webgl"==egret.Capabilities.renderMode){var c=void 0;e.$renderBuffer?c=e:(egret.sys.systemRenderer.renderClear&&egret.sys.systemRenderer.renderClear(),(c=new egret.RenderTexture).drawToTexture(new egret.Bitmap(e)));for(var h=c.$renderBuffer.getPixels(n.x,n.y,o,s),u=0,l=0,p=0;p=0?"png":"jpg"});return wx.getFileSystemManager().saveFile({tempFilePath:o,filePath:wx.env.USER_DATA_PATH+"/"+n,success:function(t){}}),o},e.getPixel32=function(t,e,n){return egret.$warn(1041,"getPixel32","getPixels"),t.getPixels(e,n)},e.getPixels=function(t,e,n,i,r){if(void 0===i&&(i=1),void 0===r&&(r=1),"webgl"==egret.Capabilities.renderMode){var o=void 0;return t.$renderBuffer?o=t:(o=new egret.RenderTexture).drawToTexture(new egret.Bitmap(t)),o.$renderBuffer.getPixels(e,n,i,r)}try{this.convertImageToCanvas(t);return this.sharedContext.getImageData(e,n,i,r).data}catch(t){egret.$error(1039)}},e}();t.TextureUtils=e}(es||(es={})),function(t){var e=function(){function t(){}return t.update=function(t){var e=(t-this._lastTime)/1e3;this.deltaTime=e*this.timeScale,this.unscaledDeltaTime=e,this._timeSinceSceneLoad+=e,this.frameCount++,this._lastTime=t},t.sceneChanged=function(){this._timeSinceSceneLoad=0},t.checkEvery=function(t){return this._timeSinceSceneLoad/t>(this._timeSinceSceneLoad-this.deltaTime)/t},t.deltaTime=0,t.timeScale=1,t.frameCount=0,t._lastTime=0,t}();t.Time=e}(es||(es={}));var TimeUtils=function(){function t(){}return t.monthId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getFullYear(),n=t.getMonth()+1;return parseInt(e+(n<10?"0":"")+n)},t.dateId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getMonth()+1,n=e<10?"0":"",i=t.getDate(),r=i<10?"0":"";return parseInt(t.getFullYear()+n+e+r+i)},t.weekId=function(t,e){void 0===t&&(t=null),void 0===e&&(e=!0),t=t||new Date;var n=new Date;n.setTime(t.getTime()),n.setDate(1),n.setMonth(0);var i=n.getFullYear(),r=n.getDay();0==r&&(r=7);var o=!1;r<=4?(o=r>1,n.setDate(n.getDate()-(r-1))):n.setDate(n.getDate()+7-r+1);var s=this.diffDay(t,n,!1);if(s<0)return n.setDate(1),n.setMonth(0),n.setDate(n.getDate()-1),this.weekId(n,!1);var a=s/7,c=Math.floor(a)+1;if(53==c){n.setTime(t.getTime()),n.setDate(n.getDate()-1);var h=n.getDay();if(0==h&&(h=7),e&&(!o||h<4))return n.setFullYear(n.getFullYear()+1),n.setDate(1),n.setMonth(0),this.weekId(n,!1)}return parseInt(i+"00"+(c>9?"":"0")+c)},t.diffDay=function(t,e,n){void 0===n&&(n=!1);var i=(t.getTime()-e.getTime())/864e5;return n?Math.ceil(i):Math.floor(i)},t.getFirstDayOfWeek=function(t){var e=(t=t||new Date).getDay()||7;return new Date(t.getFullYear(),t.getMonth(),t.getDate()+1-e,0,0,0,0)},t.getFirstOfDay=function(t){return(t=t||new Date).setHours(0,0,0,0),t},t.getNextFirstOfDay=function(t){return new Date(this.getFirstOfDay(t).getTime()+864e5)},t.formatDate=function(t){var e=t.getFullYear(),n=t.getMonth()+1;n=n<10?"0"+n:n;var i=t.getDate();return e+"-"+n+"-"+(i=i<10?"0"+i:i)},t.formatDateTime=function(t){var e=t.getFullYear(),n=t.getMonth()+1;n=n<10?"0"+n:n;var i=t.getDate();i=i<10?"0"+i:i;var r=t.getHours(),o=t.getMinutes();o=o<10?"0"+o:o;var s=t.getSeconds();return e+"-"+n+"-"+i+" "+r+":"+o+":"+(s=s<10?"0"+s:s)},t.parseDate=function(t){var e=Date.parse(t);return isNaN(e)?new Date:new Date(Date.parse(t.replace(/-/g,"/")))},t.secondToTime=function(t,e,n){void 0===t&&(t=0),void 0===e&&(e=":"),void 0===n&&(n=!0);var i=Math.floor(t/3600),r=Math.floor(t%3600/60),o=Math.floor(t%3600%60),s=i.toString(),a=r.toString(),c=o.toString();return i<10&&(s="0"+s),r<10&&(a="0"+a),o<10&&(c="0"+c),n?s+e+a+e+c:a+e+c},t.timeToMillisecond=function(t,e){void 0===e&&(e=":");for(var n=t.split(e),i=0,r=n.length,o=0;o-1?this.os="iOS":i.indexOf("android")>-1&&(this.os="Android");var r=n.language;r=r.indexOf("zh")>-1?"zh-CN":"en-US",this.language=r}},e}(egret.Capabilities);t.GraphicsCapabilities=e}(es||(es={})),function(t){var e=function(){function e(){this.setup(),this.graphicsCapabilities=new t.GraphicsCapabilities,this.graphicsCapabilities.initialize(this)}return Object.defineProperty(e.prototype,"viewport",{get:function(){return this._viewport},enumerable:!0,configurable:!0}),e.prototype.setup=function(){this._viewport=new t.Viewport(0,0,t.Core._instance.stage.stageWidth,t.Core._instance.stage.stageHeight)},e}();t.GraphicsDevice=e}(es||(es={})),function(t){var e=function(){function e(t,e,n,i){this._x=t,this._y=e,this._width=n,this._height=i,this._minDepth=0,this._maxDepth=1}return Object.defineProperty(e.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"aspectRatio",{get:function(){return 0!=this._height&&0!=this._width?this._width/this._height:0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bounds",{get:function(){return new t.Rectangle(this._x,this._y,this._width,this._height)},set:function(t){this._x=t.x,this._y=t.y,this._width=t.width,this._height=t.height},enumerable:!0,configurable:!0}),e}();t.Viewport=e}(es||(es={})),function(t){var e=function(e){function n(){return e.call(this,t.PostProcessor.default_vert,n.blur_frag,{screenWidth:t.Core.graphicsDevice.viewport.width,screenHeight:t.Core.graphicsDevice.viewport.height})||this}return __extends(n,e),n.blur_frag="precision mediump float;\nuniform sampler2D uSampler;\nuniform float screenWidth;\nuniform float screenHeight;\nfloat normpdf(in float x, in float sigma)\n{\nreturn 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;\n}\nvoid main()\n{\nvec3 c = texture2D(uSampler, gl_FragCoord.xy / vec2(screenWidth, screenHeight).xy).rgb;\nconst int mSize = 11;\nconst int kSize = (mSize - 1)/2;\nfloat kernel[mSize];\nvec3 final_colour = vec3(0.0);\nfloat sigma = 7.0;\nfloat z = 0.0;\nfor (int j = 0; j <= kSize; ++j)\n{\nkernel[kSize+j] = kernel[kSize-j] = normpdf(float(j),sigma);\n}\nfor (int j = 0; j < mSize; ++j)\n{\nz += kernel[j];\n}\nfor (int i = -kSize; i <= kSize; ++i)\n{\nfor (int j = -kSize; j <= kSize; ++j)\n{\nfinal_colour += kernel[kSize+j]*kernel[kSize+i]*texture2D(uSampler, (gl_FragCoord.xy+vec2(float(i),float(j))) / vec2(screenWidth, screenHeight).xy).rgb;\n}\n}\ngl_FragColor = vec4(final_colour/(z*z), 1.0);\n}",n}(egret.CustomFilter);t.GaussianBlurEffect=e}(es||(es={})),function(t){var e=function(t){function e(){return t.call(this,e.vertSrc,e.fragmentSrc)||this}return __extends(e,t),e.vertSrc="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nuniform vec2 projectionVector;\nvarying vec2 vTextureCoord;\nconst vec2 center = vec2(-1.0, 1.0);\nvoid main(void) {\n gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",e.fragmentSrc="precision lowp float;\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n#define SAMPLE_COUNT 15\nuniform vec2 _sampleOffsets[SAMPLE_COUNT];\nuniform float _sampleWeights[SAMPLE_COUNT];\nvoid main(void) {\nvec4 c = vec4(0, 0, 0, 0);\nfor( int i = 0; i < SAMPLE_COUNT; i++ )\n c += texture2D( uSampler, vTextureCoord + _sampleOffsets[i] ) * _sampleWeights[i];\ngl_FragColor = c;\n}",e}(egret.CustomFilter);t.PolygonLightEffect=e}(es||(es={})),function(t){var e=function(){function e(t){void 0===t&&(t=null),this.enabled=!0,this.effect=t}return e.prototype.onAddedToScene=function(e){this.scene=e,this.shape=new egret.Shape,this.shape.graphics.beginFill(16777215,1),this.shape.graphics.drawRect(0,0,t.Core.graphicsDevice.viewport.width,t.Core.graphicsDevice.viewport.height),this.shape.graphics.endFill(),e.addChild(this.shape)},e.prototype.process=function(){this.drawFullscreenQuad()},e.prototype.onSceneBackBufferSizeChanged=function(t,e){},e.prototype.unload=function(){this.effect&&(this.effect=null),this.scene.removeChild(this.shape),this.scene=null},e.prototype.drawFullscreenQuad=function(){this.scene.filters=[this.effect]},e.default_vert="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec2 aColor;\nuniform vec2 projectionVector;\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nconst vec2 center = vec2(-1.0, 1.0);\nvoid main(void) {\ngl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\nvTextureCoord = aTextureCoord;\nvColor = vec4(aColor.x, aColor.x, aColor.x, aColor.x);\n}",e}();t.PostProcessor=e}(es||(es={})),function(t){var e=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.onAddedToScene=function(n){e.prototype.onAddedToScene.call(this,n),this.effect=new t.GaussianBlurEffect},n}(t.PostProcessor);t.GaussianBlurPostProcessor=e}(es||(es={})),function(t){var e=function(){function t(t,e){void 0===e&&(e=null),this.renderOrder=0,this.camera=e,this.renderOrder=t}return t.prototype.onAddedToScene=function(t){},t.prototype.unload=function(){},t.prototype.onSceneBackBufferSizeChanged=function(t,e){},t.prototype.compareTo=function(t){return this.renderOrder-t.renderOrder},t.prototype.beginRender=function(t){},t.prototype.renderAfterStateCheck=function(t,e){t.render(e)},t}();t.Renderer=e}(es||(es={})),function(t){var e=function(t){function e(){return t.call(this,0,null)||this}return __extends(e,t),e.prototype.render=function(t){var e=this.camera?this.camera:t.camera;this.beginRender(e);for(var n=0;nn?n:t},e.pointOnCirlce=function(n,i,r){var o=e.toRadians(r);return new t.Vector2(Math.cos(o)*o+n.x,Math.sin(o)*o+n.y)},e.isEven=function(t){return t%2==0},e.clamp01=function(t){return t<0?0:t>1?1:t},e.angleBetweenVectors=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)},e.Epsilon=1e-5,e.Rad2Deg=57.29578,e.Deg2Rad=.0174532924,e}();t.MathHelper=e}(es||(es={})),function(t){t.matrixPool=[];var e=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),Object.defineProperty(n.prototype,"m11",{get:function(){return this.a},set:function(t){this.a=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"m12",{get:function(){return this.b},set:function(t){this.b=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"m21",{get:function(){return this.c},set:function(t){this.c=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"m22",{get:function(){return this.d},set:function(t){this.d=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"m31",{get:function(){return this.tx},set:function(t){this.tx=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"m32",{get:function(){return this.ty},set:function(t){this.ty=t},enumerable:!0,configurable:!0}),n.create=function(){var e=t.matrixPool.pop();return e||(e=new n),e},n.prototype.identity=function(){return this.a=this.d=1,this.b=this.c=this.tx=this.ty=0,this},n.prototype.translate=function(t,e){return this.tx+=t,this.ty+=e,this},n.prototype.scale=function(t,e){return 1!==t&&(this.a*=t,this.c*=t,this.tx*=t),1!==e&&(this.b*=e,this.d*=e,this.ty*=e),this},n.prototype.rotate=function(t){if(0!==(t=+t)){t/=DEG_TO_RAD;var e=Math.cos(t),n=Math.sin(t),i=this.a,r=this.b,o=this.c,s=this.d,a=this.tx,c=this.ty;this.a=i*e-r*n,this.b=i*n+r*e,this.c=o*e-s*n,this.d=o*n+s*e,this.tx=a*e-c*n,this.ty=a*n+c*e}return this},n.prototype.invert=function(){return this.$invertInto(this),this},n.prototype.add=function(t){return this.m11+=t.m11,this.m12+=t.m12,this.m21+=t.m21,this.m22+=t.m22,this.m31+=t.m31,this.m32+=t.m32,this},n.prototype.substract=function(t){return this.m11-=t.m11,this.m12-=t.m12,this.m21-=t.m21,this.m22-=t.m22,this.m31-=t.m31,this.m32-=t.m32,this},n.prototype.divide=function(t){return this.m11/=t.m11,this.m12/=t.m12,this.m21/=t.m21,this.m22/=t.m22,this.m31/=t.m31,this.m32/=t.m32,this},n.prototype.multiply=function(t){var e=this.m11*t.m11+this.m12*t.m21,n=this.m11*t.m12+this.m12*t.m22,i=this.m21*t.m11+this.m22*t.m21,r=this.m21*t.m12+this.m22*t.m22,o=this.m31*t.m11+this.m32*t.m21+t.m31,s=this.m31*t.m12+this.m32*t.m22+t.m32;return this.m11=e,this.m12=n,this.m21=i,this.m22=r,this.m31=o,this.m32=s,this},n.prototype.determinant=function(){return this.m11*this.m22-this.m12*this.m21},n.prototype.release=function(e){e&&t.matrixPool.push(e)},n}(egret.Matrix);t.Matrix2D=e}(es||(es={})),function(t){var e=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),Object.defineProperty(n.prototype,"max",{get:function(){return new t.Vector2(this.right,this.bottom)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"center",{get:function(){return new t.Vector2(this.x+this.width/2,this.y+this.height/2)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"location",{get:function(){return new t.Vector2(this.x,this.y)},set:function(t){this.x=t.x,this.y=t.y},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"size",{get:function(){return new t.Vector2(this.width,this.height)},set:function(t){this.width=t.x,this.height=t.y},enumerable:!0,configurable:!0}),n.fromMinMax=function(t,e,i,r){return new n(t,e,i-t,r-e)},n.rectEncompassingPoints=function(t){for(var e=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=0;oi&&(i=s.x),s.yr&&(r=s.y)}return this.fromMinMax(e,n,i,r)},n.prototype.intersects=function(t){return t.leftthis.x+this.width)return e}else{var i=1/t.direction.x,r=(this.x-t.start.x)*i,o=(this.x+this.width-t.start.x)*i;if(r>o){var s=r;r=o,o=s}if((e=Math.max(r,e))>(n=Math.min(o,n)))return e}if(Math.abs(t.direction.y)<1e-6){if(t.start.ythis.y+this.height)return e}else{var a=1/t.direction.y,c=(this.y-t.start.y)*a,h=(this.y+this.height-t.start.y)*a;if(c>h){var u=c;c=h,h=u}if((e=Math.max(c,e))>(n=Math.max(h,n)))return e}return e},n.prototype.containsRect=function(t){return this.x<=t.x&&t.x1)return!1;var u=(c.x*o.y-c.y*o.x)/a;return!(u<0||u>1)},n.lineToLineIntersection=function(e,n,i,r){var o=new t.Vector2(0,0),s=t.Vector2.subtract(n,e),a=t.Vector2.subtract(r,i),c=s.x*a.y-s.y*a.x;if(0==c)return o;var h=t.Vector2.subtract(i,e),u=(h.x*a.y-h.y*a.x)/c;if(u<0||u>1)return o;var l=(h.x*s.y-h.y*s.x)/c;return l<0||l>1?o:o=t.Vector2.add(e,new t.Vector2(u*s.x,u*s.y))},n.closestPointOnLine=function(e,n,i){var r=t.Vector2.subtract(n,e),o=t.Vector2.subtract(i,e),s=t.Vector2.dot(o,r)/t.Vector2.dot(r,r);return s=t.MathHelper.clamp(s,0,1),t.Vector2.add(e,new t.Vector2(r.x*s,r.y*s))},n.isCircleToCircle=function(e,n,i,r){return t.Vector2.distanceSquared(e,i)<(n+r)*(n+r)},n.isCircleToLine=function(e,n,i,r){return t.Vector2.distanceSquared(e,this.closestPointOnLine(i,r,e))=t&&r.y>=e&&r.x=t+i&&(s|=e.right),o.y=n+r&&(s|=e.bottom),s},n}();t.Collisions=n}(es||(es={})),function(t){var e=function(){function e(){}return e.reset=function(){this._spatialHash=new t.SpatialHash(this.spatialHashCellSize)},e.clear=function(){this._spatialHash.clear()},e.overlapCircleAll=function(t,e,n,i){if(void 0===i&&(i=-1),0!=n.length)return this._spatialHash.overlapCircle(t,e,n,i);console.error("An empty results array was passed in. No results will ever be returned.")},e.boxcastBroadphase=function(t,e){return void 0===e&&(e=this.allLayers),this._spatialHash.aabbBroadphase(t,null,e)},e.boxcastBroadphaseExcludingSelf=function(t,e,n){return void 0===n&&(n=this.allLayers),this._spatialHash.aabbBroadphase(e,t,n)},e.addCollider=function(t){e._spatialHash.register(t)},e.removeCollider=function(t){e._spatialHash.remove(t)},e.updateCollider=function(t){this._spatialHash.remove(t),this._spatialHash.register(t)},e.debugDraw=function(t){this._spatialHash.debugDraw(t,2)},e.spatialHashCellSize=100,e.allLayers=-1,e.raycastsHitTriggers=!1,e.raycastsStartInColliders=!1,e}();t.Physics=e}(es||(es={})),function(t){var e=function(){return function(e,n){this.start=e,this.end=n,this.direction=t.Vector2.subtract(this.end,this.start)}}();t.Ray2D=e}(es||(es={})),function(t){var e=function(){function e(e,n,i,r,o){this.fraction=0,this.distance=0,this.point=t.Vector2.zero,this.normal=t.Vector2.zero,this.collider=e,this.fraction=n,this.distance=i,this.point=r,this.centroid=t.Vector2.zero}return e.prototype.setValues=function(t,e,n,i){this.collider=t,this.fraction=e,this.distance=n,this.point=i},e.prototype.setValuesNonCollider=function(t,e,n,i){this.fraction=t,this.distance=e,this.point=n,this.normal=i},e.prototype.reset=function(){this.collider=null,this.fraction=this.distance=0},e.prototype.toString=function(){return"[RaycastHit] fraction: "+this.fraction+", distance: "+this.distance+", normal: "+this.normal+", centroid: "+this.centroid+", point: "+this.point},e}();t.RaycastHit=e}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.clone=function(){return ObjectUtils.clone(this)},t}();t.Shape=e}(es||(es={})),function(t){var e=function(e){function n(t,n){var i=e.call(this)||this;return i._areEdgeNormalsDirty=!0,i.isUnrotated=!0,i.setPoints(t),i.isBox=n,i}return __extends(n,e),Object.defineProperty(n.prototype,"edgeNormals",{get:function(){return this._areEdgeNormalsDirty&&this.buildEdgeNormals(),this._edgeNormals},enumerable:!0,configurable:!0}),n.prototype.setPoints=function(t){this.points=t,this.recalculateCenterAndEdgeNormals(),this._originalPoints=[];for(var e=0;e=this.points.length?this.points[0]:this.points[i+1];var o=t.Vector2Ext.perpendicular(r,e);o=t.Vector2.normalize(o),this._edgeNormals[i]=o}},n.buildSymmetricalPolygon=function(e,n){for(var i=new Array(e),r=0;rr&&(r=s,i=o)}return e[i]},n.getClosestPointOnPolygonToPoint=function(e,n,i,r){i=Number.MAX_VALUE,r=new t.Vector2(0,0);for(var o,s=new t.Vector2(0,0),a=0;ae.y!=this.points[r].y>e.y&&e.x<(this.points[r].x-this.points[i].x)*(e.y-this.points[i].y)/(this.points[r].y-this.points[i].y)+this.points[i].x&&(n=!n);return n},n.prototype.pointCollidesWithShape=function(e,n){return t.ShapeCollisions.pointToPoly(e,this,n)},n}(t.Shape);t.Polygon=e}(es||(es={})),function(t){var e=function(e){function n(t,i){var r=e.call(this,n.buildBox(t,i),!0)||this;return r.width=t,r.height=i,r}return __extends(n,e),n.buildBox=function(e,n){var i=e/2,r=n/2,o=new Array(4);return o[0]=new t.Vector2(-i,-r),o[1]=new t.Vector2(i,-r),o[2]=new t.Vector2(i,r),o[3]=new t.Vector2(-i,r),o},n.prototype.updateBox=function(e,n){this.width=e,this.height=n;var i=e/2,r=n/2;this.points[0]=new t.Vector2(-i,-r),this.points[1]=new t.Vector2(i,-r),this.points[2]=new t.Vector2(i,r),this.points[3]=new t.Vector2(-i,r);for(var o=0;o1)return s;var a,c=t.Vector2.add(o.start,t.Vector2.add(o.direction,new t.Vector2(s))),h=0;c.xn.bounds.right&&(h|=1),c.yn.bounds.bottom&&(h|=2);var u=a+h;return 3==u&&console.log("m == 3. corner "+t.Time.frameCount),s},e}();t.RealtimeCollisions=e}(es||(es={})),function(t){var e=function(){function e(){}return e.polygonToPolygon=function(e,n,i){for(var r,o=!0,s=e.edgeNormals,a=n.edgeNormals,c=Number.POSITIVE_INFINITY,h=new t.Vector2,u=t.Vector2.subtract(e.position,n.position),l=0;l0&&(o=!1),!o)return!1;(m=Math.abs(m))r&&(r=o);return{min:i,max:r}},e.circleToPolygon=function(e,n,i){var r,o=t.Vector2.subtract(e.position,n.position),s=t.Polygon.getClosestPointOnPolygonToPoint(n.points,o,0,i.normal),a=n.containsPoint(e.position);if(0>e.radius*e.radius&&!a)return!1;a?r=t.Vector2.multiply(i.normal,new t.Vector2(Math.sqrt(0)-e.radius)):r=t.Vector2.multiply(i.normal,new t.Vector2(e.radius));return i.minimumTranslationVector=r,i.point=t.Vector2.add(s,n.position),!0},e.circleToBox=function(e,n,i){var r=n.bounds.getClosestPointOnRectangleBorderToPoint(e.position,i.normal);if(n.containsPoint(e.position)){i.point=r;var o=t.Vector2.add(r,t.Vector2.multiply(i.normal,new t.Vector2(e.radius)));return i.minimumTranslationVector=t.Vector2.subtract(e.position,o),!0}var s=t.Vector2.distanceSquared(r,e.position);if(0==s)i.minimumTranslationVector=t.Vector2.multiply(i.normal,new t.Vector2(e.radius));else if(s<=e.radius*e.radius){i.normal=t.Vector2.subtract(e.position,r);var a=i.normal.length()-e.radius;return i.point=r,i.normal=t.Vector2Ext.normalize(i.normal),i.minimumTranslationVector=t.Vector2.multiply(new t.Vector2(a),i.normal),!0}return!1},e.pointToCircle=function(e,n,i){var r=t.Vector2.distanceSquared(e,n.position),o=1+n.radius;if(r1)return!1;var l=(h.x*s.y-h.y*s.x)/c;return!(l<0||l>1)&&(o=o.add(e).add(t.Vector2.multiply(new t.Vector2(u),s)),!0)},e.lineToCircle=function(e,n,i,r){var o=t.Vector2.distance(e,n),s=t.Vector2.divide(t.Vector2.subtract(n,e),new t.Vector2(o)),a=t.Vector2.subtract(e,i.position),c=t.Vector2.dot(a,s),h=t.Vector2.dot(a,a)-i.radius*i.radius;if(h>0&&c>0)return!1;var u=c*c-h;return!(u<0)&&(r.fraction=-c-Math.sqrt(u),r.fraction<0&&(r.fraction=0),r.point=t.Vector2.add(e,t.Vector2.multiply(new t.Vector2(r.fraction),s)),r.distance=t.Vector2.distance(e,r.point),r.normal=t.Vector2.normalize(t.Vector2.subtract(r.point,i.position)),r.fraction=r.distance/o,!0)},e.boxToBoxCast=function(e,n,i,r){var o=this.minkowskiDifference(e,n);if(o.contains(0,0)){var s=o.getClosestPointOnBoundsToOrigin();return!s.equals(t.Vector2.zero)&&(r.normal=new t.Vector2(-s.x),r.normal=r.normal.normalize(),r.distance=0,r.fraction=0,!0)}var a=new t.Ray2D(t.Vector2.zero,new t.Vector2(-i.x)),c=o.rayIntersects(a);return c<=1&&(r.fraction=c,r.distance=i.length()*c,r.normal=new t.Vector2(-i.x),r.normal=r.normal.normalize(),r.centroid=t.Vector2.add(e.bounds.center,t.Vector2.multiply(i,new t.Vector2(c))),!0)},e}();t.ShapeCollisions=e}(es||(es={})),function(t){var e=function(){function e(e){void 0===e&&(e=100),this.gridBounds=new t.Rectangle,this._overlapTestCircle=new t.Circle(0),this._cellDict=new n,this._tempHashSet=[],this._cellSize=e,this._inverseCellSize=1/this._cellSize,this._raycastParser=new i}return e.prototype.register=function(e){var n=e.bounds;e.registeredPhysicsBounds=n;var i=this.cellCoords(n.x,n.y),r=this.cellCoords(n.right,n.bottom);this.gridBounds.contains(i.x,i.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,i)),this.gridBounds.contains(r.x,r.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,r));for(var o=i.x;o<=r.x;o++)for(var s=i.y;s<=r.y;s++){var a=this.cellAtPosition(o,s,!0);a.firstOrDefault(function(t){return t.hashCode==e.hashCode})||a.push(e)}},e.prototype.remove=function(t){for(var e=t.registeredPhysicsBounds,n=this.cellCoords(e.x,e.y),i=this.cellCoords(e.right,e.bottom),r=n.x;r<=i.x;r++)for(var o=n.y;o<=i.y;o++){var s=this.cellAtPosition(r,o);s?s.remove(t):console.log("从不存在碰撞器的单元格中移除碰撞器: ["+t+"]")}},e.prototype.removeWithBruteForce=function(t){this._cellDict.remove(t)},e.prototype.clear=function(){this._cellDict.clear()},e.prototype.debugDraw=function(t,e){void 0===e&&(e=1);for(var n=this.gridBounds.x;n<=this.gridBounds.right;n++)for(var i=this.gridBounds.y;i<=this.gridBounds.bottom;i++){var r=this.cellAtPosition(n,i);r&&r.length>0&&this.debugDrawCellDetails(n,i,r.length,t,e)}},e.prototype.aabbBroadphase=function(e,n,i){this._tempHashSet.length=0;for(var r=this.cellCoords(e.x,e.y),o=this.cellCoords(e.right,e.bottom),s=r.x;s<=o.x;s++)for(var a=r.y;a<=o.y;a++){var c=this.cellAtPosition(s,a);if(c)for(var h=function(r){var o=c[r];if(o==n||!t.Flags.isFlagSet(i,o.physicsLayer))return"continue";e.intersects(o.bounds)&&(u._tempHashSet.firstOrDefault(function(t){return t.hashCode==o.hashCode})||u._tempHashSet.push(o))},u=this,l=0;ln;i--)if(t[i]0&&t[r-1]>i;r--)t[r]=t[r-1];t[r]=i}},t.binarySearch=function(t,e){for(var n=0,i=t.length,r=n+i>>1;n=t[r]&&(n=r+1),r=n+i>>1;return t[n]==e?n:-1},t.findElementIndex=function(t,e){for(var n=t.length,i=0;it[e]&&(e=i);return e},t.getMinElementIndex=function(t){for(var e=0,n=t.length,i=1;i=0;--r)n.unshift(e[r]);return n},t.getDifferAry=function(t,e){t=this.getUniqueAry(t),e=this.getUniqueAry(e);for(var n=t.concat(e),i={},r=[],o=n.length,s=0;s=0;e-=1)t.splice(e,1)},t.cloneList=function(t){return t?t.slice(0,t.length):null},t.equals=function(t,e){if(t==e)return!0;var n=t.length;if(n!=e.length)return!1;for(;n--;)if(t[n]!=e[n])return!1;return!0},t.insert=function(t,e,n){if(!t)return null;var i=t.length;if(e>i&&(e=i),e<0&&(e=0),e==i)t.push(n);else if(0==e)t.unshift(n);else{for(var r=i-1;r>=e;r-=1)t[r+1]=t[r];t[e]=n}return n},t}(),Base64Utils=function(){function t(){}return t.decode=function(t,e){void 0===e&&(e=!0);var n,i,r,o,s,a,c="",h=0;for(t=(t=this.getConfKey(t)).replace(/[^A-Za-z0-9\+\/\=]/g,"");h>4,i=(15&o)<<4|(s=this._keyAll.indexOf(t.charAt(h++)))>>2,r=(3&s)<<6|(a=this._keyAll.indexOf(t.charAt(h++))),c+=String.fromCharCode(n),64!=s&&(0==i?e&&(c+=String.fromCharCode(i)):c+=String.fromCharCode(i)),64!=a&&(0==r?e&&(c+=String.fromCharCode(r)):c+=String.fromCharCode(r));return c=this._utf8_decode(c)},t._utf8_encode=function(t){t=t.replace(/\r\n/g,"\n");for(var e="",n=0;n127&&i<2048?(e+=String.fromCharCode(i>>6|192),e+=String.fromCharCode(63&i|128)):(e+=String.fromCharCode(i>>12|224),e+=String.fromCharCode(i>>6&63|128),e+=String.fromCharCode(63&i|128))}return e},t._utf8_decode=function(t){for(var e="",n=0,i=0,r=0,o=0;n191&&i<224?(r=t.charCodeAt(n+1),e+=String.fromCharCode((31&i)<<6|63&r),n+=2):(r=t.charCodeAt(n+1),o=t.charCodeAt(n+2),e+=String.fromCharCode((15&i)<<12|(63&r)<<6|63&o),n+=3);return e},t.getConfKey=function(t){return t.slice(1,t.length)},t._keyNum="0123456789+/",t._keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",t._keyAll=t._keyNum+t._keyStr,t.encode=function(t){var e,n,i,r,o,s,a,c="",h=0;for(t=this._utf8_encode(t);h>2,o=(3&e)<<4|(n=t.charCodeAt(h++))>>4,s=(15&n)<<2|(i=t.charCodeAt(h++))>>6,a=63&i,isNaN(n)?s=a=64:isNaN(i)&&(a=64),c=c+this._keyAll.charAt(r)+this._keyAll.charAt(o)+this._keyAll.charAt(s)+this._keyAll.charAt(a);return this._keyStr.charAt(Math.floor(Math.random()*this._keyStr.length))+c},t}();!function(t){var e=function(){function t(){this.loadedAssets=new Map}return t.prototype.loadRes=function(t,e){var n=this;return void 0===e&&(e=!0),new Promise(function(i,r){var o=n.loadedAssets.get(t);o?i(o):e?RES.getResAsync(t).then(function(e){n.loadedAssets.set(t,e),i(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)}):RES.getResByUrl(t).then(function(e){n.loadedAssets.set(t,e),i(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)})})},t.prototype.dispose=function(){this.loadedAssets.forEach(function(t){t.dispose()}),this.loadedAssets.clear()},t}();t.ContentManager=e}(es||(es={})),function(t){var e=function(){function e(){}return e.drawLine=function(e,n,i,r,o){void 0===o&&(o=1),this.drawLineAngle(e,n,t.MathHelper.angleBetweenVectors(n,i),t.Vector2.distance(n,i),r,o)},e.drawLineAngle=function(t,e,n,i,r,o){void 0===o&&(o=1),t.graphics.beginFill(r),t.graphics.drawRect(e.x,e.y,1,1),t.graphics.endFill(),t.scaleX=i,t.scaleY=o,t.$anchorOffsetX=0,t.$anchorOffsetY=0,t.rotation=n},e.drawHollowRect=function(t,e,n,i){void 0===i&&(i=1),this.drawHollowRectR(t,e.x,e.y,e.width,e.height,n,i)},e.drawHollowRectR=function(e,n,i,r,o,s,a){void 0===a&&(a=1);var c=new t.Vector2(n,i).round(),h=new t.Vector2(n+r,i).round(),u=new t.Vector2(n+r,i+o).round(),l=new t.Vector2(n,i+o).round();this.drawLine(e,c,h,s,a),this.drawLine(e,h,u,s,a),this.drawLine(e,u,l,s,a),this.drawLine(e,l,c,s,a)},e.drawPixel=function(e,n,i,r){void 0===r&&(r=1);var o=new t.Rectangle(n.x,n.y,r,r);1!=r&&(o.x-=.5*r,o.y-=.5*r),e.graphics.beginFill(i),e.graphics.drawRect(o.x,o.y,o.width,o.height),e.graphics.endFill()},e.getColorMatrix=function(t){var e=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];return e[0]=Math.floor(t/256/256)/255,e[6]=Math.floor(t/256%256)/255,e[12]=t%256/255,new egret.ColorMatrixFilter(e)},e}();t.DrawUtils=e}(es||(es={})),function(t){var e=function(){return function(t,e){this.func=t,this.context=e}}();t.FuncPack=e;var n=function(){function t(){this._messageTable=new Map}return t.prototype.addObserver=function(t,n,i){var r=this._messageTable.get(t);r||(r=[],this._messageTable.set(t,r)),-1!=r.findIndex(function(t){return t.func==n})&&console.warn("您试图添加相同的观察者两次"),r.push(new e(n,i))},t.prototype.removeObserver=function(t,e){var n=this._messageTable.get(t),i=n.findIndex(function(t){return t.func==e});-1!=i&&n.removeAt(i)},t.prototype.emit=function(t,e){var n=this._messageTable.get(t);if(n)for(var i=n.length-1;i>=0;i--)n[i].func.call(n[i].context,e)},t}();t.Emitter=n}(es||(es={})),function(t){var e=function(){function t(){}return Object.defineProperty(t.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),t.prototype.setEnabled=function(t){this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled())},t.prototype.onEnabled=function(){},t.prototype.onDisabled=function(){},t.prototype.update=function(){},t}();t.GlobalManager=e}(es||(es={})),function(t){var e=function(){function e(){this.x=0,this.y=0,this.touchPoint=-1,this.touchDown=!1}return Object.defineProperty(e.prototype,"position",{get:function(){return new t.Vector2(this.x,this.y)},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this.x=0,this.y=0,this.touchDown=!1,this.touchPoint=-1},e}();t.TouchState=e;var n=function(){function n(){}return Object.defineProperty(n,"gameTouchs",{get:function(){return this._gameTouchs},enumerable:!0,configurable:!0}),Object.defineProperty(n,"resolutionScale",{get:function(){return this._resolutionScale},enumerable:!0,configurable:!0}),Object.defineProperty(n,"totalTouchCount",{get:function(){return this._totalTouchCount},enumerable:!0,configurable:!0}),Object.defineProperty(n,"touchPosition",{get:function(){return this._gameTouchs[0]?this._gameTouchs[0].position:t.Vector2.zero},enumerable:!0,configurable:!0}),Object.defineProperty(n,"maxSupportedTouch",{get:function(){return t.Core._instance.stage.maxTouches},set:function(e){t.Core._instance.stage.maxTouches=e,this.initTouchCache()},enumerable:!0,configurable:!0}),Object.defineProperty(n,"touchPositionDelta",{get:function(){var e=t.Vector2.subtract(this.touchPosition,this._previousTouchState.position);return e.length()>0&&this.setpreviousTouchState(this._gameTouchs[0]),e},enumerable:!0,configurable:!0}),n.initialize=function(){this._init||(this._init=!0,t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.touchBegin,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.touchMove,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_END,this.touchEnd,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL,this.touchEnd,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE,this.touchEnd,this),this.initTouchCache())},n.scaledPosition=function(e){var n=new t.Vector2(e.x-this._resolutionOffset.x,e.y-this._resolutionOffset.y);return t.Vector2.multiply(n,this.resolutionScale)},n.initTouchCache=function(){this._totalTouchCount=0,this._touchIndex=0,this._gameTouchs.length=0;for(var t=0;t0)for(var e=0;ethis._objectQueue.length;)this._objectQueue.shift()},t.clearCache=function(){this._objectQueue.length=0},t.obtain=function(){return this._objectQueue.length>0?this._objectQueue.shift():[]},t.free=function(t){this._objectQueue.unshift(t),t.length=0},t._objectQueue=[],t}();t.ListPool=e}(es||(es={}));var THREAD_ID=Math.floor(1e3*Math.random())+"-"+Date.now(),nextTick=function(t){setTimeout(t,0)},LockUtils=function(){function t(t){this._keyX="mutex_key_"+t+"_X",this._keyY="mutex_key_"+t+"_Y",this.setItem=egret.localStorage.setItem.bind(localStorage),this.getItem=egret.localStorage.getItem.bind(localStorage),this.removeItem=egret.localStorage.removeItem.bind(localStorage)}return t.prototype.lock=function(){var t=this;return new Promise(function(e,n){var i=function(){t.setItem(t._keyX,THREAD_ID),null===!t.getItem(t._keyY)&&nextTick(i),t.setItem(t._keyY,THREAD_ID),t.getItem(t._keyX)!==THREAD_ID?setTimeout(function(){t.getItem(t._keyY)===THREAD_ID?(e(),t.removeItem(t._keyY)):nextTick(i)},10):(e(),t.removeItem(t._keyY))};i()})},t}();!function(t){var e=function(){function t(t,e){this.first=t,this.second=e}return t.prototype.clear=function(){this.first=this.second=null},t.prototype.equals=function(t){return this.first==t.first&&this.second==t.second},t}();t.Pair=e}(es||(es={}));var RandomUtils=function(){function t(){}return t.randrange=function(t,e,n){if(void 0===n&&(n=1),0==n)throw new Error("step 不能为 0");var i=e-t;if(0==i)throw new Error("没有可用的范围("+t+","+e+")");i<0&&(i=t-e);var r=Math.floor((i+n-1)/n);return Math.floor(this.random()*r)*n+Math.min(t,e)},t.randint=function(t,e){return(t=Math.floor(t))>(e=Math.floor(e))?t++:e++,this.randrange(t,e)},t.randnum=function(t,e){return this.random()*(e-t)+t},t.shuffle=function(t){return t.sort(this._randomCompare),t},t.choice=function(t){if(!t.hasOwnProperty("length"))throw new Error("无法对此对象执行此操作");var e=Math.floor(this.random()*t.length);return t instanceof String?String(t).charAt(e):t[e]},t.sample=function(t,e){var n=t.length;if(e<=0||n=0;)s=Math.floor(this.random()*n);i.push(t[s]),r.push(s)}return i},t.random=function(){return Math.random()},t.boolean=function(t){return void 0===t&&(t=.5),this.random().5?1:-1},t}();!function(t){var e=function(){function e(){}return e.union=function(e,n){var i=new t.Rectangle(n.x,n.y,0,0),r=new t.Rectangle;return r.x=Math.min(e.x,i.x),r.y=Math.min(e.y,i.y),r.width=Math.max(e.right,i.right)-r.x,r.height=Math.max(e.bottom,r.bottom)-r.y,r},e}();t.RectangleExt=e}(es||(es={})),function(t){var e=function(){function e(){this.triangleIndices=[],this._triPrev=new Array(12),this._triNext=new Array(12)}return e.testPointTriangle=function(e,n,i,r){return!(t.Vector2Ext.cross(t.Vector2.subtract(e,n),t.Vector2.subtract(i,n))<0)&&(!(t.Vector2Ext.cross(t.Vector2.subtract(e,i),t.Vector2.subtract(r,i))<0)&&!(t.Vector2Ext.cross(t.Vector2.subtract(e,r),t.Vector2.subtract(n,r))<0))},e.prototype.triangulate=function(n,i){void 0===i&&(i=!0);var r=n.length;this.initialize(r);for(var o=0,s=0;r>3&&o<500;){o++;var a=!0,c=n[this._triPrev[s]],h=n[s],u=n[this._triNext[s]];if(t.Vector2Ext.isTriangleCCW(c,h,u)){var l=this._triNext[this._triNext[s]];do{if(e.testPointTriangle(n[l],c,h,u)){a=!1;break}l=this._triNext[l]}while(l!=this._triPrev[s])}else a=!1;a?(this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),this._triNext[this._triPrev[s]]=this._triNext[s],this._triPrev[this._triNext[s]]=this._triPrev[s],r--,s=this._triPrev[s]):s=this._triNext[s]}this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),i||this.triangleIndices.reverse()},e.prototype.initialize=function(t){this.triangleIndices.length=0,this._triNext.lengtht.MathHelper.Epsilon?e=t.Vector2.divide(e,new t.Vector2(n)):e.x=e.y=0,e},e.transformA=function(t,e,n,i,r,o){for(var s=0;sthis.safeArea.right&&(s.x=this.safeArea.right-s.width),s.topthis.safeArea.bottom&&(s.y=this.safeArea.bottom-s.height),s},n}();t.Layout=n,function(t){t[t.none=0]="none",t[t.left=1]="left",t[t.right=2]="right",t[t.horizontalCenter=4]="horizontalCenter",t[t.top=8]="top",t[t.bottom=16]="bottom",t[t.verticalCenter=32]="verticalCenter",t[t.topLeft=9]="topLeft",t[t.topRight=10]="topRight",t[t.topCenter=12]="topCenter",t[t.bottomLeft=17]="bottomLeft",t[t.bottomRight=18]="bottomRight",t[t.bottomCenter=20]="bottomCenter",t[t.centerLeft=33]="centerLeft",t[t.centerRight=34]="centerRight",t[t.center=36]="center"}(e=t.Alignment||(t.Alignment={}))}(es||(es={})),function(t){var e,n=function(){function t(t){void 0===t&&(t=i),this.getSystemTime=t,this._stopDuration=0,this._completeSlices=[]}return t.prototype.getState=function(){return void 0===this._startSystemTime?e.IDLE:void 0===this._stopSystemTime?e.RUNNING:e.STOPPED},t.prototype.isIdle=function(){return this.getState()===e.IDLE},t.prototype.isRunning=function(){return this.getState()===e.RUNNING},t.prototype.isStopped=function(){return this.getState()===e.STOPPED},t.prototype.slice=function(){return this.recordPendingSlice()},t.prototype.getCompletedSlices=function(){return Array.from(this._completeSlices)},t.prototype.getCompletedAndPendingSlices=function(){return this._completeSlices.concat([this.getPendingSlice()])},t.prototype.getPendingSlice=function(){return this.calculatePendingSlice()},t.prototype.getTime=function(){return this.caculateStopwatchTime()},t.prototype.reset=function(){this._startSystemTime=this._pendingSliceStartStopwatchTime=this._stopSystemTime=void 0,this._stopDuration=0,this._completeSlices=[]},t.prototype.start=function(t){if(void 0===t&&(t=!1),t&&this.reset(),void 0!==this._stopSystemTime){var e=(n=this.getSystemTime())-this._stopSystemTime;this._stopDuration+=e,this._stopSystemTime=void 0}else if(void 0===this._startSystemTime){var n=this.getSystemTime();this._startSystemTime=n,this._pendingSliceStartStopwatchTime=0}},t.prototype.stop=function(t){if(void 0===t&&(t=!1),void 0===this._startSystemTime)return 0;var e=this.getSystemTimeOfCurrentStopwatchTime();return t&&this.recordPendingSlice(this.caculateStopwatchTime(e)),this._stopSystemTime=e,this.getTime()},t.prototype.calculatePendingSlice=function(t){return void 0===this._pendingSliceStartStopwatchTime?Object.freeze({startTime:0,endTime:0,duration:0}):(void 0===t&&(t=this.getTime()),Object.freeze({startTime:this._pendingSliceStartStopwatchTime,endTime:t,duration:t-this._pendingSliceStartStopwatchTime}))},t.prototype.caculateStopwatchTime=function(t){return void 0===this._startSystemTime?0:(void 0===t&&(t=this.getSystemTimeOfCurrentStopwatchTime()),t-this._startSystemTime-this._stopDuration)},t.prototype.getSystemTimeOfCurrentStopwatchTime=function(){return void 0===this._stopSystemTime?this.getSystemTime():this._stopSystemTime},t.prototype.recordPendingSlice=function(t){if(void 0!==this._pendingSliceStartStopwatchTime){void 0===t&&(t=this.getTime());var e=this.calculatePendingSlice(t);return this._pendingSliceStartStopwatchTime=e.endTime,this._completeSlices.push(e),e}return this.calculatePendingSlice()},t}();t.Stopwatch=n,function(t){t.IDLE="IDLE",t.RUNNING="RUNNING",t.STOPPED="STOPPED"}(e||(e={})),t.setDefaultSystemTimeGetter=function(t){void 0===t&&(t=Date.now),i=t};var i=Date.now}(stopwatch||(stopwatch={})),function(t){var e=function(){function e(){this.showLog=!1,this._frameKey="frame",this._logKey="log",this.markers=[],this.stopwacth=new stopwatch.Stopwatch,this._markerNameToIdMap=new Map,this._logs=new Array(2);for(var e=0;e=e.logSnapDuration&&(l.logs[r].snapMin=l.logs[r].min,l.logs[r].snapMax=l.logs[r].max,l.logs[r].snapAvg=l.logs[r].avg,l.logs[r].samples=0)):(l.logs[r].min=h,l.logs[r].max=h,l.logs[r].avg=h,l.logs[r].initialized=!0)}s.markCount=o.nestCount,s.nestCount=o.nestCount}t.stopwacth.reset(),t.stopwacth.start()}})},e.prototype.beginMark=function(t,n,i){var r=this;void 0===i&&(i=0),new LockUtils(this._frameKey).lock().then(function(){if(i<0||i>=e.maxBars)throw new Error("barIndex argument out of range");var o=r._curLog.bars[i];if(o.markCount>=e.maxSamples)throw new Error("exceeded sample count. either set larger number to timeruler.maxsaple or lower sample count");if(o.nestCount>=e.maxNestCall)throw new Error("exceeded nest count. either set larger number to timeruler.maxnestcall or lower nest calls");var s=r._markerNameToIdMap.get(t);isNaN(s)&&(s=r.markers.length,r._markerNameToIdMap.set(t,s)),o.markerNests[o.nestCount++]=o.markCount,o.markers[o.markCount].markerId=s,o.markers[o.markCount].color=n,o.markers[o.markCount].beginTime=r.stopwacth.getTime(),o.markers[o.markCount].endTime=-1})},e.prototype.endMark=function(t,n){var i=this;void 0===n&&(n=0),new LockUtils(this._frameKey).lock().then(function(){if(n<0||n>=e.maxBars)throw new Error("barIndex argument out of range");var r=i._curLog.bars[n];if(r.nestCount<=0)throw new Error("call beginMark method before calling endMark method");var o=i._markerNameToIdMap.get(t);if(isNaN(o))throw new Error("Marker "+t+" is not registered. Make sure you specifed same name as you used for beginMark method");var s=r.markerNests[--r.nestCount];if(r.markers[s].markerId!=o)throw new Error("Incorrect call order of beginMark/endMark method. beginMark(A), beginMark(B), endMark(B), endMark(A) But you can't called it like beginMark(A), beginMark(B), endMark(A), endMark(B).");r.markers[s].endTime=i.stopwacth.getTime()})},e.prototype.getAverageTime=function(t,n){if(t<0||t>=e.maxBars)throw new Error("barIndex argument out of range");var i=0,r=this._markerNameToIdMap.get(n);return r&&(i=this.markers[r].logs[t].avg),i},e.prototype.resetLog=function(){var t=this;new LockUtils(this._logKey).lock().then(function(){var e=parseInt(egret.localStorage.getItem(t._logKey),10);e+=1,egret.localStorage.setItem(t._logKey,e.toString()),t.markers.forEach(function(t){for(var e=0;e0&&(i+=e.barHeight+2*e.barPadding,r=Math.max(r,t.markers[t.markCount-1].endTime))});var o=this.sampleFrames*(1/60*1e3);this._frameAdjust=r>o?Math.max(0,this._frameAdjust)+1:Math.min(0,this._frameAdjust)-1,Math.max(this._frameAdjust)>e.autoAdjustDelay&&(this.sampleFrames=Math.min(e.maxSampleFrames,this.sampleFrames),this.sampleFrames=Math.max(this.targetSampleFrames,r/(1/60*1e3)+1),this._frameAdjust=0);t.y,e.barHeight}},e.prototype.onGraphicsDeviceReset=function(){var n=new t.Layout;this._position=n.place(new t.Vector2(this.width,e.barHeight),0,.01,t.Alignment.bottomCenter).location},e.maxBars=8,e.maxSamples=256,e.maxNestCall=32,e.barHeight=8,e.maxSampleFrames=4,e.logSnapDuration=120,e.barPadding=2,e.autoAdjustDelay=30,e}();t.TimeRuler=e;var n=function(){return function(){this.bars=new Array(e.maxBars),this.bars.fill(new i,0,e.maxBars)}}();t.FrameLog=n;var i=function(){return function(){this.markers=new Array(e.maxSamples),this.markCount=0,this.markerNests=new Array(e.maxNestCall),this.nestCount=0,this.markers.fill(new r,0,e.maxSamples),this.markerNests.fill(0,0,e.maxNestCall)}}();t.MarkerCollection=i;var r=function(){return function(){this.markerId=0,this.beginTime=0,this.endTime=0,this.color=0}}();t.Marker=r;var o=function(){return function(t){this.logs=new Array(e.maxBars),this.name=t,this.logs.fill(new s,0,e.maxBars)}}();t.MarkerInfo=o;var s=function(){return function(){this.snapMin=0,this.snapMax=0,this.snapAvg=0,this.min=0,this.max=0,this.avg=0,this.samples=0,this.color=0,this.initialized=!1}}();t.MarkerLog=s}(es||(es={})); \ No newline at end of file +window.es={},window.__extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}();var transform,__awaiter=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{c(i.next(t))}catch(t){o(t)}}function a(t){try{c(i.throw(t))}catch(t){o(t)}}function c(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}c((i=i.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=(r=s.trys).length>0&&r[r.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]-1}(this,t)},Array.prototype.firstOrDefault=function(t){return function(t,e){var n=t.findIndex(e);return-1==n?null:t[n]}(this,t)},Array.prototype.find=function(t){return function(t,e){return t.firstOrDefault(e)}(this,t)},Array.prototype.where=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(n,i,r){return e.call(arguments[2],i,r,t)&&n.push(i),n},[]);for(var n=[],i=0,r=t.length;i=0&&t.splice(n,1)}while(n>=0)}(this,t)},Array.prototype.remove=function(t){return function(t,e){var n=t.findIndex(function(t){return t===e});return n>=0&&(t.splice(n,1),!0)}(this,t)},Array.prototype.removeAt=function(t){return function(t,e){t.splice(e,1)}(this,t)},Array.prototype.removeRange=function(t,e){return function(t,e,n){t.splice(e,n)}(this,t,e)},Array.prototype.select=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(n,i,r){return n.push(e.call(arguments[2],i,r,t)),n},[]);for(var n=[],i=0,r=t.length;io?1:-1}),t}(this,t,e)},Array.prototype.orderByDescending=function(t,e){return function(t,e,n){return t.sort(function(t,i){var r=e(t),o=e(i);return n?-n(r,o):r0;){if("break"===u())break}return s?this.recontructPath(a,i,r):null},e.recontructPath=function(t,e,n){var i=[],r=n;for(i.push(n);r!=e;)r=this.getKey(t,r),i.push(r);return i.reverse(),i},e.hasKey=function(t,e){for(var n,i=t.keys();!(n=i.next()).done;)if(JSON.stringify(n.value)==JSON.stringify(e))return!0;return!1},e.getKey=function(t,e){for(var n,i,r=t.keys(),o=t.values();n=r.next(),i=o.next(),!n.done;)if(JSON.stringify(n.value)==JSON.stringify(e))return i.value;return null},e}();t.AStarPathfinder=e;var n=function(t){function e(e){var n=t.call(this)||this;return n.data=e,n}return __extends(e,t),e}(t.PriorityQueueNode);t.AStarNode=n}(es||(es={})),function(t){var e=function(){function e(e,n){this.dirs=[new t.Vector2(1,0),new t.Vector2(0,-1),new t.Vector2(-1,0),new t.Vector2(0,1)],this.walls=[],this.weightedNodes=[],this.defaultWeight=1,this.weightedNodeWeight=5,this._neighbors=new Array(4),this._width=e,this._height=n}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x=this._nodes.length?(console.error("node.QueueIndex has been corrupted. Did you change it manually? Or add this node to another queue?"),!1):this._nodes[t.queueIndex]==t:(console.error("node cannot be null"),!1)},t.prototype.enqueue=function(t,e){t.priority=e,this._numNodes++,this._nodes[this._numNodes]=t,t.queueIndex=this._numNodes,t.insertionIndex=this._numNodesEverEnqueued++,this.cascadeUp(this._nodes[this._numNodes])},t.prototype.dequeue=function(){var t=this._nodes[1];return this.remove(t),t},t.prototype.remove=function(t){if(t.queueIndex==this._numNodes)return this._nodes[this._numNodes]=null,void this._numNodes--;var e=this._nodes[this._numNodes];this.swap(t,e),delete this._nodes[this._numNodes],this._numNodes--,this.onNodeUpdated(e)},t.prototype.isValidQueue=function(){for(var t=1;t0&&this.hasHigherPriority(t,n)?this.cascadeUp(t):this.cascadeDown(t)},t.prototype.cascadeDown=function(t){for(var e,n=t.queueIndex;;){e=t;var i=2*n;if(i>this._numNodes){t.queueIndex=n,this._nodes[n]=t;break}var r=this._nodes[i];this.hasHigherPriority(r,e)&&(e=r);var o=i+1;if(o<=this._numNodes){var s=this._nodes[o];this.hasHigherPriority(s,e)&&(e=s)}if(e==t){t.queueIndex=n,this._nodes[n]=t;break}this._nodes[n]=e;var a=e.queueIndex;e.queueIndex=n,n=a}},t.prototype.cascadeUp=function(t){for(var e=Math.floor(t.queueIndex/2);e>=1;){var n=this._nodes[e];if(this.hasHigherPriority(n,t))break;this.swap(t,n),e=Math.floor(t.queueIndex/2)}},t.prototype.swap=function(t,e){this._nodes[t.queueIndex]=e,this._nodes[e.queueIndex]=t;var n=t.queueIndex;t.queueIndex=e.queueIndex,e.queueIndex=n},t.prototype.hasHigherPriority=function(t,e){return t.priority0;){if("break"===c())break}return o?t.AStarPathfinder.recontructPath(a,n,i):null},e.hasKey=function(t,e){for(var n,i=t.keys();!(n=i.next()).done;)if(JSON.stringify(n.value)==JSON.stringify(e))return!0;return!1},e}();t.BreadthFirstPathfinder=e}(es||(es={})),function(t){var e=function(){function t(){this.edges=new Map}return t.prototype.addEdgesForNode=function(t,e){return this.edges.set(t,e),this},t.prototype.getNeighbors=function(t){return this.edges.get(t)},t}();t.UnweightedGraph=e}(es||(es={})),function(t){var e=function(){function e(t,e){this.x=0,this.y=0,this.x=t||0,this.y=null!=e?e:this.x}return Object.defineProperty(e,"zero",{get:function(){return e.zeroVector2},enumerable:!0,configurable:!0}),Object.defineProperty(e,"one",{get:function(){return e.unitVector2},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitX",{get:function(){return e.unitXVector},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitY",{get:function(){return e.unitYVector},enumerable:!0,configurable:!0}),e.add=function(t,n){var i=new e(0,0);return i.x=t.x+n.x,i.y=t.y+n.y,i},e.divide=function(t,n){var i=new e(0,0);return i.x=t.x/n.x,i.y=t.y/n.y,i},e.multiply=function(t,n){var i=new e(0,0);return i.x=t.x*n.x,i.y=t.y*n.y,i},e.subtract=function(t,n){var i=new e(0,0);return i.x=t.x-n.x,i.y=t.y-n.y,i},e.normalize=function(t){var e=1/Math.sqrt(t.x*t.x+t.y*t.y);return t.x*=e,t.y*=e,t},e.dot=function(t,e){return t.x*e.x+t.y*e.y},e.distanceSquared=function(t,e){var n=t.x-e.x,i=t.y-e.y;return n*n+i*i},e.clamp=function(n,i,r){return new e(t.MathHelper.clamp(n.x,i.x,r.x),t.MathHelper.clamp(n.y,i.y,r.y))},e.lerp=function(n,i,r){return new e(t.MathHelper.lerp(n.x,i.x,r),t.MathHelper.lerp(n.y,i.y,r))},e.transform=function(t,n){return new e(t.x*n.m11+t.y*n.m21+n.m31,t.x*n.m12+t.y*n.m22+n.m32)},e.distance=function(t,e){var n=t.x-e.x,i=t.y-e.y;return Math.sqrt(n*n+i*i)},e.angle=function(n,i){return n=e.normalize(n),i=e.normalize(i),Math.acos(t.MathHelper.clamp(e.dot(n,i),-1,1))*t.MathHelper.Rad2Deg},e.negate=function(t){var n=new e;return n.x=-t.x,n.y=-t.y,n},e.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this},e.prototype.divide=function(t){return this.x/=t.x,this.y/=t.y,this},e.prototype.multiply=function(t){return this.x*=t.x,this.y*=t.y,this},e.prototype.subtract=function(t){return this.x-=t.x,this.y-=t.y,this},e.prototype.normalize=function(){var t=1/Math.sqrt(this.x*this.x+this.y*this.y);return this.x*=t,this.y*=t,this},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},e.prototype.round=function(){return new e(Math.round(this.x),Math.round(this.y))},e.prototype.equals=function(t){return t.x==this.x&&t.y==this.y},e.unitYVector=new e(0,1),e.unitXVector=new e(1,0),e.unitVector2=new e(1,1),e.zeroVector2=new e(0,0),e}();t.Vector2=e}(es||(es={})),function(t){var e=function(){function e(t,n,i){void 0===i&&(i=!1),this.walls=[],this._neighbors=new Array(4),this._width=t,this._hegiht=n,this._dirs=i?e.COMPASS_DIRS:e.CARDINAL_DIRS}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x0;){if("break"===u())break}return s?this.recontructPath(a,i,r):null},n.recontructPath=function(t,e,n){var i=[],r=n;for(i.push(n);r!=e;)r=this.getKey(t,r),i.push(r);return i.reverse(),i},n.hasKey=function(t,e){for(var n,i=t.keys();!(n=i.next()).done;)if(JSON.stringify(n.value)==JSON.stringify(e))return!0;return!1},n.getKey=function(t,e){for(var n,i,r=t.keys(),o=t.values();n=r.next(),i=o.next(),!n.done;)if(JSON.stringify(n.value)==JSON.stringify(e))return i.value;return null},n}();t.WeightedPathfinder=n}(es||(es={})),function(t){var e=function(){function e(){}return e.drawHollowRect=function(e,n,i){void 0===i&&(i=0),this._debugDrawItems.push(new t.DebugDrawItem(e,n,i))},e.render=function(){if(this._debugDrawItems.length>0){var e=new egret.Shape;t.Core.scene&&t.Core.scene.addChild(e);for(var n=this._debugDrawItems.length-1;n>=0;n--){this._debugDrawItems[n].draw(e)&&this._debugDrawItems.removeAt(n)}}},e._debugDrawItems=[],e}();t.Debug=e}(es||(es={})),function(t){var e=function(){function t(){}return t.verletParticle=14431326,t.verletConstraintEdge=4406838,t}();t.DebugDefaults=e}(es||(es={})),function(t){var e;!function(t){t[t.line=0]="line",t[t.hollowRectangle=1]="hollowRectangle",t[t.pixel=2]="pixel",t[t.text=3]="text"}(e=t.DebugDrawType||(t.DebugDrawType={}));var n=function(){function n(t,n,i){this.rectangle=t,this.color=n,this.duration=i,this.drawType=e.hollowRectangle}return n.prototype.draw=function(n){switch(this.drawType){case e.line:t.DrawUtils.drawLine(n,this.start,this.end,this.color);break;case e.hollowRectangle:t.DrawUtils.drawHollowRect(n,this.rectangle,this.color);break;case e.pixel:t.DrawUtils.drawPixel(n,new t.Vector2(this.x,this.y),this.color,this.size);break;case e.text:}return this.duration-=t.Time.deltaTime,this.duration<0},n}();t.DebugDrawItem=n}(es||(es={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateInterval=1,e._enabled=!0,e._updateOrder=0,e}return __extends(e,t),Object.defineProperty(e.prototype,"transform",{get:function(){return this.entity.transform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this.entity?this.entity.enabled&&this._enabled:this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"updateOrder",{get:function(){return this._updateOrder},set:function(t){this.setUpdateOrder(t)},enumerable:!0,configurable:!0}),e.prototype.initialize=function(){},e.prototype.onAddedToEntity=function(){},e.prototype.onRemovedFromEntity=function(){},e.prototype.onEntityTransformChanged=function(t){},e.prototype.debugRender=function(){},e.prototype.onEnabled=function(){},e.prototype.onDisabled=function(){},e.prototype.update=function(){},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled()),this},e.prototype.setUpdateOrder=function(t){return this._updateOrder!=t&&(this._updateOrder=t),this},e.prototype.clone=function(){var t=ObjectUtils.clone(this);return t.entity=null,t},e}(egret.HashObject);t.Component=e}(es||(es={})),function(t){var e=function(e){function n(){var i=e.call(this)||this;return i._globalManagers=[],n._instance=i,n.emitter=new t.Emitter,n.content=new t.ContentManager,i.addEventListener(egret.Event.ADDED_TO_STAGE,i.onAddToStage,i),i}return __extends(n,e),Object.defineProperty(n,"Instance",{get:function(){return this._instance},enumerable:!0,configurable:!0}),Object.defineProperty(n,"scene",{get:function(){return this._instance?this._instance._scene:null},set:function(t){t?null==this._instance._scene?(this._instance._scene=t,this._instance.addChild(t),this._instance._scene.begin(),n.Instance.onSceneChanged()):this._instance._nextScene=t:console.error("场景不能为空")},enumerable:!0,configurable:!0}),n.startSceneTransition=function(t){if(!this._instance._sceneTransition)return this._instance._sceneTransition=t,t;console.warn("在前一个场景完成之前,不能开始一个新的场景转换。")},n.registerGlobalManager=function(t){this._instance._globalManagers.push(t),t.enabled=!0},n.unregisterGlobalManager=function(t){this._instance._globalManagers.remove(t),t.enabled=!1},n.getGlobalManager=function(t){for(var e=0;e=0;e--)this._globalManagers[e].enabled&&this._globalManagers[e].update();return this._sceneTransition&&(!this._sceneTransition||this._sceneTransition.loadsNewScene&&!this._sceneTransition.isNewSceneLoaded)||this._scene.update(),this._nextScene?(this.removeChild(this._scene),this._scene.end(),this._scene=this._nextScene,this._nextScene=null,this.onSceneChanged(),this.addChild(this._scene),[4,this._scene.begin()]):[3,2];case 1:n.sent(),n.label=2;case 2:return[4,this.draw()];case 3:return n.sent(),[2]}})})},n.prototype.onAddToStage=function(){n.graphicsDevice=new t.GraphicsDevice,this.addEventListener(egret.Event.RESIZE,this.onGraphicsDeviceReset,this),this.addEventListener(egret.StageOrientationEvent.ORIENTATION_CHANGE,this.onOrientationChanged,this),this.addEventListener(egret.Event.ENTER_FRAME,this.update,this),t.Input.initialize(),this.initialize()},n}(egret.DisplayObjectContainer);t.Core=e}(es||(es={})),function(t){!function(t){t[t.GraphicsDeviceReset=0]="GraphicsDeviceReset",t[t.SceneChanged=1]="SceneChanged",t[t.OrientationChanged=2]="OrientationChanged"}(t.CoreEvents||(t.CoreEvents={}))}(es||(es={})),function(t){var e=function(){function e(n){this.updateInterval=1,this._tag=0,this._enabled=!0,this._updateOrder=0,this.components=new t.ComponentList(this),this.transform=new t.Transform(this),this.name=n,this.id=e._idGenerator++,this.componentBits=new t.BitSet}return Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this._isDestroyed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tag",{get:function(){return this._tag},set:function(t){this.setTag(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"updateOrder",{get:function(){return this._updateOrder},set:function(t){this.setUpdateOrder(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this.transform.parent},set:function(t){this.transform.setParent(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"childCount",{get:function(){return this.transform.childCount},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this.transform.position},set:function(t){this.transform.setPosition(t.x,t.y)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localPosition",{get:function(){return this.transform.localPosition},set:function(t){this.transform.setLocalPosition(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotation",{get:function(){return this.transform.rotation},set:function(t){this.transform.setRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotationDegrees",{get:function(){return this.transform.rotationDegrees},set:function(t){this.transform.setRotationDegrees(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localRotation",{get:function(){return this.transform.localRotation},set:function(t){this.transform.setLocalRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localRotationDegrees",{get:function(){return this.transform.localRotationDegrees},set:function(t){this.transform.setLocalRotationDegrees(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scale",{get:function(){return this.transform.scale},set:function(t){this.transform.setScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localScale",{get:function(){return this.transform.localScale},set:function(t){this.transform.setLocalScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"worldInverseTransform",{get:function(){return this.transform.worldInverseTransform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localToWorldTransform",{get:function(){return this.transform.localToWorldTransform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"worldToLocalTransform",{get:function(){return this.transform.worldToLocalTransform},enumerable:!0,configurable:!0}),e.prototype.onTransformChanged=function(t){this.components.onEntityTransformChanged(t)},e.prototype.setTag=function(t){return this._tag!=t&&(this.scene&&this.scene.entities.removeFromTagList(this),this._tag=t,this.scene&&this.scene.entities.addToTagList(this)),this},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.components.onEntityEnabled():this.components.onEntityDisabled()),this},e.prototype.setUpdateOrder=function(t){if(this._updateOrder!=t)return this._updateOrder=t,this.scene&&(this.scene.entities.markEntityListUnsorted(),this.scene.entities.markTagUnsorted(this.tag)),this},e.prototype.destroy=function(){this._isDestroyed=!0,this.scene.entities.remove(this),this.transform.parent=null;for(var t=this.transform.childCount-1;t>=0;t--){this.transform.getChild(t).entity.destroy()}},e.prototype.detachFromScene=function(){this.scene.entities.remove(this),this.components.deregisterAllComponents();for(var t=0;t=0;t--)this._sceneComponents[t].enabled&&this._sceneComponents[t].update();this.entityProcessors&&this.entityProcessors.update(),this.entities.update(),this.entityProcessors&&this.entityProcessors.lateUpdate(),this.renderableComponents.updateList()},n.prototype.render=function(){if(0!=this._renderers.length)for(var t=0;te.x?-1:1,i=t.Vector2.normalize(t.Vector2.subtract(this.position,e));this.rotation=n*Math.acos(t.Vector2.dot(i,t.Vector2.unitY))},i.prototype.setLocalRotation=function(t){return this._localRotation=t,this._localDirty=this._positionDirty=this._localPositionDirty=this._localRotationDirty=this._localScaleDirty=!0,this.setDirty(e.rotationDirty),this},i.prototype.setLocalRotationDegrees=function(e){return this.setLocalRotation(t.MathHelper.toRadians(e))},i.prototype.setScale=function(e){return this._scale=e,this.parent?this.localScale=t.Vector2.divide(e,this.parent._scale):this.localScale=e,this},i.prototype.setLocalScale=function(t){return this._localScale=t,this._localDirty=this._positionDirty=this._localScaleDirty=!0,this.setDirty(e.scaleDirty),this},i.prototype.roundPosition=function(){this.position=this._position.round()},i.prototype.updateTransform=function(){this.hierarchyDirty!=e.clean&&(this.parent&&this.parent.updateTransform(),this._localDirty&&(this._localPositionDirty&&(this._translationMatrix=t.Matrix2D.create().translate(this._localPosition.x,this._localPosition.y),this._localPositionDirty=!1),this._localRotationDirty&&(this._rotationMatrix=t.Matrix2D.create().rotate(this._localRotation),this._localRotationDirty=!1),this._localScaleDirty&&(this._scaleMatrix=t.Matrix2D.create().scale(this._localScale.x,this._localScale.y),this._localScaleDirty=!1),this._localTransform=this._scaleMatrix.multiply(this._rotationMatrix),this._localTransform=this._localTransform.multiply(this._translationMatrix),this.parent||(this._worldTransform=this._localTransform,this._rotation=this._localRotation,this._scale=this._localScale,this._worldInverseDirty=!0),this._localDirty=!1),this.parent&&(this._worldTransform=this._localTransform.multiply(this.parent._worldTransform),this._rotation=this._localRotation+this.parent._rotation,this._scale=t.Vector2.multiply(this.parent._scale,this._localScale),this._worldInverseDirty=!0),this._worldToLocalDirty=!0,this._positionDirty=!0,this.hierarchyDirty=e.clean)},i.prototype.setDirty=function(e){if(0==(this.hierarchyDirty&e)){switch(this.hierarchyDirty|=e,e){case t.DirtyType.positionDirty:this.entity.onTransformChanged(transform.Component.position);break;case t.DirtyType.rotationDirty:this.entity.onTransformChanged(transform.Component.rotation);break;case t.DirtyType.scaleDirty:this.entity.onTransformChanged(transform.Component.scale)}this._children||(this._children=[]);for(var n=0;nt&&(this._zoom=t),this._maximumZoom=t,this;console.error("maximumZoom must be greater than zero")},r.prototype.onEntityTransformChanged=function(t){this._areMatrixedDirty=!0},r.prototype.zoomIn=function(t){this.zoom+=t},r.prototype.zoomOut=function(t){this.zoom-=t},r.prototype.worldToScreenPoint=function(e){return this.updateMatrixes(),e=t.Vector2.transform(e,this._transformMatrix)},r.prototype.screenToWorldPoint=function(e){return this.updateMatrixes(),e=t.Vector2.transform(e,this._inverseTransformMatrix)},r.prototype.mouseToWorldPoint=function(){return this.screenToWorldPoint(t.Input.touchPosition)},r.prototype.onAddedToEntity=function(){this.follow(this._targetEntity,this._cameraStyle)},r.prototype.update=function(){var e=t.Vector2.multiply(new t.Vector2(this.bounds.width,this.bounds.height),new t.Vector2(.5));this._worldSpaceDeadZone.x=this.position.x-e.x*t.Core.scene.scaleX+this.deadzone.x+this.focusOffset.x,this._worldSpaceDeadZone.y=this.position.y-e.y*t.Core.scene.scaleY+this.deadzone.y+this.focusOffset.y,this._worldSpaceDeadZone.width=this.deadzone.width,this._worldSpaceDeadZone.height=this.deadzone.height,this._targetEntity&&this.updateFollow(),this.position=t.Vector2.lerp(this.position,t.Vector2.add(this.position,this._desiredPositionDelta),this.followLerp),this.entity.transform.roundPosition(),this.mapLockEnabled&&(this.position=this.clampToMapSize(this.position),this.entity.transform.roundPosition())},r.prototype.clampToMapSize=function(e){var n=t.Vector2.multiply(new t.Vector2(this.bounds.width,this.bounds.height),new t.Vector2(.5)).add(new t.Vector2(this.mapSize.x,this.mapSize.y)),i=new t.Vector2(this.mapSize.width-n.x,this.mapSize.height-n.y);return t.Vector2.clamp(e,n,i)},r.prototype.updateFollow=function(){if(this._desiredPositionDelta.x=this._desiredPositionDelta.y=0,this._cameraStyle==e.lockOn){var n=this._targetEntity.transform.position.x,i=this._targetEntity.transform.position.y;this._worldSpaceDeadZone.x>n?this._desiredPositionDelta.x=n-this._worldSpaceDeadZone.x:this._worldSpaceDeadZone.xi&&(this._desiredPositionDelta.y=i-this._worldSpaceDeadZone.y)}else{if(!this._targetCollider&&(this._targetCollider=this._targetEntity.getComponent(t.Collider),!this._targetCollider))return;var r=this._targetEntity.getComponent(t.Collider).bounds;this._worldSpaceDeadZone.containsRect(r)||(this._worldSpaceDeadZone.left>r.left?this._desiredPositionDelta.x=r.left-this._worldSpaceDeadZone.left:this._worldSpaceDeadZone.rightr.top&&(this._desiredPositionDelta.y=r.top-this._worldSpaceDeadZone.top))}},r.prototype.follow=function(n,i){switch(void 0===i&&(i=e.cameraWindow),this._targetEntity=n,this._cameraStyle=i,this._cameraStyle){case e.cameraWindow:var r=this.bounds.width/6,o=this.bounds.height/3;this.deadzone=new t.Rectangle((this.bounds.width-r)/2,(this.bounds.height-o)/2,r,o);break;case e.lockOn:this.deadzone=new t.Rectangle(this.bounds.width/2,this.bounds.height/2,10,10)}},r.prototype.setCenteredDeadzone=function(e,n){this.deadzone=new t.Rectangle((this.bounds.width-e)/2,(this.bounds.height-n)/2,e,n)},r.prototype.updateMatrixes=function(){var e;this._areMatrixedDirty&&(this._transformMatrix=t.Matrix2D.create().translate(-this.entity.transform.position.x,-this.entity.transform.position.y),1!=this._zoom&&(e=t.Matrix2D.create().scale(this._zoom,this._zoom),this._transformMatrix=this._transformMatrix.multiply(e)),0!=this.entity.transform.rotation&&(e=t.Matrix2D.create().rotate(this.entity.transform.rotation),this._transformMatrix=this._transformMatrix.multiply(e)),e=t.Matrix2D.create().translate(this._origin.x,this._origin.y),this._transformMatrix=this._transformMatrix.multiply(e),this._inverseTransformMatrix=this._transformMatrix.invert(),this._areBoundsDirty=!0,this._areMatrixedDirty=!1)},r}(t.Component);t.Camera=i}(es||(es={})),function(t){var e=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n._shakeDirection=t.Vector2.zero,n._shakeOffset=t.Vector2.zero,n._shakeIntensity=0,n._shakeDegredation=.95,n}return __extends(n,e),n.prototype.shake=function(e,n,i){void 0===e&&(e=15),void 0===n&&(n=.9),void 0===i&&(i=t.Vector2.zero),this.enabled=!0,this._shakeIntensity=1)&&(n=.95),this._shakeDegredation=n)},n.prototype.update=function(){Math.abs(this._shakeIntensity)>0&&(this._shakeOffset=this._shakeDirection,0!=this._shakeOffset.x||0!=this._shakeOffset.y?this._shakeOffset.normalize():(this._shakeOffset.x=this._shakeOffset.x+Math.random()-.5,this._shakeOffset.y=this._shakeOffset.y+Math.random()-.5),this._shakeOffset.multiply(new t.Vector2(this._shakeIntensity)),this._shakeIntensity*=-this._shakeDegredation,Math.abs(this._shakeIntensity)<=.01&&(this._shakeIntensity=0,this.enabled=!1)),this.entity.scene.camera.position.add(this._shakeOffset)},n}(t.Component);t.CameraShake=e}(es||(es={})),function(t){var e=function(){function t(t){this._type=t,this._cache=[]}return t.prototype.obtain=function(){try{return this._cache.length>0?this._cache.shift():new this._type}catch(t){throw new Error(this._type+t)}},t.prototype.free=function(t){t.reset(),this._cache.push(t)},t}();t.ComponentPool=e}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.compare=function(t,e){return t.updateOrder-e.updateOrder},t}();t.IUpdatableComparer=e}(es||(es={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(t.Component);t.PooledComponent=e}(es||(es={})),function(t){var e=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n.displayObject=new egret.DisplayObject,n.color=0,n._areBoundsDirty=!0,n._localOffset=t.Vector2.zero,n._renderLayer=0,n._bounds=new t.Rectangle,n}return __extends(n,e),Object.defineProperty(n.prototype,"width",{get:function(){return this.bounds.width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return this.bounds.height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"localOffset",{get:function(){return this._localOffset},set:function(t){this.setLocalOffset(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"renderLayer",{get:function(){return this._renderLayer},set:function(t){this.setRenderLayer(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"bounds",{get:function(){return this._areBoundsDirty&&(this._bounds.calculateBounds(this.entity.transform.position,this._localOffset,t.Vector2.zero,this.entity.transform.scale,this.entity.transform.rotation,this.width,this.height),this._areBoundsDirty=!1),this._bounds},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isVisible",{get:function(){return this._isVisible},set:function(t){this._isVisible!=t&&(this._isVisible=t,this._isVisible?this.onBecameVisible():this.onBecameInvisible())},enumerable:!0,configurable:!0}),n.prototype.onEntityTransformChanged=function(t){this._areBoundsDirty=!0},n.prototype.isVisibleFromCamera=function(t){return this.isVisible=t.bounds.intersects(this.bounds),this.isVisible},n.prototype.setRenderLayer=function(t){if(t!=this._renderLayer){var e=this._renderLayer;this._renderLayer=t,this.entity&&this.entity.scene&&this.entity.scene.renderableComponents.updateRenderableRenderLayer(this,e,this._renderLayer)}return this},n.prototype.setColor=function(t){return this.color=t,this},n.prototype.setLocalOffset=function(t){return this._localOffset!=t&&(this._localOffset=t),this},n.prototype.sync=function(t){this.displayObject.x=this.entity.position.x+this.localOffset.x-t.position.x+t.origin.x,this.displayObject.y=this.entity.position.y+this.localOffset.y-t.position.y+t.origin.y,this.displayObject.scaleX=this.entity.scale.x,this.displayObject.scaleY=this.entity.scale.y,this.displayObject.rotation=this.entity.rotation},n.prototype.toString=function(){return"[RenderableComponent] renderLayer: "+this.renderLayer},n.prototype.onBecameVisible=function(){this.displayObject.visible=this.isVisible},n.prototype.onBecameInvisible=function(){this.displayObject.visible=this.isVisible},n}(t.Component);t.RenderableComponent=e}(es||(es={})),function(t){var e=function(){function e(){this.updateOrder=0,this._enabled=!0}return Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),e.prototype.onEnabled=function(){},e.prototype.onDisabled=function(){},e.prototype.onRemovedFromScene=function(){},e.prototype.update=function(){},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled),this},e.prototype.setUpdateOrder=function(e){return this.updateOrder!=e&&(this.updateOrder=e,t.Core.scene._sceneComponents.sort(this.compareTo)),this},e.prototype.compareTo=function(t){return this.updateOrder-t.updateOrder},e}();t.SceneComponent=e}(es||(es={})),function(t){var e=egret.Bitmap,n=function(n){function i(e){void 0===e&&(e=null);var i=n.call(this)||this;return e instanceof t.Sprite?i.setSprite(e):e instanceof egret.Texture&&i.setSprite(new t.Sprite(e)),i}return __extends(i,n),Object.defineProperty(i.prototype,"bounds",{get:function(){return this._areBoundsDirty&&this._sprite&&(this._bounds.calculateBounds(this.entity.transform.position,this._localOffset,this._origin,this.entity.transform.scale,this.entity.transform.rotation,this._sprite.sourceRect.width,this._sprite.sourceRect.height),this._areBoundsDirty=!1),this._bounds},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"originNormalized",{get:function(){return new t.Vector2(this._origin.x/this.width*this.entity.transform.scale.x,this._origin.y/this.height*this.entity.transform.scale.y)},set:function(e){this.setOrigin(new t.Vector2(e.x*this.width/this.entity.transform.scale.x,e.y*this.height/this.entity.transform.scale.y))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"origin",{get:function(){return this._origin},set:function(t){this.setOrigin(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"sprite",{get:function(){return this._sprite},set:function(t){this.setSprite(t)},enumerable:!0,configurable:!0}),i.prototype.setSprite=function(t){return this._sprite=t,this._sprite&&(this._origin=this._sprite.origin,this.displayObject.anchorOffsetX=this._origin.x,this.displayObject.anchorOffsetY=this._origin.y),this.displayObject=new e(t.texture2D),this},i.prototype.setOrigin=function(t){return this._origin!=t&&(this._origin=t,this.displayObject.anchorOffsetX=this._origin.x,this.displayObject.anchorOffsetY=this._origin.y,this._areBoundsDirty=!0),this},i.prototype.setOriginNormalized=function(e){return this.setOrigin(new t.Vector2(e.x*this.width/this.entity.transform.scale.x,e.y*this.height/this.entity.transform.scale.y)),this},i.prototype.render=function(t){this.sync(t),this.displayObject.x=this.entity.position.x+this.localOffset.x-t.position.x+t.origin.x,this.displayObject.y=this.entity.position.y+this.localOffset.y-t.position.y+t.origin.y},i}(t.RenderableComponent);t.SpriteRenderer=n}(es||(es={})),function(t){var e=egret.Bitmap,n=egret.RenderTexture,i=function(i){function r(e){var n=i.call(this,e)||this;return n._textureScale=t.Vector2.one,n._inverseTexScale=t.Vector2.one,n._gapX=0,n._gapY=0,n._sourceRect=e.sourceRect,n.displayObject.$fillMode=egret.BitmapFillMode.REPEAT,n}return __extends(r,i),Object.defineProperty(r.prototype,"bounds",{get:function(){return this._areBoundsDirty&&this._sprite&&(this._bounds.calculateBounds(this.entity.transform.position,this._localOffset,this._origin,this.entity.transform.scale,this.entity.transform.rotation,this.width,this.height),this._areBoundsDirty=!1),this._bounds},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scrollX",{get:function(){return this._sourceRect.x},set:function(t){this._sourceRect.x=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scrollY",{get:function(){return this._sourceRect.y},set:function(t){this._sourceRect.y=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"textureScale",{get:function(){return this._textureScale},set:function(e){this._textureScale=e,this._inverseTexScale=new t.Vector2(1/this._textureScale.x,1/this._textureScale.y),this._sourceRect.width=this._sprite.sourceRect.width*this._inverseTexScale.x,this._sourceRect.height=this._sprite.sourceRect.height*this._inverseTexScale.y},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"width",{get:function(){return this._sourceRect.width},set:function(t){this._areBoundsDirty=!0,this._sourceRect.width=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"height",{get:function(){return this._sourceRect.height},set:function(t){this._areBoundsDirty=!0,this._sourceRect.height=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"gapXY",{get:function(){return new t.Vector2(this._gapX,this._gapY)},set:function(t){this._gapX=t.x,this._gapY=t.y;var i=new n,r=this.sprite.sourceRect;r.x=0,r.y=0,r.width+=this._gapX,r.height+=this._gapY,i.drawToTexture(this.displayObject,r),this.displayObject?this.displayObject.texture=i:this.displayObject=new e(i)},enumerable:!0,configurable:!0}),r.prototype.setGapXY=function(t){return this.gapXY=t,this},r.prototype.render=function(t){i.prototype.render.call(this,t);var e=this.displayObject;e.width=this.width,e.height=this.height,e.scrollRect=this._sourceRect},r}(t.SpriteRenderer);t.TiledSpriteRenderer=i}(es||(es={})),function(t){var e=function(e){function n(t){var n=e.call(this,t)||this;return n.scrollSpeedX=15,n.scroolSpeedY=0,n._scrollX=0,n._scrollY=0,n._scrollWidth=0,n._scrollHeight=0,n._scrollWidth=n.width,n._scrollHeight=n.height,n}return __extends(n,e),Object.defineProperty(n.prototype,"textureScale",{get:function(){return this._textureScale},set:function(e){this._textureScale=e,this._inverseTexScale=new t.Vector2(1/this._textureScale.x,1/this._textureScale.y)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scrollWidth",{get:function(){return this._scrollWidth},set:function(t){this._scrollWidth=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scrollHeight",{get:function(){return this._scrollHeight},set:function(t){this._scrollHeight=t},enumerable:!0,configurable:!0}),n.prototype.update=function(){this.sprite&&(this._scrollX+=this.scrollSpeedX*t.Time.deltaTime,this._scrollY+=this.scroolSpeedY*t.Time.deltaTime,this._sourceRect.x=this._scrollX,this._sourceRect.y=this._scrollY,this._sourceRect.width=this._scrollWidth+Math.abs(this._scrollX),this._sourceRect.height=this._scrollHeight+Math.abs(this._scrollY))},n}(t.TiledSpriteRenderer);t.ScrollingSpriteRenderer=e}(es||(es={})),function(t){var e=function(){return function(e,n,i){void 0===n&&(n=new t.Rectangle(0,0,e.textureWidth,e.textureHeight)),void 0===i&&(i=n.getHalfSize()),this.uvs=new t.Rectangle,this.texture2D=e,this.sourceRect=n,this.center=new t.Vector2(.5*n.width,.5*n.height),this.origin=i;var r=1/e.textureWidth,o=1/e.textureHeight;this.uvs.x=n.x*r,this.uvs.y=n.y*o,this.uvs.width=n.width*r,this.uvs.height=n.height*o}}();t.Sprite=e}(es||(es={})),function(t){var e=function(){return function(t,e){this.sprites=t,this.frameRate=e}}();t.SpriteAnimation=e}(es||(es={})),function(t){var e,n;!function(t){t[t.loop=0]="loop",t[t.once=1]="once",t[t.clampForever=2]="clampForever",t[t.pingPong=3]="pingPong",t[t.pingPongOnce=4]="pingPongOnce"}(e=t.LoopMode||(t.LoopMode={})),function(t){t[t.none=0]="none",t[t.running=1]="running",t[t.paused=2]="paused",t[t.completed=3]="completed"}(n=t.State||(t.State={}));var i=function(i){function r(t){var e=i.call(this,t)||this;return e.speed=1,e.animationState=n.none,e._elapsedTime=0,e._animations=new Map,e}return __extends(r,i),Object.defineProperty(r.prototype,"isRunning",{get:function(){return this.animationState==n.running},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"animations",{get:function(){return this._animations},enumerable:!0,configurable:!0}),r.prototype.update=function(){if(this.animationState==n.running&&this.currentAnimation){var i=this.currentAnimation,r=1/(i.frameRate*this.speed),o=r*i.sprites.length;this._elapsedTime+=t.Time.deltaTime;var s=Math.abs(this._elapsedTime);if(this._loopMode==e.once&&s>o||this._loopMode==e.pingPongOnce&&s>2*o)return this.animationState=n.completed,this._elapsedTime=0,this.currentFrame=0,void(this.sprite=i.sprites[this.currentFrame]);var a=Math.floor(s/r),c=i.sprites.length;if(c>2&&(this._loopMode==e.pingPong||this._loopMode==e.pingPongOnce)){var h=c-1;this.currentFrame=h-Math.abs(h-a%(2*h))}else this.currentFrame=a%c;this.sprite=i.sprites[this.currentFrame]}},r.prototype.addAnimation=function(t,e){return!this.sprite&&e.sprites.length>0&&this.setSprite(e.sprites[0]),this._animations[t]=e,this},r.prototype.play=function(t,i){void 0===i&&(i=null),this.currentAnimation=this._animations[t],this.currentAnimationName=t,this.currentFrame=0,this.animationState=n.running,this.sprite=this.currentAnimation.sprites[0],this._elapsedTime=0,this._loopMode=i||e.loop},r.prototype.isAnimationActive=function(t){return this.currentAnimation&&this.currentAnimationName==t},r.prototype.pause=function(){this.animationState=n.paused},r.prototype.unPause=function(){this.animationState=n.running},r.prototype.stop=function(){this.currentAnimation=null,this.currentAnimationName=null,this.currentFrame=0,this.animationState=n.none},r}(t.SpriteRenderer);t.SpriteAnimator=i}(es||(es={})),function(t){var e=function(){function t(){}return Object.defineProperty(t.prototype,"hasCollision",{get:function(){return this.below||this.right||this.left||this.above},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this.becameGroundedThisFrame=this.isGroundedOnOnewayPlatform=this.right=this.left=this.above=this.below=!1,this.slopAngle=0},t.prototype.toString=function(){return"[CollisionState] r: "+this.right+", l: "+this.left+", a: "+this.above+", b: "+this.below+", angle: "+this.slopAngle+", wasGroundedLastFrame: "+this.wasGroundedLastFrame+", becameGroundedThisFrame: "+this.becameGroundedThisFrame},t}();t.CollisionState=e;var n=function(e){function n(){var t=e.call(this)||this;return t.colliderHorizontalInset=2,t.colliderVerticalInset=6,t}return __extends(n,e),n.prototype.testCollisions=function(e,n,i){this._boxColliderBounds=n,i.wasGroundedLastFrame=i.below,i.reset();var r=e.x;e.y;if(0!=r){var o=r>0?t.Edge.right:t.Edge.left,s=this.collisionRectForSide(o,r);this.testMapCollision(s,o,i,0)?(e.x=0-t.RectangleExt.getSide(n,o),i.left=o==t.Edge.left,i.right=o==t.Edge.right,i._movementRemainderX.reset()):(i.left=!1,i.right=!1)}},n.prototype.testMapCollision=function(e,n,i,r){var o=t.EdgeExt.oppositeEdge(n);t.EdgeExt.isVertical(o)?e.center.x:e.center.y,t.RectangleExt.getSide(e,n),t.EdgeExt.isVertical(o)},n.prototype.collisionRectForSide=function(e,n){var i;return i=t.EdgeExt.isHorizontal(e)?t.RectangleExt.getRectEdgePortion(this._boxColliderBounds,e):t.RectangleExt.getHalfRect(this._boxColliderBounds,e),t.EdgeExt.isVertical(e)?t.RectangleExt.contract(i,this.colliderHorizontalInset,0):t.RectangleExt.contract(i,0,this.colliderVerticalInset),t.RectangleExt.expandSide(i,e,n),i},n}(t.Component);t.TiledMapMover=n}(es||(es={})),function(t){var e=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.onAddedToEntity=function(){this._triggerHelper=new t.ColliderTriggerHelper(this.entity)},n.prototype.calculateMovement=function(e,n){if(!this.entity.getComponent(t.Collider)||!this._triggerHelper)return!1;for(var i=this.entity.getComponents(t.Collider),r=0;r>6;0!=(e&t.LONG_MASK)&&n++,this._bits=new Array(n)}return t.prototype.and=function(t){for(var e,n=Math.min(this._bits.length,t._bits.length),i=0;i=0;)this._bits[e]&=~t._bits[e]},t.prototype.cardinality=function(){for(var t=0,e=this._bits.length-1;e>=0;e--){var n=this._bits[e];if(0!=n)if(-1!=n){var i=((n=((n=(n>>1&0x5555555555555400)+(0x5555555555555400&n))>>2&0x3333333333333400)+(0x3333333333333400&n))>>32)+n;t+=((i=((i=(i>>4&252645135)+(252645135&i))>>8&16711935)+(16711935&i))>>16&65535)+(65535&i)}else t+=64}return t},t.prototype.clear=function(t){if(null!=t){var e=t>>6;this.ensure(e),this._bits[e]&=~(1<>6;return!(e>=this._bits.length)&&0!=(this._bits[e]&1<=0;)if(0!=(this._bits[e]&t._bits[e]))return!0;return!1},t.prototype.isEmpty=function(){for(var t=this._bits.length-1;t>=0;t--)if(this._bits[t])return!1;return!0},t.prototype.nextSetBit=function(t){for(var e=t>>6,n=1<>6;this.ensure(n),this._bits[n]|=1<=this._bits.length){var e=new Number[t+1];e=this._bits.copyWithin(0,0,this._bits.length),this._bits=e}},t.LONG_MASK=63,t}();t.BitSet=e}(es||(es={})),function(t){var e=function(){function e(t){this._components=[],this._componentsToAdd=[],this._componentsToRemove=[],this._tempBufferList=[],this._entity=t}return Object.defineProperty(e.prototype,"count",{get:function(){return this._components.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buffer",{get:function(){return this._components},enumerable:!0,configurable:!0}),e.prototype.markEntityListUnsorted=function(){this._isComponentListUnsorted=!0},e.prototype.add=function(t){this._componentsToAdd.push(t)},e.prototype.remove=function(t){this._componentsToRemove.contains(t)&&console.warn("You are trying to remove a Component ("+t+") that you already removed"),this._componentsToAdd.contains(t)?this._componentsToAdd.remove(t):this._componentsToRemove.push(t)},e.prototype.removeAllComponents=function(){for(var t=0;t0){for(var n=0;n0){n=0;for(var i=this._componentsToAdd.length;n0){var e=this._entitiesToRemove;this._entitiesToRemove=this._tempEntityList,this._tempEntityList=e,this._tempEntityList.forEach(function(e){t.removeFromTagList(e),t._entities.remove(e),e.onRemovedFromScene(),e.scene=null,t.scene.entityProcessors.onEntityRemoved(e)}),this._tempEntityList.length=0}if(this._entitiesToAdded.length>0){e=this._entitiesToAdded;this._entitiesToAdded=this._tempEntityList,this._tempEntityList=e,this._tempEntityList.forEach(function(e){t._entities.contains(e)||(t._entities.push(e),e.scene=t.scene,t.addToTagList(e),t.scene.entityProcessors.onEntityAdded(e))}),this._tempEntityList.forEach(function(t){return t.onAddedToScene()}),this._tempEntityList.length=0,this._isEntityListUnsorted=!0}this._isEntityListUnsorted&&(this._entities.sort(),this._isEntityListUnsorted=!1),this._unsortedTags.length>0&&(this._unsortedTags.forEach(function(e){t._entityDict.get(e).sort()}),this._unsortedTags.length=0)},e.prototype.findEntity=function(t){for(var e=0;e=0;e=this.allSet.nextSetBit(e+1))if(!t.componentBits.get(e))return!1;return!(!this.exclusionSet.isEmpty()&&this.exclusionSet.intersects(t.componentBits))&&!(!this.oneSet.isEmpty()&&!this.oneSet.intersects(t.componentBits))},e.prototype.all=function(){for(var e=this,n=[],i=0;i0){for(var t=0,n=this._unsortedRenderLayers.length;t=e)return t;var i=!1;"-"==t.substr(0,1)&&(i=!0,t=t.substr(1));for(var r=e-n,o=0;o1?this.reverse(t.substring(1))+t.substring(0,1):t},t.cutOff=function(t,e,n,i){void 0===i&&(i=!0),e=Math.floor(e),n=Math.floor(n);var r=t.length;e>r&&(e=r);var o,s=e,a=e+n;return i?o=t.substring(0,s)+t.substr(a,r):(a=(s=r-1-e-n)+n,o=t.substring(0,s+1)+t.substr(a+1,r)),o},t.strReplace=function(t,e){for(var n=0,i=e.length;n",">",'"',""","'","'","®","®","©","©","™","™"],t}();!function(t){var e=function(){function e(){}return e.convertImageToCanvas=function(e,n){this.sharedCanvas||(this.sharedCanvas=egret.sys.createCanvas(),this.sharedContext=this.sharedCanvas.getContext("2d"));var i=e.$getTextureWidth(),r=e.$getTextureHeight();n||((n=egret.$TempRectangle).x=0,n.y=0,n.width=i,n.height=r),n.x=Math.min(n.x,i-1),n.y=Math.min(n.y,r-1),n.width=Math.min(n.width,i-n.x),n.height=Math.min(n.height,r-n.y);var o=Math.floor(n.width),s=Math.floor(n.height),a=this.sharedCanvas;if(a.style.width=o+"px",a.style.height=s+"px",this.sharedCanvas.width=o,this.sharedCanvas.height=s,"webgl"==egret.Capabilities.renderMode){var c=void 0;e.$renderBuffer?c=e:(egret.sys.systemRenderer.renderClear&&egret.sys.systemRenderer.renderClear(),(c=new egret.RenderTexture).drawToTexture(new egret.Bitmap(e)));for(var h=c.$renderBuffer.getPixels(n.x,n.y,o,s),u=0,l=0,p=0;p=0?"png":"jpg"});return wx.getFileSystemManager().saveFile({tempFilePath:o,filePath:wx.env.USER_DATA_PATH+"/"+n,success:function(t){}}),o},e.getPixel32=function(t,e,n){return egret.$warn(1041,"getPixel32","getPixels"),t.getPixels(e,n)},e.getPixels=function(t,e,n,i,r){if(void 0===i&&(i=1),void 0===r&&(r=1),"webgl"==egret.Capabilities.renderMode){var o=void 0;return t.$renderBuffer?o=t:(o=new egret.RenderTexture).drawToTexture(new egret.Bitmap(t)),o.$renderBuffer.getPixels(e,n,i,r)}try{this.convertImageToCanvas(t);return this.sharedContext.getImageData(e,n,i,r).data}catch(t){egret.$error(1039)}},e}();t.TextureUtils=e}(es||(es={})),function(t){var e=function(){function t(){}return t.update=function(t){var e=(t-this._lastTime)/1e3;this.deltaTime=e*this.timeScale,this.unscaledDeltaTime=e,this._timeSinceSceneLoad+=e,this.frameCount++,this._lastTime=t},t.sceneChanged=function(){this._timeSinceSceneLoad=0},t.checkEvery=function(t){return this._timeSinceSceneLoad/t>(this._timeSinceSceneLoad-this.deltaTime)/t},t.deltaTime=0,t.timeScale=1,t.frameCount=0,t._lastTime=0,t}();t.Time=e}(es||(es={}));var TimeUtils=function(){function t(){}return t.monthId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getFullYear(),n=t.getMonth()+1;return parseInt(e+(n<10?"0":"")+n)},t.dateId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getMonth()+1,n=e<10?"0":"",i=t.getDate(),r=i<10?"0":"";return parseInt(t.getFullYear()+n+e+r+i)},t.weekId=function(t,e){void 0===t&&(t=null),void 0===e&&(e=!0),t=t||new Date;var n=new Date;n.setTime(t.getTime()),n.setDate(1),n.setMonth(0);var i=n.getFullYear(),r=n.getDay();0==r&&(r=7);var o=!1;r<=4?(o=r>1,n.setDate(n.getDate()-(r-1))):n.setDate(n.getDate()+7-r+1);var s=this.diffDay(t,n,!1);if(s<0)return n.setDate(1),n.setMonth(0),n.setDate(n.getDate()-1),this.weekId(n,!1);var a=s/7,c=Math.floor(a)+1;if(53==c){n.setTime(t.getTime()),n.setDate(n.getDate()-1);var h=n.getDay();if(0==h&&(h=7),e&&(!o||h<4))return n.setFullYear(n.getFullYear()+1),n.setDate(1),n.setMonth(0),this.weekId(n,!1)}return parseInt(i+"00"+(c>9?"":"0")+c)},t.diffDay=function(t,e,n){void 0===n&&(n=!1);var i=(t.getTime()-e.getTime())/864e5;return n?Math.ceil(i):Math.floor(i)},t.getFirstDayOfWeek=function(t){var e=(t=t||new Date).getDay()||7;return new Date(t.getFullYear(),t.getMonth(),t.getDate()+1-e,0,0,0,0)},t.getFirstOfDay=function(t){return(t=t||new Date).setHours(0,0,0,0),t},t.getNextFirstOfDay=function(t){return new Date(this.getFirstOfDay(t).getTime()+864e5)},t.formatDate=function(t){var e=t.getFullYear(),n=t.getMonth()+1;n=n<10?"0"+n:n;var i=t.getDate();return e+"-"+n+"-"+(i=i<10?"0"+i:i)},t.formatDateTime=function(t){var e=t.getFullYear(),n=t.getMonth()+1;n=n<10?"0"+n:n;var i=t.getDate();i=i<10?"0"+i:i;var r=t.getHours(),o=t.getMinutes();o=o<10?"0"+o:o;var s=t.getSeconds();return e+"-"+n+"-"+i+" "+r+":"+o+":"+(s=s<10?"0"+s:s)},t.parseDate=function(t){var e=Date.parse(t);return isNaN(e)?new Date:new Date(Date.parse(t.replace(/-/g,"/")))},t.secondToTime=function(t,e,n){void 0===t&&(t=0),void 0===e&&(e=":"),void 0===n&&(n=!0);var i=Math.floor(t/3600),r=Math.floor(t%3600/60),o=Math.floor(t%3600%60),s=i.toString(),a=r.toString(),c=o.toString();return i<10&&(s="0"+s),r<10&&(a="0"+a),o<10&&(c="0"+c),n?s+e+a+e+c:a+e+c},t.timeToMillisecond=function(t,e){void 0===e&&(e=":");for(var n=t.split(e),i=0,r=n.length,o=0;o-1?this.os="iOS":i.indexOf("android")>-1&&(this.os="Android");var r=n.language;r=r.indexOf("zh")>-1?"zh-CN":"en-US",this.language=r}},e}(egret.Capabilities);t.GraphicsCapabilities=e}(es||(es={})),function(t){var e=function(){function e(){this.setup(),this.graphicsCapabilities=new t.GraphicsCapabilities,this.graphicsCapabilities.initialize(this)}return Object.defineProperty(e.prototype,"viewport",{get:function(){return this._viewport},enumerable:!0,configurable:!0}),e.prototype.setup=function(){this._viewport=new t.Viewport(0,0,t.Core._instance.stage.stageWidth,t.Core._instance.stage.stageHeight)},e}();t.GraphicsDevice=e}(es||(es={})),function(t){var e=function(){function e(t,e,n,i){this._x=t,this._y=e,this._width=n,this._height=i,this._minDepth=0,this._maxDepth=1}return Object.defineProperty(e.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"aspectRatio",{get:function(){return 0!=this._height&&0!=this._width?this._width/this._height:0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bounds",{get:function(){return new t.Rectangle(this._x,this._y,this._width,this._height)},set:function(t){this._x=t.x,this._y=t.y,this._width=t.width,this._height=t.height},enumerable:!0,configurable:!0}),e}();t.Viewport=e}(es||(es={})),function(t){var e=function(e){function n(){return e.call(this,t.PostProcessor.default_vert,n.blur_frag,{screenWidth:t.Core.graphicsDevice.viewport.width,screenHeight:t.Core.graphicsDevice.viewport.height})||this}return __extends(n,e),n.blur_frag="precision mediump float;\nuniform sampler2D uSampler;\nuniform float screenWidth;\nuniform float screenHeight;\nfloat normpdf(in float x, in float sigma)\n{\nreturn 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;\n}\nvoid main()\n{\nvec3 c = texture2D(uSampler, gl_FragCoord.xy / vec2(screenWidth, screenHeight).xy).rgb;\nconst int mSize = 11;\nconst int kSize = (mSize - 1)/2;\nfloat kernel[mSize];\nvec3 final_colour = vec3(0.0);\nfloat sigma = 7.0;\nfloat z = 0.0;\nfor (int j = 0; j <= kSize; ++j)\n{\nkernel[kSize+j] = kernel[kSize-j] = normpdf(float(j),sigma);\n}\nfor (int j = 0; j < mSize; ++j)\n{\nz += kernel[j];\n}\nfor (int i = -kSize; i <= kSize; ++i)\n{\nfor (int j = -kSize; j <= kSize; ++j)\n{\nfinal_colour += kernel[kSize+j]*kernel[kSize+i]*texture2D(uSampler, (gl_FragCoord.xy+vec2(float(i),float(j))) / vec2(screenWidth, screenHeight).xy).rgb;\n}\n}\ngl_FragColor = vec4(final_colour/(z*z), 1.0);\n}",n}(egret.CustomFilter);t.GaussianBlurEffect=e}(es||(es={})),function(t){var e=function(t){function e(){return t.call(this,e.vertSrc,e.fragmentSrc)||this}return __extends(e,t),e.vertSrc="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nuniform vec2 projectionVector;\nvarying vec2 vTextureCoord;\nconst vec2 center = vec2(-1.0, 1.0);\nvoid main(void) {\n gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",e.fragmentSrc="precision lowp float;\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n#define SAMPLE_COUNT 15\nuniform vec2 _sampleOffsets[SAMPLE_COUNT];\nuniform float _sampleWeights[SAMPLE_COUNT];\nvoid main(void) {\nvec4 c = vec4(0, 0, 0, 0);\nfor( int i = 0; i < SAMPLE_COUNT; i++ )\n c += texture2D( uSampler, vTextureCoord + _sampleOffsets[i] ) * _sampleWeights[i];\ngl_FragColor = c;\n}",e}(egret.CustomFilter);t.PolygonLightEffect=e}(es||(es={})),function(t){var e=function(){function e(t){void 0===t&&(t=null),this.enabled=!0,this.effect=t}return e.prototype.onAddedToScene=function(e){this.scene=e,this.shape=new egret.Shape,this.shape.graphics.beginFill(16777215,1),this.shape.graphics.drawRect(0,0,t.Core.graphicsDevice.viewport.width,t.Core.graphicsDevice.viewport.height),this.shape.graphics.endFill(),e.addChild(this.shape)},e.prototype.process=function(){this.drawFullscreenQuad()},e.prototype.onSceneBackBufferSizeChanged=function(t,e){},e.prototype.unload=function(){this.effect&&(this.effect=null),this.scene.removeChild(this.shape),this.scene=null},e.prototype.drawFullscreenQuad=function(){this.scene.filters=[this.effect]},e.default_vert="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec2 aColor;\nuniform vec2 projectionVector;\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nconst vec2 center = vec2(-1.0, 1.0);\nvoid main(void) {\ngl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\nvTextureCoord = aTextureCoord;\nvColor = vec4(aColor.x, aColor.x, aColor.x, aColor.x);\n}",e}();t.PostProcessor=e}(es||(es={})),function(t){var e=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.onAddedToScene=function(n){e.prototype.onAddedToScene.call(this,n),this.effect=new t.GaussianBlurEffect},n}(t.PostProcessor);t.GaussianBlurPostProcessor=e}(es||(es={})),function(t){var e=function(){function t(t,e){void 0===e&&(e=null),this.renderOrder=0,this.camera=e,this.renderOrder=t}return t.prototype.onAddedToScene=function(t){},t.prototype.unload=function(){},t.prototype.onSceneBackBufferSizeChanged=function(t,e){},t.prototype.compareTo=function(t){return this.renderOrder-t.renderOrder},t.prototype.beginRender=function(t){},t.prototype.renderAfterStateCheck=function(t,e){t.render(e)},t}();t.Renderer=e}(es||(es={})),function(t){var e=function(t){function e(){return t.call(this,0,null)||this}return __extends(e,t),e.prototype.render=function(t){var e=this.camera?this.camera:t.camera;this.beginRender(e);for(var n=0;nn?n:t},e.pointOnCirlce=function(n,i,r){var o=e.toRadians(r);return new t.Vector2(Math.cos(o)*o+n.x,Math.sin(o)*o+n.y)},e.isEven=function(t){return t%2==0},e.clamp01=function(t){return t<0?0:t>1?1:t},e.angleBetweenVectors=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)},e.incrementWithWrap=function(t,e){return++t==e?0:t},e.Epsilon=1e-5,e.Rad2Deg=57.29578,e.Deg2Rad=.0174532924,e}();t.MathHelper=e}(es||(es={})),function(t){t.matrixPool=[];var e=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),Object.defineProperty(n.prototype,"m11",{get:function(){return this.a},set:function(t){this.a=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"m12",{get:function(){return this.b},set:function(t){this.b=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"m21",{get:function(){return this.c},set:function(t){this.c=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"m22",{get:function(){return this.d},set:function(t){this.d=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"m31",{get:function(){return this.tx},set:function(t){this.tx=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"m32",{get:function(){return this.ty},set:function(t){this.ty=t},enumerable:!0,configurable:!0}),n.create=function(){var e=t.matrixPool.pop();return e||(e=new n),e},n.prototype.identity=function(){return this.a=this.d=1,this.b=this.c=this.tx=this.ty=0,this},n.prototype.translate=function(t,e){return this.tx+=t,this.ty+=e,this},n.prototype.scale=function(t,e){return 1!==t&&(this.a*=t,this.c*=t,this.tx*=t),1!==e&&(this.b*=e,this.d*=e,this.ty*=e),this},n.prototype.rotate=function(t){if(0!==(t=+t)){t/=DEG_TO_RAD;var e=Math.cos(t),n=Math.sin(t),i=this.a,r=this.b,o=this.c,s=this.d,a=this.tx,c=this.ty;this.a=i*e-r*n,this.b=i*n+r*e,this.c=o*e-s*n,this.d=o*n+s*e,this.tx=a*e-c*n,this.ty=a*n+c*e}return this},n.prototype.invert=function(){return this.$invertInto(this),this},n.prototype.add=function(t){return this.m11+=t.m11,this.m12+=t.m12,this.m21+=t.m21,this.m22+=t.m22,this.m31+=t.m31,this.m32+=t.m32,this},n.prototype.substract=function(t){return this.m11-=t.m11,this.m12-=t.m12,this.m21-=t.m21,this.m22-=t.m22,this.m31-=t.m31,this.m32-=t.m32,this},n.prototype.divide=function(t){return this.m11/=t.m11,this.m12/=t.m12,this.m21/=t.m21,this.m22/=t.m22,this.m31/=t.m31,this.m32/=t.m32,this},n.prototype.multiply=function(t){var e=this.m11*t.m11+this.m12*t.m21,n=this.m11*t.m12+this.m12*t.m22,i=this.m21*t.m11+this.m22*t.m21,r=this.m21*t.m12+this.m22*t.m22,o=this.m31*t.m11+this.m32*t.m21+t.m31,s=this.m31*t.m12+this.m32*t.m22+t.m32;return this.m11=e,this.m12=n,this.m21=i,this.m22=r,this.m31=o,this.m32=s,this},n.prototype.determinant=function(){return this.m11*this.m22-this.m12*this.m21},n.prototype.release=function(e){e&&t.matrixPool.push(e)},n}(egret.Matrix);t.Matrix2D=e}(es||(es={})),function(t){var e=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),Object.defineProperty(n.prototype,"max",{get:function(){return new t.Vector2(this.right,this.bottom)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"center",{get:function(){return new t.Vector2(this.x+this.width/2,this.y+this.height/2)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"location",{get:function(){return new t.Vector2(this.x,this.y)},set:function(t){this.x=t.x,this.y=t.y},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"size",{get:function(){return new t.Vector2(this.width,this.height)},set:function(t){this.width=t.x,this.height=t.y},enumerable:!0,configurable:!0}),n.fromMinMax=function(t,e,i,r){return new n(t,e,i-t,r-e)},n.rectEncompassingPoints=function(t){for(var e=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=0;oi&&(i=s.x),s.yr&&(r=s.y)}return this.fromMinMax(e,n,i,r)},n.prototype.intersects=function(t){return t.leftthis.x+this.width)return e}else{var i=1/t.direction.x,r=(this.x-t.start.x)*i,o=(this.x+this.width-t.start.x)*i;if(r>o){var s=r;r=o,o=s}if((e=Math.max(r,e))>(n=Math.min(o,n)))return e}if(Math.abs(t.direction.y)<1e-6){if(t.start.ythis.y+this.height)return e}else{var a=1/t.direction.y,c=(this.y-t.start.y)*a,h=(this.y+this.height-t.start.y)*a;if(c>h){var u=c;c=h,h=u}if((e=Math.max(c,e))>(n=Math.max(h,n)))return e}return e},n.prototype.containsRect=function(t){return this.x<=t.x&&t.x1)return!1;var u=(c.x*o.y-c.y*o.x)/a;return!(u<0||u>1)},n.lineToLineIntersection=function(e,n,i,r){var o=new t.Vector2(0,0),s=t.Vector2.subtract(n,e),a=t.Vector2.subtract(r,i),c=s.x*a.y-s.y*a.x;if(0==c)return o;var h=t.Vector2.subtract(i,e),u=(h.x*a.y-h.y*a.x)/c;if(u<0||u>1)return o;var l=(h.x*s.y-h.y*s.x)/c;return l<0||l>1?o:o=t.Vector2.add(e,new t.Vector2(u*s.x,u*s.y))},n.closestPointOnLine=function(e,n,i){var r=t.Vector2.subtract(n,e),o=t.Vector2.subtract(i,e),s=t.Vector2.dot(o,r)/t.Vector2.dot(r,r);return s=t.MathHelper.clamp(s,0,1),t.Vector2.add(e,new t.Vector2(r.x*s,r.y*s))},n.isCircleToCircle=function(e,n,i,r){return t.Vector2.distanceSquared(e,i)<(n+r)*(n+r)},n.isCircleToLine=function(e,n,i,r){return t.Vector2.distanceSquared(e,this.closestPointOnLine(i,r,e))=t&&r.y>=e&&r.x=t+i&&(s|=e.right),o.y=n+r&&(s|=e.bottom),s},n}();t.Collisions=n}(es||(es={})),function(t){var e=function(){function e(){}return e.reset=function(){this._spatialHash=new t.SpatialHash(this.spatialHashCellSize)},e.clear=function(){this._spatialHash.clear()},e.overlapCircleAll=function(t,e,n,i){if(void 0===i&&(i=-1),0!=n.length)return this._spatialHash.overlapCircle(t,e,n,i);console.error("An empty results array was passed in. No results will ever be returned.")},e.boxcastBroadphase=function(t,e){return void 0===e&&(e=this.allLayers),this._spatialHash.aabbBroadphase(t,null,e)},e.boxcastBroadphaseExcludingSelf=function(t,e,n){return void 0===n&&(n=this.allLayers),this._spatialHash.aabbBroadphase(e,t,n)},e.addCollider=function(t){e._spatialHash.register(t)},e.removeCollider=function(t){e._spatialHash.remove(t)},e.updateCollider=function(t){this._spatialHash.remove(t),this._spatialHash.register(t)},e.debugDraw=function(t){this._spatialHash.debugDraw(t,2)},e.spatialHashCellSize=100,e.allLayers=-1,e.raycastsHitTriggers=!1,e.raycastsStartInColliders=!1,e}();t.Physics=e}(es||(es={})),function(t){var e=function(){return function(e,n){this.start=e,this.end=n,this.direction=t.Vector2.subtract(this.end,this.start)}}();t.Ray2D=e}(es||(es={})),function(t){var e=function(){function e(e,n,i,r,o){this.fraction=0,this.distance=0,this.point=t.Vector2.zero,this.normal=t.Vector2.zero,this.collider=e,this.fraction=n,this.distance=i,this.point=r,this.centroid=t.Vector2.zero}return e.prototype.setValues=function(t,e,n,i){this.collider=t,this.fraction=e,this.distance=n,this.point=i},e.prototype.setValuesNonCollider=function(t,e,n,i){this.fraction=t,this.distance=e,this.point=n,this.normal=i},e.prototype.reset=function(){this.collider=null,this.fraction=this.distance=0},e.prototype.toString=function(){return"[RaycastHit] fraction: "+this.fraction+", distance: "+this.distance+", normal: "+this.normal+", centroid: "+this.centroid+", point: "+this.point},e}();t.RaycastHit=e}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.clone=function(){return ObjectUtils.clone(this)},t}();t.Shape=e}(es||(es={})),function(t){var e=function(e){function n(t,n){var i=e.call(this)||this;return i._areEdgeNormalsDirty=!0,i.isUnrotated=!0,i.setPoints(t),i.isBox=n,i}return __extends(n,e),Object.defineProperty(n.prototype,"edgeNormals",{get:function(){return this._areEdgeNormalsDirty&&this.buildEdgeNormals(),this._edgeNormals},enumerable:!0,configurable:!0}),n.prototype.setPoints=function(t){this.points=t,this.recalculateCenterAndEdgeNormals(),this._originalPoints=[];for(var e=0;e=this.points.length?this.points[0]:this.points[i+1];var o=t.Vector2Ext.perpendicular(r,e);o=t.Vector2.normalize(o),this._edgeNormals[i]=o}},n.buildSymmetricalPolygon=function(e,n){for(var i=new Array(e),r=0;rr&&(r=s,i=o)}return e[i]},n.getClosestPointOnPolygonToPoint=function(e,n,i,r){i=Number.MAX_VALUE,r=new t.Vector2(0,0);for(var o,s=new t.Vector2(0,0),a=0;ae.y!=this.points[r].y>e.y&&e.x<(this.points[r].x-this.points[i].x)*(e.y-this.points[i].y)/(this.points[r].y-this.points[i].y)+this.points[i].x&&(n=!n);return n},n.prototype.pointCollidesWithShape=function(e,n){return t.ShapeCollisions.pointToPoly(e,this,n)},n}(t.Shape);t.Polygon=e}(es||(es={})),function(t){var e=function(e){function n(t,i){var r=e.call(this,n.buildBox(t,i),!0)||this;return r.width=t,r.height=i,r}return __extends(n,e),n.buildBox=function(e,n){var i=e/2,r=n/2,o=new Array(4);return o[0]=new t.Vector2(-i,-r),o[1]=new t.Vector2(i,-r),o[2]=new t.Vector2(i,r),o[3]=new t.Vector2(-i,r),o},n.prototype.updateBox=function(e,n){this.width=e,this.height=n;var i=e/2,r=n/2;this.points[0]=new t.Vector2(-i,-r),this.points[1]=new t.Vector2(i,-r),this.points[2]=new t.Vector2(i,r),this.points[3]=new t.Vector2(-i,r);for(var o=0;o1)return s;var a,c=t.Vector2.add(o.start,t.Vector2.add(o.direction,new t.Vector2(s))),h=0;c.xn.bounds.right&&(h|=1),c.yn.bounds.bottom&&(h|=2);var u=a+h;return 3==u&&console.log("m == 3. corner "+t.Time.frameCount),s},e}();t.RealtimeCollisions=e}(es||(es={})),function(t){var e=function(){function e(){}return e.polygonToPolygon=function(e,n,i){for(var r,o=!0,s=e.edgeNormals,a=n.edgeNormals,c=Number.POSITIVE_INFINITY,h=new t.Vector2,u=t.Vector2.subtract(e.position,n.position),l=0;l0&&(o=!1),!o)return!1;(g=Math.abs(g))r&&(r=o);return{min:i,max:r}},e.circleToPolygon=function(e,n,i){var r,o=t.Vector2.subtract(e.position,n.position),s=t.Polygon.getClosestPointOnPolygonToPoint(n.points,o,0,i.normal),a=n.containsPoint(e.position);if(0>e.radius*e.radius&&!a)return!1;a?r=t.Vector2.multiply(i.normal,new t.Vector2(Math.sqrt(0)-e.radius)):r=t.Vector2.multiply(i.normal,new t.Vector2(e.radius));return i.minimumTranslationVector=r,i.point=t.Vector2.add(s,n.position),!0},e.circleToBox=function(e,n,i){var r=n.bounds.getClosestPointOnRectangleBorderToPoint(e.position,i.normal);if(n.containsPoint(e.position)){i.point=r;var o=t.Vector2.add(r,t.Vector2.multiply(i.normal,new t.Vector2(e.radius)));return i.minimumTranslationVector=t.Vector2.subtract(e.position,o),!0}var s=t.Vector2.distanceSquared(r,e.position);if(0==s)i.minimumTranslationVector=t.Vector2.multiply(i.normal,new t.Vector2(e.radius));else if(s<=e.radius*e.radius){i.normal=t.Vector2.subtract(e.position,r);var a=i.normal.length()-e.radius;return i.point=r,i.normal=t.Vector2Ext.normalize(i.normal),i.minimumTranslationVector=t.Vector2.multiply(new t.Vector2(a),i.normal),!0}return!1},e.pointToCircle=function(e,n,i){var r=t.Vector2.distanceSquared(e,n.position),o=1+n.radius;if(r1)return!1;var l=(h.x*s.y-h.y*s.x)/c;return!(l<0||l>1)&&(o=o.add(e).add(t.Vector2.multiply(new t.Vector2(u),s)),!0)},e.lineToCircle=function(e,n,i,r){var o=t.Vector2.distance(e,n),s=t.Vector2.divide(t.Vector2.subtract(n,e),new t.Vector2(o)),a=t.Vector2.subtract(e,i.position),c=t.Vector2.dot(a,s),h=t.Vector2.dot(a,a)-i.radius*i.radius;if(h>0&&c>0)return!1;var u=c*c-h;return!(u<0)&&(r.fraction=-c-Math.sqrt(u),r.fraction<0&&(r.fraction=0),r.point=t.Vector2.add(e,t.Vector2.multiply(new t.Vector2(r.fraction),s)),r.distance=t.Vector2.distance(e,r.point),r.normal=t.Vector2.normalize(t.Vector2.subtract(r.point,i.position)),r.fraction=r.distance/o,!0)},e.boxToBoxCast=function(e,n,i,r){var o=this.minkowskiDifference(e,n);if(o.contains(0,0)){var s=o.getClosestPointOnBoundsToOrigin();return!s.equals(t.Vector2.zero)&&(r.normal=new t.Vector2(-s.x),r.normal=r.normal.normalize(),r.distance=0,r.fraction=0,!0)}var a=new t.Ray2D(t.Vector2.zero,new t.Vector2(-i.x)),c=o.rayIntersects(a);return c<=1&&(r.fraction=c,r.distance=i.length()*c,r.normal=new t.Vector2(-i.x),r.normal=r.normal.normalize(),r.centroid=t.Vector2.add(e.bounds.center,t.Vector2.multiply(i,new t.Vector2(c))),!0)},e}();t.ShapeCollisions=e}(es||(es={})),function(t){var e=function(){function e(e){void 0===e&&(e=100),this.gridBounds=new t.Rectangle,this._overlapTestCircle=new t.Circle(0),this._cellDict=new n,this._tempHashSet=[],this._cellSize=e,this._inverseCellSize=1/this._cellSize,this._raycastParser=new i}return e.prototype.register=function(e){var n=e.bounds;e.registeredPhysicsBounds=n;var i=this.cellCoords(n.x,n.y),r=this.cellCoords(n.right,n.bottom);this.gridBounds.contains(i.x,i.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,i)),this.gridBounds.contains(r.x,r.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,r));for(var o=i.x;o<=r.x;o++)for(var s=i.y;s<=r.y;s++){var a=this.cellAtPosition(o,s,!0);a.firstOrDefault(function(t){return t.hashCode==e.hashCode})||a.push(e)}},e.prototype.remove=function(t){for(var e=t.registeredPhysicsBounds,n=this.cellCoords(e.x,e.y),i=this.cellCoords(e.right,e.bottom),r=n.x;r<=i.x;r++)for(var o=n.y;o<=i.y;o++){var s=this.cellAtPosition(r,o);s?s.remove(t):console.log("从不存在碰撞器的单元格中移除碰撞器: ["+t+"]")}},e.prototype.removeWithBruteForce=function(t){this._cellDict.remove(t)},e.prototype.clear=function(){this._cellDict.clear()},e.prototype.debugDraw=function(t,e){void 0===e&&(e=1);for(var n=this.gridBounds.x;n<=this.gridBounds.right;n++)for(var i=this.gridBounds.y;i<=this.gridBounds.bottom;i++){var r=this.cellAtPosition(n,i);r&&r.length>0&&this.debugDrawCellDetails(n,i,r.length,t,e)}},e.prototype.aabbBroadphase=function(e,n,i){this._tempHashSet.length=0;for(var r=this.cellCoords(e.x,e.y),o=this.cellCoords(e.right,e.bottom),s=r.x;s<=o.x;s++)for(var a=r.y;a<=o.y;a++){var c=this.cellAtPosition(s,a);if(c)for(var h=function(r){var o=c[r];if(o==n||!t.Flags.isFlagSet(i,o.physicsLayer))return"continue";e.intersects(o.bounds)&&(u._tempHashSet.firstOrDefault(function(t){return t.hashCode==o.hashCode})||u._tempHashSet.push(o))},u=this,l=0;lthis.tileHeight||this.maxTileWidth>this.tileWidth},enumerable:!0,configurable:!0}),e.prototype.getTilesetForTileGid=function(t){if(0==t)return null;for(var e=this.tilesets.size-1;e>=0;e--)if(this.tilesets.get(e.toString()).firstGid<=t)return this.tilesets.get(e.toString());console.error("tile gid"+t+"未在任何tileset中找到")},e.prototype.update=function(){this.tilesets.forEach(function(t){t.update()})},e.prototype.dispose=function(t){void 0===t&&(t=!0),this._isDisposed||(t&&(this.tilesets.forEach(function(t){t.image&&t.image.dispose()}),this.imageLayers.forEach(function(t){t.image&&t.image.dispose()})),this._isDisposed=!0)},e}(t.TmxDocument);t.TmxMap=e,function(t){t[t.unknown=0]="unknown",t[t.orthogonal=1]="orthogonal",t[t.isometric=2]="isometric",t[t.staggered=3]="staggered",t[t.hexagonal=4]="hexagonal"}(t.OrientationType||(t.OrientationType={})),function(t){t[t.x=0]="x",t[t.y=1]="y"}(t.StaggerAxisType||(t.StaggerAxisType={})),function(t){t[t.odd=0]="odd",t[t.even=1]="even"}(t.StaggerIndexType||(t.StaggerIndexType={})),function(t){t[t.rightDown=0]="rightDown",t[t.rightUp=1]="rightUp",t[t.leftDown=2]="leftDown",t[t.leftUp=3]="leftUp"}(t.RenderOrderType||(t.RenderOrderType={}))}(es||(es={})),function(t){var e=function(){return function(){}}();t.TmxObjectGroup=e;var n=function(){return function(){}}();t.TmxObject=n;var i=function(){return function(){}}();t.TmxText=i;var r=function(){return function(){}}();t.TmxAlignment=r,function(t){t[t.basic=0]="basic",t[t.point=1]="point",t[t.tile=2]="tile",t[t.ellipse=3]="ellipse",t[t.polygon=4]="polygon",t[t.polyline=5]="polyline",t[t.text=6]="text"}(t.TmxObjectType||(t.TmxObjectType={})),function(t){t[t.unkownOrder=-1]="unkownOrder",t[t.TopDown=0]="TopDown",t[t.IndexOrder=1]="IndexOrder"}(t.DrawOrderType||(t.DrawOrderType={})),function(t){t[t.left=0]="left",t[t.center=1]="center",t[t.right=2]="right",t[t.justify=3]="justify"}(t.TmxHorizontalAlignment||(t.TmxHorizontalAlignment={})),function(t){t[t.top=0]="top",t[t.center=1]="center",t[t.bottom=2]="bottom"}(t.TmxVerticalAlignment||(t.TmxVerticalAlignment={}))}(es||(es={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.update=function(){this.tiles.forEach(function(t){t.updateAnimatedTiles()})},e}(t.TmxDocument);t.TmxTileset=e;var n=function(){return function(){}}();t.TmxTileOffset=n;var i=function(){return function(){}}();t.TmxTerrain=i}(es||(es={})),function(t){var e=function(){function e(){}return Object.defineProperty(e.prototype,"currentAnimationFrameGid",{get:function(){return this.animationFrames[this._animationCurrentFrame].gid+this.tileset.firstGid},enumerable:!0,configurable:!0}),e.prototype.processProperties=function(){var t;(t=this.properties.get("engine.isDestructable"))&&(this.isDestructable=Boolean(t)),(t=this.properties.get("engine:isSlope"))&&(this.isSlope=Boolean(t)),(t=this.properties.get("engine:isOneWayPlatform"))&&(this.isOneWayPlatform=Boolean(t)),(t=this.properties.get("engine:slopeTopLeft"))&&(this.slopeTopLeft=Number(t)),(t=this.properties.get("engine:slopeTopRight"))&&(this.slopeTopRight=Number(t))},e.prototype.updateAnimatedTiles=function(){0!=this.animationFrames.length&&(this._animationElapsedTime+=t.Time.deltaTime,this._animationElapsedTime>this.animationFrames[this._animationCurrentFrame].duration&&(this._animationCurrentFrame=t.MathHelper.incrementWithWrap(this._animationCurrentFrame,this.animationFrames.length),this._animationElapsedTime=0))},e}();t.TmxTilesetTile=e;var n=function(){return function(){}}();t.TmxAnimationFrame=n}(es||(es={}));var ArrayUtils=function(){function t(){}return t.bubbleSort=function(t){for(var e=!1,n=0;nn;i--)if(t[i]0&&t[r-1]>i;r--)t[r]=t[r-1];t[r]=i}},t.binarySearch=function(t,e){for(var n=0,i=t.length,r=n+i>>1;n=t[r]&&(n=r+1),r=n+i>>1;return t[n]==e?n:-1},t.findElementIndex=function(t,e){for(var n=t.length,i=0;it[e]&&(e=i);return e},t.getMinElementIndex=function(t){for(var e=0,n=t.length,i=1;i=0;--r)n.unshift(e[r]);return n},t.getDifferAry=function(t,e){t=this.getUniqueAry(t),e=this.getUniqueAry(e);for(var n=t.concat(e),i={},r=[],o=n.length,s=0;s=0;e-=1)t.splice(e,1)},t.cloneList=function(t){return t?t.slice(0,t.length):null},t.equals=function(t,e){if(t==e)return!0;var n=t.length;if(n!=e.length)return!1;for(;n--;)if(t[n]!=e[n])return!1;return!0},t.insert=function(t,e,n){if(!t)return null;var i=t.length;if(e>i&&(e=i),e<0&&(e=0),e==i)t.push(n);else if(0==e)t.unshift(n);else{for(var r=i-1;r>=e;r-=1)t[r+1]=t[r];t[e]=n}return n},t}(),Base64Utils=function(){function t(){}return t.decode=function(t,e){void 0===e&&(e=!0);var n,i,r,o,s,a,c="",h=0;for(t=(t=this.getConfKey(t)).replace(/[^A-Za-z0-9\+\/\=]/g,"");h>4,i=(15&o)<<4|(s=this._keyAll.indexOf(t.charAt(h++)))>>2,r=(3&s)<<6|(a=this._keyAll.indexOf(t.charAt(h++))),c+=String.fromCharCode(n),64!=s&&(0==i?e&&(c+=String.fromCharCode(i)):c+=String.fromCharCode(i)),64!=a&&(0==r?e&&(c+=String.fromCharCode(r)):c+=String.fromCharCode(r));return c=this._utf8_decode(c)},t._utf8_encode=function(t){t=t.replace(/\r\n/g,"\n");for(var e="",n=0;n127&&i<2048?(e+=String.fromCharCode(i>>6|192),e+=String.fromCharCode(63&i|128)):(e+=String.fromCharCode(i>>12|224),e+=String.fromCharCode(i>>6&63|128),e+=String.fromCharCode(63&i|128))}return e},t._utf8_decode=function(t){for(var e="",n=0,i=0,r=0,o=0;n191&&i<224?(r=t.charCodeAt(n+1),e+=String.fromCharCode((31&i)<<6|63&r),n+=2):(r=t.charCodeAt(n+1),o=t.charCodeAt(n+2),e+=String.fromCharCode((15&i)<<12|(63&r)<<6|63&o),n+=3);return e},t.getConfKey=function(t){return t.slice(1,t.length)},t._keyNum="0123456789+/",t._keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",t._keyAll=t._keyNum+t._keyStr,t.encode=function(t){var e,n,i,r,o,s,a,c="",h=0;for(t=this._utf8_encode(t);h>2,o=(3&e)<<4|(n=t.charCodeAt(h++))>>4,s=(15&n)<<2|(i=t.charCodeAt(h++))>>6,a=63&i,isNaN(n)?s=a=64:isNaN(i)&&(a=64),c=c+this._keyAll.charAt(r)+this._keyAll.charAt(o)+this._keyAll.charAt(s)+this._keyAll.charAt(a);return this._keyStr.charAt(Math.floor(Math.random()*this._keyStr.length))+c},t}();!function(t){var e=function(){function t(){this.loadedAssets=new Map}return t.prototype.loadRes=function(t,e){var n=this;return void 0===e&&(e=!0),new Promise(function(i,r){var o=n.loadedAssets.get(t);o?i(o):e?RES.getResAsync(t).then(function(e){n.loadedAssets.set(t,e),i(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)}):RES.getResByUrl(t).then(function(e){n.loadedAssets.set(t,e),i(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)})})},t.prototype.dispose=function(){this.loadedAssets.forEach(function(t){t.dispose()}),this.loadedAssets.clear()},t}();t.ContentManager=e}(es||(es={})),function(t){var e=function(){function e(){}return e.drawLine=function(e,n,i,r,o){void 0===o&&(o=1),this.drawLineAngle(e,n,t.MathHelper.angleBetweenVectors(n,i),t.Vector2.distance(n,i),r,o)},e.drawLineAngle=function(t,e,n,i,r,o){void 0===o&&(o=1),t.graphics.beginFill(r),t.graphics.drawRect(e.x,e.y,1,1),t.graphics.endFill(),t.scaleX=i,t.scaleY=o,t.$anchorOffsetX=0,t.$anchorOffsetY=0,t.rotation=n},e.drawHollowRect=function(t,e,n,i){void 0===i&&(i=1),this.drawHollowRectR(t,e.x,e.y,e.width,e.height,n,i)},e.drawHollowRectR=function(e,n,i,r,o,s,a){void 0===a&&(a=1);var c=new t.Vector2(n,i).round(),h=new t.Vector2(n+r,i).round(),u=new t.Vector2(n+r,i+o).round(),l=new t.Vector2(n,i+o).round();this.drawLine(e,c,h,s,a),this.drawLine(e,h,u,s,a),this.drawLine(e,u,l,s,a),this.drawLine(e,l,c,s,a)},e.drawPixel=function(e,n,i,r){void 0===r&&(r=1);var o=new t.Rectangle(n.x,n.y,r,r);1!=r&&(o.x-=.5*r,o.y-=.5*r),e.graphics.beginFill(i),e.graphics.drawRect(o.x,o.y,o.width,o.height),e.graphics.endFill()},e.getColorMatrix=function(t){var e=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];return e[0]=Math.floor(t/256/256)/255,e[6]=Math.floor(t/256%256)/255,e[12]=t%256/255,new egret.ColorMatrixFilter(e)},e}();t.DrawUtils=e}(es||(es={})),function(t){var e=function(){function e(){}return e.oppositeEdge=function(e){switch(e){case t.Edge.bottom:return t.Edge.top;case t.Edge.top:return t.Edge.bottom;case t.Edge.left:return t.Edge.right;case t.Edge.right:return t.Edge.left}},e.isHorizontal=function(e){return e==t.Edge.right||e==t.Edge.left},e.isVertical=function(e){return e==t.Edge.top||e==t.Edge.bottom},e}();t.EdgeExt=e}(es||(es={})),function(t){var e=function(){return function(t,e){this.func=t,this.context=e}}();t.FuncPack=e;var n=function(){function t(){this._messageTable=new Map}return t.prototype.addObserver=function(t,n,i){var r=this._messageTable.get(t);r||(r=[],this._messageTable.set(t,r)),-1!=r.findIndex(function(t){return t.func==n})&&console.warn("您试图添加相同的观察者两次"),r.push(new e(n,i))},t.prototype.removeObserver=function(t,e){var n=this._messageTable.get(t),i=n.findIndex(function(t){return t.func==e});-1!=i&&n.removeAt(i)},t.prototype.emit=function(t,e){var n=this._messageTable.get(t);if(n)for(var i=n.length-1;i>=0;i--)n[i].func.call(n[i].context,e)},t}();t.Emitter=n}(es||(es={})),function(t){!function(t){t[t.top=0]="top",t[t.bottom=1]="bottom",t[t.left=2]="left",t[t.right=3]="right"}(t.Edge||(t.Edge={}))}(es||(es={})),function(t){var e=function(){function t(){}return t.repeat=function(t,e){for(var n=[];e--;)n.push(t);return n},t}();t.Enumerable=e}(es||(es={})),function(t){var e=function(){function t(){}return Object.defineProperty(t.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),t.prototype.setEnabled=function(t){this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled())},t.prototype.onEnabled=function(){},t.prototype.onDisabled=function(){},t.prototype.update=function(){},t}();t.GlobalManager=e}(es||(es={})),function(t){var e=function(){function e(){this.x=0,this.y=0,this.touchPoint=-1,this.touchDown=!1}return Object.defineProperty(e.prototype,"position",{get:function(){return new t.Vector2(this.x,this.y)},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this.x=0,this.y=0,this.touchDown=!1,this.touchPoint=-1},e}();t.TouchState=e;var n=function(){function n(){}return Object.defineProperty(n,"gameTouchs",{get:function(){return this._gameTouchs},enumerable:!0,configurable:!0}),Object.defineProperty(n,"resolutionScale",{get:function(){return this._resolutionScale},enumerable:!0,configurable:!0}),Object.defineProperty(n,"totalTouchCount",{get:function(){return this._totalTouchCount},enumerable:!0,configurable:!0}),Object.defineProperty(n,"touchPosition",{get:function(){return this._gameTouchs[0]?this._gameTouchs[0].position:t.Vector2.zero},enumerable:!0,configurable:!0}),Object.defineProperty(n,"maxSupportedTouch",{get:function(){return t.Core._instance.stage.maxTouches},set:function(e){t.Core._instance.stage.maxTouches=e,this.initTouchCache()},enumerable:!0,configurable:!0}),Object.defineProperty(n,"touchPositionDelta",{get:function(){var e=t.Vector2.subtract(this.touchPosition,this._previousTouchState.position);return e.length()>0&&this.setpreviousTouchState(this._gameTouchs[0]),e},enumerable:!0,configurable:!0}),n.initialize=function(){this._init||(this._init=!0,t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.touchBegin,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.touchMove,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_END,this.touchEnd,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL,this.touchEnd,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE,this.touchEnd,this),this.initTouchCache())},n.scaledPosition=function(e){var n=new t.Vector2(e.x-this._resolutionOffset.x,e.y-this._resolutionOffset.y);return t.Vector2.multiply(n,this.resolutionScale)},n.initTouchCache=function(){this._totalTouchCount=0,this._touchIndex=0,this._gameTouchs.length=0;for(var t=0;t0)for(var e=0;ethis._objectQueue.length;)this._objectQueue.shift()},t.clearCache=function(){this._objectQueue.length=0},t.obtain=function(){return this._objectQueue.length>0?this._objectQueue.shift():[]},t.free=function(t){this._objectQueue.unshift(t),t.length=0},t._objectQueue=[],t}();t.ListPool=e}(es||(es={}));var THREAD_ID=Math.floor(1e3*Math.random())+"-"+Date.now(),nextTick=function(t){setTimeout(t,0)},LockUtils=function(){function t(t){this._keyX="mutex_key_"+t+"_X",this._keyY="mutex_key_"+t+"_Y",this.setItem=egret.localStorage.setItem.bind(localStorage),this.getItem=egret.localStorage.getItem.bind(localStorage),this.removeItem=egret.localStorage.removeItem.bind(localStorage)}return t.prototype.lock=function(){var t=this;return new Promise(function(e,n){var i=function(){t.setItem(t._keyX,THREAD_ID),null===!t.getItem(t._keyY)&&nextTick(i),t.setItem(t._keyY,THREAD_ID),t.getItem(t._keyX)!==THREAD_ID?setTimeout(function(){t.getItem(t._keyY)===THREAD_ID?(e(),t.removeItem(t._keyY)):nextTick(i)},10):(e(),t.removeItem(t._keyY))};i()})},t}();!function(t){var e=function(){function t(t,e){this.first=t,this.second=e}return t.prototype.clear=function(){this.first=this.second=null},t.prototype.equals=function(t){return this.first==t.first&&this.second==t.second},t}();t.Pair=e}(es||(es={}));var RandomUtils=function(){function t(){}return t.randrange=function(t,e,n){if(void 0===n&&(n=1),0==n)throw new Error("step 不能为 0");var i=e-t;if(0==i)throw new Error("没有可用的范围("+t+","+e+")");i<0&&(i=t-e);var r=Math.floor((i+n-1)/n);return Math.floor(this.random()*r)*n+Math.min(t,e)},t.randint=function(t,e){return(t=Math.floor(t))>(e=Math.floor(e))?t++:e++,this.randrange(t,e)},t.randnum=function(t,e){return this.random()*(e-t)+t},t.shuffle=function(t){return t.sort(this._randomCompare),t},t.choice=function(t){if(!t.hasOwnProperty("length"))throw new Error("无法对此对象执行此操作");var e=Math.floor(this.random()*t.length);return t instanceof String?String(t).charAt(e):t[e]},t.sample=function(t,e){var n=t.length;if(e<=0||n=0;)s=Math.floor(this.random()*n);i.push(t[s]),r.push(s)}return i},t.random=function(){return Math.random()},t.boolean=function(t){return void 0===t&&(t=.5),this.random().5?1:-1},t}();!function(t){var e=function(){function e(){}return e.getSide=function(e,n){switch(n){case t.Edge.top:return e.top;case t.Edge.bottom:return e.bottom;case t.Edge.left:return e.left;case t.Edge.right:return e.right}},e.union=function(e,n){var i=new t.Rectangle(n.x,n.y,0,0),r=new t.Rectangle;return r.x=Math.min(e.x,i.x),r.y=Math.min(e.y,i.y),r.width=Math.max(e.right,i.right)-r.x,r.height=Math.max(e.bottom,r.bottom)-r.y,r},e.getHalfRect=function(e,n){switch(n){case t.Edge.top:return new t.Rectangle(e.x,e.y,e.width,e.height/2);case t.Edge.bottom:return new t.Rectangle(e.x,e.y+e.height/2,e.width,e.height/2);case t.Edge.left:return new t.Rectangle(e.x,e.y,e.width/2,e.height);case t.Edge.right:return new t.Rectangle(e.x+e.width/2,e.y,e.width/2,e.height)}},e.getRectEdgePortion=function(e,n,i){switch(void 0===i&&(i=1),n){case t.Edge.top:return new t.Rectangle(e.x,e.y,e.width,i);case t.Edge.bottom:return new t.Rectangle(e.x,e.y+e.height-i,e.width,i);case t.Edge.left:return new t.Rectangle(e.x,e.y,i,e.height);case t.Edge.right:return new t.Rectangle(e.x+e.width-i,e.y,i,e.height)}},e.expandSide=function(e,n,i){switch(i=Math.abs(i),n){case t.Edge.top:e.y-=i,e.height+=i;break;case t.Edge.bottom:e.height+=i;break;case t.Edge.left:e.x-=i,e.width+=i;break;case t.Edge.right:e.width+=i}},e.contract=function(t,e,n){t.x+=e,t.y+=n,t.width-=2*e,t.height-=2*n},e}();t.RectangleExt=e}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.update=function(t){this.remainder+=t;var e=Math.trunc(this.remainder);return this.remainder-=e,e},t.prototype.reset=function(){this.remainder=0},t}();t.SubpixelNumber=e}(es||(es={})),function(t){var e=function(){function e(){this.triangleIndices=[],this._triPrev=new Array(12),this._triNext=new Array(12)}return e.testPointTriangle=function(e,n,i,r){return!(t.Vector2Ext.cross(t.Vector2.subtract(e,n),t.Vector2.subtract(i,n))<0)&&(!(t.Vector2Ext.cross(t.Vector2.subtract(e,i),t.Vector2.subtract(r,i))<0)&&!(t.Vector2Ext.cross(t.Vector2.subtract(e,r),t.Vector2.subtract(n,r))<0))},e.prototype.triangulate=function(n,i){void 0===i&&(i=!0);var r=n.length;this.initialize(r);for(var o=0,s=0;r>3&&o<500;){o++;var a=!0,c=n[this._triPrev[s]],h=n[s],u=n[this._triNext[s]];if(t.Vector2Ext.isTriangleCCW(c,h,u)){var l=this._triNext[this._triNext[s]];do{if(e.testPointTriangle(n[l],c,h,u)){a=!1;break}l=this._triNext[l]}while(l!=this._triPrev[s])}else a=!1;a?(this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),this._triNext[this._triPrev[s]]=this._triNext[s],this._triPrev[this._triNext[s]]=this._triPrev[s],r--,s=this._triPrev[s]):s=this._triNext[s]}this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),i||this.triangleIndices.reverse()},e.prototype.initialize=function(t){this.triangleIndices.length=0,this._triNext.lengtht.MathHelper.Epsilon?e=t.Vector2.divide(e,new t.Vector2(n)):e.x=e.y=0,e},e.transformA=function(t,e,n,i,r,o){for(var s=0;sthis.safeArea.right&&(s.x=this.safeArea.right-s.width),s.topthis.safeArea.bottom&&(s.y=this.safeArea.bottom-s.height),s},n}();t.Layout=n,function(t){t[t.none=0]="none",t[t.left=1]="left",t[t.right=2]="right",t[t.horizontalCenter=4]="horizontalCenter",t[t.top=8]="top",t[t.bottom=16]="bottom",t[t.verticalCenter=32]="verticalCenter",t[t.topLeft=9]="topLeft",t[t.topRight=10]="topRight",t[t.topCenter=12]="topCenter",t[t.bottomLeft=17]="bottomLeft",t[t.bottomRight=18]="bottomRight",t[t.bottomCenter=20]="bottomCenter",t[t.centerLeft=33]="centerLeft",t[t.centerRight=34]="centerRight",t[t.center=36]="center"}(e=t.Alignment||(t.Alignment={}))}(es||(es={})),function(t){var e,n=function(){function t(t){void 0===t&&(t=i),this.getSystemTime=t,this._stopDuration=0,this._completeSlices=[]}return t.prototype.getState=function(){return void 0===this._startSystemTime?e.IDLE:void 0===this._stopSystemTime?e.RUNNING:e.STOPPED},t.prototype.isIdle=function(){return this.getState()===e.IDLE},t.prototype.isRunning=function(){return this.getState()===e.RUNNING},t.prototype.isStopped=function(){return this.getState()===e.STOPPED},t.prototype.slice=function(){return this.recordPendingSlice()},t.prototype.getCompletedSlices=function(){return Array.from(this._completeSlices)},t.prototype.getCompletedAndPendingSlices=function(){return this._completeSlices.concat([this.getPendingSlice()])},t.prototype.getPendingSlice=function(){return this.calculatePendingSlice()},t.prototype.getTime=function(){return this.caculateStopwatchTime()},t.prototype.reset=function(){this._startSystemTime=this._pendingSliceStartStopwatchTime=this._stopSystemTime=void 0,this._stopDuration=0,this._completeSlices=[]},t.prototype.start=function(t){if(void 0===t&&(t=!1),t&&this.reset(),void 0!==this._stopSystemTime){var e=(n=this.getSystemTime())-this._stopSystemTime;this._stopDuration+=e,this._stopSystemTime=void 0}else if(void 0===this._startSystemTime){var n=this.getSystemTime();this._startSystemTime=n,this._pendingSliceStartStopwatchTime=0}},t.prototype.stop=function(t){if(void 0===t&&(t=!1),void 0===this._startSystemTime)return 0;var e=this.getSystemTimeOfCurrentStopwatchTime();return t&&this.recordPendingSlice(this.caculateStopwatchTime(e)),this._stopSystemTime=e,this.getTime()},t.prototype.calculatePendingSlice=function(t){return void 0===this._pendingSliceStartStopwatchTime?Object.freeze({startTime:0,endTime:0,duration:0}):(void 0===t&&(t=this.getTime()),Object.freeze({startTime:this._pendingSliceStartStopwatchTime,endTime:t,duration:t-this._pendingSliceStartStopwatchTime}))},t.prototype.caculateStopwatchTime=function(t){return void 0===this._startSystemTime?0:(void 0===t&&(t=this.getSystemTimeOfCurrentStopwatchTime()),t-this._startSystemTime-this._stopDuration)},t.prototype.getSystemTimeOfCurrentStopwatchTime=function(){return void 0===this._stopSystemTime?this.getSystemTime():this._stopSystemTime},t.prototype.recordPendingSlice=function(t){if(void 0!==this._pendingSliceStartStopwatchTime){void 0===t&&(t=this.getTime());var e=this.calculatePendingSlice(t);return this._pendingSliceStartStopwatchTime=e.endTime,this._completeSlices.push(e),e}return this.calculatePendingSlice()},t}();t.Stopwatch=n,function(t){t.IDLE="IDLE",t.RUNNING="RUNNING",t.STOPPED="STOPPED"}(e||(e={})),t.setDefaultSystemTimeGetter=function(t){void 0===t&&(t=Date.now),i=t};var i=Date.now}(stopwatch||(stopwatch={})),function(t){var e=function(){function e(){this.showLog=!1,this._frameKey="frame",this._logKey="log",this.markers=[],this.stopwacth=new stopwatch.Stopwatch,this._markerNameToIdMap=new Map,this._logs=new Array(2);for(var e=0;e=e.logSnapDuration&&(l.logs[r].snapMin=l.logs[r].min,l.logs[r].snapMax=l.logs[r].max,l.logs[r].snapAvg=l.logs[r].avg,l.logs[r].samples=0)):(l.logs[r].min=h,l.logs[r].max=h,l.logs[r].avg=h,l.logs[r].initialized=!0)}s.markCount=o.nestCount,s.nestCount=o.nestCount}t.stopwacth.reset(),t.stopwacth.start()}})},e.prototype.beginMark=function(t,n,i){var r=this;void 0===i&&(i=0),new LockUtils(this._frameKey).lock().then(function(){if(i<0||i>=e.maxBars)throw new Error("barIndex argument out of range");var o=r._curLog.bars[i];if(o.markCount>=e.maxSamples)throw new Error("exceeded sample count. either set larger number to timeruler.maxsaple or lower sample count");if(o.nestCount>=e.maxNestCall)throw new Error("exceeded nest count. either set larger number to timeruler.maxnestcall or lower nest calls");var s=r._markerNameToIdMap.get(t);isNaN(s)&&(s=r.markers.length,r._markerNameToIdMap.set(t,s)),o.markerNests[o.nestCount++]=o.markCount,o.markers[o.markCount].markerId=s,o.markers[o.markCount].color=n,o.markers[o.markCount].beginTime=r.stopwacth.getTime(),o.markers[o.markCount].endTime=-1})},e.prototype.endMark=function(t,n){var i=this;void 0===n&&(n=0),new LockUtils(this._frameKey).lock().then(function(){if(n<0||n>=e.maxBars)throw new Error("barIndex argument out of range");var r=i._curLog.bars[n];if(r.nestCount<=0)throw new Error("call beginMark method before calling endMark method");var o=i._markerNameToIdMap.get(t);if(isNaN(o))throw new Error("Marker "+t+" is not registered. Make sure you specifed same name as you used for beginMark method");var s=r.markerNests[--r.nestCount];if(r.markers[s].markerId!=o)throw new Error("Incorrect call order of beginMark/endMark method. beginMark(A), beginMark(B), endMark(B), endMark(A) But you can't called it like beginMark(A), beginMark(B), endMark(A), endMark(B).");r.markers[s].endTime=i.stopwacth.getTime()})},e.prototype.getAverageTime=function(t,n){if(t<0||t>=e.maxBars)throw new Error("barIndex argument out of range");var i=0,r=this._markerNameToIdMap.get(n);return r&&(i=this.markers[r].logs[t].avg),i},e.prototype.resetLog=function(){var t=this;new LockUtils(this._logKey).lock().then(function(){var e=parseInt(egret.localStorage.getItem(t._logKey),10);e+=1,egret.localStorage.setItem(t._logKey,e.toString()),t.markers.forEach(function(t){for(var e=0;e0&&(i+=e.barHeight+2*e.barPadding,r=Math.max(r,t.markers[t.markCount-1].endTime))});var o=this.sampleFrames*(1/60*1e3);this._frameAdjust=r>o?Math.max(0,this._frameAdjust)+1:Math.min(0,this._frameAdjust)-1,Math.max(this._frameAdjust)>e.autoAdjustDelay&&(this.sampleFrames=Math.min(e.maxSampleFrames,this.sampleFrames),this.sampleFrames=Math.max(this.targetSampleFrames,r/(1/60*1e3)+1),this._frameAdjust=0);t.y,e.barHeight}},e.prototype.onGraphicsDeviceReset=function(){var n=new t.Layout;this._position=n.place(new t.Vector2(this.width,e.barHeight),0,.01,t.Alignment.bottomCenter).location},e.maxBars=8,e.maxSamples=256,e.maxNestCall=32,e.barHeight=8,e.maxSampleFrames=4,e.logSnapDuration=120,e.barPadding=2,e.autoAdjustDelay=30,e}();t.TimeRuler=e;var n=function(){return function(){this.bars=new Array(e.maxBars),this.bars.fill(new i,0,e.maxBars)}}();t.FrameLog=n;var i=function(){return function(){this.markers=new Array(e.maxSamples),this.markCount=0,this.markerNests=new Array(e.maxNestCall),this.nestCount=0,this.markers.fill(new r,0,e.maxSamples),this.markerNests.fill(0,0,e.maxNestCall)}}();t.MarkerCollection=i;var r=function(){return function(){this.markerId=0,this.beginTime=0,this.endTime=0,this.color=0}}();t.Marker=r;var o=function(){return function(t){this.logs=new Array(e.maxBars),this.name=t,this.logs.fill(new s,0,e.maxBars)}}();t.MarkerInfo=o;var s=function(){return function(){this.snapMin=0,this.snapMax=0,this.snapAvg=0,this.min=0,this.max=0,this.avg=0,this.samples=0,this.color=0,this.initialized=!1}}();t.MarkerLog=s}(es||(es={})); \ No newline at end of file diff --git a/source/src/ECS/Components/TiledMapMover.ts b/source/src/ECS/Components/TiledMapMover.ts new file mode 100644 index 00000000..8fbb53d3 --- /dev/null +++ b/source/src/ECS/Components/TiledMapMover.ts @@ -0,0 +1,131 @@ +module es { + /** + * 用来存放来自移动调用的所有冲突信息 + */ + export class CollisionState { + public right: boolean; + public left: boolean; + public above: boolean; + public below: boolean; + public becameGroundedThisFrame: boolean; + public wasGroundedLastFrame: boolean; + public isGroundedOnOnewayPlatform: boolean; + public slopAngle: number; + + public get hasCollision(): boolean { + return this.below || this.right || this.left || this.above; + } + + public _movementRemainderX: SubpixelNumber; + public _movementRemainderY: SubpixelNumber; + + public reset() { + this.becameGroundedThisFrame = this.isGroundedOnOnewayPlatform = this.right = this.left = this.above = this.below = false; + this.slopAngle = 0; + } + + public toString() { + return `[CollisionState] r: ${this.right}, l: ${this.left}, a: ${this.above}, b: ${this.below}, angle: ${this.slopAngle}, wasGroundedLastFrame: ${this.wasGroundedLastFrame}, becameGroundedThisFrame: ${this.becameGroundedThisFrame}`; + } + } + + /** + * TiledMapMover是在基于重力的平铺地图中移动对象的助手。 + * 它要求它所在的实体有一个BoxCollider。BoxCollider将与colliderHorizontal/VerticalInset用于所有碰撞检测。 + * + * 一种方法是通过将你的Transform向下移动1个像素并调用CollisionState.clearLastGroundTile来跳过平台。 + */ + export class TiledMapMover extends Component { + /** + * 在垂直移动时,BoxCollider将根据水平面上的嵌入缩小 + */ + public colliderHorizontalInset = 2; + + /** + * 垂直平面上的嵌入,在水平移动时,BoxCollider将根据该嵌入缩小 + */ + public colliderVerticalInset = 6; + + /** + * 临时存储 + */ + public _boxColliderBounds: Rectangle; + + constructor() { + super(); + } + + /** + * 测试碰撞,然后移动实体 + * @param motion + * @param boxColliderBounds + * @param collisionState + */ + public testCollisions(motion: Vector2, boxColliderBounds: Rectangle, collisionState: CollisionState) { + this._boxColliderBounds = boxColliderBounds; + + // 保存我们当前的接地状态,我们将用于wasGroundedLastFrame和becameGroundedThisFrame + collisionState.wasGroundedLastFrame = collisionState.below; + + // 重置碰撞状态 + collisionState.reset(); + + // 获取圆角值用于我们的实际检测 + let motionX = motion.x; + let motionY = motion.y; + + // 首先,检查水平方向中的移动 + if (motionX != 0){ + let direction = motionX > 0 ? Edge.right : Edge.left; + let sweptBounds = this.collisionRectForSide(direction, motionX); + + let collisionResponse: number = 0; + if (this.testMapCollision(sweptBounds, direction, collisionState, collisionResponse)){ + motion.x = collisionResponse - RectangleExt.getSide(boxColliderBounds, direction); + collisionState.left = direction == Edge.left; + collisionState.right = direction == Edge.right; + collisionState._movementRemainderX.reset(); + }else{ + collisionState.left = false; + collisionState.right = false; + } + } + } + + public testMapCollision(collisionRect: Rectangle, direction: Edge, collisionState: CollisionState, collisionResponse: number){ + let side = EdgeExt.oppositeEdge(direction); + let perpindicularPosition = EdgeExt.isVertical(side) ? collisionRect.center.x : collisionRect.center.y; + let leadingPosition = RectangleExt.getSide(collisionRect, direction); + let shouldTestSlopes = EdgeExt.isVertical(side); + } + + /** + * 获取展开以考虑运动的给定边的碰撞矩形 + * @param side + * @param motion + */ + public collisionRectForSide(side: Edge, motion: number){ + let bounds: Rectangle; + + // 对于水平碰撞检查,我们只使用一个条块作为边界。Vertical得到矩形的一半,就可以正确地向上推, + // 当相交的斜率,忽略以进行水平移动。 + if (EdgeExt.isHorizontal(side)){ + bounds = RectangleExt.getRectEdgePortion(this._boxColliderBounds, side); + }else { + bounds = RectangleExt.getHalfRect(this._boxColliderBounds, side); + } + + // 我们水平收缩用于垂直移动,垂直收缩用于水平移动 + if (EdgeExt.isVertical(side)){ + RectangleExt.contract(bounds, this.colliderHorizontalInset, 0); + }else { + RectangleExt.contract(bounds, 0, this.colliderVerticalInset); + } + + // 最后在移动方向上扩展边 + RectangleExt.expandSide(bounds, side, motion); + + return bounds; + } + } +} \ No newline at end of file diff --git a/source/src/Math/MathHelper.ts b/source/src/Math/MathHelper.ts index 79030310..e666bc4c 100644 --- a/source/src/Math/MathHelper.ts +++ b/source/src/Math/MathHelper.ts @@ -76,5 +76,18 @@ module es { public static angleBetweenVectors(from: Vector2, to: Vector2) { return Math.atan2(to.y - from.y, to.x - from.x); } + + /** + * 增加t并确保它总是大于或等于0并且小于长度 + * @param t + * @param length + */ + public static incrementWithWrap(t: number, length: number){ + t ++; + if (t == length) + return 0; + + return t; + } } } diff --git a/source/src/Tiled/Group.ts b/source/src/Tiled/Group.ts new file mode 100644 index 00000000..5c83cadb --- /dev/null +++ b/source/src/Tiled/Group.ts @@ -0,0 +1,16 @@ +module es { + export class TmxGroup implements ITmxLayer{ + public map: TmxMap; + public offsetX: number; + public offsetY: number; + public opacity: number; + public properties: Map; + public visible: boolean; + public name: string; + public layers: TmxList; + public tileLayers: TmxList; + public objectGroups: TmxList; + public imageLayers: TmxList; + public groups: TmxList; + } +} \ No newline at end of file diff --git a/source/src/Tiled/ITmxLayer.ts b/source/src/Tiled/ITmxLayer.ts new file mode 100644 index 00000000..8778565e --- /dev/null +++ b/source/src/Tiled/ITmxLayer.ts @@ -0,0 +1,9 @@ +module es { + export interface ITmxLayer { + offsetX: number; + offsetY: number; + opacity: number; + visible: boolean; + properties: Map; + } +} \ No newline at end of file diff --git a/source/src/Tiled/ImageLayer.ts b/source/src/Tiled/ImageLayer.ts new file mode 100644 index 00000000..7419a425 --- /dev/null +++ b/source/src/Tiled/ImageLayer.ts @@ -0,0 +1,15 @@ +module es { + export class TmxImageLayer implements ITmxLayer { + public map: TmxMap; + public name: string; + public offsetX: number; + public offsetY: number; + public opacity: number; + public properties: Map; + public visible: boolean; + + public width?: number; + public height?: number; + public image: TmxImage; + } +} \ No newline at end of file diff --git a/source/src/Tiled/Layer.ts b/source/src/Tiled/Layer.ts new file mode 100644 index 00000000..f954cbc7 --- /dev/null +++ b/source/src/Tiled/Layer.ts @@ -0,0 +1,100 @@ +module es { + export class TmxLayer implements ITmxLayer { + public map: TmxMap; + public name: string; + public opacity: number; + public offsetX: number; + public offsetY: number; + public properties: Map; + public visible: boolean; + public get offset(): Vector2 { + return new Vector2(this.offsetX, this.offsetY); + } + + /** + * 这一层tile的宽度。对于固定大小的地图,始终与地图宽度相同。 + */ + public width: number; + /** + * 这一层的tile高度。对于固定大小的地图,始终与地图高度相同。 + */ + public height: number; + public tiles: TmxLayerTile[]; + + /** + * 回带有gid的TmxLayerTile。这是一个慢查询,所以要缓存它 + * @param gid + */ + public getTileWithGid(gid: number){ + for (let i = 0; i < this.tiles.length; i ++){ + if (this.tiles[i] && this.tiles[i].gid == gid) + return this.tiles[i]; + } + + return null; + } + } + + export class TmxLayerTile { + public static readonly FLIPPED_HORIZONTALLY_FLAG = 0x80000000; + public static readonly FLIPPED_VERTICALLY_FLAG = 0x40000000; + public static readonly FLIPPED_DIAGONALLY_FLAG = 0x20000000; + + public tileset: TmxTileset; + public gid: number; + public x: number; + public y: number; + public get position(): Vector2{ + return new Vector2(this.x, this.y); + } + public horizontalFlip: boolean; + public verticalFlip: boolean; + public diagonalFlip: boolean; + public _tilesetTileIndex?: number; + + /** + * 获取此TmxLayerTile(如果存在)的TmxTilesetTile + * TmxTilesetTile只存在于动态的tiles和带有附加属性的tiles中。 + */ + public get tilesetTile(): TmxTilesetTile { + if (this._tilesetTileIndex == undefined){ + this._tilesetTileIndex = -1; + if (this.tileset.firstGid <= this.gid){ + let tilesetTile = this.tileset.tiles.get(this.gid - this.tileset.firstGid); + if (tilesetTile){ + this._tilesetTileIndex = this.gid - this.tileset.firstGid; + } + } + } + + if (this._tilesetTileIndex < 0) + return null; + + return this.tileset.tiles.get(this._tilesetTileIndex); + } + + constructor(map: TmxMap, id: number, x: number, y: number){ + this.x = x; + this.y = y; + let rawGid = id; + + // 扫描平铺反转位标志 + let flip: boolean; + flip = (rawGid & TmxLayerTile.FLIPPED_HORIZONTALLY_FLAG) != 0; + this.horizontalFlip = flip; + + flip = (rawGid & TmxLayerTile.FLIPPED_VERTICALLY_FLAG) != 0; + this.verticalFlip = flip; + + flip = (rawGid & TmxLayerTile.FLIPPED_DIAGONALLY_FLAG) != 0; + this.diagonalFlip = flip; + + // 零位标志 + rawGid &= ~(TmxLayerTile.FLIPPED_HORIZONTALLY_FLAG | TmxLayerTile.FLIPPED_VERTICALLY_FLAG | TmxLayerTile.FLIPPED_DIAGONALLY_FLAG); + + // 将GID保存 + this.gid = rawGid; + this.tileset = map.getTilesetForTileGid(this.gid); + } + } +} \ No newline at end of file diff --git a/source/src/Tiled/Map.ts b/source/src/Tiled/Map.ts new file mode 100644 index 00000000..a8c7f1cc --- /dev/null +++ b/source/src/Tiled/Map.ts @@ -0,0 +1,114 @@ +/// +module es { + export class TmxMap extends TmxDocument { + public version: string; + public tiledVersion: string; + public width: number; + public height: number; + public get worldWidth(){ + return this.width * this.tileWidth; + } + public get worldHeight(){ + return this.height * this.tileHeight; + } + + public tileWidth: number; + public tileHeight: number; + public hexSideLength?: number; + public orientation: OrientationType; + public staggerAxis: StaggerAxisType; + public staggerIndex: StaggerIndexType; + public renderOrder: RenderOrderType; + public backgroundColor: number; + public nextObjectID?: number; + + /** + * 包含所有的ITmxLayers,不管它们的具体类型是什么。 + * 注意,TmxGroup中的层将不在此列表中。TmxGroup管理自己的层列表。 + */ + public layers: TmxList; + public tilesets: TmxList; + public tileLayers: TmxList; + public objectGroups: TmxList; + public imageLayers: TmxList; + public groups: TmxList; + public properties: Map; + + /** + * 当我们有一个图像tileset,tile可以是任何大小,所以我们记录的最大大小来剔除 + */ + public maxTileWidth: number; + + /** + * 当我们有一个图像tileset,tile可以是任何大小,所以我们记录的最大大小来剔除 + */ + public maxTileHeight: number; + + /** + * 此地图是否具有需要非默认平铺大小的特殊剔除 + */ + public get requiresLargeTileCulling(): boolean { + return this.maxTileHeight > this.tileHeight || this.maxTileWidth > this.tileWidth; + } + + /** + * 获取给定tileId的tile tileset + * @param gid + */ + public getTilesetForTileGid(gid: number): TmxTileset { + if (gid == 0) + return null; + + for (let i = this.tilesets.size - 1; i >= 0; i --){ + if (this.tilesets.get(i.toString()).firstGid <= gid) + return this.tilesets.get(i.toString()); + } + + console.error(`tile gid${gid}未在任何tileset中找到`); + } + + /** + * 更新他们的动画tile + */ + public update(){ + this.tilesets.forEach(tileset => {tileset.update();}); + } + + public _isDisposed; + public dispose(disposing: boolean = true){ + if (!this._isDisposed){ + if (disposing){ + this.tilesets.forEach(tileset => {if (tileset.image) tileset.image.dispose()}); + this.imageLayers.forEach(layer => {if (layer.image) layer.image.dispose();}); + } + + this._isDisposed = true; + } + } + } + + export enum OrientationType { + unknown, + orthogonal, + isometric, + staggered, + hexagonal + } + + export enum StaggerAxisType { + x, + y + } + + export enum StaggerIndexType { + odd, + even + } + + export enum RenderOrderType { + rightDown, + rightUp, + leftDown, + leftUp + } +} \ No newline at end of file diff --git a/source/src/Tiled/ObjectGroup.ts b/source/src/Tiled/ObjectGroup.ts new file mode 100644 index 00000000..7b1d4c2b --- /dev/null +++ b/source/src/Tiled/ObjectGroup.ts @@ -0,0 +1,77 @@ +module es { + export class TmxObjectGroup implements ITmxLayer { + public map: TmxMap; + public name: string; + public opacity: number; + public visible: boolean; + public offsetX: number; + public offsetY: number; + public color: number; + public drawOrder: DrawOrderType; + public objects: TmxList; + public properties: Map; + } + + export class TmxObject implements ITmxElement { + public id: number; + public name: string; + public objectType: TmxObjectType; + public type: string; + public x: number; + public y: number; + public width: number; + public height: number; + public rotation: number; + public tile: TmxLayerTile; + public visible: boolean; + public text: TmxText; + } + + export class TmxText { + public fontFamily: string; + public pixelSize: number; + public wrap: boolean; + public color: number; + public bold: boolean; + public italic: boolean; + public underline: boolean; + public strikeout: boolean; + public kerning: boolean; + public alignment: TmxAlignment; + public value: string; + } + + export class TmxAlignment { + public horizontal: TmxHorizontalAlignment; + public vertical: TmxVerticalAlignment; + } + + export enum TmxObjectType { + basic, + point, + tile, + ellipse, + polygon, + polyline, + text + } + + export enum DrawOrderType { + unkownOrder = -1, + TopDown, + IndexOrder + } + + export enum TmxHorizontalAlignment { + left, + center, + right, + justify + } + + export enum TmxVerticalAlignment { + top, + center, + bottom + } +} \ No newline at end of file diff --git a/source/src/Tiled/TiledCore.ts b/source/src/Tiled/TiledCore.ts new file mode 100644 index 00000000..4d4aa78a --- /dev/null +++ b/source/src/Tiled/TiledCore.ts @@ -0,0 +1,58 @@ +module es { + export class TmxDocument { + public TmxDirectory: string; + constructor(){ + this.TmxDirectory = ""; + } + } + + export interface ITmxElement { + name: string; + } + + export class TmxList extends Map{ + public _nameCount: Map = new Map(); + + public add(t: T){ + let tName = t.name; + + // 通过附加数字重命名重复的条目 + if (this.has(tName)) + this._nameCount.set(tName, this._nameCount.get(tName) + 1); + else + this._nameCount.set(tName, 0); + } + + protected getKeyForItem(item: T): string { + let name = item.name; + let count = this._nameCount.get(name); + + let dupes = 0; + + // 对于重复的键,附加一个计数器。对于病理情况,插入下划线以确保唯一性 + while (this.has(name)){ + name = name + Enumerable.repeat("_", dupes).toString() + count.toString(); + dupes ++; + } + + return name; + } + } + + export class TmxImage { + public texture: egret.Texture; + public source: string; + public format: string; + public data: any; + public trans: number; + public width: number; + public height: number; + + public dispose(){ + if (this.texture){ + this.texture.dispose(); + this.texture = null; + } + } + } +} \ No newline at end of file diff --git a/source/src/Tiled/Tileset.ts b/source/src/Tiled/Tileset.ts new file mode 100644 index 00000000..c7b83a96 --- /dev/null +++ b/source/src/Tiled/Tileset.ts @@ -0,0 +1,39 @@ +module es { + export class TmxTileset extends TmxDocument implements ITmxElement { + public map: TmxMap; + public firstGid: number; + public name; + public tileWidth: number; + public tileHeight: number; + public spacing: number; + public margin: number; + public columns?: number; + public tileCount?: number; + public tiles: Map; + public tileOffset: TmxTileOffset; + public properties: Map; + public image: TmxImage; + public terrains: TmxList; + /** + * 为每个块缓存源矩形 + */ + public tileRegions: Map; + + public update(){ + this.tiles.forEach(value => { + value.updateAnimatedTiles(); + }); + } + } + + export class TmxTileOffset { + public x: number; + public y: number; + } + + export class TmxTerrain implements ITmxElement { + public name; + public tile: number; + public properties: Map; + } +} \ No newline at end of file diff --git a/source/src/Tiled/TilesetTile.ts b/source/src/Tiled/TilesetTile.ts new file mode 100644 index 00000000..90ddc28b --- /dev/null +++ b/source/src/Tiled/TilesetTile.ts @@ -0,0 +1,79 @@ +module es { + export class TmxTilesetTile { + public tileset: TmxTileset; + public id: number; + public terrainEdges: TmxTerrain[]; + public probability: number; + public type: string; + public properties: Map; + public image: TmxImage; + public objectGroups: TmxList; + public animationFrames: TmxAnimationFrame[]; + + // TODO: 为什么动画瓷砖需要添加firstGid + public get currentAnimationFrameGid(){ + return this.animationFrames[this._animationCurrentFrame].gid + this.tileset.firstGid; + } + public _animationElapsedTime: number; + public _animationCurrentFrame: number; + /** + * 返回“engine:isDestructable”属性的值(如果属性字典中存在) + */ + public isDestructable: boolean; + /** + * 返回“engine:isSlope”属性的值(如果存在于属性字典中) + */ + public isSlope: boolean; + /** + * 返回“engine:isOneWayPlatform”属性的值(如果存在于属性字典中) + */ + public isOneWayPlatform: boolean; + /** + * 返回“engine:slopeTopLeft”属性的值(如果存在于属性字典中) + */ + public slopeTopLeft: number; + /** + * 如果属性字典中存在“engine:slopeTopRight”属性,则返回该属性的值 + */ + public slopeTopRight: number; + + public processProperties(){ + let value: string; + value = this.properties.get("engine.isDestructable"); + if (value) + this.isDestructable = Boolean(value); + + value = this.properties.get("engine:isSlope"); + if (value) + this.isSlope = Boolean(value); + + value = this.properties.get("engine:isOneWayPlatform"); + if (value) + this.isOneWayPlatform = Boolean(value); + + value = this.properties.get("engine:slopeTopLeft"); + if (value) + this.slopeTopLeft = Number(value); + + value = this.properties.get("engine:slopeTopRight"); + if (value) + this.slopeTopRight = Number(value); + } + + public updateAnimatedTiles(){ + if (this.animationFrames.length == 0) + return; + + this._animationElapsedTime += Time.deltaTime; + if (this._animationElapsedTime > this.animationFrames[this._animationCurrentFrame].duration){ + this._animationCurrentFrame = MathHelper.incrementWithWrap(this._animationCurrentFrame, this.animationFrames.length); + this._animationElapsedTime = 0; + } + } + } + + export class TmxAnimationFrame { + public gid: number; + public duration: number; + } +} \ No newline at end of file diff --git a/source/src/Utils/EdgeExt.ts b/source/src/Utils/EdgeExt.ts new file mode 100644 index 00000000..2c368a74 --- /dev/null +++ b/source/src/Utils/EdgeExt.ts @@ -0,0 +1,32 @@ +module es { + export class EdgeExt { + public static oppositeEdge(self: Edge) { + switch (self) { + case Edge.bottom: + return Edge.top; + case Edge.top: + return Edge.bottom; + case Edge.left: + return Edge.right; + case Edge.right: + return Edge.left; + } + } + + /** + * 如果边是右或左,则返回true + * @param self + */ + public static isHorizontal(self: Edge): boolean{ + return self == Edge.right || self == Edge.left; + } + + /** + * 如果边是顶部或底部,则返回true + * @param self + */ + public static isVertical(self: Edge): boolean { + return self == Edge.top || self == Edge.bottom; + } + } +} \ No newline at end of file diff --git a/source/src/Utils/Enum.ts b/source/src/Utils/Enum.ts new file mode 100644 index 00000000..3a5d3860 --- /dev/null +++ b/source/src/Utils/Enum.ts @@ -0,0 +1,8 @@ +module es { + export enum Edge { + top, + bottom, + left, + right + } +} \ No newline at end of file diff --git a/source/src/Utils/Enumerable.ts b/source/src/Utils/Enumerable.ts new file mode 100644 index 00000000..a045a53d --- /dev/null +++ b/source/src/Utils/Enumerable.ts @@ -0,0 +1,16 @@ +module es { + export class Enumerable { + /** + * 生成包含一个重复值的序列 + * @param element 要重复的值 + * @param count 在生成的序列中重复该值的次数 + */ + public static repeat(element: T, count: number){ + let result = []; + while (count--) { + result.push(element) + } + return result; + } + } +} \ No newline at end of file diff --git a/source/src/Utils/RectangleExt.ts b/source/src/Utils/RectangleExt.ts index 76b59fe8..90585993 100644 --- a/source/src/Utils/RectangleExt.ts +++ b/source/src/Utils/RectangleExt.ts @@ -1,5 +1,23 @@ module es { export class RectangleExt { + /** + * 获取指定边的位置 + * @param rect + * @param edge + */ + public static getSide(rect: Rectangle, edge: Edge) { + switch (edge) { + case Edge.top: + return rect.top; + case Edge.bottom: + return rect.bottom; + case es.Edge.left: + return rect.left; + case Edge.right: + return rect.right; + } + } + /** * 计算两个矩形的并集。结果将是一个包含其他两个的矩形。 * @param first @@ -15,5 +33,65 @@ module es { result.height = Math.max(first.bottom, result.bottom) - result.y; return result; } + + public static getHalfRect(rect: Rectangle, edge: Edge) { + switch (edge) { + case Edge.top: + return new Rectangle(rect.x, rect.y, rect.width, rect.height / 2); + case Edge.bottom: + return new Rectangle(rect.x, rect.y + rect.height / 2, rect.width, rect.height / 2); + case Edge.left: + return new Rectangle(rect.x, rect.y, rect.width / 2, rect.height); + case Edge.right: + return new Rectangle(rect.x + rect.width / 2, rect.y, rect.width / 2, rect.height); + } + } + + /** + * 获取矩形的一部分,其宽度/高度的大小位于矩形的边缘,但仍然包含在其中。 + * @param rect + * @param edge + * @param size + */ + public static getRectEdgePortion(rect: Rectangle, edge: Edge, size: number = 1) { + switch (edge) { + case es.Edge.top: + return new Rectangle(rect.x, rect.y, rect.width, size); + case Edge.bottom: + return new Rectangle(rect.x, rect.y + rect.height - size, rect.width, size); + case Edge.left: + return new Rectangle(rect.x, rect.y, size, rect.height); + case Edge.right: + return new Rectangle(rect.x + rect.width - size, rect.y, size, rect.height); + } + } + + public static expandSide(rect: Rectangle, edge: Edge, amount: number) { + amount = Math.abs(amount); + + switch (edge) { + case Edge.top: + rect.y -= amount; + rect.height += amount; + break; + case es.Edge.bottom: + rect.height += amount; + break; + case Edge.left: + rect.x -= amount; + rect.width += amount; + break; + case Edge.right: + rect.width += amount; + break; + } + } + + public static contract(rect: Rectangle, horizontalAmount, verticalAmount) { + rect.x += horizontalAmount; + rect.y += verticalAmount; + rect.width -= horizontalAmount * 2; + rect.height -= verticalAmount * 2; + } } } diff --git a/source/src/Utils/SubpixelNumber.ts b/source/src/Utils/SubpixelNumber.ts new file mode 100644 index 00000000..77e2f0d5 --- /dev/null +++ b/source/src/Utils/SubpixelNumber.ts @@ -0,0 +1,27 @@ +module es { + /** + * 管理数值的简单助手类。它存储值,直到累计的总数大于1。一旦超过1,该值将在调用update时添加到amount中。 + */ + export class SubpixelNumber { + public remainder: number; + + /** + * 以amount递增余数,将值截断为int,存储新的余数并将amount设置为当前值。 + * @param amount + */ + public update(amount: number){ + this.remainder += amount; + let motion = Math.trunc(this.remainder); + this.remainder -= motion; + return motion; + } + + /** + * 将余数重置为0。当一个物体与一个不可移动的物体碰撞时有用。 + * 在这种情况下,您将希望将亚像素余数归零,因为它是空的和无效的碰撞。 + */ + public reset(){ + this.remainder = 0; + } + } +} \ No newline at end of file