diff --git a/demo/libs/framework/framework.d.ts b/demo/libs/framework/framework.d.ts index cfdf66e7..3e948d6b 100644 --- a/demo/libs/framework/framework.d.ts +++ b/demo/libs/framework/framework.d.ts @@ -285,7 +285,6 @@ declare module es { update(): void; setEnabled(isEnabled: boolean): this; setUpdateOrder(updateOrder: number): this; - clone(): Component; } } declare module es { @@ -334,7 +333,6 @@ declare module es { destroy(): void; detachFromScene(): void; attachToScene(newScene: Scene): void; - clone(position?: Vector2): Entity; onAddedToScene(): void; onRemovedFromScene(): void; update(): void; @@ -349,7 +347,6 @@ declare module es { removeAllComponents(): void; compareTo(other: Entity): number; toString(): string; - protected copyFrom(entity: Entity): void; } } declare module es { @@ -691,7 +688,7 @@ declare module es { class SpriteAnimation { readonly sprites: Sprite[]; readonly frameRate: number; - constructor(sprites: Sprite[], frameRate: number); + constructor(sprites: Sprite[], frameRate?: number); } } declare module es { @@ -759,7 +756,7 @@ declare module es { declare module es { class TiledMapRenderer extends RenderableComponent { tiledMap: TmxMap; - physicsLayer: number; + physicsLayer: Ref; layerIndicesToRender: number[]; private toContainer; readonly width: number; @@ -808,11 +805,10 @@ declare module es { } declare module es { abstract class Collider extends Component { - debug: any; shape: Shape; isTrigger: boolean; - physicsLayer: number; - collidesWithLayers: number; + physicsLayer: Ref; + collidesWithLayers: Ref; shouldColliderScaleAndRotateWithTransform: boolean; registeredPhysicsBounds: Rectangle; _localOffsetLength: number; @@ -837,7 +833,6 @@ declare module es { unregisterColliderWithPhysicsSystem(): void; overlaps(other: Collider): boolean; collidesWith(collider: Collider, motion: Vector2, result: CollisionResult): boolean; - clone(): Component; } } declare module es { @@ -846,10 +841,9 @@ declare module es { polygonShape: egret.Shape; pixelShape1: egret.Shape; pixelShape2: egret.Shape; - constructor(); + constructor(x?: number, y?: number, width?: number, height?: number); width: number; height: number; - createBoxRect(x: number, y: number, width: number, height: number): BoxCollider; setSize(width: number, height: number): this; setWidth(width: number): BoxCollider; setHeight(height: number): void; @@ -1303,10 +1297,10 @@ declare module es { class Flags { static isFlagSet(self: number, flag: number): boolean; static isUnshiftedFlagSet(self: number, flag: number): boolean; - static setFlagExclusive(self: number, flag: number): number; - static setFlag(self: number, flag: number): number; - static unsetFlag(self: number, flag: number): number; - static invertFlags(self: number): number; + static setFlagExclusive(self: Ref, flag: number): void; + static setFlag(self: Ref, flag: number): void; + static unsetFlag(self: Ref, flag: number): void; + static invertFlags(self: Ref): void; } } declare module es { @@ -1422,12 +1416,12 @@ declare module es { static isLineToLine(a1: Vector2, a2: Vector2, b1: Vector2, b2: Vector2): boolean; static lineToLineIntersection(a1: Vector2, a2: Vector2, b1: Vector2, b2: Vector2): Vector2; static closestPointOnLine(lineA: Vector2, lineB: Vector2, closestTo: Vector2): Vector2; - static isCircleToCircle(circleCenter1: Vector2, circleRadius1: number, circleCenter2: Vector2, circleRadius2: number): boolean; - static isCircleToLine(circleCenter: Vector2, radius: number, lineFrom: Vector2, lineTo: Vector2): boolean; - static isCircleToPoint(circleCenter: Vector2, radius: number, point: Vector2): boolean; - static isRectToCircle(rect: egret.Rectangle, cPosition: Vector2, cRadius: number): boolean; - static isRectToLine(rect: Rectangle, lineFrom: Vector2, lineTo: Vector2): boolean; - static isRectToPoint(rX: number, rY: number, rW: number, rH: number, point: Vector2): boolean; + static circleToCircle(circleCenter1: Vector2, circleRadius1: number, circleCenter2: Vector2, circleRadius2: number): boolean; + static circleToLine(circleCenter: Vector2, radius: number, lineFrom: Vector2, lineTo: Vector2): boolean; + static circleToPoint(circleCenter: Vector2, radius: number, point: Vector2): boolean; + static rectToCircle(rect: egret.Rectangle, cPosition: Vector2, cRadius: number): boolean; + static rectToLine(rect: Rectangle, lineFrom: Vector2, lineTo: Vector2): boolean; + static rectToPoint(rX: number, rY: number, rW: number, rH: number, point: Vector2): boolean; static getSector(rX: number, rY: number, rW: number, rH: number, point: Vector2): PointSectors; } } @@ -1486,7 +1480,6 @@ declare module es { abstract collidesWithLine(start: Vector2, end: Vector2, hit: RaycastHit): boolean; abstract containsPoint(point: Vector2): any; abstract pointCollidesWithShape(point: Vector2, result: CollisionResult): boolean; - clone(): Shape; } } declare module es { @@ -1508,7 +1501,7 @@ declare module es { static findPolygonCenter(points: Vector2[]): Vector2; static getFarthestPointInDirection(points: Vector2[], direction: Vector2): Vector2; static getClosestPointOnPolygonToPoint(points: Vector2[], point: Vector2, distanceSquared: Ref, edgeNormal: Vector2): Vector2; - static rotatePolygonVerts(radians: number, originalPoints: Vector2[], rotatedPoints: any): void; + static rotatePolygonVerts(radians: number, originalPoints: Vector2[], rotatedPoints: Vector2[]): void; recalculateBounds(collider: Collider): void; overlaps(other: Shape): any; collidesWithShape(other: Shape, result: CollisionResult): boolean; @@ -2051,122 +2044,6 @@ declare module es { update(): void; } } -declare module es { - class TouchState { - x: number; - y: number; - touchPoint: number; - touchDown: boolean; - readonly position: Vector2; - reset(): void; - } - class Input { - private static _init; - private static _previousTouchState; - private static _resolutionOffset; - private static _touchIndex; - private static _gameTouchs; - static readonly gameTouchs: TouchState[]; - private static _resolutionScale; - static readonly resolutionScale: Vector2; - private static _totalTouchCount; - static readonly totalTouchCount: number; - static readonly touchPosition: Vector2; - static maxSupportedTouch: number; - static readonly touchPositionDelta: Vector2; - static initialize(): void; - static scaledPosition(position: Vector2): Vector2; - private static initTouchCache; - private static touchBegin; - private static touchMove; - private static touchEnd; - private static setpreviousTouchState; - } -} -declare class KeyboardUtils { - static TYPE_KEY_DOWN: number; - static TYPE_KEY_UP: number; - static A: string; - static B: string; - static C: string; - static D: string; - static E: string; - static F: string; - static G: string; - static H: string; - static I: string; - static J: string; - static K: string; - static L: string; - static M: string; - static N: string; - static O: string; - static P: string; - static Q: string; - static R: string; - static S: string; - static T: string; - static U: string; - static V: string; - static W: string; - static X: string; - static Y: string; - static Z: string; - static ESC: string; - static F1: string; - static F2: string; - static F3: string; - static F4: string; - static F5: string; - static F6: string; - static F7: string; - static F8: string; - static F9: string; - static F10: string; - static F11: string; - static F12: string; - static NUM_1: string; - static NUM_2: string; - static NUM_3: string; - static NUM_4: string; - static NUM_5: string; - static NUM_6: string; - static NUM_7: string; - static NUM_8: string; - static NUM_9: string; - static NUM_0: string; - static TAB: string; - static CTRL: string; - static ALT: string; - static SHIFT: string; - static CAPS_LOCK: string; - static ENTER: string; - static SPACE: string; - static BACK_SPACE: string; - static INSERT: string; - static DELETE: string; - static HOME: string; - static END: string; - static PAGE_UP: string; - static PAGE_DOWN: string; - static LEFT: string; - static RIGHT: string; - static UP: string; - static DOWN: string; - static PAUSE_BREAK: string; - static NUM_LOCK: string; - static SCROLL_LOCK: string; - static WINDOWS: string; - private static keyDownDict; - private static keyUpDict; - static init(): void; - static registerKey(key: string, fun: Function, thisObj: any, type?: number, ...args: any[]): void; - static unregisterKey(key: string, type?: number): void; - static destroy(): void; - private static onKeyDonwHander; - private static onKeyUpHander; - private static keyCodeToString; -} declare module es { class ListPool { private static readonly _objectQueue; @@ -2386,6 +2263,250 @@ declare module es { initialized: boolean; } } +declare module es { + class TouchState { + x: number; + y: number; + touchPoint: number; + touchDown: boolean; + readonly position: Vector2; + reset(): void; + } + class Input { + private static _init; + private static _previousTouchState; + private static _resolutionOffset; + private static _touchIndex; + private static _gameTouchs; + static readonly gameTouchs: TouchState[]; + private static _resolutionScale; + static readonly resolutionScale: Vector2; + private static _totalTouchCount; + static readonly totalTouchCount: number; + static readonly touchPosition: Vector2; + static _virtualInputs: VirtualInput[]; + static maxSupportedTouch: number; + static readonly touchPositionDelta: Vector2; + static initialize(): void; + static update(): void; + static scaledPosition(position: Vector2): Vector2; + static isKeyPressed(key: Keys): boolean; + static isKeyPressedBoth(keyA: Keys, keyB: Keys): boolean; + static isKeyDown(key: Keys): boolean; + static isKeyDownBoth(keyA: Keys, keyB: Keys): boolean; + static isKeyReleased(key: Keys): boolean; + static isKeyReleasedBoth(keyA: Keys, keyB: Keys): boolean; + private static initTouchCache; + private static touchBegin; + private static touchMove; + private static touchEnd; + private static setpreviousTouchState; + } +} +import Keys = es.Keys; +declare class KeyboardUtils { + static currentKeys: Keys[]; + static previousKeys: Keys[]; + private static keyStatusKeys; + static init(): void; + static update(): void; + static destroy(): void; + private static onKeyDownHandler; + private static onKeyUpHandler; +} +declare module es { + enum Keys { + none = 0, + back = 8, + tab = 9, + enter = 13, + capsLock = 20, + escape = 27, + space = 32, + pageUp = 33, + pageDown = 34, + end = 35, + home = 36, + left = 37, + up = 38, + right = 39, + down = 40, + select = 41, + print = 42, + execute = 43, + printScreen = 44, + insert = 45, + delete = 46, + help = 47, + d0 = 48, + d1 = 49, + d2 = 50, + d3 = 51, + d4 = 52, + d5 = 53, + d6 = 54, + d7 = 55, + d8 = 56, + d9 = 57, + a = 65, + b = 66, + c = 67, + d = 68, + e = 69, + f = 70, + g = 71, + h = 72, + i = 73, + j = 74, + k = 75, + l = 76, + m = 77, + n = 78, + o = 79, + p = 80, + q = 81, + r = 82, + s = 83, + t = 84, + u = 85, + v = 86, + w = 87, + x = 88, + y = 89, + z = 90, + leftWindows = 91, + rightWindows = 92, + apps = 93, + sleep = 95, + numPad0 = 96, + numPad1 = 97, + numPad2 = 98, + numPad3 = 99, + numPad4 = 100, + numPad5 = 101, + numPad6 = 102, + numPad7 = 103, + numPad8 = 104, + numPad9 = 105, + multiply = 106, + add = 107, + seperator = 108, + subtract = 109, + decimal = 110, + divide = 111, + f1 = 112, + f2 = 113, + f3 = 114, + f4 = 115, + f5 = 116, + f6 = 117, + f7 = 118, + f8 = 119, + f9 = 120, + f10 = 121, + f11 = 122, + f12 = 123, + f13 = 124, + f14 = 125, + f15 = 126, + f16 = 127, + f17 = 128, + f18 = 129, + f19 = 130, + f20 = 131, + f21 = 132, + f22 = 133, + f23 = 134, + f24 = 135, + numLock = 144, + scroll = 145, + leftShift = 160, + rightShift = 161, + leftControl = 162, + rightControl = 163, + leftAlt = 164, + rightAlt = 165, + browserBack = 166, + browserForward = 167 + } +} +declare module es { + enum OverlapBehavior { + cancelOut = 0, + takeOlder = 1, + takeNewer = 2 + } + abstract class VirtualInput { + protected constructor(); + deregister(): void; + abstract update(): any; + } + abstract class VirtualInputNode { + update(): void; + } +} +declare module es { + class VirtualIntegerAxis extends VirtualInput { + nodes: VirtualAxisNode[]; + readonly value: number; + constructor(...nodes: VirtualAxisNode[]); + update(): void; + addKeyboardKeys(overlapBehavior: OverlapBehavior, negative: Keys, positive: Keys): this; + } + abstract class VirtualAxisNode extends VirtualInputNode { + abstract value: number; + } +} +declare module es { + class VirtualAxis extends VirtualInput { + nodes: VirtualAxisNode[]; + readonly value: number; + constructor(...nodes: VirtualAxisNode[]); + update(): void; + } + class KeyboardKeys extends VirtualAxisNode { + overlapBehavior: OverlapBehavior; + positive: Keys; + negative: Keys; + _value: number; + _turned: boolean; + constructor(overlapBehavior: OverlapBehavior, negative: Keys, positive: Keys); + update(): void; + readonly value: number; + } +} +declare module es { + class VirtualButton extends VirtualInput { + nodes: Node[]; + bufferTime: number; + firstRepeatTime: number; + mutiRepeatTime: number; + isRepeating: boolean; + _bufferCounter: number; + _repeatCounter: number; + _willRepeat: boolean; + constructor(bufferTime?: number, ...nodes: Node[]); + setRepeat(firstRepeatTime: number, mutiRepeatTime?: number): void; + update(): void; + readonly isDown: boolean; + readonly isPressed: boolean; + readonly isReleased: boolean; + consumeBuffer(): void; + addKeyboardKey(key: Keys): VirtualButton; + } + abstract class Node extends VirtualInputNode { + abstract isDown: boolean; + abstract isPressed: boolean; + abstract isReleased: boolean; + } + class KeyboardKey extends Node { + key: Keys; + constructor(key: Keys); + readonly isDown: boolean; + readonly isPressed: boolean; + readonly isReleased: boolean; + } +} declare module es { class AssetPacker { protected itemsToRaster: TextureToPack[]; diff --git a/demo/libs/framework/framework.js b/demo/libs/framework/framework.js index 1261c84d..d5a7d6fe 100644 --- a/demo/libs/framework/framework.js +++ b/demo/libs/framework/framework.js @@ -1096,6 +1096,7 @@ var es; case 0: this.startDebugUpdate(); es.Time.update(egret.getTimer()); + es.Input.update(); if (!this._scene) return [3, 2]; for (i = this._globalManagers.length - 1; i >= 0; i--) { if (this._globalManagers[i].enabled) @@ -1311,11 +1312,6 @@ var es; } return this; }; - Component.prototype.clone = function () { - var component = ObjectUtils.clone(this); - component.entity = null; - return component; - }; return Component; }(egret.HashObject)); es.Component = Component; @@ -1554,13 +1550,6 @@ var es; this.transform.getChild(i).entity.attachToScene(newScene); } }; - Entity.prototype.clone = function (position) { - if (position === void 0) { position = new es.Vector2(); } - var entity = new Entity(this.name + "(clone)"); - entity.copyFrom(this); - entity.transform.position = position; - return entity; - }; Entity.prototype.onAddedToScene = function () { }; Entity.prototype.onRemovedFromScene = function () { @@ -1620,24 +1609,6 @@ var es; Entity.prototype.toString = function () { return "[Entity: name: " + this.name + ", tag: " + this.tag + ", enabled: " + this.enabled + ", depth: " + this.updateOrder + "]"; }; - Entity.prototype.copyFrom = function (entity) { - this.tag = entity.tag; - this.updateInterval = entity.updateInterval; - this.updateOrder = entity.updateOrder; - this.enabled = entity.enabled; - this.transform.scale = entity.transform.scale; - this.transform.rotation = entity.transform.rotation; - for (var i = 0; i < entity.components.count; i++) - this.addComponent(entity.components.buffer[i].clone()); - for (var i = 0; i < entity.components._componentsToAdd.length; i++) - this.addComponent(entity.components._componentsToAdd[i].clone()); - for (var i = 0; i < entity.transform.childCount; i++) { - var child = entity.transform.getChild(i).entity; - var childClone = child.clone(); - childClone.transform.copyFrom(child.transform); - childClone.transform.parent = this.transform; - } - }; Entity._idGenerator = 0; return Entity; }()); @@ -3264,6 +3235,7 @@ var es; (function (es) { var SpriteAnimation = (function () { function SpriteAnimation(sprites, frameRate) { + if (frameRate === void 0) { frameRate = 10; } this.sprites = sprites; this.frameRate = frameRate; } @@ -3461,13 +3433,13 @@ var es; if (collisionLayerName === void 0) { collisionLayerName = null; } if (shouldCreateColliders === void 0) { shouldCreateColliders = true; } var _this = _super.call(this) || this; - _this.physicsLayer = 1 << 0; + _this.physicsLayer = new es.Ref(1 << 0); _this.toContainer = false; _this.tiledMap = tiledMap; _this._shouldCreateColliders = shouldCreateColliders; _this.displayObject = new egret.DisplayObjectContainer(); if (collisionLayerName) { - _this.collisionLayer = tiledMap.tileLayers[collisionLayerName]; + _this.collisionLayer = tiledMap.tileLayers.find(function (layer) { return layer.name == collisionLayerName; }); } return _this; } @@ -3554,7 +3526,7 @@ var es; var collisionRects = this.collisionLayer.getCollisionRectangles(); this._colliders = []; for (var i = 0; i < collisionRects.length; i++) { - var collider = new es.BoxCollider().createBoxRect(collisionRects[i].x + this._localOffset.x, collisionRects[i].y + this._localOffset.y, collisionRects[i].width, collisionRects[i].height); + var collider = new es.BoxCollider(collisionRects[i].x + this._localOffset.x, collisionRects[i].y + this._localOffset.y, collisionRects[i].width, collisionRects[i].height); collider.physicsLayer = this.physicsLayer; collider.entity = this.entity; this._colliders[i] = collider; @@ -3596,7 +3568,7 @@ var es; var bounds = collider.bounds; bounds.x += motion.x; bounds.y += motion.y; - var neighbors = es.Physics.boxcastBroadphaseExcludingSelf(collider, bounds, collider.collidesWithLayers); + var neighbors = es.Physics.boxcastBroadphaseExcludingSelf(collider, bounds, collider.collidesWithLayers.value); for (var j = 0; j < neighbors.length; j++) { var neighbor = neighbors[j]; if (neighbor.isTrigger) @@ -3645,10 +3617,10 @@ var es; if (!this._collider) return false; var didCollide = false; - this.entity.position = es.Vector2.add(this.entity.position, motion); - var neighbors = es.Physics.boxcastBroadphase(this._collider.bounds, this._collider.collidesWithLayers); - for (var i = 0; i < neighbors.length; i++) { - var neighbor = neighbors[i]; + this.entity.position.add(motion); + var neighbors = es.Physics.boxcastBroadphase(this._collider.bounds, this._collider.collidesWithLayers.value); + for (var _i = 0, neighbors_1 = neighbors; _i < neighbors_1.length; _i++) { + var neighbor = neighbors_1[_i]; if (this._collider.overlaps(neighbor) && neighbor.enabled) { didCollide = true; this.notifyTriggerListeners(this._collider, neighbor); @@ -3678,8 +3650,8 @@ var es; __extends(Collider, _super); function Collider() { var _this = _super !== null && _super.apply(this, arguments) || this; - _this.physicsLayer = 1 << 0; - _this.collidesWithLayers = es.Physics.allLayers; + _this.physicsLayer = new es.Ref(1 << 0); + _this.collidesWithLayers = new es.Ref(es.Physics.allLayers); _this.shouldColliderScaleAndRotateWithTransform = true; _this.registeredPhysicsBounds = new es.Rectangle(); _this._isPositionDirty = true; @@ -3748,8 +3720,8 @@ var es; var renderable = this.entity.getComponent(es.RenderableComponent); if (renderable) { var renderableBounds = renderable.bounds; - var width = renderableBounds.width / this.entity.scale.x; - var height = renderableBounds.height / this.entity.scale.y; + var width = renderableBounds.width / this.entity.transform.scale.x; + var height = renderableBounds.height / this.entity.transform.scale.y; if (this instanceof es.CircleCollider) { this.radius = Math.max(width, height) * 0.5; } @@ -3809,20 +3781,13 @@ var es; }; Collider.prototype.collidesWith = function (collider, motion, result) { var oldPosition = this.entity.position; - this.entity.position = this.entity.position.add(motion); + this.entity.position.add(motion); var didCollide = this.shape.collidesWithShape(collider.shape, result); if (didCollide) result.collider = collider; this.entity.position = oldPosition; return didCollide; }; - Collider.prototype.clone = function () { - var collider = ObjectUtils.clone(this); - collider.entity = null; - if (this.shape) - collider.shape = this.shape.clone(); - return collider; - }; return Collider; }(es.Component)); es.Collider = Collider; @@ -3831,14 +3796,28 @@ var es; (function (es) { var BoxCollider = (function (_super) { __extends(BoxCollider, _super); - function BoxCollider() { + function BoxCollider(x, y, width, height) { var _this = _super.call(this) || this; _this.hollowShape = new egret.Shape(); _this.polygonShape = new egret.Shape(); _this.pixelShape1 = new egret.Shape(); _this.pixelShape2 = new egret.Shape(); - _this.shape = new es.Box(1, 1); - _this._colliderRequiresAutoSizing = true; + if (x == undefined && y == undefined) { + if (width == undefined && height == undefined) { + _this.shape = new es.Box(1, 1); + _this._colliderRequiresAutoSizing = true; + } + else if (width != undefined && height != undefined) { + x = -width / 2; + y = -height / 2; + _this._localOffset = new es.Vector2(x + width / 2, y + height / 2); + _this.shape = new es.Box(width, height); + } + } + else if (x != undefined && y != undefined && width != undefined && height != undefined) { + _this._localOffset = new es.Vector2(x + width / 2, y + height / 2); + _this.shape = new es.Box(width, height); + } return _this; } Object.defineProperty(BoxCollider.prototype, "width", { @@ -3861,12 +3840,6 @@ var es; enumerable: true, configurable: true }); - BoxCollider.prototype.createBoxRect = function (x, y, width, height) { - this._localOffset = new es.Vector2(x + width / 2, y + width / 2); - this.shape = new es.Box(width, height); - this._colliderRequiresAutoSizing = false; - return this; - }; BoxCollider.prototype.setSize = function (width, height) { this._colliderRequiresAutoSizing = false; var box = this.shape; @@ -3906,6 +3879,11 @@ var es; this.debugDisplayObject.addChild(this.pixelShape1); if (!this.pixelShape2.parent) this.debugDisplayObject.addChild(this.pixelShape2); + this.hollowShape.graphics.clear(); + this.hollowShape.graphics.beginFill(es.Colors.colliderBounds, 0); + this.hollowShape.graphics.lineStyle(es.Size.lineSizeMultiplier, es.Colors.colliderBounds); + this.hollowShape.graphics.drawRect(this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height); + this.hollowShape.graphics.endFill(); this.polygonShape.graphics.clear(); if (poly.points.length >= 2) { this.polygonShape.graphics.beginFill(es.Colors.colliderEdge, 0); @@ -3951,9 +3929,13 @@ var es; _this.circleShape = new egret.Shape(); _this.pixelShape1 = new egret.Shape(); _this.pixelShape2 = new egret.Shape(); - if (radius) + if (radius == undefined) { + _this.shape = new es.Circle(1); _this._colliderRequiresAutoSizing = true; - _this.shape = new es.Circle(radius ? radius : 1); + } + else { + _this.shape = new es.Circle(radius); + } return _this; } Object.defineProperty(CircleCollider.prototype, "radius", { @@ -6155,17 +6137,17 @@ var es; return (self & flag) != 0; }; Flags.setFlagExclusive = function (self, flag) { - return 1 << flag; + self.value = 1 << flag; }; Flags.setFlag = function (self, flag) { - return (self | 1 << flag); + self.value = (self.value | 1 << flag); }; Flags.unsetFlag = function (self, flag) { flag = 1 << flag; - return (self & (~flag)); + self.value = (self.value & (~flag)); }; Flags.invertFlags = function (self) { - return ~self; + self.value = ~self.value; }; return Flags; }()); @@ -6828,23 +6810,42 @@ var es; t = es.MathHelper.clamp(t, 0, 1); return es.Vector2.add(lineA, new es.Vector2(v.x * t, v.y * t)); }; - Collisions.isCircleToCircle = function (circleCenter1, circleRadius1, circleCenter2, circleRadius2) { + Collisions.circleToCircle = function (circleCenter1, circleRadius1, circleCenter2, circleRadius2) { return es.Vector2.distanceSquared(circleCenter1, circleCenter2) < (circleRadius1 + circleRadius2) * (circleRadius1 + circleRadius2); }; - Collisions.isCircleToLine = function (circleCenter, radius, lineFrom, lineTo) { + Collisions.circleToLine = function (circleCenter, radius, lineFrom, lineTo) { return es.Vector2.distanceSquared(circleCenter, this.closestPointOnLine(lineFrom, lineTo, circleCenter)) < radius * radius; }; - Collisions.isCircleToPoint = function (circleCenter, radius, point) { + Collisions.circleToPoint = function (circleCenter, radius, point) { return es.Vector2.distanceSquared(circleCenter, point) < radius * radius; }; - Collisions.isRectToCircle = function (rect, cPosition, cRadius) { - var ew = rect.width * 0.5; - var eh = rect.height * 0.5; - var vx = Math.max(0, Math.max(cPosition.x - rect.x) - ew); - var vy = Math.max(0, Math.max(cPosition.y - rect.y) - eh); - return vx * vx + vy * vy < cRadius * cRadius; + Collisions.rectToCircle = function (rect, cPosition, cRadius) { + if (this.rectToPoint(rect.x, rect.y, rect.width, rect.height, cPosition)) + return true; + var edgeFrom = es.Vector2.zero; + var edgeTo = es.Vector2.zero; + var sector = this.getSector(rect.x, rect.y, rect.width, rect.height, cPosition); + if ((sector & PointSectors.top) != 0) { + edgeFrom = new es.Vector2(rect.x, rect.y); + edgeTo = new es.Vector2(rect.x + rect.width, rect.y); + if (this.circleToLine(cPosition, cRadius, edgeFrom, edgeTo)) + return true; + } + if ((sector & PointSectors.bottom) != 0) { + edgeFrom = new es.Vector2(rect.x, rect.y + rect.width); + edgeTo = new es.Vector2(rect.x + rect.width, rect.y + rect.height); + if (this.circleToLine(cPosition, cRadius, edgeFrom, edgeTo)) + return true; + } + if ((sector & PointSectors.left) != 0) { + edgeFrom = new es.Vector2(rect.x + rect.width, rect.y); + edgeTo = new es.Vector2(rect.x + rect.width, rect.y + rect.height); + if (this.circleToLine(cPosition, cRadius, edgeFrom, edgeTo)) + return true; + } + return false; }; - Collisions.isRectToLine = function (rect, lineFrom, lineTo) { + Collisions.rectToLine = function (rect, lineFrom, lineTo) { var fromSector = this.getSector(rect.x, rect.y, rect.width, rect.height, lineFrom); var toSector = this.getSector(rect.x, rect.y, rect.width, rect.height, lineTo); if (fromSector == PointSectors.center || toSector == PointSectors.center) { @@ -6884,7 +6885,7 @@ var es; } return false; }; - Collisions.isRectToPoint = function (rX, rY, rW, rH, point) { + Collisions.rectToPoint = function (rX, rY, rW, rH, point) { return point.x >= rX && point.y >= rY && point.x < rX + rW && point.y < rY + rH; }; Collisions.getSector = function (rX, rY, rW, rH, point) { @@ -7022,9 +7023,6 @@ var es; var Shape = (function () { function Shape() { } - Shape.prototype.clone = function () { - return ObjectUtils.clone(this); - }; return Shape; }()); es.Shape = Shape; @@ -7064,7 +7062,7 @@ var es; }; Polygon.prototype.buildEdgeNormals = function () { var totalEdges = this.isBox ? 2 : this.points.length; - if (this._edgeNormals == null || this._edgeNormals.length != totalEdges) + if (this._edgeNormals == undefined || this._edgeNormals.length != totalEdges) this._edgeNormals = new Array(totalEdges); var p2; for (var i = 0; i < totalEdges; i++) { @@ -7116,7 +7114,7 @@ var es; edgeNormal.x = 0; edgeNormal.y = 0; var closestPoint = new es.Vector2(0, 0); - var tempDistanceSquared; + var tempDistanceSquared = 0; for (var i = 0; i < points.length; i++) { var j = i + 1; if (j == points.length) @@ -7136,7 +7134,7 @@ var es; }; Polygon.rotatePolygonVerts = function (radians, originalPoints, rotatedPoints) { var cos = Math.cos(radians); - var sin = Math.sign(radians); + var sin = Math.sin(radians); for (var i = 0; i < originalPoints.length; i++) { var position = originalPoints[i]; rotatedPoints[i] = new es.Vector2(position.x * cos + position.y * -sin, position.x * sin + position.y * cos); @@ -7258,7 +7256,7 @@ var es; if (other instanceof Box && other.isUnrotated) return this.bounds.intersects(other.bounds); if (other instanceof es.Circle) - return es.Collisions.isRectToCircle(this.bounds, other.position, other.radius); + return es.Collisions.rectToCircle(this.bounds, other.position, other.radius); } return _super.prototype.overlaps.call(this, other); }; @@ -7302,18 +7300,18 @@ var es; if (collider.entity.transform.rotation != 0) { var offsetAngle = Math.atan2(collider.localOffset.y, collider.localOffset.x) * es.MathHelper.Rad2Deg; var offsetLength = hasUnitScale ? collider._localOffsetLength : es.Vector2.multiply(collider.localOffset, collider.entity.transform.scale).length(); - this.center = es.MathHelper.pointOnCirlce(es.Vector2.zero, offsetLength, collider.entity.transform.rotation + offsetAngle); + this.center = es.MathHelper.pointOnCirlce(es.Vector2.zero, offsetLength, collider.entity.transform.rotationDegrees + offsetAngle); } } - this.position = es.Vector2.add(collider.transform.position, this.center); + this.position = es.Vector2.add(collider.entity.transform.position, this.center); this.bounds = new es.Rectangle(this.position.x - this.radius, this.position.y - this.radius, this.radius * 2, this.radius * 2); }; Circle.prototype.overlaps = function (other) { var result = new es.CollisionResult(); if (other instanceof es.Box && other.isUnrotated) - return es.Collisions.isRectToCircle(other.bounds, this.position, this.radius); + return es.Collisions.rectToCircle(other.bounds, this.position, this.radius); if (other instanceof Circle) - return es.Collisions.isCircleToCircle(this.position, this.radius, other.position, other.radius); + return es.Collisions.circleToCircle(this.position, this.radius, other.position, other.radius); if (other instanceof es.Polygon) return es.ShapeCollisions.circleToPolygon(this, other, result); throw new Error("overlaps of circle to " + other + " are not supported"); @@ -7760,7 +7758,7 @@ var es; continue; var _loop_8 = function (i) { var collider = cell[i]; - if (collider == excludeCollider || !es.Flags.isFlagSet(layerMask, collider.physicsLayer)) + if (collider == excludeCollider || !es.Flags.isFlagSet(layerMask, collider.physicsLayer.value)) return "continue"; if (bounds.intersects(collider.bounds)) { if (!this_4._tempHashSet.firstOrDefault(function (c) { return c.hashCode == collider.hashCode; })) @@ -7916,7 +7914,7 @@ var es; this._checkedColliders.push(potential); if (potential.isTrigger && !es.Physics.raycastsHitTriggers) continue; - if (!es.Flags.isFlagSet(this._layerMask, potential.physicsLayer)) + if (!es.Flags.isFlagSet(this._layerMask, potential.physicsLayer.value)) continue; var colliderBounds = potential.bounds; if (colliderBounds.rayIntersects(this._ray, fraction) && fraction.value <= 1) { @@ -7992,7 +7990,7 @@ var es; return this.tiles[x + y * this.width]; }; TmxLayer.prototype.getCollisionRectangles = function () { - var checkedIndexes = []; + var checkedIndexes = new Array(this.tiles.length); var rectangles = []; var startCol = -1; var index = -1; @@ -8005,7 +8003,7 @@ var es; startCol = x; checkedIndexes[index] = true; } - else if (tile || checkedIndexes[index]) { + else if (!tile || checkedIndexes[index] == true) { if (startCol >= 0) { rectangles.push(this.findBoundsRect(startCol, x, y, checkedIndexes)); startCol = -1; @@ -8025,7 +8023,7 @@ var es; for (var x = startX; x < endX; x++) { index = y * this.map.width + x; var tile = this.getTile(x, y); - if (tile || checkedIndexes[index]) { + if (!tile || checkedIndexes[index]) { for (var _x = startX; _x < x; _x++) { index = y * this.map.width + _x; checkedIndexes[index] = false; @@ -8063,7 +8061,7 @@ var es; }); Object.defineProperty(TmxLayerTile.prototype, "tilesetTile", { get: function () { - if (this._tilesetTileIndex == undefined) { + if (!this._tilesetTileIndex) { this._tilesetTileIndex = -1; if (this.tileset.firstGid <= this.gid) { var tilesetTile = this.tileset.tiles.get(this.gid - this.tileset.firstGid); @@ -9892,364 +9890,6 @@ var es; es.GlobalManager = GlobalManager; })(es || (es = {})); var es; -(function (es) { - var TouchState = (function () { - function TouchState() { - this.x = 0; - this.y = 0; - this.touchPoint = -1; - this.touchDown = false; - } - Object.defineProperty(TouchState.prototype, "position", { - get: function () { - return new es.Vector2(this.x, this.y); - }, - enumerable: true, - configurable: true - }); - TouchState.prototype.reset = function () { - this.x = 0; - this.y = 0; - this.touchDown = false; - this.touchPoint = -1; - }; - return TouchState; - }()); - es.TouchState = TouchState; - var Input = (function () { - function Input() { - } - Object.defineProperty(Input, "gameTouchs", { - get: function () { - return this._gameTouchs; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "resolutionScale", { - get: function () { - return this._resolutionScale; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "totalTouchCount", { - get: function () { - return this._totalTouchCount; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "touchPosition", { - get: function () { - if (!this._gameTouchs[0]) - return es.Vector2.zero; - return this._gameTouchs[0].position; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "maxSupportedTouch", { - get: function () { - return es.Core._instance.stage.maxTouches; - }, - set: function (value) { - es.Core._instance.stage.maxTouches = value; - this.initTouchCache(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "touchPositionDelta", { - get: function () { - var delta = es.Vector2.subtract(this.touchPosition, this._previousTouchState.position); - if (delta.length() > 0) { - this.setpreviousTouchState(this._gameTouchs[0]); - } - return delta; - }, - enumerable: true, - configurable: true - }); - Input.initialize = function () { - if (this._init) - return; - this._init = true; - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.touchBegin, this); - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.touchMove, this); - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.touchEnd, this); - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.touchEnd, this); - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.touchEnd, this); - this.initTouchCache(); - }; - Input.scaledPosition = function (position) { - var scaledPos = new es.Vector2(position.x - this._resolutionOffset.x, position.y - this._resolutionOffset.y); - return es.Vector2.multiply(scaledPos, this.resolutionScale); - }; - Input.initTouchCache = function () { - this._totalTouchCount = 0; - this._touchIndex = 0; - this._gameTouchs.length = 0; - for (var i = 0; i < this.maxSupportedTouch; i++) { - this._gameTouchs.push(new TouchState()); - } - }; - Input.touchBegin = function (evt) { - if (this._touchIndex < this.maxSupportedTouch) { - this._gameTouchs[this._touchIndex].touchPoint = evt.touchPointID; - this._gameTouchs[this._touchIndex].touchDown = evt.touchDown; - this._gameTouchs[this._touchIndex].x = evt.stageX; - this._gameTouchs[this._touchIndex].y = evt.stageY; - if (this._touchIndex == 0) { - this.setpreviousTouchState(this._gameTouchs[0]); - } - this._touchIndex++; - this._totalTouchCount++; - } - }; - Input.touchMove = function (evt) { - if (evt.touchPointID == this._gameTouchs[0].touchPoint) { - this.setpreviousTouchState(this._gameTouchs[0]); - } - var touchIndex = this._gameTouchs.findIndex(function (touch) { return touch.touchPoint == evt.touchPointID; }); - if (touchIndex != -1) { - var touchData = this._gameTouchs[touchIndex]; - touchData.x = evt.stageX; - touchData.y = evt.stageY; - } - }; - Input.touchEnd = function (evt) { - var touchIndex = this._gameTouchs.findIndex(function (touch) { return touch.touchPoint == evt.touchPointID; }); - if (touchIndex != -1) { - var touchData = this._gameTouchs[touchIndex]; - touchData.reset(); - if (touchIndex == 0) - this._previousTouchState.reset(); - this._totalTouchCount--; - if (this.totalTouchCount == 0) { - this._touchIndex = 0; - } - } - }; - Input.setpreviousTouchState = function (touchState) { - this._previousTouchState = new TouchState(); - this._previousTouchState.x = touchState.position.x; - this._previousTouchState.y = touchState.position.y; - this._previousTouchState.touchPoint = touchState.touchPoint; - this._previousTouchState.touchDown = touchState.touchDown; - }; - Input._init = false; - Input._previousTouchState = new TouchState(); - Input._resolutionOffset = new es.Vector2(); - Input._touchIndex = 0; - Input._gameTouchs = []; - Input._resolutionScale = es.Vector2.one; - Input._totalTouchCount = 0; - return Input; - }()); - es.Input = Input; -})(es || (es = {})); -var KeyboardUtils = (function () { - function KeyboardUtils() { - } - KeyboardUtils.init = function () { - KeyboardUtils.keyDownDict = {}; - KeyboardUtils.keyUpDict = {}; - document.addEventListener("keydown", KeyboardUtils.onKeyDonwHander); - document.addEventListener("keyup", KeyboardUtils.onKeyUpHander); - }; - KeyboardUtils.registerKey = function (key, fun, thisObj, type) { - if (type === void 0) { type = 0; } - var args = []; - for (var _i = 4; _i < arguments.length; _i++) { - args[_i - 4] = arguments[_i]; - } - var keyDict = type ? this.keyUpDict : this.keyDownDict; - keyDict[key] = { "fun": fun, args: args, "thisObj": thisObj }; - }; - KeyboardUtils.unregisterKey = function (key, type) { - if (type === void 0) { type = 0; } - var keyDict = type ? this.keyUpDict : this.keyDownDict; - delete keyDict[key]; - }; - KeyboardUtils.destroy = function () { - KeyboardUtils.keyDownDict = null; - KeyboardUtils.keyUpDict = null; - document.removeEventListener("keydown", this.onKeyDonwHander); - document.removeEventListener("keyup", this.onKeyUpHander); - }; - KeyboardUtils.onKeyDonwHander = function (event) { - if (!KeyboardUtils.keyDownDict) - return; - var key = KeyboardUtils.keyCodeToString(event.keyCode); - var o = KeyboardUtils.keyDownDict[key]; - if (o) { - var fun = o["fun"]; - var thisObj = o["thisObj"]; - var args = o["args"]; - fun.apply(thisObj, args); - } - }; - KeyboardUtils.onKeyUpHander = function (event) { - if (!KeyboardUtils.keyUpDict) - return; - var key = KeyboardUtils.keyCodeToString(event.keyCode); - var o = KeyboardUtils.keyUpDict[key]; - if (o) { - var fun = o["fun"]; - var thisObj = o["thisObj"]; - var args = o["args"]; - fun.apply(thisObj, args); - } - }; - KeyboardUtils.keyCodeToString = function (keyCode) { - switch (keyCode) { - case 8: - return this.BACK_SPACE; - case 9: - return this.TAB; - case 13: - return this.ENTER; - case 16: - return this.SHIFT; - case 17: - return this.CTRL; - case 19: - return this.PAUSE_BREAK; - case 20: - return this.CAPS_LOCK; - case 27: - return this.ESC; - case 32: - return this.SPACE; - case 33: - return this.PAGE_UP; - case 34: - return this.PAGE_DOWN; - case 35: - return this.END; - case 36: - return this.HOME; - case 37: - return this.LEFT; - case 38: - return this.UP; - case 39: - return this.RIGHT; - case 40: - return this.DOWN; - case 45: - return this.INSERT; - case 46: - return this.DELETE; - case 91: - return this.WINDOWS; - case 112: - return this.F1; - case 113: - return this.F2; - case 114: - return this.F3; - case 115: - return this.F4; - case 116: - return this.F5; - case 117: - return this.F6; - case 118: - return this.F7; - case 119: - return this.F8; - case 120: - return this.F9; - case 122: - return this.F11; - case 123: - return this.F12; - case 144: - return this.NUM_LOCK; - case 145: - return this.SCROLL_LOCK; - default: - return String.fromCharCode(keyCode); - } - }; - KeyboardUtils.TYPE_KEY_DOWN = 0; - KeyboardUtils.TYPE_KEY_UP = 1; - KeyboardUtils.A = "A"; - KeyboardUtils.B = "B"; - KeyboardUtils.C = "C"; - KeyboardUtils.D = "D"; - KeyboardUtils.E = "E"; - KeyboardUtils.F = "F"; - KeyboardUtils.G = "G"; - KeyboardUtils.H = "H"; - KeyboardUtils.I = "I"; - KeyboardUtils.J = "J"; - KeyboardUtils.K = "K"; - KeyboardUtils.L = "L"; - KeyboardUtils.M = "M"; - KeyboardUtils.N = "N"; - KeyboardUtils.O = "O"; - KeyboardUtils.P = "P"; - KeyboardUtils.Q = "Q"; - KeyboardUtils.R = "R"; - KeyboardUtils.S = "S"; - KeyboardUtils.T = "T"; - KeyboardUtils.U = "U"; - KeyboardUtils.V = "V"; - KeyboardUtils.W = "W"; - KeyboardUtils.X = "X"; - KeyboardUtils.Y = "Y"; - KeyboardUtils.Z = "Z"; - KeyboardUtils.ESC = "Esc"; - KeyboardUtils.F1 = "F1"; - KeyboardUtils.F2 = "F2"; - KeyboardUtils.F3 = "F3"; - KeyboardUtils.F4 = "F4"; - KeyboardUtils.F5 = "F5"; - KeyboardUtils.F6 = "F6"; - KeyboardUtils.F7 = "F7"; - KeyboardUtils.F8 = "F8"; - KeyboardUtils.F9 = "F9"; - KeyboardUtils.F10 = "F10"; - KeyboardUtils.F11 = "F11"; - KeyboardUtils.F12 = "F12"; - KeyboardUtils.NUM_1 = "1"; - KeyboardUtils.NUM_2 = "2"; - KeyboardUtils.NUM_3 = "3"; - KeyboardUtils.NUM_4 = "4"; - KeyboardUtils.NUM_5 = "5"; - KeyboardUtils.NUM_6 = "6"; - KeyboardUtils.NUM_7 = "7"; - KeyboardUtils.NUM_8 = "8"; - KeyboardUtils.NUM_9 = "9"; - KeyboardUtils.NUM_0 = "0"; - KeyboardUtils.TAB = "Tab"; - KeyboardUtils.CTRL = "Ctrl"; - KeyboardUtils.ALT = "Alt"; - KeyboardUtils.SHIFT = "Shift"; - KeyboardUtils.CAPS_LOCK = "Caps Lock"; - KeyboardUtils.ENTER = "Enter"; - KeyboardUtils.SPACE = "Space"; - KeyboardUtils.BACK_SPACE = "Back Space"; - KeyboardUtils.INSERT = "Insert"; - KeyboardUtils.DELETE = "Page Down"; - KeyboardUtils.HOME = "Home"; - KeyboardUtils.END = "Page Down"; - KeyboardUtils.PAGE_UP = "Page Up"; - KeyboardUtils.PAGE_DOWN = "Page Down"; - KeyboardUtils.LEFT = "Left"; - KeyboardUtils.RIGHT = "Right"; - KeyboardUtils.UP = "Up"; - KeyboardUtils.DOWN = "Down"; - KeyboardUtils.PAUSE_BREAK = "Pause Break"; - KeyboardUtils.NUM_LOCK = "Num Lock"; - KeyboardUtils.SCROLL_LOCK = "Scroll Lock"; - KeyboardUtils.WINDOWS = "Windows"; - return KeyboardUtils; -}()); -var es; (function (es) { var ListPool = (function () { function ListPool() { @@ -11097,6 +10737,651 @@ var es; es.MarkerLog = MarkerLog; })(es || (es = {})); var es; +(function (es) { + var TouchState = (function () { + function TouchState() { + this.x = 0; + this.y = 0; + this.touchPoint = -1; + this.touchDown = false; + } + Object.defineProperty(TouchState.prototype, "position", { + get: function () { + return new es.Vector2(this.x, this.y); + }, + enumerable: true, + configurable: true + }); + TouchState.prototype.reset = function () { + this.x = 0; + this.y = 0; + this.touchDown = false; + this.touchPoint = -1; + }; + return TouchState; + }()); + es.TouchState = TouchState; + var Input = (function () { + function Input() { + } + Object.defineProperty(Input, "gameTouchs", { + get: function () { + return this._gameTouchs; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Input, "resolutionScale", { + get: function () { + return this._resolutionScale; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Input, "totalTouchCount", { + get: function () { + return this._totalTouchCount; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Input, "touchPosition", { + get: function () { + if (!this._gameTouchs[0]) + return es.Vector2.zero; + return this._gameTouchs[0].position; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Input, "maxSupportedTouch", { + get: function () { + return es.Core._instance.stage.maxTouches; + }, + set: function (value) { + es.Core._instance.stage.maxTouches = value; + this.initTouchCache(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Input, "touchPositionDelta", { + get: function () { + var delta = es.Vector2.subtract(this.touchPosition, this._previousTouchState.position); + if (delta.length() > 0) { + this.setpreviousTouchState(this._gameTouchs[0]); + } + return delta; + }, + enumerable: true, + configurable: true + }); + Input.initialize = function () { + if (this._init) + return; + this._init = true; + es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.touchBegin, this); + es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.touchMove, this); + es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.touchEnd, this); + es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.touchEnd, this); + es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.touchEnd, this); + this.initTouchCache(); + }; + Input.update = function () { + KeyboardUtils.update(); + for (var i = 0; i < this._virtualInputs.length; i++) + this._virtualInputs[i].update(); + }; + Input.scaledPosition = function (position) { + var scaledPos = new es.Vector2(position.x - this._resolutionOffset.x, position.y - this._resolutionOffset.y); + return es.Vector2.multiply(scaledPos, this.resolutionScale); + }; + Input.isKeyPressed = function (key) { + return KeyboardUtils.currentKeys.contains(key) && !KeyboardUtils.previousKeys.contains(key); + }; + Input.isKeyPressedBoth = function (keyA, keyB) { + return this.isKeyPressed(keyA) || this.isKeyPressed(keyB); + }; + Input.isKeyDown = function (key) { + return KeyboardUtils.currentKeys.contains(key); + }; + Input.isKeyDownBoth = function (keyA, keyB) { + return this.isKeyDown(keyA) || this.isKeyDown(keyB); + }; + Input.isKeyReleased = function (key) { + return !KeyboardUtils.currentKeys.contains(key) && KeyboardUtils.previousKeys.contains(key); + }; + Input.isKeyReleasedBoth = function (keyA, keyB) { + return this.isKeyReleased(keyA) || this.isKeyReleased(keyB); + }; + Input.initTouchCache = function () { + this._totalTouchCount = 0; + this._touchIndex = 0; + this._gameTouchs.length = 0; + for (var i = 0; i < this.maxSupportedTouch; i++) { + this._gameTouchs.push(new TouchState()); + } + }; + Input.touchBegin = function (evt) { + if (this._touchIndex < this.maxSupportedTouch) { + this._gameTouchs[this._touchIndex].touchPoint = evt.touchPointID; + this._gameTouchs[this._touchIndex].touchDown = evt.touchDown; + this._gameTouchs[this._touchIndex].x = evt.stageX; + this._gameTouchs[this._touchIndex].y = evt.stageY; + if (this._touchIndex == 0) { + this.setpreviousTouchState(this._gameTouchs[0]); + } + this._touchIndex++; + this._totalTouchCount++; + } + }; + Input.touchMove = function (evt) { + if (evt.touchPointID == this._gameTouchs[0].touchPoint) { + this.setpreviousTouchState(this._gameTouchs[0]); + } + var touchIndex = this._gameTouchs.findIndex(function (touch) { return touch.touchPoint == evt.touchPointID; }); + if (touchIndex != -1) { + var touchData = this._gameTouchs[touchIndex]; + touchData.x = evt.stageX; + touchData.y = evt.stageY; + } + }; + Input.touchEnd = function (evt) { + var touchIndex = this._gameTouchs.findIndex(function (touch) { return touch.touchPoint == evt.touchPointID; }); + if (touchIndex != -1) { + var touchData = this._gameTouchs[touchIndex]; + touchData.reset(); + if (touchIndex == 0) + this._previousTouchState.reset(); + this._totalTouchCount--; + if (this.totalTouchCount == 0) { + this._touchIndex = 0; + } + } + }; + Input.setpreviousTouchState = function (touchState) { + this._previousTouchState = new TouchState(); + this._previousTouchState.x = touchState.position.x; + this._previousTouchState.y = touchState.position.y; + this._previousTouchState.touchPoint = touchState.touchPoint; + this._previousTouchState.touchDown = touchState.touchDown; + }; + Input._init = false; + Input._previousTouchState = new TouchState(); + Input._resolutionOffset = new es.Vector2(); + Input._touchIndex = 0; + Input._gameTouchs = []; + Input._resolutionScale = es.Vector2.one; + Input._totalTouchCount = 0; + Input._virtualInputs = []; + return Input; + }()); + es.Input = Input; +})(es || (es = {})); +var Keys = es.Keys; +var KeyboardUtils = (function () { + function KeyboardUtils() { + } + KeyboardUtils.init = function () { + document.addEventListener("keydown", KeyboardUtils.onKeyDownHandler); + document.addEventListener("keyup", KeyboardUtils.onKeyUpHandler); + }; + KeyboardUtils.update = function () { + KeyboardUtils.previousKeys.length = 0; + for (var _i = 0, _a = KeyboardUtils.currentKeys; _i < _a.length; _i++) { + var key = _a[_i]; + KeyboardUtils.previousKeys.push(key); + KeyboardUtils.currentKeys.remove(key); + } + KeyboardUtils.currentKeys.length = 0; + for (var _b = 0, _c = KeyboardUtils.keyStatusKeys; _b < _c.length; _b++) { + var key = _c[_b]; + KeyboardUtils.currentKeys.push(key); + } + }; + KeyboardUtils.destroy = function () { + KeyboardUtils.currentKeys.length = 0; + document.removeEventListener("keyup", KeyboardUtils.onKeyUpHandler); + document.removeEventListener("keypress", KeyboardUtils.onKeyDownHandler); + }; + KeyboardUtils.onKeyDownHandler = function (event) { + if (!KeyboardUtils.keyStatusKeys.contains(event.keyCode)) + KeyboardUtils.keyStatusKeys.push(event.keyCode); + }; + KeyboardUtils.onKeyUpHandler = function (event) { + if (KeyboardUtils.keyStatusKeys.contains(event.keyCode)) + KeyboardUtils.keyStatusKeys.remove(event.keyCode); + }; + KeyboardUtils.currentKeys = []; + KeyboardUtils.previousKeys = []; + KeyboardUtils.keyStatusKeys = []; + return KeyboardUtils; +}()); +var es; +(function (es) { + var Keys; + (function (Keys) { + Keys[Keys["none"] = 0] = "none"; + Keys[Keys["back"] = 8] = "back"; + Keys[Keys["tab"] = 9] = "tab"; + Keys[Keys["enter"] = 13] = "enter"; + Keys[Keys["capsLock"] = 20] = "capsLock"; + Keys[Keys["escape"] = 27] = "escape"; + Keys[Keys["space"] = 32] = "space"; + Keys[Keys["pageUp"] = 33] = "pageUp"; + Keys[Keys["pageDown"] = 34] = "pageDown"; + Keys[Keys["end"] = 35] = "end"; + Keys[Keys["home"] = 36] = "home"; + Keys[Keys["left"] = 37] = "left"; + Keys[Keys["up"] = 38] = "up"; + Keys[Keys["right"] = 39] = "right"; + Keys[Keys["down"] = 40] = "down"; + Keys[Keys["select"] = 41] = "select"; + Keys[Keys["print"] = 42] = "print"; + Keys[Keys["execute"] = 43] = "execute"; + Keys[Keys["printScreen"] = 44] = "printScreen"; + Keys[Keys["insert"] = 45] = "insert"; + Keys[Keys["delete"] = 46] = "delete"; + Keys[Keys["help"] = 47] = "help"; + Keys[Keys["d0"] = 48] = "d0"; + Keys[Keys["d1"] = 49] = "d1"; + Keys[Keys["d2"] = 50] = "d2"; + Keys[Keys["d3"] = 51] = "d3"; + Keys[Keys["d4"] = 52] = "d4"; + Keys[Keys["d5"] = 53] = "d5"; + Keys[Keys["d6"] = 54] = "d6"; + Keys[Keys["d7"] = 55] = "d7"; + Keys[Keys["d8"] = 56] = "d8"; + Keys[Keys["d9"] = 57] = "d9"; + Keys[Keys["a"] = 65] = "a"; + Keys[Keys["b"] = 66] = "b"; + Keys[Keys["c"] = 67] = "c"; + Keys[Keys["d"] = 68] = "d"; + Keys[Keys["e"] = 69] = "e"; + Keys[Keys["f"] = 70] = "f"; + Keys[Keys["g"] = 71] = "g"; + Keys[Keys["h"] = 72] = "h"; + Keys[Keys["i"] = 73] = "i"; + Keys[Keys["j"] = 74] = "j"; + Keys[Keys["k"] = 75] = "k"; + Keys[Keys["l"] = 76] = "l"; + Keys[Keys["m"] = 77] = "m"; + Keys[Keys["n"] = 78] = "n"; + Keys[Keys["o"] = 79] = "o"; + Keys[Keys["p"] = 80] = "p"; + Keys[Keys["q"] = 81] = "q"; + Keys[Keys["r"] = 82] = "r"; + Keys[Keys["s"] = 83] = "s"; + Keys[Keys["t"] = 84] = "t"; + Keys[Keys["u"] = 85] = "u"; + Keys[Keys["v"] = 86] = "v"; + Keys[Keys["w"] = 87] = "w"; + Keys[Keys["x"] = 88] = "x"; + Keys[Keys["y"] = 89] = "y"; + Keys[Keys["z"] = 90] = "z"; + Keys[Keys["leftWindows"] = 91] = "leftWindows"; + Keys[Keys["rightWindows"] = 92] = "rightWindows"; + Keys[Keys["apps"] = 93] = "apps"; + Keys[Keys["sleep"] = 95] = "sleep"; + Keys[Keys["numPad0"] = 96] = "numPad0"; + Keys[Keys["numPad1"] = 97] = "numPad1"; + Keys[Keys["numPad2"] = 98] = "numPad2"; + Keys[Keys["numPad3"] = 99] = "numPad3"; + Keys[Keys["numPad4"] = 100] = "numPad4"; + Keys[Keys["numPad5"] = 101] = "numPad5"; + Keys[Keys["numPad6"] = 102] = "numPad6"; + Keys[Keys["numPad7"] = 103] = "numPad7"; + Keys[Keys["numPad8"] = 104] = "numPad8"; + Keys[Keys["numPad9"] = 105] = "numPad9"; + Keys[Keys["multiply"] = 106] = "multiply"; + Keys[Keys["add"] = 107] = "add"; + Keys[Keys["seperator"] = 108] = "seperator"; + Keys[Keys["subtract"] = 109] = "subtract"; + Keys[Keys["decimal"] = 110] = "decimal"; + Keys[Keys["divide"] = 111] = "divide"; + Keys[Keys["f1"] = 112] = "f1"; + Keys[Keys["f2"] = 113] = "f2"; + Keys[Keys["f3"] = 114] = "f3"; + Keys[Keys["f4"] = 115] = "f4"; + Keys[Keys["f5"] = 116] = "f5"; + Keys[Keys["f6"] = 117] = "f6"; + Keys[Keys["f7"] = 118] = "f7"; + Keys[Keys["f8"] = 119] = "f8"; + Keys[Keys["f9"] = 120] = "f9"; + Keys[Keys["f10"] = 121] = "f10"; + Keys[Keys["f11"] = 122] = "f11"; + Keys[Keys["f12"] = 123] = "f12"; + Keys[Keys["f13"] = 124] = "f13"; + Keys[Keys["f14"] = 125] = "f14"; + Keys[Keys["f15"] = 126] = "f15"; + Keys[Keys["f16"] = 127] = "f16"; + Keys[Keys["f17"] = 128] = "f17"; + Keys[Keys["f18"] = 129] = "f18"; + Keys[Keys["f19"] = 130] = "f19"; + Keys[Keys["f20"] = 131] = "f20"; + Keys[Keys["f21"] = 132] = "f21"; + Keys[Keys["f22"] = 133] = "f22"; + Keys[Keys["f23"] = 134] = "f23"; + Keys[Keys["f24"] = 135] = "f24"; + Keys[Keys["numLock"] = 144] = "numLock"; + Keys[Keys["scroll"] = 145] = "scroll"; + Keys[Keys["leftShift"] = 160] = "leftShift"; + Keys[Keys["rightShift"] = 161] = "rightShift"; + Keys[Keys["leftControl"] = 162] = "leftControl"; + Keys[Keys["rightControl"] = 163] = "rightControl"; + Keys[Keys["leftAlt"] = 164] = "leftAlt"; + Keys[Keys["rightAlt"] = 165] = "rightAlt"; + Keys[Keys["browserBack"] = 166] = "browserBack"; + Keys[Keys["browserForward"] = 167] = "browserForward"; + })(Keys = es.Keys || (es.Keys = {})); +})(es || (es = {})); +var es; +(function (es) { + var OverlapBehavior; + (function (OverlapBehavior) { + OverlapBehavior[OverlapBehavior["cancelOut"] = 0] = "cancelOut"; + OverlapBehavior[OverlapBehavior["takeOlder"] = 1] = "takeOlder"; + OverlapBehavior[OverlapBehavior["takeNewer"] = 2] = "takeNewer"; + })(OverlapBehavior = es.OverlapBehavior || (es.OverlapBehavior = {})); + var VirtualInput = (function () { + function VirtualInput() { + es.Input._virtualInputs.push(this); + } + VirtualInput.prototype.deregister = function () { + es.Input._virtualInputs.remove(this); + }; + return VirtualInput; + }()); + es.VirtualInput = VirtualInput; + var VirtualInputNode = (function () { + function VirtualInputNode() { + } + VirtualInputNode.prototype.update = function () { }; + return VirtualInputNode; + }()); + es.VirtualInputNode = VirtualInputNode; +})(es || (es = {})); +var es; +(function (es) { + var VirtualIntegerAxis = (function (_super) { + __extends(VirtualIntegerAxis, _super); + function VirtualIntegerAxis() { + var nodes = []; + for (var _i = 0; _i < arguments.length; _i++) { + nodes[_i] = arguments[_i]; + } + var _this = _super.call(this) || this; + _this.nodes = []; + _this.nodes.concat(nodes); + return _this; + } + Object.defineProperty(VirtualIntegerAxis.prototype, "value", { + get: function () { + for (var i = 0; i < this.nodes.length; i++) { + var val = this.nodes[i].value; + if (val != 0) + return Math.sign(val); + } + return 0; + }, + enumerable: true, + configurable: true + }); + VirtualIntegerAxis.prototype.update = function () { + for (var i = 0; i < this.nodes.length; i++) + this.nodes[i].update(); + }; + VirtualIntegerAxis.prototype.addKeyboardKeys = function (overlapBehavior, negative, positive) { + this.nodes.push(new es.KeyboardKeys(overlapBehavior, negative, positive)); + return this; + }; + return VirtualIntegerAxis; + }(es.VirtualInput)); + es.VirtualIntegerAxis = VirtualIntegerAxis; + var VirtualAxisNode = (function (_super) { + __extends(VirtualAxisNode, _super); + function VirtualAxisNode() { + return _super !== null && _super.apply(this, arguments) || this; + } + return VirtualAxisNode; + }(es.VirtualInputNode)); + es.VirtualAxisNode = VirtualAxisNode; +})(es || (es = {})); +var es; +(function (es) { + var VirtualAxis = (function (_super) { + __extends(VirtualAxis, _super); + function VirtualAxis() { + var nodes = []; + for (var _i = 0; _i < arguments.length; _i++) { + nodes[_i] = arguments[_i]; + } + var _this = _super.call(this) || this; + _this.nodes = []; + _this.nodes.concat(nodes); + return _this; + } + Object.defineProperty(VirtualAxis.prototype, "value", { + get: function () { + for (var i = 0; i < this.nodes.length; i++) { + var val = this.nodes[i].value; + if (val != 0) + return val; + } + return 0; + }, + enumerable: true, + configurable: true + }); + VirtualAxis.prototype.update = function () { + for (var i = 0; i < this.nodes.length; i++) + this.nodes[i].update(); + }; + return VirtualAxis; + }(es.VirtualInput)); + es.VirtualAxis = VirtualAxis; + var KeyboardKeys = (function (_super) { + __extends(KeyboardKeys, _super); + function KeyboardKeys(overlapBehavior, negative, positive) { + var _this = _super.call(this) || this; + _this._value = 0; + _this.overlapBehavior = overlapBehavior; + _this.negative = negative; + _this.positive = positive; + return _this; + } + KeyboardKeys.prototype.update = function () { + if (es.Input.isKeyDown(this.positive)) { + if (es.Input.isKeyDown(this.negative)) { + switch (this.overlapBehavior) { + default: + case es.OverlapBehavior.cancelOut: + this._value = 0; + break; + case es.OverlapBehavior.takeNewer: + if (!this._turned) { + this._value *= -1; + this._turned = true; + } + break; + case es.OverlapBehavior.takeOlder: + break; + } + } + else { + this._turned = false; + this._value = 1; + } + } + else if (es.Input.isKeyDown(this.negative)) { + this._turned = false; + this._value = -1; + } + else { + this._turned = false; + this._value = 0; + } + }; + Object.defineProperty(KeyboardKeys.prototype, "value", { + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return KeyboardKeys; + }(es.VirtualAxisNode)); + es.KeyboardKeys = KeyboardKeys; +})(es || (es = {})); +var es; +(function (es) { + var VirtualButton = (function (_super) { + __extends(VirtualButton, _super); + function VirtualButton(bufferTime) { + if (bufferTime === void 0) { bufferTime = 0; } + var nodes = []; + for (var _i = 1; _i < arguments.length; _i++) { + nodes[_i - 1] = arguments[_i]; + } + var _this = _super.call(this) || this; + _this.nodes = []; + _this.bufferTime = 0; + _this.firstRepeatTime = 0; + _this.mutiRepeatTime = 0; + _this._bufferCounter = 0; + _this._repeatCounter = 0; + _this.nodes = nodes; + _this.bufferTime = bufferTime; + return _this; + } + VirtualButton.prototype.setRepeat = function (firstRepeatTime, mutiRepeatTime) { + if (mutiRepeatTime === void 0) { mutiRepeatTime = firstRepeatTime; } + this.firstRepeatTime = firstRepeatTime; + this.mutiRepeatTime = mutiRepeatTime; + this._willRepeat = this.firstRepeatTime > 0; + if (!this._willRepeat) + this.isRepeating = false; + }; + VirtualButton.prototype.update = function () { + this._bufferCounter -= es.Time.unscaledDeltaTime; + this.isRepeating = false; + var check = false; + for (var i = 0; i < this.nodes.length; i++) { + this.nodes[i].update(); + if (this.nodes[i].isPressed) { + this._bufferCounter = this.bufferTime; + check = true; + } + else if (this.nodes[i].isDown) { + check = true; + } + } + if (!check) { + this._repeatCounter = 0; + this._bufferCounter = 0; + } + else if (this._willRepeat) { + if (this._repeatCounter == 0) { + this._repeatCounter = this.firstRepeatTime; + } + else { + this._repeatCounter -= es.Time.unscaledDeltaTime; + if (this._repeatCounter <= 0) { + this.isRepeating = true; + this._repeatCounter = this.mutiRepeatTime; + } + } + } + }; + Object.defineProperty(VirtualButton.prototype, "isDown", { + get: function () { + for (var _i = 0, _a = this.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.isDown) + return true; + } + return false; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(VirtualButton.prototype, "isPressed", { + get: function () { + if (this._bufferCounter > 0 || this.isRepeating) + return true; + for (var _i = 0, _a = this.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.isPressed) + return true; + } + return false; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(VirtualButton.prototype, "isReleased", { + get: function () { + for (var _i = 0, _a = this.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.isReleased) + return true; + } + return false; + }, + enumerable: true, + configurable: true + }); + VirtualButton.prototype.consumeBuffer = function () { + this._bufferCounter = 0; + }; + VirtualButton.prototype.addKeyboardKey = function (key) { + this.nodes.push(new KeyboardKey(key)); + return this; + }; + return VirtualButton; + }(es.VirtualInput)); + es.VirtualButton = VirtualButton; + var Node = (function (_super) { + __extends(Node, _super); + function Node() { + return _super !== null && _super.apply(this, arguments) || this; + } + return Node; + }(es.VirtualInputNode)); + es.Node = Node; + var KeyboardKey = (function (_super) { + __extends(KeyboardKey, _super); + function KeyboardKey(key) { + var _this = _super.call(this) || this; + _this.key = key; + return _this; + } + Object.defineProperty(KeyboardKey.prototype, "isDown", { + get: function () { + return es.Input.isKeyDown(this.key); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(KeyboardKey.prototype, "isPressed", { + get: function () { + return es.Input.isKeyPressed(this.key); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(KeyboardKey.prototype, "isReleased", { + get: function () { + return es.Input.isKeyReleased(this.key); + }, + enumerable: true, + configurable: true + }); + return KeyboardKey; + }(Node)); + es.KeyboardKey = KeyboardKey; +})(es || (es = {})); +var es; (function (es) { var Bitmap = egret.Bitmap; var AssetPacker = (function () { diff --git a/demo/libs/framework/framework.min.js b/demo/libs/framework/framework.min.js index 4c0da89f..5b173882 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 i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};return function(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();var transform,__awaiter=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))(function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){t.done?r(t.value):new i(function(e){e(t.value)}).then(s,a)}h((n=n.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){var i,n,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(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=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++,n=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 i=t.findIndex(e);return-1==i?null:t[i]}(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(i,n,r){return e.call(arguments[2],n,r,t)&&i.push(n),i},[]);for(var i=[],n=0,r=t.length;n=0&&t.splice(i,1)}while(i>=0)}(this,t)},Array.prototype.remove=function(t){return function(t,e){var i=t.findIndex(function(t){return t===e});return i>=0&&(t.splice(i,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,i){t.splice(e,i)}(this,t,e)},Array.prototype.select=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(i,n,r){return i.push(e.call(arguments[2],n,r,t)),i},[]);for(var i=[],n=0,r=t.length;no?1:-1}),t}(this,t,e)},Array.prototype.orderByDescending=function(t,e){return function(t,e,i){return t.sort(function(t,n){var r=e(t),o=e(n);return i?-i(r,o):r0;){if("break"===l())break}return s?this.recontructPath(a,n,r):null},e.recontructPath=function(t,e,i){var n=[],r=i;for(n.push(i);r!=e;)r=this.getKey(t,r),n.push(r);return n.reverse(),n},e.hasKey=function(t,e){for(var i,n=t.keys();!(i=n.next()).done;)if(JSON.stringify(i.value)==JSON.stringify(e))return!0;return!1},e.getKey=function(t,e){for(var i,n,r=t.keys(),o=t.values();i=r.next(),n=o.next(),!i.done;)if(JSON.stringify(i.value)==JSON.stringify(e))return n.value;return null},e}();t.AStarPathfinder=e;var i=function(t){function e(e){var i=t.call(this)||this;return i.data=e,i}return __extends(e,t),e}(t.PriorityQueueNode);t.AStarNode=i}(es||(es={})),function(t){var e=function(){function e(e,i){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=i}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,i)?this.cascadeUp(t):this.cascadeDown(t)},t.prototype.cascadeDown=function(t){for(var e,i=t.queueIndex;;){e=t;var n=2*i;if(n>this._numNodes){t.queueIndex=i,this._nodes[i]=t;break}var r=this._nodes[n];this.hasHigherPriority(r,e)&&(e=r);var o=n+1;if(o<=this._numNodes){var s=this._nodes[o];this.hasHigherPriority(s,e)&&(e=s)}if(e==t){t.queueIndex=i,this._nodes[i]=t;break}this._nodes[i]=e;var a=e.queueIndex;e.queueIndex=i,i=a}},t.prototype.cascadeUp=function(t){for(var e=Math.floor(t.queueIndex/2);e>=1;){var i=this._nodes[e];if(this.hasHigherPriority(i,t))break;this.swap(t,i),e=Math.floor(t.queueIndex/2)}},t.prototype.swap=function(t,e){this._nodes[t.queueIndex]=e,this._nodes[e.queueIndex]=t;var i=t.queueIndex;t.queueIndex=e.queueIndex,e.queueIndex=i},t.prototype.hasHigherPriority=function(t,e){return t.priority0;){if("break"===h())break}return o?t.AStarPathfinder.recontructPath(a,i,n):null},e.hasKey=function(t,e){for(var i,n=t.keys();!(i=n.next()).done;)if(JSON.stringify(i.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 new e(0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"one",{get:function(){return new e(1,1)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitX",{get:function(){return new e(1,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitY",{get:function(){return new e(0,1)},enumerable:!0,configurable:!0}),e.add=function(t,i){var n=new e(0,0);return n.x=t.x+i.x,n.y=t.y+i.y,n},e.divide=function(t,i){var n=new e(0,0);return n.x=t.x/i.x,n.y=t.y/i.y,n},e.multiply=function(t,i){var n=new e(0,0);return n.x=t.x*i.x,n.y=t.y*i.y,n},e.subtract=function(t,i){var n=new e(0,0);return n.x=t.x-i.x,n.y=t.y-i.y,n},e.normalize=function(t){var i=new e(t.x,t.y),n=1/Math.sqrt(i.x*i.x+i.y*i.y);return i.x*=n,i.y*=n,i},e.dot=function(t,e){return t.x*e.x+t.y*e.y},e.distanceSquared=function(t,e){var i=t.x-e.x,n=t.y-e.y;return i*i+n*n},e.clamp=function(i,n,r){return new e(t.MathHelper.clamp(i.x,n.x,r.x),t.MathHelper.clamp(i.y,n.y,r.y))},e.lerp=function(i,n,r){return new e(t.MathHelper.lerp(i.x,n.x,r),t.MathHelper.lerp(i.y,n.y,r))},e.transform=function(t,i){return new e(t.x*i.m11+t.y*i.m21+i.m31,t.x*i.m12+t.y*i.m22+i.m32)},e.distance=function(t,e){var i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)},e.angle=function(i,n){return i=e.normalize(i),n=e.normalize(n),Math.acos(t.MathHelper.clamp(e.dot(i,n),-1,1))*t.MathHelper.Rad2Deg},e.negate=function(t){var i=new e;return i.x=-t.x,i.y=-t.y,i},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);this.x*=t,this.y*=t},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}();t.Vector2=e}(es||(es={})),function(t){var e=function(){function e(t,i,n){void 0===n&&(n=!1),this.walls=[],this._neighbors=new Array(4),this._width=t,this._hegiht=i,this._dirs=n?e.COMPASS_DIRS:e.CARDINAL_DIRS}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x0;){if("break"===l())break}return s?this.recontructPath(a,n,r):null},i.recontructPath=function(t,e,i){var n=[],r=i;for(n.push(i);r!=e;)r=this.getKey(t,r),n.push(r);return n.reverse(),n},i.hasKey=function(t,e){for(var i,n=t.keys();!(i=n.next()).done;)if(JSON.stringify(i.value)==JSON.stringify(e))return!0;return!1},i.getKey=function(t,e){for(var i,n,r=t.keys(),o=t.values();i=r.next(),n=o.next(),!i.done;)if(JSON.stringify(i.value)==JSON.stringify(e))return n.value;return null},i}();t.WeightedPathfinder=i}(es||(es={})),function(t){var e=function(e){function i(){var n=e.call(this)||this;return n._globalManagers=[],n._timerManager=new t.TimerManager,i._instance=n,i.emitter=new t.Emitter,i.content=new t.ContentManager,n.addEventListener(egret.Event.ADDED_TO_STAGE,n.onAddToStage,n),i.registerGlobalManager(n._timerManager),n}return __extends(i,e),Object.defineProperty(i,"Instance",{get:function(){return this._instance},enumerable:!0,configurable:!0}),Object.defineProperty(i,"scene",{get:function(){return this._instance?this._instance._scene:null},set:function(t){t?null==this._instance._scene?(this._instance.addChild(t),this._instance._scene=t,this._instance._scene.begin(),i.Instance.onSceneChanged()):this._instance._nextScene=t:console.error("场景不能为空")},enumerable:!0,configurable:!0}),i.startSceneTransition=function(t){if(!this._instance._sceneTransition)return this._instance._sceneTransition=t,t;console.warn("在前一个场景完成之前,不能开始一个新的场景转换。")},i.registerGlobalManager=function(t){this._instance._globalManagers.push(t),t.enabled=!0},i.unregisterGlobalManager=function(t){this._instance._globalManagers.remove(t),t.enabled=!1},i.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._scene.parent&&this._scene.parent.removeChild(this._scene),this._scene.end(),this._scene=this._nextScene,this._nextScene=null,this.onSceneChanged(),[4,this._scene.begin()]):[3,2];case 1:i.sent(),this.addChild(this._scene),i.label=2;case 2:return this.endDebugUpdate(),[4,this.draw()];case 3:return i.sent(),[2]}})})},i.prototype.onAddToStage=function(){i.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(),KeyboardUtils.init(),this.initialize()},i.debugRenderEndabled=!1,i}(egret.DisplayObjectContainer);t.Core=e}(es||(es={})),function(t){var e=function(){function t(){}return t.renderableBounds=16776960,t.renderableCenter=10040012,t.colliderBounds=5592405,t.colliderEdge=9109504,t.colliderPosition=16776960,t.colliderCenter=16711680,t}();t.Colors=e;var i=function(){function e(){}return Object.defineProperty(e,"lineSizeMultiplier",{get:function(){return Math.max(Math.ceil(t.Core.scene.x/t.Core.scene.width),1)},enumerable:!0,configurable:!0}),e}();t.Size=i;var n=function(){function e(){}return e.drawHollowRect=function(e,i,n){void 0===n&&(n=0),this._debugDrawItems.push(new t.DebugDrawItem(e,i,n))},e.render=function(){if(this._debugDrawItems.length>0){var e=new egret.Shape;t.Core.scene&&t.Core.scene.addChild(e);for(var i=this._debugDrawItems.length-1;i>=0;i--){this._debugDrawItems[i].draw(e)&&this._debugDrawItems.removeAt(i)}}},e._debugDrawItems=[],e}();t.Debug=n}(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 i=function(){function i(t,i,n){this.rectangle=t,this.color=i,this.duration=n,this.drawType=e.hollowRectangle}return i.prototype.draw=function(i){switch(this.drawType){case e.line:case e.hollowRectangle:case e.pixel:case e.text:}return this.duration-=t.Time.deltaTime,this.duration<0},i}();t.DebugDrawItem=i}(es||(es={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateInterval=1,e.debugDisplayObject=new egret.DisplayObjectContainer,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){!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(i){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=i,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()},i.prototype.render=function(){if(0!=this._renderers.length)for(var t=0;te.x?-1:1,n=t.Vector2.normalize(t.Vector2.subtract(this.position,e));this.rotation=i*Math.acos(t.Vector2.dot(n,t.Vector2.unitY))},n.prototype.setLocalRotation=function(t){return this._localRotation=t,this._localDirty=this._positionDirty=this._localPositionDirty=this._localRotationDirty=this._localScaleDirty=!0,this.setDirty(e.rotationDirty),this},n.prototype.setLocalRotationDegrees=function(e){return this.setLocalRotation(t.MathHelper.toRadians(e))},n.prototype.setScale=function(e){return this._scale=e,this.parent?this.localScale=t.Vector2.divide(e,this.parent._scale):this.localScale=e,this},n.prototype.setLocalScale=function(t){return this._localScale=t,this._localDirty=this._positionDirty=this._localScaleDirty=!0,this.setDirty(e.scaleDirty),this},n.prototype.roundPosition=function(){this.position=this._position.round()},n.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)},n.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 i=0;it&&(this._zoom=t),this._maximumZoom=t,this;console.error("maximumZoom must be greater than zero")},n.prototype.forceMatrixUpdate=function(){this._areMatrixedDirty=!0},n.prototype.onEntityTransformChanged=function(t){this._areMatrixedDirty=!0},n.prototype.zoomIn=function(t){this.zoom+=t},n.prototype.zoomOut=function(t){this.zoom-=t},n.prototype.worldToScreenPoint=function(e){return this.updateMatrixes(),e=t.Vector2Ext.transformR(e,this._transformMatrix)},n.prototype.screenToWorldPoint=function(e){return this.updateMatrixes(),e=t.Vector2Ext.transformR(e,this._inverseTransformMatrix)},n.prototype.onSceneRenderTargetSizeChanged=function(e,i){this._isProjectionMatrixDirty=!0;var n=this._origin;this.origin=new t.Vector2(e/2,i/2),this.entity.transform.position.add(t.Vector2.subtract(this._origin,n))},n.prototype.mouseToWorldPoint=function(){return this.screenToWorldPoint(t.Input.touchPosition)},n.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)},n}(t.Component);t.Camera=i}(es||(es={})),function(t){var e=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i._shakeDirection=t.Vector2.zero,i._shakeOffset=t.Vector2.zero,i._shakeIntensity=0,i._shakeDegredation=.95,i}return __extends(i,e),i.prototype.shake=function(e,i,n){void 0===e&&(e=15),void 0===i&&(i=.9),void 0===n&&(n=t.Vector2.zero),this.enabled=!0,this._shakeIntensity=1)&&(i=.95),this._shakeDegredation=i)},i.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)},i}(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(t){t[t.lockOn=0]="lockOn",t[t.cameraWindow=1]="cameraWindow"}(e=t.CameraStyle||(t.CameraStyle={}));var i=function(i){function n(n,r,o){void 0===n&&(n=null),void 0===r&&(r=null),void 0===o&&(o=e.lockOn);var s=i.call(this)||this;return s.followLerp=.1,s.deadzone=new t.Rectangle,s.focusOffset=t.Vector2.zero,s.mapLockEnabled=!1,s.mapSize=new t.Rectangle,s._desiredPositionDelta=new t.Vector2,s._worldSpaceDeadZone=new t.Rectangle,s.rectShape=new egret.Shape,s._targetEntity=n,s._cameraStyle=o,s.camera=r,s}return __extends(n,i),n.prototype.onAddedToEntity=function(){this.camera||(this.camera=this.entity.scene.camera),this.follow(this._targetEntity,this._cameraStyle),t.Core.emitter.addObserver(t.CoreEvents.GraphicsDeviceReset,this.onGraphicsDeviceReset,this)},n.prototype.onGraphicsDeviceReset=function(){t.Core.schedule(0,!1,this,function(t){var e=t.context;e.follow(e._targetEntity,e._cameraStyle)})},n.prototype.update=function(){var e=t.Vector2.multiply(this.camera.bounds.size,new t.Vector2(.5));this._worldSpaceDeadZone.x=this.camera.position.x-e.x*t.Core.scene.scaleX+this.deadzone.x+this.focusOffset.x,this._worldSpaceDeadZone.y=this.camera.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.camera.position=t.Vector2.lerp(this.camera.position,t.Vector2.add(this.camera.position,this._desiredPositionDelta),this.followLerp),this.entity.transform.roundPosition(),this.mapLockEnabled&&(this.camera.position=this.clampToMapSize(this.camera.position),this.entity.transform.roundPosition())},n.prototype.debugRender=function(){this.rectShape||this.debugDisplayObject.addChild(this.rectShape),this.rectShape.graphics.clear(),this._cameraStyle==e.lockOn?(this.rectShape.graphics.beginFill(9109504,0),this.rectShape.graphics.lineStyle(1,9109504),this.rectShape.graphics.drawRect(this._worldSpaceDeadZone.x-5,this._worldSpaceDeadZone.y-5,this._worldSpaceDeadZone.width,this._worldSpaceDeadZone.height),this.rectShape.graphics.endFill()):(this.rectShape.graphics.beginFill(9109504,0),this.rectShape.graphics.lineStyle(1,9109504),this.rectShape.graphics.drawRect(this._worldSpaceDeadZone.x,this._worldSpaceDeadZone.y,this._worldSpaceDeadZone.width,this._worldSpaceDeadZone.height),this.rectShape.graphics.endFill())},n.prototype.clampToMapSize=function(e){var i=t.Vector2.multiply(this.camera.bounds.size,new t.Vector2(.5)).add(new t.Vector2(this.mapSize.x,this.mapSize.y)),n=new t.Vector2(this.mapSize.width-i.x,this.mapSize.height-i.y);return t.Vector2.clamp(e,i,n)},n.prototype.follow=function(i,n){void 0===n&&(n=e.cameraWindow),this._targetEntity=i,this._cameraStyle=n;var r=this.camera.bounds;switch(this._cameraStyle){case e.cameraWindow:var o=r.width/6,s=r.height/3;this.deadzone=new t.Rectangle((r.width-o)/2,(r.height-s)/2,o,s);break;case e.lockOn:this.deadzone=new t.Rectangle(r.width/2,r.height/2,10,10)}},n.prototype.updateFollow=function(){if(this._desiredPositionDelta.x=this._desiredPositionDelta.y=0,this._cameraStyle==e.lockOn){var i=this._targetEntity.transform.position.x,n=this._targetEntity.transform.position.y;this._worldSpaceDeadZone.x>i?this._desiredPositionDelta.x=i-this._worldSpaceDeadZone.x:this._worldSpaceDeadZone.xn&&(this._desiredPositionDelta.y=n-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))}},n.prototype.setCenteredDeadzone=function(e,i){if(this.camera){var n=this.camera.bounds;this.deadzone=new t.Rectangle((n.width-e)/2,(n.height-i)/2,e,i)}else console.error("相机是null。我们不能得到它的边界。请等到该组件添加到实体之后")},n}(t.Component);t.FollowCamera=i}(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 i(){var i=null!==e&&e.apply(this,arguments)||this;return i.displayObject=new egret.DisplayObject,i.hollowShape=new egret.Shape,i.pixelShape=new egret.Shape,i.color=0,i._areBoundsDirty=!0,i.debugRenderEnabled=!0,i._localOffset=t.Vector2.zero,i._renderLayer=0,i._bounds=new t.Rectangle,i}return __extends(i,e),Object.defineProperty(i.prototype,"width",{get:function(){return this.bounds.width},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this.bounds.height},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"localOffset",{get:function(){return this._localOffset},set:function(t){this.setLocalOffset(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"renderLayer",{get:function(){return this._renderLayer},set:function(t){this.setRenderLayer(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.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(i.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}),i.prototype.onEntityTransformChanged=function(t){this._areBoundsDirty=!0},i.prototype.debugRender=function(){if(this.debugRenderEnabled){this.hollowShape.parent||this.debugDisplayObject.addChild(this.hollowShape),this.pixelShape.parent||this.debugDisplayObject.addChild(this.pixelShape);var e=t.Vector2.add(this.entity.transform.position,this._localOffset);this.pixelShape.graphics.clear(),this.pixelShape.graphics.beginFill(t.Colors.renderableCenter,0),this.pixelShape.graphics.lineStyle(4,t.Colors.renderableCenter),this.pixelShape.graphics.lineTo(e.x,e.y),this.pixelShape.graphics.moveTo(e.x,e.y),this.pixelShape.graphics.endFill()}},i.prototype.isVisibleFromCamera=function(t){return!!t&&(this.isVisible=t.bounds.intersects(this.bounds),this.isVisible)},i.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},i.prototype.setColor=function(t){return this.color=t,this},i.prototype.setLocalOffset=function(t){return this._localOffset!=t&&(this._localOffset=t),this},i.prototype.sync=function(e){var i=new t.Vector2(this.entity.position.x+this.localOffset.x-e.position.x+e.origin.x,this.entity.position.y+this.localOffset.y-e.position.y+e.origin.y);this.displayObject.x!=i.x&&(this.displayObject.x=i.x),this.displayObject.y!=i.y&&(this.displayObject.y=i.y),this.displayObject.scaleX!=this.entity.scale.x&&(this.displayObject.scaleX=this.entity.scale.x),this.displayObject.scaleY!=this.entity.scale.y&&(this.displayObject.scaleY=this.entity.scale.y),this.displayObject.rotation!=this.entity.rotation&&(this.displayObject.rotation=this.entity.rotation)},i.prototype.toString=function(){return"[RenderableComponent] renderLayer: "+this.renderLayer},i.prototype.onBecameVisible=function(){this.displayObject.visible=this.isVisible,this.debugDisplayObject.visible=this.isVisible},i.prototype.onBecameInvisible=function(){this.displayObject.visible=this.isVisible,this.debugDisplayObject.visible=this.isVisible},i}(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,i=function(i){function n(e){void 0===e&&(e=null);var n=i.call(this)||this;return e instanceof t.Sprite?n.setSprite(e):e instanceof egret.Texture&&n.setSprite(new t.Sprite(e)),n}return __extends(n,i),Object.defineProperty(n.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(n.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(n.prototype,"origin",{get:function(){return this._origin},set:function(t){this.setOrigin(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"sprite",{get:function(){return this._sprite},set:function(t){this.setSprite(t)},enumerable:!0,configurable:!0}),n.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},n.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},n.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},n.prototype.render=function(e){this.sync(e);var i=new t.Vector2(this.entity.position.x+this.localOffset.x-this.origin.x-e.position.x+e.origin.x,this.entity.position.y+this.localOffset.y-this.origin.y-e.position.y+e.origin.y);this.displayObject.x!=i.x&&(this.displayObject.x=i.x),this.displayObject.y!=i.y&&(this.displayObject.y=i.y)},n}(t.RenderableComponent);t.SpriteRenderer=i}(es||(es={})),function(t){var e=egret.Bitmap,i=egret.RenderTexture,n=function(n){function r(e){var i=n.call(this,e)||this;return i._textureScale=t.Vector2.one,i._inverseTexScale=t.Vector2.one,i._gapX=0,i._gapY=0,i._sourceRect=e.sourceRect,i.displayObject.$fillMode=egret.BitmapFillMode.REPEAT,i}return __extends(r,n),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 n=new i,r=this.sprite.sourceRect;r.x=0,r.y=0,r.width+=this._gapX,r.height+=this._gapY,n.drawToTexture(this.displayObject,r),this.displayObject?this.displayObject.texture=n:this.displayObject=new e(n)},enumerable:!0,configurable:!0}),r.prototype.setGapXY=function(t){return this.gapXY=t,this},r.prototype.render=function(t){n.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=n}(es||(es={})),function(t){var e=function(e){function i(t){var i=e.call(this,t)||this;return i.scrollSpeedX=15,i.scroolSpeedY=0,i._scrollX=0,i._scrollY=0,i._scrollWidth=0,i._scrollHeight=0,i._scrollWidth=i.width,i._scrollHeight=i.height,i}return __extends(i,e),Object.defineProperty(i.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(i.prototype,"scrollWidth",{get:function(){return this._scrollWidth},set:function(t){this._scrollWidth=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scrollHeight",{get:function(){return this._scrollHeight},set:function(t){this._scrollHeight=t},enumerable:!0,configurable:!0}),i.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))},i}(t.TiledSpriteRenderer);t.ScrollingSpriteRenderer=e}(es||(es={})),function(t){var e=egret.SpriteSheet,i=function(){function i(e,i,n){void 0===i&&(i=new t.Rectangle(0,0,e.textureWidth,e.textureHeight)),void 0===n&&(n=i.getHalfSize()),this.uvs=new t.Rectangle,this.texture2D=e,this.sourceRect=i,this.center=new t.Vector2(.5*i.width,.5*i.height),this.origin=n;var r=1/e.textureWidth,o=1/e.textureHeight;this.uvs.x=i.x*r,this.uvs.y=i.y*o,this.uvs.width=i.width*r,this.uvs.height=i.height*o}return i.spritesFromAtlas=function(t,n,r,o,s){void 0===o&&(o=0),void 0===s&&(s=Number.MAX_VALUE);for(var a=[],h=t.textureWidth/n,c=t.textureHeight/r,l=0,u=new e(t),p=0;po||this._loopMode==e.pingPongOnce&&s>2*o)return this.animationState=i.completed,this._elapsedTime=0,this.currentFrame=0,void(this.displayObject.texture=n.sprites[this.currentFrame].texture2D);var a=Math.floor(s/r),h=n.sprites.length;if(h>2&&(this._loopMode==e.pingPong||this._loopMode==e.pingPongOnce)){var c=h-1;this.currentFrame=c-Math.abs(c-a%(2*c))}else this.currentFrame=a%h;this.displayObject.texture=n.sprites[this.currentFrame].texture2D}},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,n){void 0===n&&(n=null),this.currentAnimation=this._animations[t],this.currentAnimationName=t,this.currentFrame=0,this.animationState=i.running,this.displayObject.texture=this.currentAnimation.sprites[0].texture2D,this._elapsedTime=0,this._loopMode=n||e.loop},r.prototype.isAnimationActive=function(t){return this.currentAnimation&&this.currentAnimationName==t},r.prototype.pause=function(){this.animationState=i.paused},r.prototype.unPause=function(){this.animationState=i.running},r.prototype.stop=function(){this.currentAnimation=null,this.currentAnimationName=null,this.currentFrame=0,this.animationState=i.none},r}(t.SpriteRenderer);t.SpriteAnimator=n}(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 i=function(e){function i(){var t=e.call(this)||this;return t.colliderHorizontalInset=2,t.colliderVerticalInset=6,t}return __extends(i,e),i.prototype.testCollisions=function(e,i,n){this._boxColliderBounds=i,n.wasGroundedLastFrame=n.below,n.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,n,0)?(e.x=0-t.RectangleExt.getSide(i,o),n.left=o==t.Edge.left,n.right=o==t.Edge.right,n._movementRemainderX.reset()):(n.left=!1,n.right=!1)}},i.prototype.testMapCollision=function(e,i,n,r){var o=t.EdgeExt.oppositeEdge(i);t.EdgeExt.isVertical(o)?e.center.x:e.center.y,t.RectangleExt.getSide(e,i),t.EdgeExt.isVertical(o)},i.prototype.collisionRectForSide=function(e,i){var n;return n=t.EdgeExt.isHorizontal(e)?t.RectangleExt.getRectEdgePortion(this._boxColliderBounds,e):t.RectangleExt.getHalfRect(this._boxColliderBounds,e),t.EdgeExt.isVertical(e)?t.RectangleExt.contract(n,this.colliderHorizontalInset,0):t.RectangleExt.contract(n,0,this.colliderVerticalInset),t.RectangleExt.expandSide(n,e,i),n},i}(t.Component);t.TiledMapMover=i}(es||(es={})),function(t){var e=function(e){function i(t,i,n){void 0===i&&(i=null),void 0===n&&(n=!0);var r=e.call(this)||this;return r.physicsLayer=1,r.toContainer=!1,r.tiledMap=t,r._shouldCreateColliders=n,r.displayObject=new egret.DisplayObjectContainer,i&&(r.collisionLayer=t.tileLayers[i]),r}return __extends(i,e),Object.defineProperty(i.prototype,"width",{get:function(){return this.tiledMap.width*this.tiledMap.tileWidth},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this.tiledMap.height*this.tiledMap.tileHeight},enumerable:!0,configurable:!0}),i.prototype.setLayerToRender=function(t){this.layerIndicesToRender=[],this.layerIndicesToRender[0]=this.getLayerIndex(t)},i.prototype.setLayersToRender=function(){for(var t=[],e=0;e=2){this.polygonShape.graphics.beginFill(t.Colors.colliderEdge,0),this.polygonShape.graphics.lineStyle(t.Size.lineSizeMultiplier,t.Colors.colliderEdge);for(var i=0;i>6;0!=(e&t.LONG_MASK)&&i++,this._bits=new Array(i)}return t.prototype.and=function(t){for(var e,i=Math.min(this._bits.length,t._bits.length),n=0;n=0;)this._bits[e]&=~t._bits[e]},t.prototype.cardinality=function(){for(var t=0,e=this._bits.length-1;e>=0;e--){var i=this._bits[e];if(0!=i)if(-1!=i){var n=((i=((i=(i>>1&0x5555555555555400)+(0x5555555555555400&i))>>2&0x3333333333333400)+(0x3333333333333400&i))>>32)+i;t+=((n=((n=(n>>4&252645135)+(252645135&n))>>8&16711935)+(16711935&n))>>16&65535)+(65535&n)}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,i=1<>6;this.ensure(i),this._bits[i]|=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 i=0;i0){i=0;for(var n=this._componentsToAdd.length;i0){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,i=[],n=0;n0){for(var t=0,i=this._unsortedRenderLayers.length;t=e)return t;var n=!1;"-"==t.substr(0,1)&&(n=!0,t=t.substr(1));for(var r=e-i,o=0;o1?this.reverse(t.substring(1))+t.substring(0,1):t},t.cutOff=function(t,e,i,n){void 0===n&&(n=!0),e=Math.floor(e),i=Math.floor(i);var r=t.length;e>r&&(e=r);var o,s=e,a=e+i;return n?o=t.substring(0,s)+t.substr(a,r):(a=(s=r-1-e-i)+i,o=t.substring(0,s+1)+t.substr(a+1,r)),o},t.strReplace=function(t,e){for(var i=0,n=e.length;i",">",'"',""","'","'","®","®","©","©","™","™"],t}();!function(t){var e=function(){function e(){}return e.convertImageToCanvas=function(e,i){this.sharedCanvas||(this.sharedCanvas=egret.sys.createCanvas(),this.sharedContext=this.sharedCanvas.getContext("2d"));var n=e.$getTextureWidth(),r=e.$getTextureHeight();i||((i=egret.$TempRectangle).x=0,i.y=0,i.width=n,i.height=r),i.x=Math.min(i.x,n-1),i.y=Math.min(i.y,r-1),i.width=Math.min(i.width,n-i.x),i.height=Math.min(i.height,r-i.y);var o=Math.floor(i.width),s=Math.floor(i.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 h=void 0;e.$renderBuffer?h=e:(egret.sys.systemRenderer.renderClear&&egret.sys.systemRenderer.renderClear(),(h=new egret.RenderTexture).drawToTexture(new egret.Bitmap(e)));for(var c=h.$renderBuffer.getPixels(i.x,i.y,o,s),l=0,u=0,p=0;p=0?"png":"jpg"});return wx.getFileSystemManager().saveFile({tempFilePath:o,filePath:wx.env.USER_DATA_PATH+"/"+i,success:function(t){}}),o},e.getPixel32=function(t,e,i){return egret.$warn(1041,"getPixel32","getPixels"),t.getPixels(e,i)},e.getPixels=function(t,e,i,n,r){if(void 0===n&&(n=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,i,n,r)}try{this.convertImageToCanvas(t);return this.sharedContext.getImageData(e,i,n,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(),i=t.getMonth()+1;return parseInt(e+(i<10?"0":"")+i)},t.dateId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getMonth()+1,i=e<10?"0":"",n=t.getDate(),r=n<10?"0":"";return parseInt(t.getFullYear()+i+e+r+n)},t.weekId=function(t,e){void 0===t&&(t=null),void 0===e&&(e=!0),t=t||new Date;var i=new Date;i.setTime(t.getTime()),i.setDate(1),i.setMonth(0);var n=i.getFullYear(),r=i.getDay();0==r&&(r=7);var o=!1;r<=4?(o=r>1,i.setDate(i.getDate()-(r-1))):i.setDate(i.getDate()+7-r+1);var s=this.diffDay(t,i,!1);if(s<0)return i.setDate(1),i.setMonth(0),i.setDate(i.getDate()-1),this.weekId(i,!1);var a=s/7,h=Math.floor(a)+1;if(53==h){i.setTime(t.getTime()),i.setDate(i.getDate()-1);var c=i.getDay();if(0==c&&(c=7),e&&(!o||c<4))return i.setFullYear(i.getFullYear()+1),i.setDate(1),i.setMonth(0),this.weekId(i,!1)}return parseInt(n+"00"+(h>9?"":"0")+h)},t.diffDay=function(t,e,i){void 0===i&&(i=!1);var n=(t.getTime()-e.getTime())/864e5;return i?Math.ceil(n):Math.floor(n)},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(),i=t.getMonth()+1;i=i<10?"0"+i:i;var n=t.getDate();return e+"-"+i+"-"+(n=n<10?"0"+n:n)},t.formatDateTime=function(t){var e=t.getFullYear(),i=t.getMonth()+1;i=i<10?"0"+i:i;var n=t.getDate();n=n<10?"0"+n:n;var r=t.getHours(),o=t.getMinutes();o=o<10?"0"+o:o;var s=t.getSeconds();return e+"-"+i+"-"+n+" "+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,i){void 0===t&&(t=0),void 0===e&&(e=":"),void 0===i&&(i=!0);var n=Math.floor(t/3600),r=Math.floor(t%3600/60),o=Math.floor(t%3600%60),s=n.toString(),a=r.toString(),h=o.toString();return n<10&&(s="0"+s),r<10&&(a="0"+a),o<10&&(h="0"+h),i?s+e+a+e+h:a+e+h},t.timeToMillisecond=function(t,e){void 0===e&&(e=":");for(var i=t.split(e),n=0,r=i.length,o=0;o-1?this.os="iOS":n.indexOf("android")>-1&&(this.os="Android");var r=i.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,i,n){this._x=t,this._y=e,this._width=i,this._height=n,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 i(){return e.call(this,t.PostProcessor.default_vert,i.blur_frag,{screenWidth:t.Core.graphicsDevice.viewport.width,screenHeight:t.Core.graphicsDevice.viewport.height})||this}return __extends(i,e),i.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}",i}(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 i(){return null!==e&&e.apply(this,arguments)||this}return __extends(i,e),i.prototype.onAddedToScene=function(i){e.prototype.onAddedToScene.call(this,i),this.effect=new t.GaussianBlurEffect},i}(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.shouldDebugRender=!0,this.camera=e,this.renderOrder=t}return Object.defineProperty(t.prototype,"wantsToRenderToSceneRenderTarget",{get:function(){return!!this.renderTexture},enumerable:!0,configurable:!0}),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.prototype.debugRender=function(t,e){for(var i=0;ii?i:t},e.pointOnCirlce=function(i,n,r){var o=e.toRadians(r);return new t.Vector2(Math.cos(o)*o+i.x,Math.sin(o)*o+i.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.approach=function(t,e,i){return tn&&(n=s.x),s.yr&&(r=s.y)}return this.fromMinMax(e,i,n,r)},i.prototype.intersects=function(t){return t.leftthis.x+this.width)return!1}else{var n=1/t.direction.x,r=(this.x-t.start.x)*n,o=(this.x+this.width-t.start.x)*n;if(r>o){var s=r;r=o,o=s}if(e.value=Math.max(r,e.value),i=Math.min(o,i),e.value>i)return!1}if(Math.abs(t.direction.y)<1e-6){if(t.start.ythis.y+this.height)return!1}else{var a=1/t.direction.y,h=(this.y-t.start.y)*a,c=(this.y+this.height-t.start.y)*a;if(h>c){var l=h;h=c,c=l}if(e.value=Math.max(h,e.value),i=Math.max(c,i),e.value>i)return!1}return!0},i.prototype.containsRect=function(t){return this.x<=t.x&&t.x1)return!1;var l=(h.x*o.y-h.y*o.x)/a;return!(l<0||l>1)},i.lineToLineIntersection=function(e,i,n,r){var o=new t.Vector2(0,0),s=t.Vector2.subtract(i,e),a=t.Vector2.subtract(r,n),h=s.x*a.y-s.y*a.x;if(0==h)return o;var c=t.Vector2.subtract(n,e),l=(c.x*a.y-c.y*a.x)/h;if(l<0||l>1)return o;var u=(c.x*s.y-c.y*s.x)/h;return u<0||u>1?o:o=t.Vector2.add(e,new t.Vector2(l*s.x,l*s.y))},i.closestPointOnLine=function(e,i,n){var r=t.Vector2.subtract(i,e),o=t.Vector2.subtract(n,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))},i.isCircleToCircle=function(e,i,n,r){return t.Vector2.distanceSquared(e,n)<(i+r)*(i+r)},i.isCircleToLine=function(e,i,n,r){return t.Vector2.distanceSquared(e,this.closestPointOnLine(n,r,e))=t&&r.y>=e&&r.x=t+n&&(s|=e.right),o.y=i+r&&(s|=e.bottom),s},i}();t.Collisions=i}(es||(es={})),function(t){var e=function(){function e(e,i,n,r,o){this.fraction=0,this.distance=0,this.point=t.Vector2.zero,this.normal=t.Vector2.zero,this.collider=e,this.fraction=i,this.distance=n,this.point=r,this.centroid=t.Vector2.zero}return e.prototype.setValues=function(t,e,i,n){this.collider=t,this.fraction=e,this.distance=i,this.point=n},e.prototype.setValuesNonCollider=function(t,e,i,n){this.fraction=t,this.distance=e,this.point=i,this.normal=n},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 e(){}return e.reset=function(){this._spatialHash=new t.SpatialHash(this.spatialHashCellSize)},e.clear=function(){this._spatialHash.clear()},e.overlapCircleAll=function(t,e,i,n){if(void 0===n&&(n=-1),0!=i.length)return this._spatialHash.overlapCircle(t,e,i,n);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,i){return void 0===i&&(i=this.allLayers),this._spatialHash.aabbBroadphase(e,t,i)},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.linecast=function(t,i,n){return void 0===n&&(n=e.allLayers),this._hitArray[0].reset(),this.linecastAll(t,i,this._hitArray,n),this._hitArray[0]},e.linecastAll=function(t,i,n,r){return void 0===r&&(r=e.allLayers),0==n.length?(console.warn("传入了一个空的hits数组。没有点击会被返回"),0):this._spatialHash.linecast(t,i,n,r)},e.debugDraw=function(t){this._spatialHash.debugDraw(t,2)},e.spatialHashCellSize=100,e.allLayers=-1,e.raycastsHitTriggers=!1,e.raycastsStartInColliders=!1,e._hitArray=[new t.RaycastHit],e}();t.Physics=e}(es||(es={})),function(t){var e=function(){return function(e,i){this.start=e,this.end=i,this.direction=t.Vector2.subtract(this.end,this.start)}}();t.Ray2D=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 i(t,i){var n=e.call(this)||this;return n._areEdgeNormalsDirty=!0,n.isUnrotated=!0,n.setPoints(t),n.isBox=i,n}return __extends(i,e),Object.defineProperty(i.prototype,"edgeNormals",{get:function(){return this._areEdgeNormalsDirty&&this.buildEdgeNormals(),this._edgeNormals},enumerable:!0,configurable:!0}),i.prototype.setPoints=function(t){this.points=t,this.recalculateCenterAndEdgeNormals(),this._originalPoints=[];for(var e=0;e=this.points.length?this.points[0]:this.points[n+1];var o=t.Vector2Ext.perpendicular(r,e);t.Vector2Ext.normalize(o),this._edgeNormals[n]=o}},i.buildSymmetricalPolygon=function(e,i){for(var n=new Array(e),r=0;rr&&(r=s,n=o)}return e[n]},i.getClosestPointOnPolygonToPoint=function(e,i,n,r){n.value=Number.MAX_VALUE,r.x=0,r.y=0;for(var o,s=new t.Vector2(0,0),a=0;at.y!=this.points[n].y>t.y&&t.x<(this.points[n].x-this.points[i].x)*(t.y-this.points[i].y)/(this.points[n].y-this.points[i].y)+this.points[i].x&&(e=!e);return e},i.prototype.pointCollidesWithShape=function(e,i){return t.ShapeCollisions.pointToPoly(e,this,i)},i}(t.Shape);t.Polygon=e}(es||(es={})),function(t){var e=function(e){function i(t,n){var r=e.call(this,i.buildBox(t,n),!0)||this;return r.width=t,r.height=n,r}return __extends(i,e),i.buildBox=function(e,i){var n=e/2,r=i/2,o=new Array(4);return o[0]=new t.Vector2(-n,-r),o[1]=new t.Vector2(n,-r),o[2]=new t.Vector2(n,r),o[3]=new t.Vector2(-n,r),o},i.prototype.updateBox=function(e,i){this.width=e,this.height=i;var n=e/2,r=i/2;this.points[0]=new t.Vector2(-n,-r),this.points[1]=new t.Vector2(n,-r),this.points[2]=new t.Vector2(n,r),this.points[3]=new t.Vector2(-n,r);for(var o=0;o1)return!1;var a,h=t.Vector2.add(s.start,t.Vector2.add(s.direction,new t.Vector2(r.value))),c=0;h.xi.bounds.right&&(c|=1),h.yi.bounds.bottom&&(c|=2);var l=a+c;return 3==l&&console.log("m == 3. corner "+t.Time.frameCount),!0},e}();t.RealtimeCollisions=e}(es||(es={})),function(t){var e=function(){function e(){}return e.polygonToPolygon=function(e,i,n){for(var r,o=!0,s=e.edgeNormals,a=i.edgeNormals,h=Number.POSITIVE_INFINITY,c=new t.Vector2,l=t.Vector2.subtract(e.position,i.position),u=0;u0&&(o=!1),!o)return!1;(y=Math.abs(y))r&&(r=o);return{min:n,max:r}},e.circleToPolygon=function(e,i,n){var r,o=t.Vector2.subtract(e.position,i.position),s=new t.Ref(0),a=t.Polygon.getClosestPointOnPolygonToPoint(i.points,o,s,n.normal),h=i.containsPoint(e.position);if(s.value>e.radius*e.radius&&!h)return!1;if(h)r=t.Vector2.multiply(n.normal,new t.Vector2(Math.sqrt(s.value)-e.radius));else if(0==s.value)r=t.Vector2.multiply(n.normal,new t.Vector2(e.radius));else{var c=Math.sqrt(s.value);r=t.Vector2.multiply(new t.Vector2(-t.Vector2.subtract(o,a)),new t.Vector2((e.radius-s.value)/c))}return n.minimumTranslationVector=r,n.point=t.Vector2.add(a,i.position),!0},e.circleToBox=function(e,i,n){var r=i.bounds.getClosestPointOnRectangleBorderToPoint(e.position,n.normal);if(i.containsPoint(e.position)){n.point=r;var o=t.Vector2.add(r,t.Vector2.multiply(n.normal,new t.Vector2(e.radius)));return n.minimumTranslationVector=t.Vector2.subtract(e.position,o),!0}var s=t.Vector2.distanceSquared(r,e.position);if(0==s)n.minimumTranslationVector=t.Vector2.multiply(n.normal,new t.Vector2(e.radius));else if(s<=e.radius*e.radius){n.normal=t.Vector2.subtract(e.position,r);var a=n.normal.length()-e.radius;return n.point=r,t.Vector2Ext.normalize(n.normal),n.minimumTranslationVector=t.Vector2.multiply(new t.Vector2(a),n.normal),!0}return!1},e.pointToCircle=function(e,i,n){var r=t.Vector2.distanceSquared(e,i.position),o=1+i.radius;if(r1)return!1;var u=(c.x*s.y-c.y*s.x)/h;return!(u<0||u>1)&&(o=o.add(e).add(t.Vector2.multiply(new t.Vector2(l),s)),!0)},e.lineToCircle=function(e,i,n,r){var o=t.Vector2.distance(e,i),s=t.Vector2.divide(t.Vector2.subtract(i,e),new t.Vector2(o)),a=t.Vector2.subtract(e,n.position),h=t.Vector2.dot(a,s),c=t.Vector2.dot(a,a)-n.radius*n.radius;if(c>0&&h>0)return!1;var l=h*h-c;return!(l<0)&&(r.fraction=-h-Math.sqrt(l),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,n.position)),r.fraction=r.distance/o,!0)},e.boxToBoxCast=function(e,i,n,r){var o=this.minkowskiDifference(e,i);if(o.contains(0,0)){var s=o.getClosestPointOnBoundsToOrigin();return!s.equals(t.Vector2.zero)&&(r.normal=new t.Vector2(-s.x),r.normal.normalize(),r.distance=0,r.fraction=0,!0)}var a=new t.Ray2D(t.Vector2.zero,new t.Vector2(-n.x)),h=new t.Ref(0);return!!(o.rayIntersects(a,h)&&h.value<=1)&&(r.fraction=h.value,r.distance=n.length()*h.value,r.normal=new t.Vector2(-n.x,-n.y),r.normal.normalize(),r.centroid=t.Vector2.add(e.bounds.center,t.Vector2.multiply(n,new t.Vector2(h.value))),!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 i,this._tempHashSet=[],this._cellSize=e,this._inverseCellSize=1/this._cellSize,this._raycastParser=new n}return e.prototype.register=function(e){var i=e.bounds;e.registeredPhysicsBounds=i;var n=this.cellCoords(i.x,i.y),r=this.cellCoords(i.right,i.bottom);this.gridBounds.contains(n.x,n.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,n)),this.gridBounds.contains(r.x,r.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,r));for(var o=n.x;o<=r.x;o++)for(var s=n.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,i=this.cellCoords(e.x,e.y),n=this.cellCoords(e.right,e.bottom),r=i.x;r<=n.x;r++)for(var o=i.y;o<=n.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 i=this.gridBounds.x;i<=this.gridBounds.right;i++)for(var n=this.gridBounds.y;n<=this.gridBounds.bottom;n++){var r=this.cellAtPosition(i,n);r&&r.length>0&&this.debugDrawCellDetails(i,n,r.length,t,e)}},e.prototype.aabbBroadphase=function(e,i,n){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 h=this.cellAtPosition(s,a);if(h)for(var c=function(r){var o=h[r];if(o==i||!t.Flags.isFlagSet(n,o.physicsLayer))return"continue";e.intersects(o.bounds)&&(l._tempHashSet.firstOrDefault(function(t){return t.hashCode==o.hashCode})||l._tempHashSet.push(o))},l=this,u=0;u=0&&(e.push(this.findBoundsRect(i,o,r,t)),i=-1)}i>=0&&(e.push(this.findBoundsRect(i,this.map.width,r,t)),i=-1)}return e},e.prototype.findBoundsRect=function(e,i,n,r){for(var o=-1,s=n+1;sthis.tileHeight||this.maxTileWidth>this.tileWidth},enumerable:!0,configurable:!0}),i.prototype.getTilesetForTileGid=function(t){if(0==t)return null;for(var e=this.tilesets.length-1;e>=0;e--)if(this.tilesets[e].firstGid<=t)return this.tilesets[e];console.error("tile gid"+t+"未在任何tileset中找到")},i.prototype.worldToTilePositionX=function(e,i){void 0===i&&(i=!0);var n=Math.floor(e/this.tileWidth);return i?t.MathHelper.clamp(n,0,this.width-1):n},i.prototype.worldToTilePositionY=function(e,i){void 0===i&&(i=!0);var n=Math.floor(e/this.tileHeight);return i?t.MathHelper.clamp(n,0,this.height-1):n},i.prototype.getLayer=function(t){return this.layers[t]},i.prototype.update=function(){this.tilesets.forEach(function(t){t.update()})},i.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)},i}(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 i=function(){return function(){this.shape=new egret.Shape,this.textField=new egret.TextField}}();t.TmxObject=i;var n=function(){return function(){}}();t.TmxText=n;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(){function e(){}return e.loadTmxMap=function(t,e){var i=RES.getRes(e);return this.loadTmxMapData(t,i,RES.getResourceInfo(e))},e.loadTmxMapData=function(e,i,n){return __awaiter(this,void 0,void 0,function(){var r,o,s,a;return __generator(this,function(h){switch(h.label){case 0:e.version=i.version,e.tiledVersion=i.tiledversion,e.width=i.width,e.height=i.height,e.tileWidth=i.tilewidth,e.tileHeight=i.tileheight,e.hexSideLength=i.hexsidelength,e.orientation=this.parseOrientationType(i.orientation),e.staggerAxis=this.parseStaggerAxisType(i.staggeraxis),e.staggerIndex=this.parseStaggerIndexType(i.staggerindex),e.renderOrder=this.parseRenderOrderType(i.renderorder),e.nextObjectID=i.nextobjectid,e.backgroundColor=t.TmxUtils.color16ToUnit(i.color),e.properties=this.parsePropertyDict(i.properties),e.maxTileWidth=e.tileWidth,e.maxTileHeight=e.tileHeight,e.tmxDirectory=n.root+n.url.replace(".","_").replace(n.name,""),e.tilesets=[],r=0,o=i.tilesets,h.label=1;case 1:return rt.map.maxTileWidth&&(t.map.maxTileWidth=e.image.width),e.image.height>t.map.maxTileHeight&&(t.map.maxTileHeight=e.image.height))}),t.tileRegions.forEach(function(e){var i=e.width,n=e.height;i>t.map.maxTileWidth&&(t.map.maxTileWidth=i),i>t.map.maxTileHeight&&(t.map.maxTileHeight=n)})},e.parseOrientationType=function(e){return"unknown"==e?t.OrientationType.unknown:"orthogonal"==e?t.OrientationType.orthogonal:"isometric"==e?t.OrientationType.isometric:"staggered"==e?t.OrientationType.staggered:"hexagonal"==e?t.OrientationType.hexagonal:t.OrientationType.unknown},e.parseStaggerAxisType=function(e){return"y"==e?t.StaggerAxisType.y:t.StaggerAxisType.x},e.parseStaggerIndexType=function(e){return"even"==e?t.StaggerIndexType.even:t.StaggerIndexType.odd},e.parseRenderOrderType=function(e){return"right-up"==e?t.RenderOrderType.rightUp:"left-down"==e?t.RenderOrderType.leftDown:"left-up"==e?t.RenderOrderType.leftUp:t.RenderOrderType.rightDown},e.parsePropertyDict=function(e){if(!e)return null;for(var i=new Map,n=0,r=e;n=e.columns));m+=e.tileWidth+e.spacing);else e.tiles.forEach(function(i,n){e.tileRegions.set(n,new t.Rectangle(0,0,i.image.width,i.image.height))});return[2,e]}})})},e.loadTmxTilesetTile=function(e,i,n,r,o){return __awaiter(this,void 0,void 0,function(){var s,a,h,c,l,u,p,d,f,g,y,m,_;return __generator(this,function(v){switch(v.label){case 0:if(e.tileset=i,e.id=n.id,s=n.terrain)for(e.terrainEdges=new Array(4),a=0,h=0,c=s;h0){a.shape.x=h.x,a.shape.y=h.y,i.addChild(a.shape),a.shape.graphics.clear(),a.shape.graphics.lineStyle(1,10526884);for(u=0;u0&&(l=u.currentAnimationFrameGid);var p=i.tileset.tileRegions.get(l),d=Math.floor(i.x)*s,f=Math.floor(i.y)*a;i.horizontalFlip&&i.verticalFlip?(d+=a+(p.height*o.y-a),f-=p.width*o.x-s):i.horizontalFlip?d+=s+(p.height*o.y-a):i.verticalFlip?f+=s-p.width*o.x:f+=a-p.height*o.y;var g=new t.Vector2(d,f).add(r);if(i.tileset.image){if(n){var y=i.tileset.image.bitmap.getTexture(""+l);y||(y=i.tileset.image.bitmap.createTexture(""+l,p.x,p.y,p.width,p.height)),i.tileset.image.texture=new e(y),n.addChild(i.tileset.image.texture),i.tileset.image.texture.x!=g.x&&(i.tileset.image.texture.x=g.x),i.tileset.image.texture.y!=g.y&&(i.tileset.image.texture.y=g.y),i.verticalFlip&&i.horizontalFlip?(i.tileset.image.texture.scaleX=-1,i.tileset.image.texture.scaleY=-1):i.verticalFlip?(i.tileset.image.texture.scaleX=o.x,i.tileset.image.texture.scaleY=-1):i.horizontalFlip?(i.tileset.image.texture.scaleX=-1,i.tileset.image.texture.scaleY=o.y):(i.tileset.image.texture.scaleX=o.x,i.tileset.image.texture.scaleY=o.y),0!=i.tileset.image.texture.rotation&&(i.tileset.image.texture.rotation=0),0!=i.tileset.image.texture.anchorOffsetX&&(i.tileset.image.texture.anchorOffsetX=0),0!=i.tileset.image.texture.anchorOffsetY&&(i.tileset.image.texture.anchorOffsetY=0)}}else u.image.texture&&(u.image.bitmap.getTexture(l.toString())||(u.image.texture=new e(u.image.bitmap.createTexture(l.toString(),p.x,p.y,p.width,p.height)),n.addChild(u.image.texture)),u.image.texture.x=g.x,u.image.texture.y=g.y,u.image.texture.scaleX=o.x,u.image.texture.scaleY=o.y,u.image.texture.rotation=0,u.image.texture.anchorOffsetX=0,u.image.texture.anchorOffsetY=0,u.image.texture.filters=[h])},i}();t.TiledRendering=i}(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 i=function(){return function(){}}();t.TmxTileOffset=i;var n=function(){return function(){}}();t.TmxTerrain=n}(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 i=function(){return function(){}}();t.TmxAnimationFrame=i}(es||(es={})),function(t){var e=function(){function e(){}return e.decode=function(e,i,n){switch(n=n||"none",i=i||"none"){case"base64":var r=t.Base64Utils.decodeBase64AsArray(e,4);return"none"===n?r:t.Base64Utils.decompress(e,r,n);case"csv":return t.Base64Utils.decodeCSV(e);case"none":for(var o=[],s=0;si;n--)if(t[n]0&&t[r-1]>n;r--)t[r]=t[r-1];t[r]=n}},t.binarySearch=function(t,e){for(var i=0,n=t.length,r=i+n>>1;i=t[r]&&(i=r+1),r=i+n>>1;return t[i]==e?i:-1},t.findElementIndex=function(t,e){for(var i=t.length,n=0;nt[e]&&(e=n);return e},t.getMinElementIndex=function(t){for(var e=0,i=t.length,n=1;n=0;--r)i.unshift(e[r]);return i},t.getDifferAry=function(t,e){t=this.getUniqueAry(t),e=this.getUniqueAry(e);for(var i=t.concat(e),n={},r=[],o=i.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 i=t.length;if(i!=e.length)return!1;for(;i--;)if(t[i]!=e[i])return!1;return!0},t.insert=function(t,e,i){if(!t)return null;var n=t.length;if(e>n&&(e=n),e<0&&(e=0),e==n)t.push(i);else if(0==e)t.unshift(i);else{for(var r=n-1;r>=e;r-=1)t[r+1]=t[r];t[e]=i}return i},t}();!function(t){var e=function(){function t(){}return Object.defineProperty(t,"nativeBase64",{get:function(){return"function"==typeof window.atob},enumerable:!0,configurable:!0}),t.decode=function(t){if(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,""),this.nativeBase64)return window.atob(t);for(var e,i,n,r,o,s,a=[],h=0;h>4,i=(15&r)<<4|(o=this._keyStr.indexOf(t.charAt(h++)))>>2,n=(3&o)<<6|(s=this._keyStr.indexOf(t.charAt(h++))),a.push(String.fromCharCode(e)),64!==o&&a.push(String.fromCharCode(i)),64!==s&&a.push(String.fromCharCode(n));return a=a.join("")},t.encode=function(t){if(t=t.replace(/\r\n/g,"\n"),!this.nativeBase64){for(var e,i,n,r,o,s,a,h=[],c=0;c>2,o=(3&e)<<4|(i=t.charCodeAt(c++))>>4,s=(15&i)<<2|(n=t.charCodeAt(c++))>>6,a=63&n,isNaN(i)?s=a=64:isNaN(n)&&(a=64),h.push(this._keyStr.charAt(r)),h.push(this._keyStr.charAt(o)),h.push(this._keyStr.charAt(s)),h.push(this._keyStr.charAt(a));return h=h.join("")}window.btoa(t)},t.decodeBase64AsArray=function(e,i){i=i||1;var n,r,o,s=t.decode(e),a=new Uint32Array(s.length/i);for(n=0,o=s.length/i;n=0;--r)a[n]+=s.charCodeAt(n*i+r)<<(r<<3);return a},t.decompress=function(t,e,i){throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!")},t.decodeCSV=function(t){for(var e=t.replace("\n","").trim().split(","),i=[],n=0;n>16},set:function(t){this._packedValue=4278255615&this._packedValue|t<<16},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"g",{get:function(){return this._packedValue>>8},set:function(t){this._packedValue=4294902015&this._packedValue|t<<8},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"r",{get:function(){return this._packedValue},set:function(t){this._packedValue=4294967040&this._packedValue|t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"a",{get:function(){return this._packedValue>>24},set:function(t){this._packedValue=16777215&this._packedValue|t<<24},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"packedValue",{get:function(){return this._packedValue},set:function(t){this._packedValue=t},enumerable:!0,configurable:!0}),e.prototype.equals=function(t){return this._packedValue==t._packedValue},e}();t.Color=e}(es||(es={})),function(t){var e=function(){function t(){this.loadedAssets=new Map}return t.prototype.loadRes=function(t,e){var i=this;return void 0===e&&(e=!0),new Promise(function(n,r){var o=i.loadedAssets.get(t);o?n(o):e?RES.getResAsync(t).then(function(e){i.loadedAssets.set(t,e),n(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)}):RES.getResByUrl(t).then(function(e){i.loadedAssets.set(t,e),n(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)})})},t.prototype.dispose=function(){this.loadedAssets.forEach(function(t){var e=t;RES.destroyRes(e)&&e.dispose()}),this.loadedAssets.clear()},t}();t.ContentManager=e}(es||(es={})),function(t){var e=function(){function t(){}return t.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)},t}();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 i=function(){function t(){this._messageTable=new Map}return t.prototype.addObserver=function(t,i,n){var r=this._messageTable.get(t);r||(r=[],this._messageTable.set(t,r)),-1!=r.findIndex(function(t){return t.func==i})&&console.warn("您试图添加相同的观察者两次"),r.push(new e(i,n))},t.prototype.removeObserver=function(t,e){var i=this._messageTable.get(t),n=i.findIndex(function(t){return t.func==e});-1!=n&&i.removeAt(n)},t.prototype.emit=function(t,e){var i=this._messageTable.get(t);if(i)for(var n=i.length-1;n>=0;n--)i[n].func.call(i[n].context,e)},t}();t.Emitter=i}(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 i=[];e--;)i.push(t);return i},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 i=function(){function i(){}return Object.defineProperty(i,"gameTouchs",{get:function(){return this._gameTouchs},enumerable:!0,configurable:!0}),Object.defineProperty(i,"resolutionScale",{get:function(){return this._resolutionScale},enumerable:!0,configurable:!0}),Object.defineProperty(i,"totalTouchCount",{get:function(){return this._totalTouchCount},enumerable:!0,configurable:!0}),Object.defineProperty(i,"touchPosition",{get:function(){return this._gameTouchs[0]?this._gameTouchs[0].position:t.Vector2.zero},enumerable:!0,configurable:!0}),Object.defineProperty(i,"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(i,"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}),i.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())},i.scaledPosition=function(e){var i=new t.Vector2(e.x-this._resolutionOffset.x,e.y-this._resolutionOffset.y);return t.Vector2.multiply(i,this.resolutionScale)},i.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={})),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,i){if(void 0===i&&(i=1),0==i)throw new Error("step 不能为 0");var n=e-t;if(0==n)throw new Error("没有可用的范围("+t+","+e+")");n<0&&(n=t-e);var r=Math.floor((n+i-1)/i);return Math.floor(this.random()*r)*i+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 i=t.length;if(e<=0||i=0;)s=Math.floor(this.random()*i);n.push(t[s]),r.push(s)}return n},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,i){switch(i){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,i){var n=new t.Rectangle(i.x,i.y,0,0),r=new t.Rectangle;return r.x=Math.min(e.x,n.x),r.y=Math.min(e.y,n.y),r.width=Math.max(e.right,n.right)-r.x,r.height=Math.max(e.bottom,r.bottom)-r.y,r},e.getHalfRect=function(e,i){switch(i){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,i,n){switch(void 0===n&&(n=1),i){case t.Edge.top:return new t.Rectangle(e.x,e.y,e.width,n);case t.Edge.bottom:return new t.Rectangle(e.x,e.y+e.height-n,e.width,n);case t.Edge.left:return new t.Rectangle(e.x,e.y,n,e.height);case t.Edge.right:return new t.Rectangle(e.x+e.width-n,e.y,n,e.height)}},e.expandSide=function(e,i,n){switch(n=Math.abs(n),i){case t.Edge.top:e.y-=n,e.height+=n;break;case t.Edge.bottom:e.height+=n;break;case t.Edge.left:e.x-=n,e.width+=n;break;case t.Edge.right:e.width+=n}},e.contract=function(t,e,i){t.x+=e,t.y+=i,t.width-=2*e,t.height-=2*i},e}();t.RectangleExt=e}(es||(es={})),function(t){var e=function(){return function(t){this.value=t}}();t.Ref=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,i,n,r){return!(t.Vector2Ext.cross(t.Vector2.subtract(e,i),t.Vector2.subtract(n,i))<0)&&(!(t.Vector2Ext.cross(t.Vector2.subtract(e,n),t.Vector2.subtract(r,n))<0)&&!(t.Vector2Ext.cross(t.Vector2.subtract(e,r),t.Vector2.subtract(i,r))<0))},e.prototype.triangulate=function(i,n){void 0===n&&(n=!0);var r=i.length;this.initialize(r);for(var o=0,s=0;r>3&&o<500;){o++;var a=!0,h=i[this._triPrev[s]],c=i[s],l=i[this._triNext[s]];if(t.Vector2Ext.isTriangleCCW(h,c,l)){var u=this._triNext[this._triNext[s]];do{if(e.testPointTriangle(i[u],h,c,l)){a=!1;break}u=this._triNext[u]}while(u!=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]),n||this.triangleIndices.reverse()},e.prototype.initialize=function(t){this.triangleIndices.length=0,this._triNext.lengtht.MathHelper.Epsilon?e.divide(new t.Vector2(i)):e.x=e.y=0},e.transformA=function(t,e,i,n,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},i}();t.Layout=i,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,i=function(){function t(t){void 0===t&&(t=n),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=(i=this.getSystemTime())-this._stopSystemTime;this._stopDuration+=e,this._stopSystemTime=void 0}else if(void 0===this._startSystemTime){var i=this.getSystemTime();this._startSystemTime=i,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=i,function(t){t.IDLE="IDLE",t.RUNNING="RUNNING",t.STOPPED="STOPPED"}(e||(e={})),t.setDefaultSystemTimeGetter=function(t){void 0===t&&(t=Date.now),n=t};var n=Date.now}(stopwatch||(stopwatch={})),function(t){var e=function(){function e(){this.showLog=!1,this.markers=[],this.stopwacth=new stopwatch.Stopwatch,this._markerNameToIdMap=new Map,this._rectShape1=new egret.Shape,this._rectShape2=new egret.Shape,this._rectShape3=new egret.Shape,this._rectShape4=new egret.Shape,this._rectShape5=new egret.Shape,this._rectShape6=new egret.Shape,this._logs=new Array(2);for(var e=0;e=e.logSnapDuration&&(l.logs[n].snapMin=l.logs[n].min,l.logs[n].snapMax=l.logs[n].max,l.logs[n].snapAvg=l.logs[n].avg,l.logs[n].samples=0)):(l.logs[n].min=h,l.logs[n].max=h,l.logs[n].avg=h,l.logs[n].initialized=!0)}o.markCount=r.nestCount,o.nestCount=r.nestCount}this.stopwacth.reset(),this.stopwacth.start()}},e.prototype.beginMark=function(t,i,n){if(void 0===n&&(n=0),n<0||n>=e.maxBars)throw new Error("barIndex argument out of range");var r=this._curLog.bars[n];if(r.markCount>=e.maxSamples)throw new Error("exceeded sample count. either set larger number to timeruler.maxsaple or lower sample count");if(r.nestCount>=e.maxNestCall)throw new Error("exceeded nest count. either set larger number to timeruler.maxnestcall or lower nest calls");var o=this._markerNameToIdMap.get(t);isNaN(o)&&(o=this.markers.length,this._markerNameToIdMap.set(t,o)),r.markerNests[r.nestCount++]=r.markCount,r.markers[r.markCount].markerId=o,r.markers[r.markCount].color=i,r.markers[r.markCount].beginTime=this.stopwacth.getTime(),r.markers[r.markCount].endTime=-1},e.prototype.endMark=function(t,i){if(void 0===i&&(i=0),i<0||i>=e.maxBars)throw new Error("barIndex argument out of range");var n=this._curLog.bars[i];if(n.nestCount<=0)throw new Error("call beginMark method before calling endMark method");var r=this._markerNameToIdMap.get(t);if(isNaN(r))throw new Error("Marker "+t+" is not registered. Make sure you specifed same name as you used for beginMark method");var o=n.markerNests[--n.nestCount];if(n.markers[o].markerId!=r)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).");n.markers[o].endTime=this.stopwacth.getTime()},e.prototype.getAverageTime=function(t,i){if(t<0||t>=e.maxBars)throw new Error("barIndex argument out of range");var n=0,r=this._markerNameToIdMap.get(i);return r&&(n=this.markers[r].logs[t].avg),n},e.prototype.resetLog=function(){this.markers.forEach(function(t){for(var e=0;e0&&(r+=e.barHeight+2*e.barPadding,o=Math.max(o,t.markers[t.markCount-1].endTime))});var s=this.sampleFrames*(1/60*1e3);this._frameAdjust=o>s?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,o/(1/60*1e3)+1),this._frameAdjust=0);var a=n/s,h=i.y-(r-e.barHeight),c=h,l=new t.Rectangle(i.x,c,n,r);this._rectShape1.graphics.clear(),this._rectShape1.graphics.beginFill(0,128/255),this._rectShape1.graphics.drawRect(l.x,l.y,l.width,l.height),this._rectShape1.graphics.endFill(),l.height=e.barHeight,this._rectShape2.graphics.clear();for(var u=0,p=this._prevLog.bars;u0)for(var f=0;fa||i[c].height>a)throw new Error("一个纹理的大小比图集的大小大");h.push(new t.Rectangle(0,0,i[c].width,i[c].height))}for(;h.length>0;){var l=new egret.RenderTexture,u=new t.RectanglePacker(a,a,1);for(c=0;c0){for(var p=new t.IntegerRectangle,d=[],f=[],g=[],y=[],m=0;m0;)this.freeRectangle(this._insertedRectangles.pop());for(;this._freeAreas.length>0;)this.freeRectangle(this._freeAreas.pop());for(this._width=t,this._height=e,this._packedWidth=0,this._packedHeight=0,this._freeAreas.push(this.allocateRectangle(0,0,this._width,this._height));this._insertedRectangles.length>0;)this.freeSize(this._insertList.pop());this._padding=i},e.prototype.insertRectangle=function(t,e,i){var n=this.allocateSize(t,e,i);this._insertList.push(n)},e.prototype.packRectangles=function(t){for(void 0===t&&(t=!0),t&&this._insertList.sort(function(t,e){return t.width-e.width});this._insertList.length>0;){var e=this._insertList.pop(),i=e.width,n=e.height,r=this.getFreeAreaIndex(i,n);if(r>=0){var o=this._freeAreas[r],s=this.allocateRectangle(o.x,o.y,i,n);for(s.id=e.id,this.generateNewFreeAreas(s,this._freeAreas,this._newFreeAreas);this._newFreeAreas.length>0;)this._freeAreas.push(this._newFreeAreas.pop());this._insertedRectangles.push(s),s.right>this._packedWidth&&(this._packedWidth=s.right),s.bottom>this._packedHeight&&(this._packedHeight=s.bottom)}this.freeSize(e)}return this.rectangleCount},e.prototype.getRectangle=function(t,e){var i=this._insertedRectangles[t];return e.x=i.x,e.y=i.y,e.width=i.width,e.height=i.height,e},e.prototype.getRectangleId=function(t){return this._insertedRectangles[t].id},e.prototype.generateNewFreeAreas=function(t,e,i){var n=t.x,r=t.y,o=t.right+1+this._padding,s=t.bottom+1+this._padding,a=null;0==this._padding&&(a=t);for(var h=e.length-1;h>=0;h--){var c=e[h];if(!(n>=c.right||o<=c.x||r>=c.bottom||s<=c.y)){null==a&&(a=this.allocateRectangle(t.x,t.y,t.width+this._padding,t.height+this._padding)),this.generateDividedAreas(a,c,i);var l=e.pop();h=0;e--)for(var i=t[e],n=t.length-1;n>=0;n--)if(e!=n){var r=t[n];if(i.x>=r.x&&i.y>=r.y&&i.right<=r.right&&i.bottom<=r.bottom){this.freeRectangle(i);var o=t.pop();e0&&(i.push(this.allocateRectangle(t.right,e.y,r,e.height)),n++);var o=t.x-e.x;o>0&&(i.push(this.allocateRectangle(e.x,e.y,o,e.height)),n++);var s=e.bottom-t.bottom;s>0&&(i.push(this.allocateRectangle(e.x,t.bottom,e.width,s)),n++);var a=t.y-e.y;a>0&&(i.push(this.allocateRectangle(e.x,e.y,e.width,a)),n++),0==n&&(t.width=0;s--){var a=this._freeAreas[s];if(a.x0){var r=this._sortableSizeStack.pop();return r.width=e,r.height=i,r.id=n,r}return new t.SortableSize(e,i,n)},e.prototype.freeSize=function(t){this._sortableSizeStack.push(t)},e.prototype.allocateRectangle=function(e,i,n,r){if(this._rectangleStack.length>0){var o=this._rectangleStack.pop();return o.x=e,o.y=i,o.width=n,o.height=r,o.right=e+n,o.bottom=i+r,o}return new t.IntegerRectangle(e,i,n,r)},e.prototype.freeRectangle=function(t){this._rectangleStack.push(t)},e}();t.RectanglePacker=e}(es||(es={})),function(t){var e=function(){return function(t,e,i){this.width=t,this.height=e,this.id=i}}();t.SortableSize=e}(es||(es={})),function(t){var e=function(){return function(t){this.assets=t}}();t.TextureAssets=e;var i=function(){return function(){}}();t.TextureAsset=i}(es||(es={})),function(t){var e=function(){return function(t,e){this.texture=t,this.id=e}}();t.TextureToPack=e}(es||(es={})),function(t){var e=function(){function e(){this._timeInSeconds=0,this._repeats=!1,this._isDone=!1,this._elapsedTime=0}return e.prototype.getContext=function(){return this.context},e.prototype.reset=function(){this._elapsedTime=0},e.prototype.stop=function(){this._isDone=!0},e.prototype.tick=function(){return!this._isDone&&this._elapsedTime>this._timeInSeconds&&(this._elapsedTime-=this._timeInSeconds,this._onTime(this),this._isDone||this._repeats||(this._isDone=!0)),this._elapsedTime+=t.Time.deltaTime,this._isDone},e.prototype.initialize=function(t,e,i,n){this._timeInSeconds=t,this._repeats=e,this.context=i,this._onTime=n},e.prototype.unload=function(){this.context=null,this._onTime=null},e}();t.Timer=e}(es||(es={})),function(t){var e=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t._timers=[],t}return __extends(i,e),i.prototype.update=function(){for(var t=this._timers.length-1;t>=0;t--)this._timers[t].tick()&&(this._timers[t].unload(),this._timers.removeAt(t))},i.prototype.schedule=function(e,i,n,r){var o=new t.Timer;return o.initialize(e,i,n,r),this._timers.push(o),o},i}(t.GlobalManager);t.TimerManager=e}(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 i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};return function(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();var transform,__awaiter=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))(function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){t.done?r(t.value):new i(function(e){e(t.value)}).then(s,a)}h((n=n.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){var i,n,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(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=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++,n=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 i=t.findIndex(e);return-1==i?null:t[i]}(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(i,n,r){return e.call(arguments[2],n,r,t)&&i.push(n),i},[]);for(var i=[],n=0,r=t.length;n=0&&t.splice(i,1)}while(i>=0)}(this,t)},Array.prototype.remove=function(t){return function(t,e){var i=t.findIndex(function(t){return t===e});return i>=0&&(t.splice(i,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,i){t.splice(e,i)}(this,t,e)},Array.prototype.select=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(i,n,r){return i.push(e.call(arguments[2],n,r,t)),i},[]);for(var i=[],n=0,r=t.length;no?1:-1}),t}(this,t,e)},Array.prototype.orderByDescending=function(t,e){return function(t,e,i){return t.sort(function(t,n){var r=e(t),o=e(n);return i?-i(r,o):r0;){if("break"===l())break}return s?this.recontructPath(a,n,r):null},e.recontructPath=function(t,e,i){var n=[],r=i;for(n.push(i);r!=e;)r=this.getKey(t,r),n.push(r);return n.reverse(),n},e.hasKey=function(t,e){for(var i,n=t.keys();!(i=n.next()).done;)if(JSON.stringify(i.value)==JSON.stringify(e))return!0;return!1},e.getKey=function(t,e){for(var i,n,r=t.keys(),o=t.values();i=r.next(),n=o.next(),!i.done;)if(JSON.stringify(i.value)==JSON.stringify(e))return n.value;return null},e}();t.AStarPathfinder=e;var i=function(t){function e(e){var i=t.call(this)||this;return i.data=e,i}return __extends(e,t),e}(t.PriorityQueueNode);t.AStarNode=i}(es||(es={})),function(t){var e=function(){function e(e,i){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=i}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,i)?this.cascadeUp(t):this.cascadeDown(t)},t.prototype.cascadeDown=function(t){for(var e,i=t.queueIndex;;){e=t;var n=2*i;if(n>this._numNodes){t.queueIndex=i,this._nodes[i]=t;break}var r=this._nodes[n];this.hasHigherPriority(r,e)&&(e=r);var o=n+1;if(o<=this._numNodes){var s=this._nodes[o];this.hasHigherPriority(s,e)&&(e=s)}if(e==t){t.queueIndex=i,this._nodes[i]=t;break}this._nodes[i]=e;var a=e.queueIndex;e.queueIndex=i,i=a}},t.prototype.cascadeUp=function(t){for(var e=Math.floor(t.queueIndex/2);e>=1;){var i=this._nodes[e];if(this.hasHigherPriority(i,t))break;this.swap(t,i),e=Math.floor(t.queueIndex/2)}},t.prototype.swap=function(t,e){this._nodes[t.queueIndex]=e,this._nodes[e.queueIndex]=t;var i=t.queueIndex;t.queueIndex=e.queueIndex,e.queueIndex=i},t.prototype.hasHigherPriority=function(t,e){return t.priority0;){if("break"===h())break}return o?t.AStarPathfinder.recontructPath(a,i,n):null},e.hasKey=function(t,e){for(var i,n=t.keys();!(i=n.next()).done;)if(JSON.stringify(i.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 new e(0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"one",{get:function(){return new e(1,1)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitX",{get:function(){return new e(1,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitY",{get:function(){return new e(0,1)},enumerable:!0,configurable:!0}),e.add=function(t,i){var n=new e(0,0);return n.x=t.x+i.x,n.y=t.y+i.y,n},e.divide=function(t,i){var n=new e(0,0);return n.x=t.x/i.x,n.y=t.y/i.y,n},e.multiply=function(t,i){var n=new e(0,0);return n.x=t.x*i.x,n.y=t.y*i.y,n},e.subtract=function(t,i){var n=new e(0,0);return n.x=t.x-i.x,n.y=t.y-i.y,n},e.normalize=function(t){var i=new e(t.x,t.y),n=1/Math.sqrt(i.x*i.x+i.y*i.y);return i.x*=n,i.y*=n,i},e.dot=function(t,e){return t.x*e.x+t.y*e.y},e.distanceSquared=function(t,e){var i=t.x-e.x,n=t.y-e.y;return i*i+n*n},e.clamp=function(i,n,r){return new e(t.MathHelper.clamp(i.x,n.x,r.x),t.MathHelper.clamp(i.y,n.y,r.y))},e.lerp=function(i,n,r){return new e(t.MathHelper.lerp(i.x,n.x,r),t.MathHelper.lerp(i.y,n.y,r))},e.transform=function(t,i){return new e(t.x*i.m11+t.y*i.m21+i.m31,t.x*i.m12+t.y*i.m22+i.m32)},e.distance=function(t,e){var i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)},e.angle=function(i,n){return i=e.normalize(i),n=e.normalize(n),Math.acos(t.MathHelper.clamp(e.dot(i,n),-1,1))*t.MathHelper.Rad2Deg},e.negate=function(t){var i=new e;return i.x=-t.x,i.y=-t.y,i},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);this.x*=t,this.y*=t},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}();t.Vector2=e}(es||(es={})),function(t){var e=function(){function e(t,i,n){void 0===n&&(n=!1),this.walls=[],this._neighbors=new Array(4),this._width=t,this._hegiht=i,this._dirs=n?e.COMPASS_DIRS:e.CARDINAL_DIRS}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x0;){if("break"===l())break}return s?this.recontructPath(a,n,r):null},i.recontructPath=function(t,e,i){var n=[],r=i;for(n.push(i);r!=e;)r=this.getKey(t,r),n.push(r);return n.reverse(),n},i.hasKey=function(t,e){for(var i,n=t.keys();!(i=n.next()).done;)if(JSON.stringify(i.value)==JSON.stringify(e))return!0;return!1},i.getKey=function(t,e){for(var i,n,r=t.keys(),o=t.values();i=r.next(),n=o.next(),!i.done;)if(JSON.stringify(i.value)==JSON.stringify(e))return n.value;return null},i}();t.WeightedPathfinder=i}(es||(es={})),function(t){var e=function(e){function i(){var n=e.call(this)||this;return n._globalManagers=[],n._timerManager=new t.TimerManager,i._instance=n,i.emitter=new t.Emitter,i.content=new t.ContentManager,n.addEventListener(egret.Event.ADDED_TO_STAGE,n.onAddToStage,n),i.registerGlobalManager(n._timerManager),n}return __extends(i,e),Object.defineProperty(i,"Instance",{get:function(){return this._instance},enumerable:!0,configurable:!0}),Object.defineProperty(i,"scene",{get:function(){return this._instance?this._instance._scene:null},set:function(t){t?null==this._instance._scene?(this._instance.addChild(t),this._instance._scene=t,this._instance._scene.begin(),i.Instance.onSceneChanged()):this._instance._nextScene=t:console.error("场景不能为空")},enumerable:!0,configurable:!0}),i.startSceneTransition=function(t){if(!this._instance._sceneTransition)return this._instance._sceneTransition=t,t;console.warn("在前一个场景完成之前,不能开始一个新的场景转换。")},i.registerGlobalManager=function(t){this._instance._globalManagers.push(t),t.enabled=!0},i.unregisterGlobalManager=function(t){this._instance._globalManagers.remove(t),t.enabled=!1},i.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._scene.parent&&this._scene.parent.removeChild(this._scene),this._scene.end(),this._scene=this._nextScene,this._nextScene=null,this.onSceneChanged(),[4,this._scene.begin()]):[3,2];case 1:i.sent(),this.addChild(this._scene),i.label=2;case 2:return this.endDebugUpdate(),[4,this.draw()];case 3:return i.sent(),[2]}})})},i.prototype.onAddToStage=function(){i.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(),KeyboardUtils.init(),this.initialize()},i.debugRenderEndabled=!1,i}(egret.DisplayObjectContainer);t.Core=e}(es||(es={})),function(t){var e=function(){function t(){}return t.renderableBounds=16776960,t.renderableCenter=10040012,t.colliderBounds=5592405,t.colliderEdge=9109504,t.colliderPosition=16776960,t.colliderCenter=16711680,t}();t.Colors=e;var i=function(){function e(){}return Object.defineProperty(e,"lineSizeMultiplier",{get:function(){return Math.max(Math.ceil(t.Core.scene.x/t.Core.scene.width),1)},enumerable:!0,configurable:!0}),e}();t.Size=i;var n=function(){function e(){}return e.drawHollowRect=function(e,i,n){void 0===n&&(n=0),this._debugDrawItems.push(new t.DebugDrawItem(e,i,n))},e.render=function(){if(this._debugDrawItems.length>0){var e=new egret.Shape;t.Core.scene&&t.Core.scene.addChild(e);for(var i=this._debugDrawItems.length-1;i>=0;i--){this._debugDrawItems[i].draw(e)&&this._debugDrawItems.removeAt(i)}}},e._debugDrawItems=[],e}();t.Debug=n}(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 i=function(){function i(t,i,n){this.rectangle=t,this.color=i,this.duration=n,this.drawType=e.hollowRectangle}return i.prototype.draw=function(i){switch(this.drawType){case e.line:case e.hollowRectangle:case e.pixel:case e.text:}return this.duration-=t.Time.deltaTime,this.duration<0},i}();t.DebugDrawItem=i}(es||(es={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateInterval=1,e.debugDisplayObject=new egret.DisplayObjectContainer,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}(egret.HashObject);t.Component=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(i){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=i,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()},i.prototype.render=function(){if(0!=this._renderers.length)for(var t=0;te.x?-1:1,n=t.Vector2.normalize(t.Vector2.subtract(this.position,e));this.rotation=i*Math.acos(t.Vector2.dot(n,t.Vector2.unitY))},n.prototype.setLocalRotation=function(t){return this._localRotation=t,this._localDirty=this._positionDirty=this._localPositionDirty=this._localRotationDirty=this._localScaleDirty=!0,this.setDirty(e.rotationDirty),this},n.prototype.setLocalRotationDegrees=function(e){return this.setLocalRotation(t.MathHelper.toRadians(e))},n.prototype.setScale=function(e){return this._scale=e,this.parent?this.localScale=t.Vector2.divide(e,this.parent._scale):this.localScale=e,this},n.prototype.setLocalScale=function(t){return this._localScale=t,this._localDirty=this._positionDirty=this._localScaleDirty=!0,this.setDirty(e.scaleDirty),this},n.prototype.roundPosition=function(){this.position=this._position.round()},n.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)},n.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 i=0;it&&(this._zoom=t),this._maximumZoom=t,this;console.error("maximumZoom must be greater than zero")},n.prototype.forceMatrixUpdate=function(){this._areMatrixedDirty=!0},n.prototype.onEntityTransformChanged=function(t){this._areMatrixedDirty=!0},n.prototype.zoomIn=function(t){this.zoom+=t},n.prototype.zoomOut=function(t){this.zoom-=t},n.prototype.worldToScreenPoint=function(e){return this.updateMatrixes(),e=t.Vector2Ext.transformR(e,this._transformMatrix)},n.prototype.screenToWorldPoint=function(e){return this.updateMatrixes(),e=t.Vector2Ext.transformR(e,this._inverseTransformMatrix)},n.prototype.onSceneRenderTargetSizeChanged=function(e,i){this._isProjectionMatrixDirty=!0;var n=this._origin;this.origin=new t.Vector2(e/2,i/2),this.entity.transform.position.add(t.Vector2.subtract(this._origin,n))},n.prototype.mouseToWorldPoint=function(){return this.screenToWorldPoint(t.Input.touchPosition)},n.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)},n}(t.Component);t.Camera=i}(es||(es={})),function(t){var e=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i._shakeDirection=t.Vector2.zero,i._shakeOffset=t.Vector2.zero,i._shakeIntensity=0,i._shakeDegredation=.95,i}return __extends(i,e),i.prototype.shake=function(e,i,n){void 0===e&&(e=15),void 0===i&&(i=.9),void 0===n&&(n=t.Vector2.zero),this.enabled=!0,this._shakeIntensity=1)&&(i=.95),this._shakeDegredation=i)},i.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)},i}(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(t){t[t.lockOn=0]="lockOn",t[t.cameraWindow=1]="cameraWindow"}(e=t.CameraStyle||(t.CameraStyle={}));var i=function(i){function n(n,r,o){void 0===n&&(n=null),void 0===r&&(r=null),void 0===o&&(o=e.lockOn);var s=i.call(this)||this;return s.followLerp=.1,s.deadzone=new t.Rectangle,s.focusOffset=t.Vector2.zero,s.mapLockEnabled=!1,s.mapSize=new t.Rectangle,s._desiredPositionDelta=new t.Vector2,s._worldSpaceDeadZone=new t.Rectangle,s.rectShape=new egret.Shape,s._targetEntity=n,s._cameraStyle=o,s.camera=r,s}return __extends(n,i),n.prototype.onAddedToEntity=function(){this.camera||(this.camera=this.entity.scene.camera),this.follow(this._targetEntity,this._cameraStyle),t.Core.emitter.addObserver(t.CoreEvents.GraphicsDeviceReset,this.onGraphicsDeviceReset,this)},n.prototype.onGraphicsDeviceReset=function(){t.Core.schedule(0,!1,this,function(t){var e=t.context;e.follow(e._targetEntity,e._cameraStyle)})},n.prototype.update=function(){var e=t.Vector2.multiply(this.camera.bounds.size,new t.Vector2(.5));this._worldSpaceDeadZone.x=this.camera.position.x-e.x*t.Core.scene.scaleX+this.deadzone.x+this.focusOffset.x,this._worldSpaceDeadZone.y=this.camera.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.camera.position=t.Vector2.lerp(this.camera.position,t.Vector2.add(this.camera.position,this._desiredPositionDelta),this.followLerp),this.entity.transform.roundPosition(),this.mapLockEnabled&&(this.camera.position=this.clampToMapSize(this.camera.position),this.entity.transform.roundPosition())},n.prototype.debugRender=function(){this.rectShape||this.debugDisplayObject.addChild(this.rectShape),this.rectShape.graphics.clear(),this._cameraStyle==e.lockOn?(this.rectShape.graphics.beginFill(9109504,0),this.rectShape.graphics.lineStyle(1,9109504),this.rectShape.graphics.drawRect(this._worldSpaceDeadZone.x-5,this._worldSpaceDeadZone.y-5,this._worldSpaceDeadZone.width,this._worldSpaceDeadZone.height),this.rectShape.graphics.endFill()):(this.rectShape.graphics.beginFill(9109504,0),this.rectShape.graphics.lineStyle(1,9109504),this.rectShape.graphics.drawRect(this._worldSpaceDeadZone.x,this._worldSpaceDeadZone.y,this._worldSpaceDeadZone.width,this._worldSpaceDeadZone.height),this.rectShape.graphics.endFill())},n.prototype.clampToMapSize=function(e){var i=t.Vector2.multiply(this.camera.bounds.size,new t.Vector2(.5)).add(new t.Vector2(this.mapSize.x,this.mapSize.y)),n=new t.Vector2(this.mapSize.width-i.x,this.mapSize.height-i.y);return t.Vector2.clamp(e,i,n)},n.prototype.follow=function(i,n){void 0===n&&(n=e.cameraWindow),this._targetEntity=i,this._cameraStyle=n;var r=this.camera.bounds;switch(this._cameraStyle){case e.cameraWindow:var o=r.width/6,s=r.height/3;this.deadzone=new t.Rectangle((r.width-o)/2,(r.height-s)/2,o,s);break;case e.lockOn:this.deadzone=new t.Rectangle(r.width/2,r.height/2,10,10)}},n.prototype.updateFollow=function(){if(this._desiredPositionDelta.x=this._desiredPositionDelta.y=0,this._cameraStyle==e.lockOn){var i=this._targetEntity.transform.position.x,n=this._targetEntity.transform.position.y;this._worldSpaceDeadZone.x>i?this._desiredPositionDelta.x=i-this._worldSpaceDeadZone.x:this._worldSpaceDeadZone.xn&&(this._desiredPositionDelta.y=n-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))}},n.prototype.setCenteredDeadzone=function(e,i){if(this.camera){var n=this.camera.bounds;this.deadzone=new t.Rectangle((n.width-e)/2,(n.height-i)/2,e,i)}else console.error("相机是null。我们不能得到它的边界。请等到该组件添加到实体之后")},n}(t.Component);t.FollowCamera=i}(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 i(){var i=null!==e&&e.apply(this,arguments)||this;return i.displayObject=new egret.DisplayObject,i.hollowShape=new egret.Shape,i.pixelShape=new egret.Shape,i.color=0,i._areBoundsDirty=!0,i.debugRenderEnabled=!0,i._localOffset=t.Vector2.zero,i._renderLayer=0,i._bounds=new t.Rectangle,i}return __extends(i,e),Object.defineProperty(i.prototype,"width",{get:function(){return this.bounds.width},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this.bounds.height},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"localOffset",{get:function(){return this._localOffset},set:function(t){this.setLocalOffset(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"renderLayer",{get:function(){return this._renderLayer},set:function(t){this.setRenderLayer(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.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(i.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}),i.prototype.onEntityTransformChanged=function(t){this._areBoundsDirty=!0},i.prototype.debugRender=function(){if(this.debugRenderEnabled){this.hollowShape.parent||this.debugDisplayObject.addChild(this.hollowShape),this.pixelShape.parent||this.debugDisplayObject.addChild(this.pixelShape);var e=t.Vector2.add(this.entity.transform.position,this._localOffset);this.pixelShape.graphics.clear(),this.pixelShape.graphics.beginFill(t.Colors.renderableCenter,0),this.pixelShape.graphics.lineStyle(4,t.Colors.renderableCenter),this.pixelShape.graphics.lineTo(e.x,e.y),this.pixelShape.graphics.moveTo(e.x,e.y),this.pixelShape.graphics.endFill()}},i.prototype.isVisibleFromCamera=function(t){return!!t&&(this.isVisible=t.bounds.intersects(this.bounds),this.isVisible)},i.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},i.prototype.setColor=function(t){return this.color=t,this},i.prototype.setLocalOffset=function(t){return this._localOffset!=t&&(this._localOffset=t),this},i.prototype.sync=function(e){var i=new t.Vector2(this.entity.position.x+this.localOffset.x-e.position.x+e.origin.x,this.entity.position.y+this.localOffset.y-e.position.y+e.origin.y);this.displayObject.x!=i.x&&(this.displayObject.x=i.x),this.displayObject.y!=i.y&&(this.displayObject.y=i.y),this.displayObject.scaleX!=this.entity.scale.x&&(this.displayObject.scaleX=this.entity.scale.x),this.displayObject.scaleY!=this.entity.scale.y&&(this.displayObject.scaleY=this.entity.scale.y),this.displayObject.rotation!=this.entity.rotation&&(this.displayObject.rotation=this.entity.rotation)},i.prototype.toString=function(){return"[RenderableComponent] renderLayer: "+this.renderLayer},i.prototype.onBecameVisible=function(){this.displayObject.visible=this.isVisible,this.debugDisplayObject.visible=this.isVisible},i.prototype.onBecameInvisible=function(){this.displayObject.visible=this.isVisible,this.debugDisplayObject.visible=this.isVisible},i}(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,i=function(i){function n(e){void 0===e&&(e=null);var n=i.call(this)||this;return e instanceof t.Sprite?n.setSprite(e):e instanceof egret.Texture&&n.setSprite(new t.Sprite(e)),n}return __extends(n,i),Object.defineProperty(n.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(n.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(n.prototype,"origin",{get:function(){return this._origin},set:function(t){this.setOrigin(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"sprite",{get:function(){return this._sprite},set:function(t){this.setSprite(t)},enumerable:!0,configurable:!0}),n.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},n.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},n.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},n.prototype.render=function(e){this.sync(e);var i=new t.Vector2(this.entity.position.x+this.localOffset.x-this.origin.x-e.position.x+e.origin.x,this.entity.position.y+this.localOffset.y-this.origin.y-e.position.y+e.origin.y);this.displayObject.x!=i.x&&(this.displayObject.x=i.x),this.displayObject.y!=i.y&&(this.displayObject.y=i.y)},n}(t.RenderableComponent);t.SpriteRenderer=i}(es||(es={})),function(t){var e=egret.Bitmap,i=egret.RenderTexture,n=function(n){function r(e){var i=n.call(this,e)||this;return i._textureScale=t.Vector2.one,i._inverseTexScale=t.Vector2.one,i._gapX=0,i._gapY=0,i._sourceRect=e.sourceRect,i.displayObject.$fillMode=egret.BitmapFillMode.REPEAT,i}return __extends(r,n),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 n=new i,r=this.sprite.sourceRect;r.x=0,r.y=0,r.width+=this._gapX,r.height+=this._gapY,n.drawToTexture(this.displayObject,r),this.displayObject?this.displayObject.texture=n:this.displayObject=new e(n)},enumerable:!0,configurable:!0}),r.prototype.setGapXY=function(t){return this.gapXY=t,this},r.prototype.render=function(t){n.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=n}(es||(es={})),function(t){var e=function(e){function i(t){var i=e.call(this,t)||this;return i.scrollSpeedX=15,i.scroolSpeedY=0,i._scrollX=0,i._scrollY=0,i._scrollWidth=0,i._scrollHeight=0,i._scrollWidth=i.width,i._scrollHeight=i.height,i}return __extends(i,e),Object.defineProperty(i.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(i.prototype,"scrollWidth",{get:function(){return this._scrollWidth},set:function(t){this._scrollWidth=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scrollHeight",{get:function(){return this._scrollHeight},set:function(t){this._scrollHeight=t},enumerable:!0,configurable:!0}),i.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))},i}(t.TiledSpriteRenderer);t.ScrollingSpriteRenderer=e}(es||(es={})),function(t){var e=egret.SpriteSheet,i=function(){function i(e,i,n){void 0===i&&(i=new t.Rectangle(0,0,e.textureWidth,e.textureHeight)),void 0===n&&(n=i.getHalfSize()),this.uvs=new t.Rectangle,this.texture2D=e,this.sourceRect=i,this.center=new t.Vector2(.5*i.width,.5*i.height),this.origin=n;var r=1/e.textureWidth,o=1/e.textureHeight;this.uvs.x=i.x*r,this.uvs.y=i.y*o,this.uvs.width=i.width*r,this.uvs.height=i.height*o}return i.spritesFromAtlas=function(t,n,r,o,s){void 0===o&&(o=0),void 0===s&&(s=Number.MAX_VALUE);for(var a=[],h=t.textureWidth/n,c=t.textureHeight/r,l=0,u=new e(t),p=0;po||this._loopMode==e.pingPongOnce&&s>2*o)return this.animationState=i.completed,this._elapsedTime=0,this.currentFrame=0,void(this.displayObject.texture=n.sprites[this.currentFrame].texture2D);var a=Math.floor(s/r),h=n.sprites.length;if(h>2&&(this._loopMode==e.pingPong||this._loopMode==e.pingPongOnce)){var c=h-1;this.currentFrame=c-Math.abs(c-a%(2*c))}else this.currentFrame=a%h;this.displayObject.texture=n.sprites[this.currentFrame].texture2D}},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,n){void 0===n&&(n=null),this.currentAnimation=this._animations[t],this.currentAnimationName=t,this.currentFrame=0,this.animationState=i.running,this.displayObject.texture=this.currentAnimation.sprites[0].texture2D,this._elapsedTime=0,this._loopMode=n||e.loop},r.prototype.isAnimationActive=function(t){return this.currentAnimation&&this.currentAnimationName==t},r.prototype.pause=function(){this.animationState=i.paused},r.prototype.unPause=function(){this.animationState=i.running},r.prototype.stop=function(){this.currentAnimation=null,this.currentAnimationName=null,this.currentFrame=0,this.animationState=i.none},r}(t.SpriteRenderer);t.SpriteAnimator=n}(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 i=function(e){function i(){var t=e.call(this)||this;return t.colliderHorizontalInset=2,t.colliderVerticalInset=6,t}return __extends(i,e),i.prototype.testCollisions=function(e,i,n){this._boxColliderBounds=i,n.wasGroundedLastFrame=n.below,n.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,n,0)?(e.x=0-t.RectangleExt.getSide(i,o),n.left=o==t.Edge.left,n.right=o==t.Edge.right,n._movementRemainderX.reset()):(n.left=!1,n.right=!1)}},i.prototype.testMapCollision=function(e,i,n,r){var o=t.EdgeExt.oppositeEdge(i);t.EdgeExt.isVertical(o)?e.center.x:e.center.y,t.RectangleExt.getSide(e,i),t.EdgeExt.isVertical(o)},i.prototype.collisionRectForSide=function(e,i){var n;return n=t.EdgeExt.isHorizontal(e)?t.RectangleExt.getRectEdgePortion(this._boxColliderBounds,e):t.RectangleExt.getHalfRect(this._boxColliderBounds,e),t.EdgeExt.isVertical(e)?t.RectangleExt.contract(n,this.colliderHorizontalInset,0):t.RectangleExt.contract(n,0,this.colliderVerticalInset),t.RectangleExt.expandSide(n,e,i),n},i}(t.Component);t.TiledMapMover=i}(es||(es={})),function(t){var e=function(e){function i(i,n,r){void 0===n&&(n=null),void 0===r&&(r=!0);var o=e.call(this)||this;return o.physicsLayer=new t.Ref(1),o.toContainer=!1,o.tiledMap=i,o._shouldCreateColliders=r,o.displayObject=new egret.DisplayObjectContainer,n&&(o.collisionLayer=i.tileLayers.find(function(t){return t.name==n})),o}return __extends(i,e),Object.defineProperty(i.prototype,"width",{get:function(){return this.tiledMap.width*this.tiledMap.tileWidth},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this.tiledMap.height*this.tiledMap.tileHeight},enumerable:!0,configurable:!0}),i.prototype.setLayerToRender=function(t){this.layerIndicesToRender=[],this.layerIndicesToRender[0]=this.getLayerIndex(t)},i.prototype.setLayersToRender=function(){for(var t=[],e=0;e=2){this.polygonShape.graphics.beginFill(t.Colors.colliderEdge,0),this.polygonShape.graphics.lineStyle(t.Size.lineSizeMultiplier,t.Colors.colliderEdge);for(var i=0;i>6;0!=(e&t.LONG_MASK)&&i++,this._bits=new Array(i)}return t.prototype.and=function(t){for(var e,i=Math.min(this._bits.length,t._bits.length),n=0;n=0;)this._bits[e]&=~t._bits[e]},t.prototype.cardinality=function(){for(var t=0,e=this._bits.length-1;e>=0;e--){var i=this._bits[e];if(0!=i)if(-1!=i){var n=((i=((i=(i>>1&0x5555555555555400)+(0x5555555555555400&i))>>2&0x3333333333333400)+(0x3333333333333400&i))>>32)+i;t+=((n=((n=(n>>4&252645135)+(252645135&n))>>8&16711935)+(16711935&n))>>16&65535)+(65535&n)}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,i=1<>6;this.ensure(i),this._bits[i]|=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 i=0;i0){i=0;for(var n=this._componentsToAdd.length;i0){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,i=[],n=0;n0){for(var t=0,i=this._unsortedRenderLayers.length;t=e)return t;var n=!1;"-"==t.substr(0,1)&&(n=!0,t=t.substr(1));for(var r=e-i,o=0;o1?this.reverse(t.substring(1))+t.substring(0,1):t},t.cutOff=function(t,e,i,n){void 0===n&&(n=!0),e=Math.floor(e),i=Math.floor(i);var r=t.length;e>r&&(e=r);var o,s=e,a=e+i;return n?o=t.substring(0,s)+t.substr(a,r):(a=(s=r-1-e-i)+i,o=t.substring(0,s+1)+t.substr(a+1,r)),o},t.strReplace=function(t,e){for(var i=0,n=e.length;i",">",'"',""","'","'","®","®","©","©","™","™"],t}();!function(t){var e=function(){function e(){}return e.convertImageToCanvas=function(e,i){this.sharedCanvas||(this.sharedCanvas=egret.sys.createCanvas(),this.sharedContext=this.sharedCanvas.getContext("2d"));var n=e.$getTextureWidth(),r=e.$getTextureHeight();i||((i=egret.$TempRectangle).x=0,i.y=0,i.width=n,i.height=r),i.x=Math.min(i.x,n-1),i.y=Math.min(i.y,r-1),i.width=Math.min(i.width,n-i.x),i.height=Math.min(i.height,r-i.y);var o=Math.floor(i.width),s=Math.floor(i.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 h=void 0;e.$renderBuffer?h=e:(egret.sys.systemRenderer.renderClear&&egret.sys.systemRenderer.renderClear(),(h=new egret.RenderTexture).drawToTexture(new egret.Bitmap(e)));for(var c=h.$renderBuffer.getPixels(i.x,i.y,o,s),l=0,u=0,p=0;p=0?"png":"jpg"});return wx.getFileSystemManager().saveFile({tempFilePath:o,filePath:wx.env.USER_DATA_PATH+"/"+i,success:function(t){}}),o},e.getPixel32=function(t,e,i){return egret.$warn(1041,"getPixel32","getPixels"),t.getPixels(e,i)},e.getPixels=function(t,e,i,n,r){if(void 0===n&&(n=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,i,n,r)}try{this.convertImageToCanvas(t);return this.sharedContext.getImageData(e,i,n,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(),i=t.getMonth()+1;return parseInt(e+(i<10?"0":"")+i)},t.dateId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getMonth()+1,i=e<10?"0":"",n=t.getDate(),r=n<10?"0":"";return parseInt(t.getFullYear()+i+e+r+n)},t.weekId=function(t,e){void 0===t&&(t=null),void 0===e&&(e=!0),t=t||new Date;var i=new Date;i.setTime(t.getTime()),i.setDate(1),i.setMonth(0);var n=i.getFullYear(),r=i.getDay();0==r&&(r=7);var o=!1;r<=4?(o=r>1,i.setDate(i.getDate()-(r-1))):i.setDate(i.getDate()+7-r+1);var s=this.diffDay(t,i,!1);if(s<0)return i.setDate(1),i.setMonth(0),i.setDate(i.getDate()-1),this.weekId(i,!1);var a=s/7,h=Math.floor(a)+1;if(53==h){i.setTime(t.getTime()),i.setDate(i.getDate()-1);var c=i.getDay();if(0==c&&(c=7),e&&(!o||c<4))return i.setFullYear(i.getFullYear()+1),i.setDate(1),i.setMonth(0),this.weekId(i,!1)}return parseInt(n+"00"+(h>9?"":"0")+h)},t.diffDay=function(t,e,i){void 0===i&&(i=!1);var n=(t.getTime()-e.getTime())/864e5;return i?Math.ceil(n):Math.floor(n)},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(),i=t.getMonth()+1;i=i<10?"0"+i:i;var n=t.getDate();return e+"-"+i+"-"+(n=n<10?"0"+n:n)},t.formatDateTime=function(t){var e=t.getFullYear(),i=t.getMonth()+1;i=i<10?"0"+i:i;var n=t.getDate();n=n<10?"0"+n:n;var r=t.getHours(),o=t.getMinutes();o=o<10?"0"+o:o;var s=t.getSeconds();return e+"-"+i+"-"+n+" "+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,i){void 0===t&&(t=0),void 0===e&&(e=":"),void 0===i&&(i=!0);var n=Math.floor(t/3600),r=Math.floor(t%3600/60),o=Math.floor(t%3600%60),s=n.toString(),a=r.toString(),h=o.toString();return n<10&&(s="0"+s),r<10&&(a="0"+a),o<10&&(h="0"+h),i?s+e+a+e+h:a+e+h},t.timeToMillisecond=function(t,e){void 0===e&&(e=":");for(var i=t.split(e),n=0,r=i.length,o=0;o-1?this.os="iOS":n.indexOf("android")>-1&&(this.os="Android");var r=i.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,i,n){this._x=t,this._y=e,this._width=i,this._height=n,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 i(){return e.call(this,t.PostProcessor.default_vert,i.blur_frag,{screenWidth:t.Core.graphicsDevice.viewport.width,screenHeight:t.Core.graphicsDevice.viewport.height})||this}return __extends(i,e),i.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}",i}(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 i(){return null!==e&&e.apply(this,arguments)||this}return __extends(i,e),i.prototype.onAddedToScene=function(i){e.prototype.onAddedToScene.call(this,i),this.effect=new t.GaussianBlurEffect},i}(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.shouldDebugRender=!0,this.camera=e,this.renderOrder=t}return Object.defineProperty(t.prototype,"wantsToRenderToSceneRenderTarget",{get:function(){return!!this.renderTexture},enumerable:!0,configurable:!0}),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.prototype.debugRender=function(t,e){for(var i=0;ii?i:t},e.pointOnCirlce=function(i,n,r){var o=e.toRadians(r);return new t.Vector2(Math.cos(o)*o+i.x,Math.sin(o)*o+i.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.approach=function(t,e,i){return tn&&(n=s.x),s.yr&&(r=s.y)}return this.fromMinMax(e,i,n,r)},i.prototype.intersects=function(t){return t.leftthis.x+this.width)return!1}else{var n=1/t.direction.x,r=(this.x-t.start.x)*n,o=(this.x+this.width-t.start.x)*n;if(r>o){var s=r;r=o,o=s}if(e.value=Math.max(r,e.value),i=Math.min(o,i),e.value>i)return!1}if(Math.abs(t.direction.y)<1e-6){if(t.start.ythis.y+this.height)return!1}else{var a=1/t.direction.y,h=(this.y-t.start.y)*a,c=(this.y+this.height-t.start.y)*a;if(h>c){var l=h;h=c,c=l}if(e.value=Math.max(h,e.value),i=Math.max(c,i),e.value>i)return!1}return!0},i.prototype.containsRect=function(t){return this.x<=t.x&&t.x1)return!1;var l=(h.x*o.y-h.y*o.x)/a;return!(l<0||l>1)},i.lineToLineIntersection=function(e,i,n,r){var o=new t.Vector2(0,0),s=t.Vector2.subtract(i,e),a=t.Vector2.subtract(r,n),h=s.x*a.y-s.y*a.x;if(0==h)return o;var c=t.Vector2.subtract(n,e),l=(c.x*a.y-c.y*a.x)/h;if(l<0||l>1)return o;var u=(c.x*s.y-c.y*s.x)/h;return u<0||u>1?o:o=t.Vector2.add(e,new t.Vector2(l*s.x,l*s.y))},i.closestPointOnLine=function(e,i,n){var r=t.Vector2.subtract(i,e),o=t.Vector2.subtract(n,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))},i.circleToCircle=function(e,i,n,r){return t.Vector2.distanceSquared(e,n)<(i+r)*(i+r)},i.circleToLine=function(e,i,n,r){return t.Vector2.distanceSquared(e,this.closestPointOnLine(n,r,e))=t&&r.y>=e&&r.x=t+n&&(s|=e.right),o.y=i+r&&(s|=e.bottom),s},i}();t.Collisions=i}(es||(es={})),function(t){var e=function(){function e(e,i,n,r,o){this.fraction=0,this.distance=0,this.point=t.Vector2.zero,this.normal=t.Vector2.zero,this.collider=e,this.fraction=i,this.distance=n,this.point=r,this.centroid=t.Vector2.zero}return e.prototype.setValues=function(t,e,i,n){this.collider=t,this.fraction=e,this.distance=i,this.point=n},e.prototype.setValuesNonCollider=function(t,e,i,n){this.fraction=t,this.distance=e,this.point=i,this.normal=n},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 e(){}return e.reset=function(){this._spatialHash=new t.SpatialHash(this.spatialHashCellSize)},e.clear=function(){this._spatialHash.clear()},e.overlapCircleAll=function(t,e,i,n){if(void 0===n&&(n=-1),0!=i.length)return this._spatialHash.overlapCircle(t,e,i,n);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,i){return void 0===i&&(i=this.allLayers),this._spatialHash.aabbBroadphase(e,t,i)},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.linecast=function(t,i,n){return void 0===n&&(n=e.allLayers),this._hitArray[0].reset(),this.linecastAll(t,i,this._hitArray,n),this._hitArray[0]},e.linecastAll=function(t,i,n,r){return void 0===r&&(r=e.allLayers),0==n.length?(console.warn("传入了一个空的hits数组。没有点击会被返回"),0):this._spatialHash.linecast(t,i,n,r)},e.debugDraw=function(t){this._spatialHash.debugDraw(t,2)},e.spatialHashCellSize=100,e.allLayers=-1,e.raycastsHitTriggers=!1,e.raycastsStartInColliders=!1,e._hitArray=[new t.RaycastHit],e}();t.Physics=e}(es||(es={})),function(t){var e=function(){return function(e,i){this.start=e,this.end=i,this.direction=t.Vector2.subtract(this.end,this.start)}}();t.Ray2D=e}(es||(es={})),function(t){var e=function(){return function(){}}();t.Shape=e}(es||(es={})),function(t){var e=function(e){function i(t,i){var n=e.call(this)||this;return n._areEdgeNormalsDirty=!0,n.isUnrotated=!0,n.setPoints(t),n.isBox=i,n}return __extends(i,e),Object.defineProperty(i.prototype,"edgeNormals",{get:function(){return this._areEdgeNormalsDirty&&this.buildEdgeNormals(),this._edgeNormals},enumerable:!0,configurable:!0}),i.prototype.setPoints=function(t){this.points=t,this.recalculateCenterAndEdgeNormals(),this._originalPoints=[];for(var e=0;e=this.points.length?this.points[0]:this.points[n+1];var o=t.Vector2Ext.perpendicular(r,e);t.Vector2Ext.normalize(o),this._edgeNormals[n]=o}},i.buildSymmetricalPolygon=function(e,i){for(var n=new Array(e),r=0;rr&&(r=s,n=o)}return e[n]},i.getClosestPointOnPolygonToPoint=function(e,i,n,r){n.value=Number.MAX_VALUE,r.x=0,r.y=0;for(var o=new t.Vector2(0,0),s=0,a=0;at.y!=this.points[n].y>t.y&&t.x<(this.points[n].x-this.points[i].x)*(t.y-this.points[i].y)/(this.points[n].y-this.points[i].y)+this.points[i].x&&(e=!e);return e},i.prototype.pointCollidesWithShape=function(e,i){return t.ShapeCollisions.pointToPoly(e,this,i)},i}(t.Shape);t.Polygon=e}(es||(es={})),function(t){var e=function(e){function i(t,n){var r=e.call(this,i.buildBox(t,n),!0)||this;return r.width=t,r.height=n,r}return __extends(i,e),i.buildBox=function(e,i){var n=e/2,r=i/2,o=new Array(4);return o[0]=new t.Vector2(-n,-r),o[1]=new t.Vector2(n,-r),o[2]=new t.Vector2(n,r),o[3]=new t.Vector2(-n,r),o},i.prototype.updateBox=function(e,i){this.width=e,this.height=i;var n=e/2,r=i/2;this.points[0]=new t.Vector2(-n,-r),this.points[1]=new t.Vector2(n,-r),this.points[2]=new t.Vector2(n,r),this.points[3]=new t.Vector2(-n,r);for(var o=0;o1)return!1;var a,h=t.Vector2.add(s.start,t.Vector2.add(s.direction,new t.Vector2(r.value))),c=0;h.xi.bounds.right&&(c|=1),h.yi.bounds.bottom&&(c|=2);var l=a+c;return 3==l&&console.log("m == 3. corner "+t.Time.frameCount),!0},e}();t.RealtimeCollisions=e}(es||(es={})),function(t){var e=function(){function e(){}return e.polygonToPolygon=function(e,i,n){for(var r,o=!0,s=e.edgeNormals,a=i.edgeNormals,h=Number.POSITIVE_INFINITY,c=new t.Vector2,l=t.Vector2.subtract(e.position,i.position),u=0;u0&&(o=!1),!o)return!1;(y=Math.abs(y))r&&(r=o);return{min:n,max:r}},e.circleToPolygon=function(e,i,n){var r,o=t.Vector2.subtract(e.position,i.position),s=new t.Ref(0),a=t.Polygon.getClosestPointOnPolygonToPoint(i.points,o,s,n.normal),h=i.containsPoint(e.position);if(s.value>e.radius*e.radius&&!h)return!1;if(h)r=t.Vector2.multiply(n.normal,new t.Vector2(Math.sqrt(s.value)-e.radius));else if(0==s.value)r=t.Vector2.multiply(n.normal,new t.Vector2(e.radius));else{var c=Math.sqrt(s.value);r=t.Vector2.multiply(new t.Vector2(-t.Vector2.subtract(o,a)),new t.Vector2((e.radius-s.value)/c))}return n.minimumTranslationVector=r,n.point=t.Vector2.add(a,i.position),!0},e.circleToBox=function(e,i,n){var r=i.bounds.getClosestPointOnRectangleBorderToPoint(e.position,n.normal);if(i.containsPoint(e.position)){n.point=r;var o=t.Vector2.add(r,t.Vector2.multiply(n.normal,new t.Vector2(e.radius)));return n.minimumTranslationVector=t.Vector2.subtract(e.position,o),!0}var s=t.Vector2.distanceSquared(r,e.position);if(0==s)n.minimumTranslationVector=t.Vector2.multiply(n.normal,new t.Vector2(e.radius));else if(s<=e.radius*e.radius){n.normal=t.Vector2.subtract(e.position,r);var a=n.normal.length()-e.radius;return n.point=r,t.Vector2Ext.normalize(n.normal),n.minimumTranslationVector=t.Vector2.multiply(new t.Vector2(a),n.normal),!0}return!1},e.pointToCircle=function(e,i,n){var r=t.Vector2.distanceSquared(e,i.position),o=1+i.radius;if(r1)return!1;var u=(c.x*s.y-c.y*s.x)/h;return!(u<0||u>1)&&(o=o.add(e).add(t.Vector2.multiply(new t.Vector2(l),s)),!0)},e.lineToCircle=function(e,i,n,r){var o=t.Vector2.distance(e,i),s=t.Vector2.divide(t.Vector2.subtract(i,e),new t.Vector2(o)),a=t.Vector2.subtract(e,n.position),h=t.Vector2.dot(a,s),c=t.Vector2.dot(a,a)-n.radius*n.radius;if(c>0&&h>0)return!1;var l=h*h-c;return!(l<0)&&(r.fraction=-h-Math.sqrt(l),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,n.position)),r.fraction=r.distance/o,!0)},e.boxToBoxCast=function(e,i,n,r){var o=this.minkowskiDifference(e,i);if(o.contains(0,0)){var s=o.getClosestPointOnBoundsToOrigin();return!s.equals(t.Vector2.zero)&&(r.normal=new t.Vector2(-s.x),r.normal.normalize(),r.distance=0,r.fraction=0,!0)}var a=new t.Ray2D(t.Vector2.zero,new t.Vector2(-n.x)),h=new t.Ref(0);return!!(o.rayIntersects(a,h)&&h.value<=1)&&(r.fraction=h.value,r.distance=n.length()*h.value,r.normal=new t.Vector2(-n.x,-n.y),r.normal.normalize(),r.centroid=t.Vector2.add(e.bounds.center,t.Vector2.multiply(n,new t.Vector2(h.value))),!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 i,this._tempHashSet=[],this._cellSize=e,this._inverseCellSize=1/this._cellSize,this._raycastParser=new n}return e.prototype.register=function(e){var i=e.bounds;e.registeredPhysicsBounds=i;var n=this.cellCoords(i.x,i.y),r=this.cellCoords(i.right,i.bottom);this.gridBounds.contains(n.x,n.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,n)),this.gridBounds.contains(r.x,r.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,r));for(var o=n.x;o<=r.x;o++)for(var s=n.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,i=this.cellCoords(e.x,e.y),n=this.cellCoords(e.right,e.bottom),r=i.x;r<=n.x;r++)for(var o=i.y;o<=n.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 i=this.gridBounds.x;i<=this.gridBounds.right;i++)for(var n=this.gridBounds.y;n<=this.gridBounds.bottom;n++){var r=this.cellAtPosition(i,n);r&&r.length>0&&this.debugDrawCellDetails(i,n,r.length,t,e)}},e.prototype.aabbBroadphase=function(e,i,n){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 h=this.cellAtPosition(s,a);if(h)for(var c=function(r){var o=h[r];if(o==i||!t.Flags.isFlagSet(n,o.physicsLayer.value))return"continue";e.intersects(o.bounds)&&(l._tempHashSet.firstOrDefault(function(t){return t.hashCode==o.hashCode})||l._tempHashSet.push(o))},l=this,u=0;u=0&&(e.push(this.findBoundsRect(i,o,r,t)),i=-1)}i>=0&&(e.push(this.findBoundsRect(i,this.map.width,r,t)),i=-1)}return e},e.prototype.findBoundsRect=function(e,i,n,r){for(var o=-1,s=n+1;sthis.tileHeight||this.maxTileWidth>this.tileWidth},enumerable:!0,configurable:!0}),i.prototype.getTilesetForTileGid=function(t){if(0==t)return null;for(var e=this.tilesets.length-1;e>=0;e--)if(this.tilesets[e].firstGid<=t)return this.tilesets[e];console.error("tile gid"+t+"未在任何tileset中找到")},i.prototype.worldToTilePositionX=function(e,i){void 0===i&&(i=!0);var n=Math.floor(e/this.tileWidth);return i?t.MathHelper.clamp(n,0,this.width-1):n},i.prototype.worldToTilePositionY=function(e,i){void 0===i&&(i=!0);var n=Math.floor(e/this.tileHeight);return i?t.MathHelper.clamp(n,0,this.height-1):n},i.prototype.getLayer=function(t){return this.layers[t]},i.prototype.update=function(){this.tilesets.forEach(function(t){t.update()})},i.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)},i}(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 i=function(){return function(){this.shape=new egret.Shape,this.textField=new egret.TextField}}();t.TmxObject=i;var n=function(){return function(){}}();t.TmxText=n;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(){function e(){}return e.loadTmxMap=function(t,e){var i=RES.getRes(e);return this.loadTmxMapData(t,i,RES.getResourceInfo(e))},e.loadTmxMapData=function(e,i,n){return __awaiter(this,void 0,void 0,function(){var r,o,s,a;return __generator(this,function(h){switch(h.label){case 0:e.version=i.version,e.tiledVersion=i.tiledversion,e.width=i.width,e.height=i.height,e.tileWidth=i.tilewidth,e.tileHeight=i.tileheight,e.hexSideLength=i.hexsidelength,e.orientation=this.parseOrientationType(i.orientation),e.staggerAxis=this.parseStaggerAxisType(i.staggeraxis),e.staggerIndex=this.parseStaggerIndexType(i.staggerindex),e.renderOrder=this.parseRenderOrderType(i.renderorder),e.nextObjectID=i.nextobjectid,e.backgroundColor=t.TmxUtils.color16ToUnit(i.color),e.properties=this.parsePropertyDict(i.properties),e.maxTileWidth=e.tileWidth,e.maxTileHeight=e.tileHeight,e.tmxDirectory=n.root+n.url.replace(".","_").replace(n.name,""),e.tilesets=[],r=0,o=i.tilesets,h.label=1;case 1:return rt.map.maxTileWidth&&(t.map.maxTileWidth=e.image.width),e.image.height>t.map.maxTileHeight&&(t.map.maxTileHeight=e.image.height))}),t.tileRegions.forEach(function(e){var i=e.width,n=e.height;i>t.map.maxTileWidth&&(t.map.maxTileWidth=i),i>t.map.maxTileHeight&&(t.map.maxTileHeight=n)})},e.parseOrientationType=function(e){return"unknown"==e?t.OrientationType.unknown:"orthogonal"==e?t.OrientationType.orthogonal:"isometric"==e?t.OrientationType.isometric:"staggered"==e?t.OrientationType.staggered:"hexagonal"==e?t.OrientationType.hexagonal:t.OrientationType.unknown},e.parseStaggerAxisType=function(e){return"y"==e?t.StaggerAxisType.y:t.StaggerAxisType.x},e.parseStaggerIndexType=function(e){return"even"==e?t.StaggerIndexType.even:t.StaggerIndexType.odd},e.parseRenderOrderType=function(e){return"right-up"==e?t.RenderOrderType.rightUp:"left-down"==e?t.RenderOrderType.leftDown:"left-up"==e?t.RenderOrderType.leftUp:t.RenderOrderType.rightDown},e.parsePropertyDict=function(e){if(!e)return null;for(var i=new Map,n=0,r=e;n=e.columns));m+=e.tileWidth+e.spacing);else e.tiles.forEach(function(i,n){e.tileRegions.set(n,new t.Rectangle(0,0,i.image.width,i.image.height))});return[2,e]}})})},e.loadTmxTilesetTile=function(e,i,n,r,o){return __awaiter(this,void 0,void 0,function(){var s,a,h,c,l,u,p,d,f,g,y,m,_;return __generator(this,function(v){switch(v.label){case 0:if(e.tileset=i,e.id=n.id,s=n.terrain)for(e.terrainEdges=new Array(4),a=0,h=0,c=s;h0){a.shape.x=h.x,a.shape.y=h.y,i.addChild(a.shape),a.shape.graphics.clear(),a.shape.graphics.lineStyle(1,10526884);for(u=0;u0&&(l=u.currentAnimationFrameGid);var p=i.tileset.tileRegions.get(l),d=Math.floor(i.x)*s,f=Math.floor(i.y)*a;i.horizontalFlip&&i.verticalFlip?(d+=a+(p.height*o.y-a),f-=p.width*o.x-s):i.horizontalFlip?d+=s+(p.height*o.y-a):i.verticalFlip?f+=s-p.width*o.x:f+=a-p.height*o.y;var g=new t.Vector2(d,f).add(r);if(i.tileset.image){if(n){var y=i.tileset.image.bitmap.getTexture(""+l);y||(y=i.tileset.image.bitmap.createTexture(""+l,p.x,p.y,p.width,p.height)),i.tileset.image.texture=new e(y),n.addChild(i.tileset.image.texture),i.tileset.image.texture.x!=g.x&&(i.tileset.image.texture.x=g.x),i.tileset.image.texture.y!=g.y&&(i.tileset.image.texture.y=g.y),i.verticalFlip&&i.horizontalFlip?(i.tileset.image.texture.scaleX=-1,i.tileset.image.texture.scaleY=-1):i.verticalFlip?(i.tileset.image.texture.scaleX=o.x,i.tileset.image.texture.scaleY=-1):i.horizontalFlip?(i.tileset.image.texture.scaleX=-1,i.tileset.image.texture.scaleY=o.y):(i.tileset.image.texture.scaleX=o.x,i.tileset.image.texture.scaleY=o.y),0!=i.tileset.image.texture.rotation&&(i.tileset.image.texture.rotation=0),0!=i.tileset.image.texture.anchorOffsetX&&(i.tileset.image.texture.anchorOffsetX=0),0!=i.tileset.image.texture.anchorOffsetY&&(i.tileset.image.texture.anchorOffsetY=0)}}else u.image.texture&&(u.image.bitmap.getTexture(l.toString())||(u.image.texture=new e(u.image.bitmap.createTexture(l.toString(),p.x,p.y,p.width,p.height)),n.addChild(u.image.texture)),u.image.texture.x=g.x,u.image.texture.y=g.y,u.image.texture.scaleX=o.x,u.image.texture.scaleY=o.y,u.image.texture.rotation=0,u.image.texture.anchorOffsetX=0,u.image.texture.anchorOffsetY=0,u.image.texture.filters=[h])},i}();t.TiledRendering=i}(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 i=function(){return function(){}}();t.TmxTileOffset=i;var n=function(){return function(){}}();t.TmxTerrain=n}(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 i=function(){return function(){}}();t.TmxAnimationFrame=i}(es||(es={})),function(t){var e=function(){function e(){}return e.decode=function(e,i,n){switch(n=n||"none",i=i||"none"){case"base64":var r=t.Base64Utils.decodeBase64AsArray(e,4);return"none"===n?r:t.Base64Utils.decompress(e,r,n);case"csv":return t.Base64Utils.decodeCSV(e);case"none":for(var o=[],s=0;si;n--)if(t[n]0&&t[r-1]>n;r--)t[r]=t[r-1];t[r]=n}},t.binarySearch=function(t,e){for(var i=0,n=t.length,r=i+n>>1;i=t[r]&&(i=r+1),r=i+n>>1;return t[i]==e?i:-1},t.findElementIndex=function(t,e){for(var i=t.length,n=0;nt[e]&&(e=n);return e},t.getMinElementIndex=function(t){for(var e=0,i=t.length,n=1;n=0;--r)i.unshift(e[r]);return i},t.getDifferAry=function(t,e){t=this.getUniqueAry(t),e=this.getUniqueAry(e);for(var i=t.concat(e),n={},r=[],o=i.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 i=t.length;if(i!=e.length)return!1;for(;i--;)if(t[i]!=e[i])return!1;return!0},t.insert=function(t,e,i){if(!t)return null;var n=t.length;if(e>n&&(e=n),e<0&&(e=0),e==n)t.push(i);else if(0==e)t.unshift(i);else{for(var r=n-1;r>=e;r-=1)t[r+1]=t[r];t[e]=i}return i},t}();!function(t){var e=function(){function t(){}return Object.defineProperty(t,"nativeBase64",{get:function(){return"function"==typeof window.atob},enumerable:!0,configurable:!0}),t.decode=function(t){if(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,""),this.nativeBase64)return window.atob(t);for(var e,i,n,r,o,s,a=[],h=0;h>4,i=(15&r)<<4|(o=this._keyStr.indexOf(t.charAt(h++)))>>2,n=(3&o)<<6|(s=this._keyStr.indexOf(t.charAt(h++))),a.push(String.fromCharCode(e)),64!==o&&a.push(String.fromCharCode(i)),64!==s&&a.push(String.fromCharCode(n));return a=a.join("")},t.encode=function(t){if(t=t.replace(/\r\n/g,"\n"),!this.nativeBase64){for(var e,i,n,r,o,s,a,h=[],c=0;c>2,o=(3&e)<<4|(i=t.charCodeAt(c++))>>4,s=(15&i)<<2|(n=t.charCodeAt(c++))>>6,a=63&n,isNaN(i)?s=a=64:isNaN(n)&&(a=64),h.push(this._keyStr.charAt(r)),h.push(this._keyStr.charAt(o)),h.push(this._keyStr.charAt(s)),h.push(this._keyStr.charAt(a));return h=h.join("")}window.btoa(t)},t.decodeBase64AsArray=function(e,i){i=i||1;var n,r,o,s=t.decode(e),a=new Uint32Array(s.length/i);for(n=0,o=s.length/i;n=0;--r)a[n]+=s.charCodeAt(n*i+r)<<(r<<3);return a},t.decompress=function(t,e,i){throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!")},t.decodeCSV=function(t){for(var e=t.replace("\n","").trim().split(","),i=[],n=0;n>16},set:function(t){this._packedValue=4278255615&this._packedValue|t<<16},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"g",{get:function(){return this._packedValue>>8},set:function(t){this._packedValue=4294902015&this._packedValue|t<<8},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"r",{get:function(){return this._packedValue},set:function(t){this._packedValue=4294967040&this._packedValue|t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"a",{get:function(){return this._packedValue>>24},set:function(t){this._packedValue=16777215&this._packedValue|t<<24},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"packedValue",{get:function(){return this._packedValue},set:function(t){this._packedValue=t},enumerable:!0,configurable:!0}),e.prototype.equals=function(t){return this._packedValue==t._packedValue},e}();t.Color=e}(es||(es={})),function(t){var e=function(){function t(){this.loadedAssets=new Map}return t.prototype.loadRes=function(t,e){var i=this;return void 0===e&&(e=!0),new Promise(function(n,r){var o=i.loadedAssets.get(t);o?n(o):e?RES.getResAsync(t).then(function(e){i.loadedAssets.set(t,e),n(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)}):RES.getResByUrl(t).then(function(e){i.loadedAssets.set(t,e),n(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)})})},t.prototype.dispose=function(){this.loadedAssets.forEach(function(t){var e=t;RES.destroyRes(e)&&e.dispose()}),this.loadedAssets.clear()},t}();t.ContentManager=e}(es||(es={})),function(t){var e=function(){function t(){}return t.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)},t}();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 i=function(){function t(){this._messageTable=new Map}return t.prototype.addObserver=function(t,i,n){var r=this._messageTable.get(t);r||(r=[],this._messageTable.set(t,r)),-1!=r.findIndex(function(t){return t.func==i})&&console.warn("您试图添加相同的观察者两次"),r.push(new e(i,n))},t.prototype.removeObserver=function(t,e){var i=this._messageTable.get(t),n=i.findIndex(function(t){return t.func==e});-1!=n&&i.removeAt(n)},t.prototype.emit=function(t,e){var i=this._messageTable.get(t);if(i)for(var n=i.length-1;n>=0;n--)i[n].func.call(i[n].context,e)},t}();t.Emitter=i}(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 i=[];e--;)i.push(t);return i},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 t(){}return t.warmCache=function(t){if((t-=this._objectQueue.length)>0)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={})),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,i){if(void 0===i&&(i=1),0==i)throw new Error("step 不能为 0");var n=e-t;if(0==n)throw new Error("没有可用的范围("+t+","+e+")");n<0&&(n=t-e);var r=Math.floor((n+i-1)/i);return Math.floor(this.random()*r)*i+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 i=t.length;if(e<=0||i=0;)s=Math.floor(this.random()*i);n.push(t[s]),r.push(s)}return n},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,i){switch(i){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,i){var n=new t.Rectangle(i.x,i.y,0,0),r=new t.Rectangle;return r.x=Math.min(e.x,n.x),r.y=Math.min(e.y,n.y),r.width=Math.max(e.right,n.right)-r.x,r.height=Math.max(e.bottom,r.bottom)-r.y,r},e.getHalfRect=function(e,i){switch(i){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,i,n){switch(void 0===n&&(n=1),i){case t.Edge.top:return new t.Rectangle(e.x,e.y,e.width,n);case t.Edge.bottom:return new t.Rectangle(e.x,e.y+e.height-n,e.width,n);case t.Edge.left:return new t.Rectangle(e.x,e.y,n,e.height);case t.Edge.right:return new t.Rectangle(e.x+e.width-n,e.y,n,e.height)}},e.expandSide=function(e,i,n){switch(n=Math.abs(n),i){case t.Edge.top:e.y-=n,e.height+=n;break;case t.Edge.bottom:e.height+=n;break;case t.Edge.left:e.x-=n,e.width+=n;break;case t.Edge.right:e.width+=n}},e.contract=function(t,e,i){t.x+=e,t.y+=i,t.width-=2*e,t.height-=2*i},e}();t.RectangleExt=e}(es||(es={})),function(t){var e=function(){return function(t){this.value=t}}();t.Ref=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,i,n,r){return!(t.Vector2Ext.cross(t.Vector2.subtract(e,i),t.Vector2.subtract(n,i))<0)&&(!(t.Vector2Ext.cross(t.Vector2.subtract(e,n),t.Vector2.subtract(r,n))<0)&&!(t.Vector2Ext.cross(t.Vector2.subtract(e,r),t.Vector2.subtract(i,r))<0))},e.prototype.triangulate=function(i,n){void 0===n&&(n=!0);var r=i.length;this.initialize(r);for(var o=0,s=0;r>3&&o<500;){o++;var a=!0,h=i[this._triPrev[s]],c=i[s],l=i[this._triNext[s]];if(t.Vector2Ext.isTriangleCCW(h,c,l)){var u=this._triNext[this._triNext[s]];do{if(e.testPointTriangle(i[u],h,c,l)){a=!1;break}u=this._triNext[u]}while(u!=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]),n||this.triangleIndices.reverse()},e.prototype.initialize=function(t){this.triangleIndices.length=0,this._triNext.lengtht.MathHelper.Epsilon?e.divide(new t.Vector2(i)):e.x=e.y=0},e.transformA=function(t,e,i,n,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},i}();t.Layout=i,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,i=function(){function t(t){void 0===t&&(t=n),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=(i=this.getSystemTime())-this._stopSystemTime;this._stopDuration+=e,this._stopSystemTime=void 0}else if(void 0===this._startSystemTime){var i=this.getSystemTime();this._startSystemTime=i,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=i,function(t){t.IDLE="IDLE",t.RUNNING="RUNNING",t.STOPPED="STOPPED"}(e||(e={})),t.setDefaultSystemTimeGetter=function(t){void 0===t&&(t=Date.now),n=t};var n=Date.now}(stopwatch||(stopwatch={})),function(t){var e=function(){function e(){this.showLog=!1,this.markers=[],this.stopwacth=new stopwatch.Stopwatch,this._markerNameToIdMap=new Map,this._rectShape1=new egret.Shape,this._rectShape2=new egret.Shape,this._rectShape3=new egret.Shape,this._rectShape4=new egret.Shape,this._rectShape5=new egret.Shape,this._rectShape6=new egret.Shape,this._logs=new Array(2);for(var e=0;e=e.logSnapDuration&&(l.logs[n].snapMin=l.logs[n].min,l.logs[n].snapMax=l.logs[n].max,l.logs[n].snapAvg=l.logs[n].avg,l.logs[n].samples=0)):(l.logs[n].min=h,l.logs[n].max=h,l.logs[n].avg=h,l.logs[n].initialized=!0)}o.markCount=r.nestCount,o.nestCount=r.nestCount}this.stopwacth.reset(),this.stopwacth.start()}},e.prototype.beginMark=function(t,i,n){if(void 0===n&&(n=0),n<0||n>=e.maxBars)throw new Error("barIndex argument out of range");var r=this._curLog.bars[n];if(r.markCount>=e.maxSamples)throw new Error("exceeded sample count. either set larger number to timeruler.maxsaple or lower sample count");if(r.nestCount>=e.maxNestCall)throw new Error("exceeded nest count. either set larger number to timeruler.maxnestcall or lower nest calls");var o=this._markerNameToIdMap.get(t);isNaN(o)&&(o=this.markers.length,this._markerNameToIdMap.set(t,o)),r.markerNests[r.nestCount++]=r.markCount,r.markers[r.markCount].markerId=o,r.markers[r.markCount].color=i,r.markers[r.markCount].beginTime=this.stopwacth.getTime(),r.markers[r.markCount].endTime=-1},e.prototype.endMark=function(t,i){if(void 0===i&&(i=0),i<0||i>=e.maxBars)throw new Error("barIndex argument out of range");var n=this._curLog.bars[i];if(n.nestCount<=0)throw new Error("call beginMark method before calling endMark method");var r=this._markerNameToIdMap.get(t);if(isNaN(r))throw new Error("Marker "+t+" is not registered. Make sure you specifed same name as you used for beginMark method");var o=n.markerNests[--n.nestCount];if(n.markers[o].markerId!=r)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).");n.markers[o].endTime=this.stopwacth.getTime()},e.prototype.getAverageTime=function(t,i){if(t<0||t>=e.maxBars)throw new Error("barIndex argument out of range");var n=0,r=this._markerNameToIdMap.get(i);return r&&(n=this.markers[r].logs[t].avg),n},e.prototype.resetLog=function(){this.markers.forEach(function(t){for(var e=0;e0&&(r+=e.barHeight+2*e.barPadding,o=Math.max(o,t.markers[t.markCount-1].endTime))});var s=this.sampleFrames*(1/60*1e3);this._frameAdjust=o>s?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,o/(1/60*1e3)+1),this._frameAdjust=0);var a=n/s,h=i.y-(r-e.barHeight),c=h,l=new t.Rectangle(i.x,c,n,r);this._rectShape1.graphics.clear(),this._rectShape1.graphics.beginFill(0,128/255),this._rectShape1.graphics.drawRect(l.x,l.y,l.width,l.height),this._rectShape1.graphics.endFill(),l.height=e.barHeight,this._rectShape2.graphics.clear();for(var u=0,p=this._prevLog.bars;u0)for(var f=0;f0&&this.setpreviousTouchState(this._gameTouchs[0]),e},enumerable:!0,configurable:!0}),i.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())},i.update=function(){KeyboardUtils.update();for(var t=0;t0,this._willRepeat||(this.isRepeating=!1)},i.prototype.update=function(){this._bufferCounter-=t.Time.unscaledDeltaTime,this.isRepeating=!1;for(var e=!1,i=0;i0||this.isRepeating)return!0;for(var t=0,e=this.nodes;ta||i[c].height>a)throw new Error("一个纹理的大小比图集的大小大");h.push(new t.Rectangle(0,0,i[c].width,i[c].height))}for(;h.length>0;){var l=new egret.RenderTexture,u=new t.RectanglePacker(a,a,1);for(c=0;c0){for(var p=new t.IntegerRectangle,d=[],f=[],g=[],y=[],m=0;m0;)this.freeRectangle(this._insertedRectangles.pop());for(;this._freeAreas.length>0;)this.freeRectangle(this._freeAreas.pop());for(this._width=t,this._height=e,this._packedWidth=0,this._packedHeight=0,this._freeAreas.push(this.allocateRectangle(0,0,this._width,this._height));this._insertedRectangles.length>0;)this.freeSize(this._insertList.pop());this._padding=i},e.prototype.insertRectangle=function(t,e,i){var n=this.allocateSize(t,e,i);this._insertList.push(n)},e.prototype.packRectangles=function(t){for(void 0===t&&(t=!0),t&&this._insertList.sort(function(t,e){return t.width-e.width});this._insertList.length>0;){var e=this._insertList.pop(),i=e.width,n=e.height,r=this.getFreeAreaIndex(i,n);if(r>=0){var o=this._freeAreas[r],s=this.allocateRectangle(o.x,o.y,i,n);for(s.id=e.id,this.generateNewFreeAreas(s,this._freeAreas,this._newFreeAreas);this._newFreeAreas.length>0;)this._freeAreas.push(this._newFreeAreas.pop());this._insertedRectangles.push(s),s.right>this._packedWidth&&(this._packedWidth=s.right),s.bottom>this._packedHeight&&(this._packedHeight=s.bottom)}this.freeSize(e)}return this.rectangleCount},e.prototype.getRectangle=function(t,e){var i=this._insertedRectangles[t];return e.x=i.x,e.y=i.y,e.width=i.width,e.height=i.height,e},e.prototype.getRectangleId=function(t){return this._insertedRectangles[t].id},e.prototype.generateNewFreeAreas=function(t,e,i){var n=t.x,r=t.y,o=t.right+1+this._padding,s=t.bottom+1+this._padding,a=null;0==this._padding&&(a=t);for(var h=e.length-1;h>=0;h--){var c=e[h];if(!(n>=c.right||o<=c.x||r>=c.bottom||s<=c.y)){null==a&&(a=this.allocateRectangle(t.x,t.y,t.width+this._padding,t.height+this._padding)),this.generateDividedAreas(a,c,i);var l=e.pop();h=0;e--)for(var i=t[e],n=t.length-1;n>=0;n--)if(e!=n){var r=t[n];if(i.x>=r.x&&i.y>=r.y&&i.right<=r.right&&i.bottom<=r.bottom){this.freeRectangle(i);var o=t.pop();e0&&(i.push(this.allocateRectangle(t.right,e.y,r,e.height)),n++);var o=t.x-e.x;o>0&&(i.push(this.allocateRectangle(e.x,e.y,o,e.height)),n++);var s=e.bottom-t.bottom;s>0&&(i.push(this.allocateRectangle(e.x,t.bottom,e.width,s)),n++);var a=t.y-e.y;a>0&&(i.push(this.allocateRectangle(e.x,e.y,e.width,a)),n++),0==n&&(t.width=0;s--){var a=this._freeAreas[s];if(a.x0){var r=this._sortableSizeStack.pop();return r.width=e,r.height=i,r.id=n,r}return new t.SortableSize(e,i,n)},e.prototype.freeSize=function(t){this._sortableSizeStack.push(t)},e.prototype.allocateRectangle=function(e,i,n,r){if(this._rectangleStack.length>0){var o=this._rectangleStack.pop();return o.x=e,o.y=i,o.width=n,o.height=r,o.right=e+n,o.bottom=i+r,o}return new t.IntegerRectangle(e,i,n,r)},e.prototype.freeRectangle=function(t){this._rectangleStack.push(t)},e}();t.RectanglePacker=e}(es||(es={})),function(t){var e=function(){return function(t,e,i){this.width=t,this.height=e,this.id=i}}();t.SortableSize=e}(es||(es={})),function(t){var e=function(){return function(t){this.assets=t}}();t.TextureAssets=e;var i=function(){return function(){}}();t.TextureAsset=i}(es||(es={})),function(t){var e=function(){return function(t,e){this.texture=t,this.id=e}}();t.TextureToPack=e}(es||(es={})),function(t){var e=function(){function e(){this._timeInSeconds=0,this._repeats=!1,this._isDone=!1,this._elapsedTime=0}return e.prototype.getContext=function(){return this.context},e.prototype.reset=function(){this._elapsedTime=0},e.prototype.stop=function(){this._isDone=!0},e.prototype.tick=function(){return!this._isDone&&this._elapsedTime>this._timeInSeconds&&(this._elapsedTime-=this._timeInSeconds,this._onTime(this),this._isDone||this._repeats||(this._isDone=!0)),this._elapsedTime+=t.Time.deltaTime,this._isDone},e.prototype.initialize=function(t,e,i,n){this._timeInSeconds=t,this._repeats=e,this.context=i,this._onTime=n},e.prototype.unload=function(){this.context=null,this._onTime=null},e}();t.Timer=e}(es||(es={})),function(t){var e=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t._timers=[],t}return __extends(i,e),i.prototype.update=function(){for(var t=this._timers.length-1;t>=0;t--)this._timers[t].tick()&&(this._timers[t].unload(),this._timers.removeAt(t))},i.prototype.schedule=function(e,i,n,r){var o=new t.Timer;return o.initialize(e,i,n,r),this._timers.push(o),o},i}(t.GlobalManager);t.TimerManager=e}(es||(es={})); \ No newline at end of file diff --git a/demo/manifest.json b/demo/manifest.json index 96ddfde6..98368b7c 100644 --- a/demo/manifest.json +++ b/demo/manifest.json @@ -17,7 +17,7 @@ "bin-debug/SampleHelpers/SampleScene.js", "bin-debug/Scenes/Ninja Adventure/ProjectileHitDetector.js", "bin-debug/UI/loading/LoadingView.js", - "bin-debug/Scenes/LineCasting/LineCastingScene.js", + "bin-debug/Scenes/Ninja Adventure/CameraBounds.js", "bin-debug/Fgui/loading/loadingBinder.js", "bin-debug/Fgui/loading/UI_View_loading.js", "bin-debug/Fgui/sc/scBinder.js", @@ -28,7 +28,9 @@ "bin-debug/Scenes/Animated Tiles/AnimatedTilesScene.js", "bin-debug/Scenes/Empty Scene/BasicScene.js", "bin-debug/Scenes/LineCasting/LineCaster.js", + "bin-debug/Scenes/LineCasting/LineCastingScene.js", "bin-debug/Main.js", + "bin-debug/Scenes/Ninja Adventure/FireballProjectileController.js", "bin-debug/Scenes/Ninja Adventure/Ninja.js", "bin-debug/Scenes/Ninja Adventure/NinjaAdventureScene.js", "bin-debug/ThemeAdapter.js", diff --git a/demo/resource/default.res.json b/demo/resource/default.res.json index e1f582e3..8ea95f5a 100644 --- a/demo/resource/default.res.json +++ b/demo/resource/default.res.json @@ -1,7 +1,7 @@ { "groups": [ { - "keys": "bg_png,bgNorm_png,moon_png,orange_png,moonNorm_png,orangeNorm_png,orthogonal-outside_json", + "keys": "bg_png,bgNorm_png,moon_png,orange_png,moonNorm_png,orangeNorm_png,tiledMap_json,orthogonal-outside_json,tilemap_json,plume_png", "name": "preload" }, { @@ -52,11 +52,6 @@ "type": "image", "name": "orangeNorm_png" }, - { - "url": "preload/orthogonal-outside.json", - "type": "json", - "name": "orthogonal-outside_json" - }, { "url": "characters/1.png", "type": "image", @@ -101,6 +96,26 @@ "url": "fgui/loading.zip", "type": "bin", "name": "loading" + }, + { + "url": "preload/caveman/tiledMap.json", + "type": "json", + "name": "tiledMap_json" + }, + { + "url": "preload/orthogonal/orthogonal-outside.json", + "type": "json", + "name": "orthogonal-outside_json" + }, + { + "url": "preload/ninja/tilemap.json", + "type": "json", + "name": "tilemap_json" + }, + { + "url": "preload/plume.png", + "type": "image", + "name": "plume_png" } ] } \ No newline at end of file diff --git a/demo/resource/preload/caveman/caveman.png b/demo/resource/preload/caveman/caveman.png new file mode 100644 index 00000000..0dd80b88 Binary files /dev/null and b/demo/resource/preload/caveman/caveman.png differ diff --git a/demo/resource/preload/caveman/tiledMap.json b/demo/resource/preload/caveman/tiledMap.json new file mode 100644 index 00000000..7bf28972 --- /dev/null +++ b/demo/resource/preload/caveman/tiledMap.json @@ -0,0 +1,193 @@ +{ "height":30, + "infinite":false, + "layers":[ + { + "data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2147483652, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2147483652, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2147483652, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2147483652, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 0, 0, 0, 0, 0, 0, 2147483652, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + "height":30, + "id":1, + "name":"main", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":40, + "x":0, + "y":0 + }, + { + "draworder":"topdown", + "id":2, + "name":"objects", + "objects":[ + { + "height":14.8796, + "id":6, + "name":"spawn", + "rotation":0, + "type":"", + "visible":true, + "width":14.8796, + "x":48.4346, + "y":240.503 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }], + "nextlayerid":3, + "nextobjectid":7, + "orientation":"orthogonal", + "renderorder":"right-down", + "tiledversion":"1.2.1", + "tileheight":16, + "tilesets":[ + { + "columns":2, + "firstgid":1, + "image":"tileset.png", + "imageheight":32, + "imagewidth":32, + "margin":0, + "name":"tileset", + "spacing":0, + "tilecount":4, + "tileheight":16, + "tiles":[ + { + "id":0, + "objectgroup": + { + "draworder":"index", + "name":"", + "objects":[ + { + "height":16, + "id":1, + "name":"", + "rotation":0, + "type":"", + "visible":true, + "width":16, + "x":0, + "y":0 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + } + }, + { + "id":2, + "objectgroup": + { + "draworder":"index", + "name":"", + "objects":[ + { + "height":3, + "id":1, + "name":"", + "rotation":0, + "type":"", + "visible":true, + "width":16, + "x":0, + "y":0 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }, + "properties":[ + { + "name":"filewtf", + "type":"file", + "value":"" + }, + { + "name":"floaty", + "type":"float", + "value":0 + }, + { + "name":"inty", + "type":"int", + "value":0 + }, + { + "name":"nez:isOneWayPlatform", + "type":"bool", + "value":true + }, + { + "name":"poop", + "type":"color", + "value":"" + }] + }, + { + "id":3, + "objectgroup": + { + "draworder":"index", + "name":"", + "objects":[ + { + "height":0, + "id":1, + "name":"", + "polygon":[ + { + "x":0, + "y":0 + }, + { + "x":0, + "y":16 + }, + { + "x":16, + "y":16 + }], + "rotation":0, + "type":"", + "visible":true, + "width":0, + "x":0, + "y":0 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }, + "properties":[ + { + "name":"nez:isSlope", + "type":"bool", + "value":true + }, + { + "name":"nez:slopeTopLeft", + "type":"int", + "value":0 + }, + { + "name":"nez:slopeTopRight", + "type":"int", + "value":15 + }] + }], + "tilewidth":16 + }], + "tilewidth":16, + "type":"map", + "version":1.2, + "width":40 +} \ No newline at end of file diff --git a/demo/resource/preload/caveman/tileset.png b/demo/resource/preload/caveman/tileset.png new file mode 100644 index 00000000..b83d1d89 Binary files /dev/null and b/demo/resource/preload/caveman/tileset.png differ diff --git a/demo/resource/preload/ninja/tilemap.json b/demo/resource/preload/ninja/tilemap.json new file mode 100644 index 00000000..19b786a6 --- /dev/null +++ b/demo/resource/preload/ninja/tilemap.json @@ -0,0 +1,370 @@ +{ "height":42, + "infinite":false, + "layers":[ + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 848, 850, 850, 850, 850, 850, 850, 850, 850, 851, 852, 852, 852, 852, 852, 853, 355, 383, 411, 384, 355, 383, 383, 356, 383, 412, 383, 384, 412, 412, 384, 384, 412, 383, 383, 412, 328, 412, 411, 355, 0, 0, 876, 878, 878, 878, 878, 878, 878, 878, 878, 879, 906, 906, 906, 906, 906, 881, 356, 411, 328, 384, 327, 328, 384, 355, 383, 383, 327, 356, 412, 412, 384, 356, 327, 328, 383, 356, 356, 356, 356, 356, 0, 0, 904, 906, 906, 906, 906, 906, 906, 906, 906, 907, 906, 906, 906, 906, 906, 909, 355, 384, 398, 400, 327, 383, 330, 327, 399, 328, 398, 330, 399, 384, 399, 327, 398, 356, 398, 327, 399, 328, 383, 411, 0, 0, 932, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 937, 411, 384, 399, 327, 427, 356, 328, 399, 328, 356, 427, 398, 398, 328, 327, 327, 330, 412, 399, 366, 400, 355, 384, 356, 0, 0, 904, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 909, 383, 384, 427, 427, 327, 327, 327, 330, 399, 356, 398, 427, 398, 328, 328, 427, 330, 356, 398, 399, 327, 412, 356, 356, 0, 0, 904, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 909, 356, 355, 327, 399, 330, 327, 398, 328, 328, 328, 427, 399, 327, 356, 327, 328, 330, 412, 427, 398, 328, 411, 356, 411, 0, 0, 904, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 909, 411, 327, 399, 330, 399, 356, 327, 398, 398, 355, 328, 327, 327, 412, 400, 398, 398, 411, 328, 330, 399, 327, 328, 383, 0, 0, 904, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 909, 356, 327, 412, 327, 383, 383, 328, 412, 383, 356, 412, 355, 412, 328, 356, 384, 383, 355, 328, 411, 355, 355, 383, 356, 0, 0, 904, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 906, 909, 355, 355, 398, 399, 398, 412, 399, 328, 398, 355, 327, 327, 330, 383, 399, 327, 330, 411, 328, 398, 330, 355, 356, 328, 0, 0, 960, 961, 961, 961, 961, 961, 961, 961, 962, 906, 964, 961, 961, 961, 961, 965, 327, 328, 330, 328, 330, 355, 399, 327, 399, 383, 427, 399, 328, 356, 330, 366, 398, 384, 427, 328, 398, 411, 328, 355, 0, 0, 411, 327, 411, 384, 355, 384, 383, 328, 904, 906, 909, 383, 412, 328, 383, 411, 328, 411, 327, 427, 399, 411, 400, 427, 330, 412, 427, 398, 328, 356, 398, 328, 327, 412, 399, 427, 398, 327, 411, 383, 0, 0, 356, 328, 412, 412, 383, 412, 356, 411, 904, 906, 909, 384, 411, 328, 356, 411, 356, 411, 328, 400, 327, 355, 327, 399, 399, 328, 427, 328, 327, 327, 398, 399, 328, 384, 330, 328, 327, 328, 355, 355, 0, 0, 411, 327, 412, 411, 384, 355, 411, 356, 904, 906, 909, 327, 384, 356, 412, 412, 328, 356, 399, 330, 328, 411, 327, 398, 399, 383, 327, 330, 427, 356, 427, 399, 328, 328, 398, 328, 327, 327, 355, 383, 0, 0, 327, 327, 355, 328, 411, 356, 328, 411, 384, 383, 328, 328, 384, 383, 328, 384, 328, 327, 383, 412, 383, 383, 411, 411, 327, 328, 411, 412, 384, 327, 412, 328, 328, 356, 411, 327, 355, 412, 384, 411, 0, 0, 384, 383, 411, 383, 384, 328, 355, 411, 355, 328, 328, 411, 412, 411, 384, 411, 411, 412, 328, 328, 384, 328, 327, 327, 356, 383, 411, 384, 412, 411, 412, 356, 383, 328, 384, 384, 328, 327, 383, 383, 0, 0, 383, 412, 411, 328, 355, 355, 328, 383, 412, 355, 412, 412, 328, 356, 327, 355, 328, 411, 356, 383, 412, 356, 412, 383, 328, 356, 355, 412, 327, 411, 384, 356, 383, 356, 355, 384, 384, 383, 328, 355, 0, 0, 328, 384, 384, 355, 356, 356, 328, 356, 384, 355, 356, 328, 355, 384, 327, 355, 383, 328, 411, 328, 384, 383, 384, 327, 411, 411, 411, 384, 327, 328, 328, 412, 327, 327, 412, 356, 356, 328, 411, 411, 0, 0, 328, 327, 356, 356, 383, 356, 328, 328, 355, 412, 383, 355, 356, 411, 355, 328, 356, 356, 356, 412, 327, 411, 384, 327, 412, 328, 356, 328, 327, 327, 355, 328, 327, 327, 383, 383, 327, 412, 328, 356, 0, 0, 384, 327, 328, 328, 327, 383, 327, 328, 327, 411, 356, 412, 384, 384, 328, 327, 412, 328, 328, 383, 356, 355, 356, 327, 383, 356, 356, 383, 411, 355, 384, 328, 411, 384, 384, 328, 356, 355, 355, 327, 0, 0, 355, 383, 356, 384, 412, 327, 356, 411, 328, 412, 383, 327, 356, 355, 355, 327, 383, 383, 412, 383, 384, 383, 327, 355, 383, 412, 327, 412, 355, 356, 355, 412, 383, 412, 411, 411, 327, 412, 328, 328, 0, 0, 411, 384, 411, 412, 328, 355, 328, 327, 383, 412, 355, 412, 411, 355, 356, 327, 383, 328, 411, 356, 355, 384, 356, 411, 412, 411, 327, 383, 356, 356, 355, 327, 383, 383, 356, 327, 327, 383, 383, 356, 0, 0, 356, 328, 384, 356, 384, 412, 383, 412, 384, 328, 328, 383, 327, 383, 328, 384, 412, 355, 355, 412, 412, 411, 327, 383, 327, 412, 328, 411, 356, 328, 355, 384, 355, 411, 384, 384, 383, 356, 327, 412, 0, 0, 383, 383, 384, 355, 412, 412, 355, 412, 384, 411, 412, 327, 328, 328, 411, 328, 355, 411, 327, 411, 356, 356, 327, 411, 355, 383, 383, 411, 355, 356, 411, 412, 328, 411, 384, 356, 356, 384, 411, 411, 0, 0, 327, 411, 328, 412, 384, 411, 412, 356, 383, 412, 327, 328, 328, 355, 355, 356, 412, 355, 384, 412, 383, 327, 356, 383, 355, 384, 383, 412, 327, 412, 384, 383, 328, 327, 412, 328, 383, 412, 355, 355, 0, 0, 383, 327, 384, 355, 355, 411, 327, 384, 356, 328, 411, 384, 412, 384, 383, 384, 383, 356, 327, 384, 383, 356, 412, 355, 355, 383, 384, 328, 327, 383, 328, 384, 328, 327, 383, 412, 412, 356, 355, 355, 0, 0, 412, 411, 411, 328, 411, 327, 327, 383, 328, 383, 356, 383, 327, 411, 328, 384, 356, 356, 356, 356, 327, 412, 355, 356, 411, 384, 328, 355, 411, 327, 328, 384, 383, 412, 355, 384, 383, 383, 411, 355, 0, 0, 327, 356, 355, 411, 327, 355, 356, 412, 328, 355, 383, 328, 327, 383, 411, 383, 327, 411, 328, 328, 412, 327, 411, 356, 383, 411, 328, 356, 411, 356, 328, 384, 355, 328, 411, 384, 384, 327, 383, 356, 0, 0, 383, 384, 328, 356, 355, 384, 411, 355, 384, 384, 328, 355, 411, 355, 328, 328, 411, 412, 411, 384, 327, 412, 384, 327, 384, 384, 356, 384, 327, 327, 327, 412, 328, 327, 384, 327, 327, 411, 328, 412, 0, 0, 383, 328, 384, 327, 412, 356, 412, 412, 383, 355, 355, 328, 383, 412, 355, 412, 412, 328, 356, 327, 412, 327, 411, 411, 411, 327, 412, 356, 327, 412, 412, 412, 384, 384, 412, 411, 411, 356, 327, 328, 0, 0, 411, 355, 384, 356, 411, 384, 328, 328, 355, 356, 356, 328, 356, 384, 355, 356, 328, 355, 384, 327, 412, 356, 327, 327, 328, 328, 356, 383, 327, 383, 383, 383, 384, 327, 327, 412, 327, 412, 383, 356, 0, 0, 328, 328, 412, 328, 355, 356, 327, 411, 384, 383, 356, 328, 328, 355, 412, 383, 355, 356, 411, 355, 355, 328, 327, 412, 384, 411, 384, 356, 384, 412, 356, 327, 328, 383, 327, 383, 412, 412, 356, 327, 0, 0, 383, 327, 327, 356, 327, 356, 411, 327, 327, 327, 383, 327, 328, 327, 411, 356, 412, 384, 384, 328, 383, 411, 328, 411, 383, 355, 383, 412, 383, 328, 356, 355, 412, 411, 327, 383, 383, 383, 384, 412, 0, 0, 411, 328, 383, 355, 355, 327, 412, 356, 355, 412, 327, 356, 411, 328, 412, 383, 327, 356, 355, 355, 384, 384, 328, 411, 412, 383, 384, 383, 384, 412, 355, 328, 328, 411, 356, 328, 383, 355, 411, 355, 0, 0, 328, 383, 328, 327, 411, 383, 383, 384, 355, 328, 355, 328, 327, 383, 412, 355, 412, 411, 355, 356, 412, 384, 355, 355, 355, 355, 328, 412, 383, 384, 384, 384, 356, 384, 327, 412, 412, 383, 412, 383, 0, 0, 384, 384, 384, 411, 384, 328, 384, 411, 327, 384, 412, 383, 412, 384, 328, 328, 383, 327, 383, 328, 355, 384, 356, 328, 328, 355, 383, 383, 384, 411, 412, 384, 384, 328, 384, 327, 355, 384, 411, 412, 0, 0, 327, 356, 384, 327, 383, 328, 327, 328, 328, 412, 412, 355, 412, 384, 411, 412, 327, 328, 328, 411, 327, 411, 355, 356, 412, 412, 383, 383, 383, 327, 356, 355, 412, 355, 412, 355, 327, 411, 384, 328, 0, 0, 412, 411, 384, 356, 383, 356, 356, 328, 355, 384, 411, 412, 356, 383, 412, 327, 328, 328, 355, 355, 355, 327, 327, 327, 411, 411, 383, 328, 327, 412, 412, 411, 327, 327, 328, 412, 327, 327, 411, 383, 0, 0, 411, 412, 328, 412, 412, 356, 328, 383, 327, 356, 328, 328, 327, 327, 355, 327, 412, 328, 412, 384, 328, 411, 383, 411, 327, 412, 411, 411, 356, 356, 412, 327, 327, 327, 412, 355, 355, 412, 384, 328, 0, 0, 355, 355, 383, 411, 383, 355, 355, 327, 327, 412, 383, 356, 327, 411, 412, 356, 411, 412, 412, 411, 327, 327, 411, 328, 411, 328, 384, 411, 384, 355, 355, 328, 411, 412, 327, 411, 356, 383, 412, 355, 0, 0, 411, 327, 383, 412, 327, 383, 327, 411, 383, 327, 384, 356, 411, 328, 328, 328, 328, 412, 411, 356, 328, 411, 327, 411, 328, 328, 384, 384, 356, 327, 355, 411, 383, 355, 383, 412, 411, 355, 412, 356, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":42, + "id":1, + "name":"tiles", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":42, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 362, 363, 364, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 362, 363, 363, 363, 389, 391, 388, 363, 363, 363, 363, 364, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 390, 391, 391, 391, 391, 391, 391, 391, 391, 391, 391, 392, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 390, 391, 391, 391, 391, 391, 391, 391, 391, 391, 391, 388, 364, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 390, 391, 391, 391, 391, 391, 391, 391, 391, 391, 391, 391, 392, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 390, 391, 391, 391, 391, 391, 391, 391, 391, 391, 391, 391, 392, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 390, 391, 391, 391, 391, 391, 391, 391, 391, 391, 391, 391, 392, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 390, 391, 391, 391, 391, 391, 391, 391, 391, 391, 391, 391, 392, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 362, 363, 389, 391, 391, 391, 391, 391, 391, 391, 391, 391, 391, 360, 420, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 390, 391, 391, 391, 360, 419, 419, 419, 419, 419, 419, 419, 419, 420, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 418, 419, 419, 419, 420, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 441, 442, 442, 442, 442, 442, 442, 442, 442, 442, 442, 443, 0, 0, 0, 446, 447, 448, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 441, 468, 470, 470, 470, 470, 470, 470, 470, 470, 470, 470, 467, 443, 0, 0, 502, 445, 472, 447, 448, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 469, 470, 470, 470, 470, 470, 470, 470, 470, 470, 470, 470, 470, 471, 0, 0, 0, 502, 503, 445, 472, 448, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 469, 470, 470, 470, 470, 470, 470, 470, 470, 470, 470, 470, 470, 471, 0, 0, 0, 0, 0, 474, 475, 472, 448, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 497, 440, 470, 470, 470, 470, 470, 470, 470, 470, 470, 470, 439, 499, 0, 0, 0, 0, 446, 473, 475, 444, 504, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 497, 498, 498, 498, 498, 498, 498, 498, 498, 498, 498, 499, 0, 0, 0, 446, 447, 473, 444, 503, 504, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 446, 473, 475, 444, 504, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 502, 503, 503, 504, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":42, + "id":2, + "name":"terrain", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":42, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 393, 394, 395, 0, 393, 394, 395, 0, 393, 394, 395, 0, 393, 394, 395, 0, 393, 394, 395, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 421, 422, 423, 0, 421, 422, 423, 0, 421, 422, 423, 0, 421, 422, 423, 0, 421, 422, 423, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 449, 450, 451, 0, 449, 450, 451, 0, 449, 450, 451, 0, 449, 450, 451, 0, 449, 450, 451, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 393, 394, 395, 0, 393, 394, 395, 0, 393, 394, 395, 0, 393, 394, 395, 0, 393, 394, 395, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 421, 422, 423, 0, 421, 422, 423, 0, 421, 422, 423, 0, 421, 422, 423, 0, 421, 422, 423, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 449, 450, 451, 0, 449, 450, 451, 0, 449, 450, 451, 0, 449, 450, 451, 0, 449, 450, 451, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 481, 482, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 481, 482, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 481, 482, 0, 0, 0, 0, 0, 0, 0, 0, 481, 482, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 481, 482, 0, 0, 0, 481, 482, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 42, 43, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 69, 70, 71, 72, 0, 0, 0, 0, 0, 0, 0, 0, 37, 38, 39, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 66, 67, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 113, 114, 115, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 186, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 214, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 321, 322, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 145, 0, 0, 242, 0, 146, 147, 148, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":42, + "id":3, + "name":"details", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":42, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 337, 338, 339, 0, 337, 338, 339, 0, 337, 338, 339, 0, 337, 338, 339, 0, 337, 338, 339, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 365, 366, 367, 0, 365, 366, 367, 0, 365, 366, 367, 0, 365, 366, 367, 0, 365, 366, 367, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 337, 338, 339, 0, 337, 338, 339, 0, 337, 338, 339, 0, 337, 338, 339, 0, 337, 338, 339, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 365, 366, 367, 0, 365, 366, 367, 0, 365, 366, 367, 0, 365, 366, 367, 0, 365, 366, 367, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 453, 454, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 453, 454, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 453, 454, 0, 0, 0, 0, 0, 0, 0, 0, 453, 454, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 453, 454, 0, 0, 0, 453, 454, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 127, 128, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 86, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 89, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 293, 294, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 117, 0, 0, 0, 0, 118, 119, 120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":42, + "id":4, + "name":"above-details", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":42, + "x":0, + "y":0 + }, + { + "data":[300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 301, 302, 303, 300, 300, 300, 300, 300, 300, 300, 301, 187, 1073, 1073, 1073, 1073, 1073, 1073, 1073, 1073, 1073, 1073, 1073, 1073, 1073, 1073, 1073, 1073, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 187, 187, 1073, 0, 0, 0, 0, 0, 0, 0, 0, 1073, 0, 0, 0, 0, 0, 1073, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 187, 187, 1073, 0, 0, 0, 0, 0, 0, 0, 0, 1073, 0, 0, 0, 0, 0, 1073, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 187, 187, 1073, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1073, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 187, 187, 1073, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1073, 0, 0, 928, 898, 899, 0, 898, 926, 927, 0, 898, 899, 899, 0, 928, 898, 899, 0, 928, 898, 899, 0, 0, 0, 187, 187, 1073, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1073, 0, 0, 928, 926, 927, 0, 898, 926, 927, 0, 898, 898, 899, 0, 928, 926, 927, 0, 928, 926, 927, 0, 0, 0, 187, 187, 1073, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1073, 0, 0, 928, 928, 928, 0, 926, 926, 927, 0, 926, 926, 927, 0, 928, 928, 928, 0, 928, 928, 928, 0, 0, 0, 187, 187, 1073, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1073, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 187, 187, 1073, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1073, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 187, 187, 1073, 1073, 1073, 1073, 1073, 1073, 1073, 1073, 1073, 0, 1073, 1073, 1073, 1073, 1073, 1073, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 187, 187, 0, 0, 0, 0, 0, 0, 0, 0, 1073, 0, 1073, 0, 0, 0, 0, 0, 0, 0, 928, 928, 928, 0, 898, 898, 899, 0, 928, 898, 899, 0, 928, 898, 899, 0, 928, 898, 899, 0, 0, 0, 215, 187, 0, 0, 0, 0, 0, 0, 0, 0, 1073, 0, 1073, 0, 0, 0, 0, 0, 0, 0, 928, 928, 928, 0, 898, 898, 899, 0, 928, 926, 927, 0, 928, 926, 927, 0, 928, 926, 927, 0, 0, 0, 243, 187, 0, 0, 0, 0, 0, 0, 0, 0, 1073, 0, 1073, 0, 0, 0, 0, 0, 0, 0, 928, 928, 928, 0, 926, 926, 927, 0, 928, 928, 928, 0, 928, 928, 928, 0, 928, 928, 928, 0, 0, 0, 271, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 299, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 327, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 355, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 187, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 927, 927, 0, 0, 0, 0, 0, 187, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 927, 927, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 187, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 187, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 927, 927, 0, 0, 0, 0, 0, 0, 0, 0, 927, 927, 0, 0, 187, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 187, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 187, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 187, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 927, 927, 0, 0, 0, 927, 927, 0, 0, 0, 0, 0, 187, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 187, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 187, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 187, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 187, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 187, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 187, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 187, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 215, 215, 215, 0, 0, 187, 215, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 215, 215, 0, 0, 215, 243, 0, 0, 0, 0, 215, 215, 215, 215, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 243, 271, 0, 0, 0, 0, 215, 0, 215, 215, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 215, 0, 0, 0, 271, 299, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 299, 327, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 215, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 327, 355, 0, 0, 215, 0, 0, 0, 0, 215, 0, 215, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 355, 383, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 383, 300, 301, 302, 303, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 301, 302, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 301, 302, 300, 300, 300, 301, 302, 303, 411], + "height":42, + "id":5, + "name":"collision", + "opacity":1, + "type":"tilelayer", + "visible":false, + "width":42, + "x":0, + "y":0 + }], + "nextlayerid":6, + "nextobjectid":1, + "orientation":"orthogonal", + "renderorder":"right-down", + "tiledversion":"1.2.1", + "tileheight":16, + "tilesets":[ + { + "columns":28, + "firstgid":1, + "image":"tileset.png", + "imageheight":640, + "imagewidth":448, + "margin":0, + "name":"tileset", + "spacing":0, + "terrains":[ + { + "name":"snow", + "tile":553 + }, + { + "name":"dirt", + "tile":385 + }, + { + "name":"dirt temple", + "tile":390 + }, + { + "name":"farm", + "tile":469 + }, + { + "name":"dark farm", + "tile":474 + }], + "tilecount":1120, + "tileheight":16, + "tiles":[ + { + "id":354, + "terrain":[1, 1, 1, -1] + }, + { + "id":355, + "terrain":[1, 1, -1, 1] + }, + { + "id":356, + "terrain":[-1, -1, -1, 1] + }, + { + "id":357, + "terrain":[-1, -1, 1, 1] + }, + { + "id":358, + "terrain":[-1, -1, 1, -1] + }, + { + "id":359, + "terrain":[2, 2, 2, -1] + }, + { + "id":360, + "terrain":[2, 2, -1, 2] + }, + { + "id":361, + "terrain":[-1, -1, -1, 2] + }, + { + "id":362, + "terrain":[-1, -1, 2, 2] + }, + { + "id":363, + "terrain":[-1, -1, 2, -1] + }, + { + "id":382, + "terrain":[1, -1, 1, 1] + }, + { + "id":383, + "terrain":[-1, 1, 1, 1] + }, + { + "id":384, + "terrain":[-1, 1, -1, 1] + }, + { + "id":385, + "terrain":[1, 1, 1, 1] + }, + { + "id":386, + "terrain":[1, -1, 1, -1] + }, + { + "id":387, + "terrain":[2, -1, 2, 2] + }, + { + "id":388, + "terrain":[-1, 2, 2, 2] + }, + { + "id":389, + "terrain":[-1, 2, -1, 2] + }, + { + "id":390, + "terrain":[2, 2, 2, 2] + }, + { + "id":391, + "terrain":[2, -1, 2, -1] + }, + { + "id":412, + "terrain":[-1, 1, -1, -1] + }, + { + "id":413, + "terrain":[1, 1, -1, -1] + }, + { + "id":414, + "terrain":[1, -1, -1, -1] + }, + { + "id":417, + "terrain":[-1, 2, -1, -1] + }, + { + "id":418, + "terrain":[2, 2, -1, -1] + }, + { + "id":419, + "terrain":[2, -1, -1, -1] + }, + { + "id":438, + "terrain":[3, 3, 3, -1] + }, + { + "id":439, + "terrain":[3, 3, -1, 3] + }, + { + "id":440, + "terrain":[-1, -1, -1, 3] + }, + { + "id":441, + "terrain":[-1, -1, 3, 3] + }, + { + "id":442, + "terrain":[-1, -1, 3, -1] + }, + { + "id":443, + "terrain":[4, 4, 4, -1] + }, + { + "id":444, + "terrain":[4, 4, -1, 4] + }, + { + "id":445, + "terrain":[-1, -1, -1, 4] + }, + { + "id":446, + "terrain":[-1, -1, 4, 4] + }, + { + "id":447, + "terrain":[-1, -1, 4, -1] + }, + { + "id":466, + "terrain":[3, -1, 3, 3] + }, + { + "id":467, + "terrain":[-1, 3, 3, 3] + }, + { + "id":468, + "terrain":[-1, 3, -1, 3] + }, + { + "id":469, + "terrain":[3, 3, 3, 3] + }, + { + "id":470, + "terrain":[3, -1, 3, -1] + }, + { + "id":471, + "terrain":[4, -1, 4, 4] + }, + { + "id":472, + "terrain":[-1, 4, 4, 4] + }, + { + "id":473, + "terrain":[-1, 4, -1, 4] + }, + { + "id":474, + "terrain":[4, 4, 4, 4] + }, + { + "id":475, + "terrain":[4, -1, 4, -1] + }, + { + "id":496, + "terrain":[-1, 3, -1, -1] + }, + { + "id":497, + "terrain":[3, 3, -1, -1] + }, + { + "id":498, + "terrain":[3, -1, -1, -1] + }, + { + "id":501, + "terrain":[-1, 4, -1, -1] + }, + { + "id":502, + "terrain":[4, 4, -1, -1] + }, + { + "id":503, + "terrain":[4, -1, -1, -1] + }, + { + "id":522, + "terrain":[0, 0, 0, -1] + }, + { + "id":523, + "terrain":[0, 0, -1, 0] + }, + { + "id":524, + "terrain":[-1, -1, -1, 0] + }, + { + "id":525, + "terrain":[-1, -1, 0, 0] + }, + { + "id":526, + "terrain":[-1, -1, 0, -1] + }, + { + "id":550, + "terrain":[0, -1, 0, 0] + }, + { + "id":551, + "terrain":[-1, 0, 0, 0] + }, + { + "id":552, + "terrain":[-1, 0, -1, 0] + }, + { + "id":553, + "terrain":[0, 0, 0, 0] + }, + { + "id":554, + "terrain":[0, -1, 0, -1] + }, + { + "id":580, + "terrain":[-1, 0, -1, -1] + }, + { + "id":581, + "terrain":[0, 0, -1, -1] + }, + { + "id":582, + "terrain":[0, -1, -1, -1] + }], + "tilewidth":16 + }], + "tilewidth":16, + "type":"map", + "version":1.2, + "width":42 +} \ No newline at end of file diff --git a/demo/resource/preload/ninja/tileset.png b/demo/resource/preload/ninja/tileset.png new file mode 100644 index 00000000..1379fb4a Binary files /dev/null and b/demo/resource/preload/ninja/tileset.png differ diff --git a/demo/resource/preload/buch-outdoor.png b/demo/resource/preload/orthogonal/buch-outdoor.png similarity index 100% rename from demo/resource/preload/buch-outdoor.png rename to demo/resource/preload/orthogonal/buch-outdoor.png diff --git a/demo/resource/preload/orthogonal-outside.json b/demo/resource/preload/orthogonal/orthogonal-outside.json similarity index 100% rename from demo/resource/preload/orthogonal-outside.json rename to demo/resource/preload/orthogonal/orthogonal-outside.json diff --git a/demo/resource/preload/plume.png b/demo/resource/preload/plume.png new file mode 100644 index 00000000..fe8aee47 Binary files /dev/null and b/demo/resource/preload/plume.png differ diff --git a/demo/src/Scenes/LineCasting/LineCaster.ts b/demo/src/Scenes/LineCasting/LineCaster.ts index 60b248e4..56b441f3 100644 --- a/demo/src/Scenes/LineCasting/LineCaster.ts +++ b/demo/src/Scenes/LineCasting/LineCaster.ts @@ -38,22 +38,6 @@ module samples { displayContainer.addChild(this._lineShape); } - public onAddedToEntity(): void { - KeyboardUtils.registerKey(KeyboardUtils.SPACE, this.spaceDown, this, KeyboardUtils.TYPE_KEY_DOWN); - } - - public onRemovedFromEntity(): void { - KeyboardUtils.unregisterKey(KeyboardUtils.SPACE, KeyboardUtils.TYPE_KEY_DOWN); - } - - private spaceDown(){ - let hit = Physics.linecast(this._lastPosition, this.transform.position); - if (hit.collider){ - this._collisionPosition = hit.point; - } - } - - public render(camera: es.Camera): any { this._pixelShape1.graphics.clear(); this._pixelShape1.graphics.beginFill(0xffff00); diff --git a/demo/src/Scenes/Ninja Adventure/CameraBounds.ts b/demo/src/Scenes/Ninja Adventure/CameraBounds.ts new file mode 100644 index 00000000..182c6401 --- /dev/null +++ b/demo/src/Scenes/Ninja Adventure/CameraBounds.ts @@ -0,0 +1,37 @@ +module samples { + import Component = es.Component; + import Vector2 = es.Vector2; + + export class CameraBounds extends Component { + public min: Vector2; + public max: Vector2; + + constructor(min: Vector2 = Vector2.zero, max: Vector2 = Vector2.zero){ + super(); + + this.min = min; + this.max = max; + this.setUpdateOrder(Number.MAX_VALUE); + } + + public onAddedToEntity(): void { + this.entity.updateOrder = Number.MAX_VALUE; + } + + public update(): void { + let cameraBounds = this.entity.scene.camera.bounds; + + if (cameraBounds.top < this.min.y) + this.entity.scene.camera.position.add(new Vector2(0, this.min.y - cameraBounds.top)); + + if (cameraBounds.left < this.min.x) + this.entity.scene.camera.position.add(new Vector2(this.min.x - cameraBounds.left, 0)); + + if (cameraBounds.bottom > this.max.y) + this.entity.scene.camera.position.add(new Vector2(0, this.max.y - cameraBounds.bottom)); + + if (cameraBounds.right > this.max.x) + this.entity.scene.camera.position.add(new Vector2(this.max.x - cameraBounds.right, 0)); + } + } +} \ No newline at end of file diff --git a/demo/src/Scenes/Ninja Adventure/FireballProjectileController.ts b/demo/src/Scenes/Ninja Adventure/FireballProjectileController.ts new file mode 100644 index 00000000..5e53a7f6 --- /dev/null +++ b/demo/src/Scenes/Ninja Adventure/FireballProjectileController.ts @@ -0,0 +1,28 @@ +module samples { + import Component = es.Component; + import Vector2 = es.Vector2; + import ProjectileMover = es.ProjectileMover; + import Time = es.Time; + + /** + * 移动一个投射器并在它击中任何东西时摧毁它 + */ + export class FireballProjectileController extends Component { + public velocity: Vector2; + public _mover: ProjectileMover; + + constructor(velocity: Vector2){ + super(); + this.velocity = velocity; + } + + public onAddedToEntity(): void { + this._mover = this.entity.getComponent(ProjectileMover); + } + + public update(): void { + if (this._mover.move(Vector2.multiply(this.velocity, new Vector2(Time.deltaTime)))) + this.entity.destroy(); + } + } +} \ No newline at end of file diff --git a/demo/src/Scenes/Ninja Adventure/Ninja.ts b/demo/src/Scenes/Ninja Adventure/Ninja.ts index b23de2c6..1d1944a3 100644 --- a/demo/src/Scenes/Ninja Adventure/Ninja.ts +++ b/demo/src/Scenes/Ninja Adventure/Ninja.ts @@ -1,50 +1,145 @@ module samples { import SpriteAnimator = es.SpriteAnimator; import Mover = es.Mover; + import VirtualButton = es.VirtualButton; + import VirtualIntegerAxis = es.VirtualIntegerAxis; + import KeyboardKey = es.KeyboardKey; + import KeyboardKeys = es.KeyboardKeys; + import OverlapBehavior = es.OverlapBehavior; + import Vector2 = es.Vector2; + import Time = es.Time; + import Keys = es.Keys; + import CollisionResult = es.CollisionResult; + import SubpixelVector2 = es.SubpixelVector2; + import ITriggerListener = es.ITriggerListener; - export class Ninja extends es.Component { + export class Ninja extends es.Component implements ITriggerListener{ public _animator: SpriteAnimator; + public _subpixelV2: SubpixelVector2 = new SubpixelVector2(); public _mover: Mover; + public _moveSpeed = 100; + public _projectileVelocity: Vector2 = new Vector2(175); + + public _fireInput: VirtualButton; + public _xAxisInput: VirtualIntegerAxis; + public _yAxisInput: VirtualIntegerAxis; public onAddedToEntity(): void { let characterPng = RandomUtils.randint(1, 6); - this.entity.scene.content.loadRes(`${characterPng}_png`).then(texture => { - let sprites = es.Sprite.spritesFromAtlas(texture, 16, 16); + let texture = RES.getRes(`${characterPng}_png`); + let sprites = es.Sprite.spritesFromAtlas(texture, 16, 16); - this._mover = this.entity.addComponent(new Mover()); - this._animator = this.entity.addComponent(new SpriteAnimator()); + this._mover = this.entity.addComponent(new Mover()); + this._animator = this.entity.addComponent(new SpriteAnimator()); - this._animator.addAnimation("walkLeft", new es.SpriteAnimation([ - sprites[2], - sprites[6], - sprites[10], - sprites[14] - ], 4)); + this._animator.addAnimation("walkLeft", new es.SpriteAnimation([ + sprites[2], + sprites[6], + sprites[10], + sprites[14] + ], 4)); - this._animator.addAnimation("walkRight", new es.SpriteAnimation([ - sprites[3], - sprites[7], - sprites[11], - sprites[15] - ], 4)); + this._animator.addAnimation("walkRight", new es.SpriteAnimation([ + sprites[3], + sprites[7], + sprites[11], + sprites[15] + ], 4)); - this._animator.addAnimation("walkDown", new es.SpriteAnimation([ - sprites[0], - sprites[4], - sprites[8], - sprites[12] - ], 4)); + this._animator.addAnimation("walkDown", new es.SpriteAnimation([ + sprites[0], + sprites[4], + sprites[8], + sprites[12] + ], 4)); - this._animator.addAnimation("walkUp", new es.SpriteAnimation([ - sprites[1], - sprites[5], - sprites[9], - sprites[13] - ], 4)); + this._animator.addAnimation("walkUp", new es.SpriteAnimation([ + sprites[1], + sprites[5], + sprites[9], + sprites[13] + ], 4)); - this._animator.play("walkDown"); - }); + this.setupInput(); + } + + public onRemovedFromEntity(): void { + this._fireInput.deregister(); + } + + public setupInput(){ + // 设置输入射击一个火球。我们允许在键盘z上使用 + this._fireInput = new VirtualButton(); + this._fireInput.nodes.push(new KeyboardKey(Keys.z)); + + this._xAxisInput = new VirtualIntegerAxis(); + this._xAxisInput.nodes.push(new KeyboardKeys(OverlapBehavior.takeNewer, Keys.left, Keys.right)); + + this._yAxisInput = new VirtualIntegerAxis(); + this._yAxisInput.nodes.push(new KeyboardKeys(OverlapBehavior.takeNewer, Keys.up, Keys.down)); + } + + public update(): void { + let moveDir = new Vector2(this._xAxisInput.value, this._yAxisInput.value); + let animation = "walkDown"; + + if (moveDir.x < 0) + animation = "walkLeft"; + else if(moveDir.x > 0) + animation = "walkRight"; + + if (moveDir.y < 0) + animation = "walkUp"; + else if(moveDir.y > 0) + animation = "walkDown"; + + if (!moveDir.equals(Vector2.zero)){ + if (!this._animator.isAnimationActive(animation)) + this._animator.play(animation); + else + this._animator.unPause(); + + let movement = Vector2.multiply(moveDir, new Vector2(this._moveSpeed * Time.deltaTime)); + let res: CollisionResult = new CollisionResult(); + this._mover.calculateMovement(movement, res); + this._subpixelV2.update(movement); + this._mover.applyMovement(movement); + }else{ + this._animator.pause(); + } + + if (this._fireInput.isPressed){ + let dir = Vector2.zero; + switch (this._animator.currentAnimationName) { + case "walkUp": + dir.y = -1; + break; + case "walkDown": + dir.y = 1; + break; + case "walkRight": + dir.x = 1; + break; + case "walkLeft": + dir.x = -1; + break; + default: + dir = new Vector2(1, 0); + break; + } + + let ninjaScene = this.entity.scene as NinjaAdventureScene; + ninjaScene.createProjectiles(this.entity.transform.position, Vector2.multiply(this._projectileVelocity, dir)); + } + } + + public onTriggerEnter(other: es.Collider, local: es.Collider): any { + console.log(`triggerEnter: ${other.entity.name}`); + } + + public onTriggerExit(other: es.Collider, local: es.Collider): any { + console.log(`triggerExit: ${other.entity.name}`); } } } \ No newline at end of file diff --git a/demo/src/Scenes/Ninja Adventure/NinjaAdventureScene.ts b/demo/src/Scenes/Ninja Adventure/NinjaAdventureScene.ts index f654781f..35279895 100644 --- a/demo/src/Scenes/Ninja Adventure/NinjaAdventureScene.ts +++ b/demo/src/Scenes/Ninja Adventure/NinjaAdventureScene.ts @@ -4,13 +4,38 @@ module samples { import SpriteRenderer = es.SpriteRenderer; import ProjectileHitDetector = es.ProjectileHitDetector; import FollowCamera = es.FollowCamera; + import TiledMapLoader = es.TiledMapLoader; + import TiledMapRenderer = es.TiledMapRenderer; + import Vector2 = es.Vector2; + import ProjectileMover = es.ProjectileMover; + import Sprite = es.Sprite; + import SpriteAnimator = es.SpriteAnimator; + import SpriteAnimation = es.SpriteAnimation; export class NinjaAdventureScene extends SampleScene { public async onStart() { super.onStart(); + let tiledEntity = this.createEntity("tiled-map-entity"); + TiledMapLoader.loadTmxMap(new es.TmxMap(), "tilemap_json").then(map => { + let tiledMapRenderer = tiledEntity.addComponent(new TiledMapRenderer(map, "collision")); + tiledMapRenderer.setLayersToRender("tiles", "terrain", "details"); + + tiledMapRenderer.renderLayer = 10; + + let tiledMapDetailsComp = tiledEntity.addComponent(new TiledMapRenderer(map)); + tiledMapRenderer.setLayerToRender("above-details"); + tiledMapRenderer.renderLayer = -1; + + let topLeft = new Vector2(map.tileWidth, map.tileWidth); + let bottomRight = new Vector2(map.tileWidth * (map.width - 1), + map.tileWidth * (map.height - 1)); + tiledEntity.addComponent(new CameraBounds(topLeft, bottomRight)); + }); + + let playerEntity = this.createEntity("player"); - playerEntity.position = new es.Vector2(256, 224); + playerEntity.position = new es.Vector2(256 / 2, 224 / 2); playerEntity.addComponent(new Ninja()); let collider = playerEntity.addComponent(new CircleCollider()); @@ -21,20 +46,39 @@ module samples { this.camera.entity.addComponent(new FollowCamera(playerEntity)); - this.content.loadRes("moon_png").then(moonTexture => { - let moonEntity = this.createEntity("moon"); - moonEntity.position = new es.Vector2(412, 460); - moonEntity.addComponent(new SpriteRenderer(moonTexture)); - moonEntity.addComponent(new ProjectileHitDetector()); - moonEntity.addComponent(new CircleCollider()); - }); + let moonTexture = RES.getRes("moon_png"); + let moonEntity = this.createEntity("moon"); + moonEntity.position = new es.Vector2(412, 460); + moonEntity.addComponent(new SpriteRenderer(moonTexture)); + moonEntity.addComponent(new ProjectileHitDetector()); + moonEntity.addComponent(new CircleCollider()); } - public update(){ - super.update(); + /** + * 创建抛射物并使其运动 + * @param position + * @param velocity + */ + public createProjectiles(position: Vector2, velocity: Vector2) { + // 创建一个实体来存放投射程序及其逻辑 + let entity = this.createEntity("projectile"); + entity.position = position; + entity.addComponent(new ProjectileMover()); + entity.addComponent(new FireballProjectileController(velocity)); - this.findEntity("player").position.x -= es.Time.deltaTime * 10; - this.findEntity("player").position.y -= es.Time.deltaTime * 10; + let collider = entity.addComponent(new CircleCollider()); + Flags.setFlagExclusive(collider.collidesWithLayers, 0); + Flags.setFlagExclusive(collider.physicsLayer, 1); + + let texture = RES.getRes("plume_png"); + let sprites = Sprite.spritesFromAtlas(texture, 16, 16); + let animator = entity.addComponent(new SpriteAnimator()); + animator.renderLayer = 1; + + animator.addAnimation("default", new SpriteAnimation(sprites)); + animator.play("default"); + + return entity; } } } \ No newline at end of file diff --git a/source/bin/framework.d.ts b/source/bin/framework.d.ts index cfdf66e7..3e948d6b 100644 --- a/source/bin/framework.d.ts +++ b/source/bin/framework.d.ts @@ -285,7 +285,6 @@ declare module es { update(): void; setEnabled(isEnabled: boolean): this; setUpdateOrder(updateOrder: number): this; - clone(): Component; } } declare module es { @@ -334,7 +333,6 @@ declare module es { destroy(): void; detachFromScene(): void; attachToScene(newScene: Scene): void; - clone(position?: Vector2): Entity; onAddedToScene(): void; onRemovedFromScene(): void; update(): void; @@ -349,7 +347,6 @@ declare module es { removeAllComponents(): void; compareTo(other: Entity): number; toString(): string; - protected copyFrom(entity: Entity): void; } } declare module es { @@ -691,7 +688,7 @@ declare module es { class SpriteAnimation { readonly sprites: Sprite[]; readonly frameRate: number; - constructor(sprites: Sprite[], frameRate: number); + constructor(sprites: Sprite[], frameRate?: number); } } declare module es { @@ -759,7 +756,7 @@ declare module es { declare module es { class TiledMapRenderer extends RenderableComponent { tiledMap: TmxMap; - physicsLayer: number; + physicsLayer: Ref; layerIndicesToRender: number[]; private toContainer; readonly width: number; @@ -808,11 +805,10 @@ declare module es { } declare module es { abstract class Collider extends Component { - debug: any; shape: Shape; isTrigger: boolean; - physicsLayer: number; - collidesWithLayers: number; + physicsLayer: Ref; + collidesWithLayers: Ref; shouldColliderScaleAndRotateWithTransform: boolean; registeredPhysicsBounds: Rectangle; _localOffsetLength: number; @@ -837,7 +833,6 @@ declare module es { unregisterColliderWithPhysicsSystem(): void; overlaps(other: Collider): boolean; collidesWith(collider: Collider, motion: Vector2, result: CollisionResult): boolean; - clone(): Component; } } declare module es { @@ -846,10 +841,9 @@ declare module es { polygonShape: egret.Shape; pixelShape1: egret.Shape; pixelShape2: egret.Shape; - constructor(); + constructor(x?: number, y?: number, width?: number, height?: number); width: number; height: number; - createBoxRect(x: number, y: number, width: number, height: number): BoxCollider; setSize(width: number, height: number): this; setWidth(width: number): BoxCollider; setHeight(height: number): void; @@ -1303,10 +1297,10 @@ declare module es { class Flags { static isFlagSet(self: number, flag: number): boolean; static isUnshiftedFlagSet(self: number, flag: number): boolean; - static setFlagExclusive(self: number, flag: number): number; - static setFlag(self: number, flag: number): number; - static unsetFlag(self: number, flag: number): number; - static invertFlags(self: number): number; + static setFlagExclusive(self: Ref, flag: number): void; + static setFlag(self: Ref, flag: number): void; + static unsetFlag(self: Ref, flag: number): void; + static invertFlags(self: Ref): void; } } declare module es { @@ -1422,12 +1416,12 @@ declare module es { static isLineToLine(a1: Vector2, a2: Vector2, b1: Vector2, b2: Vector2): boolean; static lineToLineIntersection(a1: Vector2, a2: Vector2, b1: Vector2, b2: Vector2): Vector2; static closestPointOnLine(lineA: Vector2, lineB: Vector2, closestTo: Vector2): Vector2; - static isCircleToCircle(circleCenter1: Vector2, circleRadius1: number, circleCenter2: Vector2, circleRadius2: number): boolean; - static isCircleToLine(circleCenter: Vector2, radius: number, lineFrom: Vector2, lineTo: Vector2): boolean; - static isCircleToPoint(circleCenter: Vector2, radius: number, point: Vector2): boolean; - static isRectToCircle(rect: egret.Rectangle, cPosition: Vector2, cRadius: number): boolean; - static isRectToLine(rect: Rectangle, lineFrom: Vector2, lineTo: Vector2): boolean; - static isRectToPoint(rX: number, rY: number, rW: number, rH: number, point: Vector2): boolean; + static circleToCircle(circleCenter1: Vector2, circleRadius1: number, circleCenter2: Vector2, circleRadius2: number): boolean; + static circleToLine(circleCenter: Vector2, radius: number, lineFrom: Vector2, lineTo: Vector2): boolean; + static circleToPoint(circleCenter: Vector2, radius: number, point: Vector2): boolean; + static rectToCircle(rect: egret.Rectangle, cPosition: Vector2, cRadius: number): boolean; + static rectToLine(rect: Rectangle, lineFrom: Vector2, lineTo: Vector2): boolean; + static rectToPoint(rX: number, rY: number, rW: number, rH: number, point: Vector2): boolean; static getSector(rX: number, rY: number, rW: number, rH: number, point: Vector2): PointSectors; } } @@ -1486,7 +1480,6 @@ declare module es { abstract collidesWithLine(start: Vector2, end: Vector2, hit: RaycastHit): boolean; abstract containsPoint(point: Vector2): any; abstract pointCollidesWithShape(point: Vector2, result: CollisionResult): boolean; - clone(): Shape; } } declare module es { @@ -1508,7 +1501,7 @@ declare module es { static findPolygonCenter(points: Vector2[]): Vector2; static getFarthestPointInDirection(points: Vector2[], direction: Vector2): Vector2; static getClosestPointOnPolygonToPoint(points: Vector2[], point: Vector2, distanceSquared: Ref, edgeNormal: Vector2): Vector2; - static rotatePolygonVerts(radians: number, originalPoints: Vector2[], rotatedPoints: any): void; + static rotatePolygonVerts(radians: number, originalPoints: Vector2[], rotatedPoints: Vector2[]): void; recalculateBounds(collider: Collider): void; overlaps(other: Shape): any; collidesWithShape(other: Shape, result: CollisionResult): boolean; @@ -2051,122 +2044,6 @@ declare module es { update(): void; } } -declare module es { - class TouchState { - x: number; - y: number; - touchPoint: number; - touchDown: boolean; - readonly position: Vector2; - reset(): void; - } - class Input { - private static _init; - private static _previousTouchState; - private static _resolutionOffset; - private static _touchIndex; - private static _gameTouchs; - static readonly gameTouchs: TouchState[]; - private static _resolutionScale; - static readonly resolutionScale: Vector2; - private static _totalTouchCount; - static readonly totalTouchCount: number; - static readonly touchPosition: Vector2; - static maxSupportedTouch: number; - static readonly touchPositionDelta: Vector2; - static initialize(): void; - static scaledPosition(position: Vector2): Vector2; - private static initTouchCache; - private static touchBegin; - private static touchMove; - private static touchEnd; - private static setpreviousTouchState; - } -} -declare class KeyboardUtils { - static TYPE_KEY_DOWN: number; - static TYPE_KEY_UP: number; - static A: string; - static B: string; - static C: string; - static D: string; - static E: string; - static F: string; - static G: string; - static H: string; - static I: string; - static J: string; - static K: string; - static L: string; - static M: string; - static N: string; - static O: string; - static P: string; - static Q: string; - static R: string; - static S: string; - static T: string; - static U: string; - static V: string; - static W: string; - static X: string; - static Y: string; - static Z: string; - static ESC: string; - static F1: string; - static F2: string; - static F3: string; - static F4: string; - static F5: string; - static F6: string; - static F7: string; - static F8: string; - static F9: string; - static F10: string; - static F11: string; - static F12: string; - static NUM_1: string; - static NUM_2: string; - static NUM_3: string; - static NUM_4: string; - static NUM_5: string; - static NUM_6: string; - static NUM_7: string; - static NUM_8: string; - static NUM_9: string; - static NUM_0: string; - static TAB: string; - static CTRL: string; - static ALT: string; - static SHIFT: string; - static CAPS_LOCK: string; - static ENTER: string; - static SPACE: string; - static BACK_SPACE: string; - static INSERT: string; - static DELETE: string; - static HOME: string; - static END: string; - static PAGE_UP: string; - static PAGE_DOWN: string; - static LEFT: string; - static RIGHT: string; - static UP: string; - static DOWN: string; - static PAUSE_BREAK: string; - static NUM_LOCK: string; - static SCROLL_LOCK: string; - static WINDOWS: string; - private static keyDownDict; - private static keyUpDict; - static init(): void; - static registerKey(key: string, fun: Function, thisObj: any, type?: number, ...args: any[]): void; - static unregisterKey(key: string, type?: number): void; - static destroy(): void; - private static onKeyDonwHander; - private static onKeyUpHander; - private static keyCodeToString; -} declare module es { class ListPool { private static readonly _objectQueue; @@ -2386,6 +2263,250 @@ declare module es { initialized: boolean; } } +declare module es { + class TouchState { + x: number; + y: number; + touchPoint: number; + touchDown: boolean; + readonly position: Vector2; + reset(): void; + } + class Input { + private static _init; + private static _previousTouchState; + private static _resolutionOffset; + private static _touchIndex; + private static _gameTouchs; + static readonly gameTouchs: TouchState[]; + private static _resolutionScale; + static readonly resolutionScale: Vector2; + private static _totalTouchCount; + static readonly totalTouchCount: number; + static readonly touchPosition: Vector2; + static _virtualInputs: VirtualInput[]; + static maxSupportedTouch: number; + static readonly touchPositionDelta: Vector2; + static initialize(): void; + static update(): void; + static scaledPosition(position: Vector2): Vector2; + static isKeyPressed(key: Keys): boolean; + static isKeyPressedBoth(keyA: Keys, keyB: Keys): boolean; + static isKeyDown(key: Keys): boolean; + static isKeyDownBoth(keyA: Keys, keyB: Keys): boolean; + static isKeyReleased(key: Keys): boolean; + static isKeyReleasedBoth(keyA: Keys, keyB: Keys): boolean; + private static initTouchCache; + private static touchBegin; + private static touchMove; + private static touchEnd; + private static setpreviousTouchState; + } +} +import Keys = es.Keys; +declare class KeyboardUtils { + static currentKeys: Keys[]; + static previousKeys: Keys[]; + private static keyStatusKeys; + static init(): void; + static update(): void; + static destroy(): void; + private static onKeyDownHandler; + private static onKeyUpHandler; +} +declare module es { + enum Keys { + none = 0, + back = 8, + tab = 9, + enter = 13, + capsLock = 20, + escape = 27, + space = 32, + pageUp = 33, + pageDown = 34, + end = 35, + home = 36, + left = 37, + up = 38, + right = 39, + down = 40, + select = 41, + print = 42, + execute = 43, + printScreen = 44, + insert = 45, + delete = 46, + help = 47, + d0 = 48, + d1 = 49, + d2 = 50, + d3 = 51, + d4 = 52, + d5 = 53, + d6 = 54, + d7 = 55, + d8 = 56, + d9 = 57, + a = 65, + b = 66, + c = 67, + d = 68, + e = 69, + f = 70, + g = 71, + h = 72, + i = 73, + j = 74, + k = 75, + l = 76, + m = 77, + n = 78, + o = 79, + p = 80, + q = 81, + r = 82, + s = 83, + t = 84, + u = 85, + v = 86, + w = 87, + x = 88, + y = 89, + z = 90, + leftWindows = 91, + rightWindows = 92, + apps = 93, + sleep = 95, + numPad0 = 96, + numPad1 = 97, + numPad2 = 98, + numPad3 = 99, + numPad4 = 100, + numPad5 = 101, + numPad6 = 102, + numPad7 = 103, + numPad8 = 104, + numPad9 = 105, + multiply = 106, + add = 107, + seperator = 108, + subtract = 109, + decimal = 110, + divide = 111, + f1 = 112, + f2 = 113, + f3 = 114, + f4 = 115, + f5 = 116, + f6 = 117, + f7 = 118, + f8 = 119, + f9 = 120, + f10 = 121, + f11 = 122, + f12 = 123, + f13 = 124, + f14 = 125, + f15 = 126, + f16 = 127, + f17 = 128, + f18 = 129, + f19 = 130, + f20 = 131, + f21 = 132, + f22 = 133, + f23 = 134, + f24 = 135, + numLock = 144, + scroll = 145, + leftShift = 160, + rightShift = 161, + leftControl = 162, + rightControl = 163, + leftAlt = 164, + rightAlt = 165, + browserBack = 166, + browserForward = 167 + } +} +declare module es { + enum OverlapBehavior { + cancelOut = 0, + takeOlder = 1, + takeNewer = 2 + } + abstract class VirtualInput { + protected constructor(); + deregister(): void; + abstract update(): any; + } + abstract class VirtualInputNode { + update(): void; + } +} +declare module es { + class VirtualIntegerAxis extends VirtualInput { + nodes: VirtualAxisNode[]; + readonly value: number; + constructor(...nodes: VirtualAxisNode[]); + update(): void; + addKeyboardKeys(overlapBehavior: OverlapBehavior, negative: Keys, positive: Keys): this; + } + abstract class VirtualAxisNode extends VirtualInputNode { + abstract value: number; + } +} +declare module es { + class VirtualAxis extends VirtualInput { + nodes: VirtualAxisNode[]; + readonly value: number; + constructor(...nodes: VirtualAxisNode[]); + update(): void; + } + class KeyboardKeys extends VirtualAxisNode { + overlapBehavior: OverlapBehavior; + positive: Keys; + negative: Keys; + _value: number; + _turned: boolean; + constructor(overlapBehavior: OverlapBehavior, negative: Keys, positive: Keys); + update(): void; + readonly value: number; + } +} +declare module es { + class VirtualButton extends VirtualInput { + nodes: Node[]; + bufferTime: number; + firstRepeatTime: number; + mutiRepeatTime: number; + isRepeating: boolean; + _bufferCounter: number; + _repeatCounter: number; + _willRepeat: boolean; + constructor(bufferTime?: number, ...nodes: Node[]); + setRepeat(firstRepeatTime: number, mutiRepeatTime?: number): void; + update(): void; + readonly isDown: boolean; + readonly isPressed: boolean; + readonly isReleased: boolean; + consumeBuffer(): void; + addKeyboardKey(key: Keys): VirtualButton; + } + abstract class Node extends VirtualInputNode { + abstract isDown: boolean; + abstract isPressed: boolean; + abstract isReleased: boolean; + } + class KeyboardKey extends Node { + key: Keys; + constructor(key: Keys); + readonly isDown: boolean; + readonly isPressed: boolean; + readonly isReleased: boolean; + } +} declare module es { class AssetPacker { protected itemsToRaster: TextureToPack[]; diff --git a/source/bin/framework.js b/source/bin/framework.js index 1261c84d..d5a7d6fe 100644 --- a/source/bin/framework.js +++ b/source/bin/framework.js @@ -1096,6 +1096,7 @@ var es; case 0: this.startDebugUpdate(); es.Time.update(egret.getTimer()); + es.Input.update(); if (!this._scene) return [3, 2]; for (i = this._globalManagers.length - 1; i >= 0; i--) { if (this._globalManagers[i].enabled) @@ -1311,11 +1312,6 @@ var es; } return this; }; - Component.prototype.clone = function () { - var component = ObjectUtils.clone(this); - component.entity = null; - return component; - }; return Component; }(egret.HashObject)); es.Component = Component; @@ -1554,13 +1550,6 @@ var es; this.transform.getChild(i).entity.attachToScene(newScene); } }; - Entity.prototype.clone = function (position) { - if (position === void 0) { position = new es.Vector2(); } - var entity = new Entity(this.name + "(clone)"); - entity.copyFrom(this); - entity.transform.position = position; - return entity; - }; Entity.prototype.onAddedToScene = function () { }; Entity.prototype.onRemovedFromScene = function () { @@ -1620,24 +1609,6 @@ var es; Entity.prototype.toString = function () { return "[Entity: name: " + this.name + ", tag: " + this.tag + ", enabled: " + this.enabled + ", depth: " + this.updateOrder + "]"; }; - Entity.prototype.copyFrom = function (entity) { - this.tag = entity.tag; - this.updateInterval = entity.updateInterval; - this.updateOrder = entity.updateOrder; - this.enabled = entity.enabled; - this.transform.scale = entity.transform.scale; - this.transform.rotation = entity.transform.rotation; - for (var i = 0; i < entity.components.count; i++) - this.addComponent(entity.components.buffer[i].clone()); - for (var i = 0; i < entity.components._componentsToAdd.length; i++) - this.addComponent(entity.components._componentsToAdd[i].clone()); - for (var i = 0; i < entity.transform.childCount; i++) { - var child = entity.transform.getChild(i).entity; - var childClone = child.clone(); - childClone.transform.copyFrom(child.transform); - childClone.transform.parent = this.transform; - } - }; Entity._idGenerator = 0; return Entity; }()); @@ -3264,6 +3235,7 @@ var es; (function (es) { var SpriteAnimation = (function () { function SpriteAnimation(sprites, frameRate) { + if (frameRate === void 0) { frameRate = 10; } this.sprites = sprites; this.frameRate = frameRate; } @@ -3461,13 +3433,13 @@ var es; if (collisionLayerName === void 0) { collisionLayerName = null; } if (shouldCreateColliders === void 0) { shouldCreateColliders = true; } var _this = _super.call(this) || this; - _this.physicsLayer = 1 << 0; + _this.physicsLayer = new es.Ref(1 << 0); _this.toContainer = false; _this.tiledMap = tiledMap; _this._shouldCreateColliders = shouldCreateColliders; _this.displayObject = new egret.DisplayObjectContainer(); if (collisionLayerName) { - _this.collisionLayer = tiledMap.tileLayers[collisionLayerName]; + _this.collisionLayer = tiledMap.tileLayers.find(function (layer) { return layer.name == collisionLayerName; }); } return _this; } @@ -3554,7 +3526,7 @@ var es; var collisionRects = this.collisionLayer.getCollisionRectangles(); this._colliders = []; for (var i = 0; i < collisionRects.length; i++) { - var collider = new es.BoxCollider().createBoxRect(collisionRects[i].x + this._localOffset.x, collisionRects[i].y + this._localOffset.y, collisionRects[i].width, collisionRects[i].height); + var collider = new es.BoxCollider(collisionRects[i].x + this._localOffset.x, collisionRects[i].y + this._localOffset.y, collisionRects[i].width, collisionRects[i].height); collider.physicsLayer = this.physicsLayer; collider.entity = this.entity; this._colliders[i] = collider; @@ -3596,7 +3568,7 @@ var es; var bounds = collider.bounds; bounds.x += motion.x; bounds.y += motion.y; - var neighbors = es.Physics.boxcastBroadphaseExcludingSelf(collider, bounds, collider.collidesWithLayers); + var neighbors = es.Physics.boxcastBroadphaseExcludingSelf(collider, bounds, collider.collidesWithLayers.value); for (var j = 0; j < neighbors.length; j++) { var neighbor = neighbors[j]; if (neighbor.isTrigger) @@ -3645,10 +3617,10 @@ var es; if (!this._collider) return false; var didCollide = false; - this.entity.position = es.Vector2.add(this.entity.position, motion); - var neighbors = es.Physics.boxcastBroadphase(this._collider.bounds, this._collider.collidesWithLayers); - for (var i = 0; i < neighbors.length; i++) { - var neighbor = neighbors[i]; + this.entity.position.add(motion); + var neighbors = es.Physics.boxcastBroadphase(this._collider.bounds, this._collider.collidesWithLayers.value); + for (var _i = 0, neighbors_1 = neighbors; _i < neighbors_1.length; _i++) { + var neighbor = neighbors_1[_i]; if (this._collider.overlaps(neighbor) && neighbor.enabled) { didCollide = true; this.notifyTriggerListeners(this._collider, neighbor); @@ -3678,8 +3650,8 @@ var es; __extends(Collider, _super); function Collider() { var _this = _super !== null && _super.apply(this, arguments) || this; - _this.physicsLayer = 1 << 0; - _this.collidesWithLayers = es.Physics.allLayers; + _this.physicsLayer = new es.Ref(1 << 0); + _this.collidesWithLayers = new es.Ref(es.Physics.allLayers); _this.shouldColliderScaleAndRotateWithTransform = true; _this.registeredPhysicsBounds = new es.Rectangle(); _this._isPositionDirty = true; @@ -3748,8 +3720,8 @@ var es; var renderable = this.entity.getComponent(es.RenderableComponent); if (renderable) { var renderableBounds = renderable.bounds; - var width = renderableBounds.width / this.entity.scale.x; - var height = renderableBounds.height / this.entity.scale.y; + var width = renderableBounds.width / this.entity.transform.scale.x; + var height = renderableBounds.height / this.entity.transform.scale.y; if (this instanceof es.CircleCollider) { this.radius = Math.max(width, height) * 0.5; } @@ -3809,20 +3781,13 @@ var es; }; Collider.prototype.collidesWith = function (collider, motion, result) { var oldPosition = this.entity.position; - this.entity.position = this.entity.position.add(motion); + this.entity.position.add(motion); var didCollide = this.shape.collidesWithShape(collider.shape, result); if (didCollide) result.collider = collider; this.entity.position = oldPosition; return didCollide; }; - Collider.prototype.clone = function () { - var collider = ObjectUtils.clone(this); - collider.entity = null; - if (this.shape) - collider.shape = this.shape.clone(); - return collider; - }; return Collider; }(es.Component)); es.Collider = Collider; @@ -3831,14 +3796,28 @@ var es; (function (es) { var BoxCollider = (function (_super) { __extends(BoxCollider, _super); - function BoxCollider() { + function BoxCollider(x, y, width, height) { var _this = _super.call(this) || this; _this.hollowShape = new egret.Shape(); _this.polygonShape = new egret.Shape(); _this.pixelShape1 = new egret.Shape(); _this.pixelShape2 = new egret.Shape(); - _this.shape = new es.Box(1, 1); - _this._colliderRequiresAutoSizing = true; + if (x == undefined && y == undefined) { + if (width == undefined && height == undefined) { + _this.shape = new es.Box(1, 1); + _this._colliderRequiresAutoSizing = true; + } + else if (width != undefined && height != undefined) { + x = -width / 2; + y = -height / 2; + _this._localOffset = new es.Vector2(x + width / 2, y + height / 2); + _this.shape = new es.Box(width, height); + } + } + else if (x != undefined && y != undefined && width != undefined && height != undefined) { + _this._localOffset = new es.Vector2(x + width / 2, y + height / 2); + _this.shape = new es.Box(width, height); + } return _this; } Object.defineProperty(BoxCollider.prototype, "width", { @@ -3861,12 +3840,6 @@ var es; enumerable: true, configurable: true }); - BoxCollider.prototype.createBoxRect = function (x, y, width, height) { - this._localOffset = new es.Vector2(x + width / 2, y + width / 2); - this.shape = new es.Box(width, height); - this._colliderRequiresAutoSizing = false; - return this; - }; BoxCollider.prototype.setSize = function (width, height) { this._colliderRequiresAutoSizing = false; var box = this.shape; @@ -3906,6 +3879,11 @@ var es; this.debugDisplayObject.addChild(this.pixelShape1); if (!this.pixelShape2.parent) this.debugDisplayObject.addChild(this.pixelShape2); + this.hollowShape.graphics.clear(); + this.hollowShape.graphics.beginFill(es.Colors.colliderBounds, 0); + this.hollowShape.graphics.lineStyle(es.Size.lineSizeMultiplier, es.Colors.colliderBounds); + this.hollowShape.graphics.drawRect(this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height); + this.hollowShape.graphics.endFill(); this.polygonShape.graphics.clear(); if (poly.points.length >= 2) { this.polygonShape.graphics.beginFill(es.Colors.colliderEdge, 0); @@ -3951,9 +3929,13 @@ var es; _this.circleShape = new egret.Shape(); _this.pixelShape1 = new egret.Shape(); _this.pixelShape2 = new egret.Shape(); - if (radius) + if (radius == undefined) { + _this.shape = new es.Circle(1); _this._colliderRequiresAutoSizing = true; - _this.shape = new es.Circle(radius ? radius : 1); + } + else { + _this.shape = new es.Circle(radius); + } return _this; } Object.defineProperty(CircleCollider.prototype, "radius", { @@ -6155,17 +6137,17 @@ var es; return (self & flag) != 0; }; Flags.setFlagExclusive = function (self, flag) { - return 1 << flag; + self.value = 1 << flag; }; Flags.setFlag = function (self, flag) { - return (self | 1 << flag); + self.value = (self.value | 1 << flag); }; Flags.unsetFlag = function (self, flag) { flag = 1 << flag; - return (self & (~flag)); + self.value = (self.value & (~flag)); }; Flags.invertFlags = function (self) { - return ~self; + self.value = ~self.value; }; return Flags; }()); @@ -6828,23 +6810,42 @@ var es; t = es.MathHelper.clamp(t, 0, 1); return es.Vector2.add(lineA, new es.Vector2(v.x * t, v.y * t)); }; - Collisions.isCircleToCircle = function (circleCenter1, circleRadius1, circleCenter2, circleRadius2) { + Collisions.circleToCircle = function (circleCenter1, circleRadius1, circleCenter2, circleRadius2) { return es.Vector2.distanceSquared(circleCenter1, circleCenter2) < (circleRadius1 + circleRadius2) * (circleRadius1 + circleRadius2); }; - Collisions.isCircleToLine = function (circleCenter, radius, lineFrom, lineTo) { + Collisions.circleToLine = function (circleCenter, radius, lineFrom, lineTo) { return es.Vector2.distanceSquared(circleCenter, this.closestPointOnLine(lineFrom, lineTo, circleCenter)) < radius * radius; }; - Collisions.isCircleToPoint = function (circleCenter, radius, point) { + Collisions.circleToPoint = function (circleCenter, radius, point) { return es.Vector2.distanceSquared(circleCenter, point) < radius * radius; }; - Collisions.isRectToCircle = function (rect, cPosition, cRadius) { - var ew = rect.width * 0.5; - var eh = rect.height * 0.5; - var vx = Math.max(0, Math.max(cPosition.x - rect.x) - ew); - var vy = Math.max(0, Math.max(cPosition.y - rect.y) - eh); - return vx * vx + vy * vy < cRadius * cRadius; + Collisions.rectToCircle = function (rect, cPosition, cRadius) { + if (this.rectToPoint(rect.x, rect.y, rect.width, rect.height, cPosition)) + return true; + var edgeFrom = es.Vector2.zero; + var edgeTo = es.Vector2.zero; + var sector = this.getSector(rect.x, rect.y, rect.width, rect.height, cPosition); + if ((sector & PointSectors.top) != 0) { + edgeFrom = new es.Vector2(rect.x, rect.y); + edgeTo = new es.Vector2(rect.x + rect.width, rect.y); + if (this.circleToLine(cPosition, cRadius, edgeFrom, edgeTo)) + return true; + } + if ((sector & PointSectors.bottom) != 0) { + edgeFrom = new es.Vector2(rect.x, rect.y + rect.width); + edgeTo = new es.Vector2(rect.x + rect.width, rect.y + rect.height); + if (this.circleToLine(cPosition, cRadius, edgeFrom, edgeTo)) + return true; + } + if ((sector & PointSectors.left) != 0) { + edgeFrom = new es.Vector2(rect.x + rect.width, rect.y); + edgeTo = new es.Vector2(rect.x + rect.width, rect.y + rect.height); + if (this.circleToLine(cPosition, cRadius, edgeFrom, edgeTo)) + return true; + } + return false; }; - Collisions.isRectToLine = function (rect, lineFrom, lineTo) { + Collisions.rectToLine = function (rect, lineFrom, lineTo) { var fromSector = this.getSector(rect.x, rect.y, rect.width, rect.height, lineFrom); var toSector = this.getSector(rect.x, rect.y, rect.width, rect.height, lineTo); if (fromSector == PointSectors.center || toSector == PointSectors.center) { @@ -6884,7 +6885,7 @@ var es; } return false; }; - Collisions.isRectToPoint = function (rX, rY, rW, rH, point) { + Collisions.rectToPoint = function (rX, rY, rW, rH, point) { return point.x >= rX && point.y >= rY && point.x < rX + rW && point.y < rY + rH; }; Collisions.getSector = function (rX, rY, rW, rH, point) { @@ -7022,9 +7023,6 @@ var es; var Shape = (function () { function Shape() { } - Shape.prototype.clone = function () { - return ObjectUtils.clone(this); - }; return Shape; }()); es.Shape = Shape; @@ -7064,7 +7062,7 @@ var es; }; Polygon.prototype.buildEdgeNormals = function () { var totalEdges = this.isBox ? 2 : this.points.length; - if (this._edgeNormals == null || this._edgeNormals.length != totalEdges) + if (this._edgeNormals == undefined || this._edgeNormals.length != totalEdges) this._edgeNormals = new Array(totalEdges); var p2; for (var i = 0; i < totalEdges; i++) { @@ -7116,7 +7114,7 @@ var es; edgeNormal.x = 0; edgeNormal.y = 0; var closestPoint = new es.Vector2(0, 0); - var tempDistanceSquared; + var tempDistanceSquared = 0; for (var i = 0; i < points.length; i++) { var j = i + 1; if (j == points.length) @@ -7136,7 +7134,7 @@ var es; }; Polygon.rotatePolygonVerts = function (radians, originalPoints, rotatedPoints) { var cos = Math.cos(radians); - var sin = Math.sign(radians); + var sin = Math.sin(radians); for (var i = 0; i < originalPoints.length; i++) { var position = originalPoints[i]; rotatedPoints[i] = new es.Vector2(position.x * cos + position.y * -sin, position.x * sin + position.y * cos); @@ -7258,7 +7256,7 @@ var es; if (other instanceof Box && other.isUnrotated) return this.bounds.intersects(other.bounds); if (other instanceof es.Circle) - return es.Collisions.isRectToCircle(this.bounds, other.position, other.radius); + return es.Collisions.rectToCircle(this.bounds, other.position, other.radius); } return _super.prototype.overlaps.call(this, other); }; @@ -7302,18 +7300,18 @@ var es; if (collider.entity.transform.rotation != 0) { var offsetAngle = Math.atan2(collider.localOffset.y, collider.localOffset.x) * es.MathHelper.Rad2Deg; var offsetLength = hasUnitScale ? collider._localOffsetLength : es.Vector2.multiply(collider.localOffset, collider.entity.transform.scale).length(); - this.center = es.MathHelper.pointOnCirlce(es.Vector2.zero, offsetLength, collider.entity.transform.rotation + offsetAngle); + this.center = es.MathHelper.pointOnCirlce(es.Vector2.zero, offsetLength, collider.entity.transform.rotationDegrees + offsetAngle); } } - this.position = es.Vector2.add(collider.transform.position, this.center); + this.position = es.Vector2.add(collider.entity.transform.position, this.center); this.bounds = new es.Rectangle(this.position.x - this.radius, this.position.y - this.radius, this.radius * 2, this.radius * 2); }; Circle.prototype.overlaps = function (other) { var result = new es.CollisionResult(); if (other instanceof es.Box && other.isUnrotated) - return es.Collisions.isRectToCircle(other.bounds, this.position, this.radius); + return es.Collisions.rectToCircle(other.bounds, this.position, this.radius); if (other instanceof Circle) - return es.Collisions.isCircleToCircle(this.position, this.radius, other.position, other.radius); + return es.Collisions.circleToCircle(this.position, this.radius, other.position, other.radius); if (other instanceof es.Polygon) return es.ShapeCollisions.circleToPolygon(this, other, result); throw new Error("overlaps of circle to " + other + " are not supported"); @@ -7760,7 +7758,7 @@ var es; continue; var _loop_8 = function (i) { var collider = cell[i]; - if (collider == excludeCollider || !es.Flags.isFlagSet(layerMask, collider.physicsLayer)) + if (collider == excludeCollider || !es.Flags.isFlagSet(layerMask, collider.physicsLayer.value)) return "continue"; if (bounds.intersects(collider.bounds)) { if (!this_4._tempHashSet.firstOrDefault(function (c) { return c.hashCode == collider.hashCode; })) @@ -7916,7 +7914,7 @@ var es; this._checkedColliders.push(potential); if (potential.isTrigger && !es.Physics.raycastsHitTriggers) continue; - if (!es.Flags.isFlagSet(this._layerMask, potential.physicsLayer)) + if (!es.Flags.isFlagSet(this._layerMask, potential.physicsLayer.value)) continue; var colliderBounds = potential.bounds; if (colliderBounds.rayIntersects(this._ray, fraction) && fraction.value <= 1) { @@ -7992,7 +7990,7 @@ var es; return this.tiles[x + y * this.width]; }; TmxLayer.prototype.getCollisionRectangles = function () { - var checkedIndexes = []; + var checkedIndexes = new Array(this.tiles.length); var rectangles = []; var startCol = -1; var index = -1; @@ -8005,7 +8003,7 @@ var es; startCol = x; checkedIndexes[index] = true; } - else if (tile || checkedIndexes[index]) { + else if (!tile || checkedIndexes[index] == true) { if (startCol >= 0) { rectangles.push(this.findBoundsRect(startCol, x, y, checkedIndexes)); startCol = -1; @@ -8025,7 +8023,7 @@ var es; for (var x = startX; x < endX; x++) { index = y * this.map.width + x; var tile = this.getTile(x, y); - if (tile || checkedIndexes[index]) { + if (!tile || checkedIndexes[index]) { for (var _x = startX; _x < x; _x++) { index = y * this.map.width + _x; checkedIndexes[index] = false; @@ -8063,7 +8061,7 @@ var es; }); Object.defineProperty(TmxLayerTile.prototype, "tilesetTile", { get: function () { - if (this._tilesetTileIndex == undefined) { + if (!this._tilesetTileIndex) { this._tilesetTileIndex = -1; if (this.tileset.firstGid <= this.gid) { var tilesetTile = this.tileset.tiles.get(this.gid - this.tileset.firstGid); @@ -9892,364 +9890,6 @@ var es; es.GlobalManager = GlobalManager; })(es || (es = {})); var es; -(function (es) { - var TouchState = (function () { - function TouchState() { - this.x = 0; - this.y = 0; - this.touchPoint = -1; - this.touchDown = false; - } - Object.defineProperty(TouchState.prototype, "position", { - get: function () { - return new es.Vector2(this.x, this.y); - }, - enumerable: true, - configurable: true - }); - TouchState.prototype.reset = function () { - this.x = 0; - this.y = 0; - this.touchDown = false; - this.touchPoint = -1; - }; - return TouchState; - }()); - es.TouchState = TouchState; - var Input = (function () { - function Input() { - } - Object.defineProperty(Input, "gameTouchs", { - get: function () { - return this._gameTouchs; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "resolutionScale", { - get: function () { - return this._resolutionScale; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "totalTouchCount", { - get: function () { - return this._totalTouchCount; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "touchPosition", { - get: function () { - if (!this._gameTouchs[0]) - return es.Vector2.zero; - return this._gameTouchs[0].position; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "maxSupportedTouch", { - get: function () { - return es.Core._instance.stage.maxTouches; - }, - set: function (value) { - es.Core._instance.stage.maxTouches = value; - this.initTouchCache(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "touchPositionDelta", { - get: function () { - var delta = es.Vector2.subtract(this.touchPosition, this._previousTouchState.position); - if (delta.length() > 0) { - this.setpreviousTouchState(this._gameTouchs[0]); - } - return delta; - }, - enumerable: true, - configurable: true - }); - Input.initialize = function () { - if (this._init) - return; - this._init = true; - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.touchBegin, this); - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.touchMove, this); - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.touchEnd, this); - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.touchEnd, this); - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.touchEnd, this); - this.initTouchCache(); - }; - Input.scaledPosition = function (position) { - var scaledPos = new es.Vector2(position.x - this._resolutionOffset.x, position.y - this._resolutionOffset.y); - return es.Vector2.multiply(scaledPos, this.resolutionScale); - }; - Input.initTouchCache = function () { - this._totalTouchCount = 0; - this._touchIndex = 0; - this._gameTouchs.length = 0; - for (var i = 0; i < this.maxSupportedTouch; i++) { - this._gameTouchs.push(new TouchState()); - } - }; - Input.touchBegin = function (evt) { - if (this._touchIndex < this.maxSupportedTouch) { - this._gameTouchs[this._touchIndex].touchPoint = evt.touchPointID; - this._gameTouchs[this._touchIndex].touchDown = evt.touchDown; - this._gameTouchs[this._touchIndex].x = evt.stageX; - this._gameTouchs[this._touchIndex].y = evt.stageY; - if (this._touchIndex == 0) { - this.setpreviousTouchState(this._gameTouchs[0]); - } - this._touchIndex++; - this._totalTouchCount++; - } - }; - Input.touchMove = function (evt) { - if (evt.touchPointID == this._gameTouchs[0].touchPoint) { - this.setpreviousTouchState(this._gameTouchs[0]); - } - var touchIndex = this._gameTouchs.findIndex(function (touch) { return touch.touchPoint == evt.touchPointID; }); - if (touchIndex != -1) { - var touchData = this._gameTouchs[touchIndex]; - touchData.x = evt.stageX; - touchData.y = evt.stageY; - } - }; - Input.touchEnd = function (evt) { - var touchIndex = this._gameTouchs.findIndex(function (touch) { return touch.touchPoint == evt.touchPointID; }); - if (touchIndex != -1) { - var touchData = this._gameTouchs[touchIndex]; - touchData.reset(); - if (touchIndex == 0) - this._previousTouchState.reset(); - this._totalTouchCount--; - if (this.totalTouchCount == 0) { - this._touchIndex = 0; - } - } - }; - Input.setpreviousTouchState = function (touchState) { - this._previousTouchState = new TouchState(); - this._previousTouchState.x = touchState.position.x; - this._previousTouchState.y = touchState.position.y; - this._previousTouchState.touchPoint = touchState.touchPoint; - this._previousTouchState.touchDown = touchState.touchDown; - }; - Input._init = false; - Input._previousTouchState = new TouchState(); - Input._resolutionOffset = new es.Vector2(); - Input._touchIndex = 0; - Input._gameTouchs = []; - Input._resolutionScale = es.Vector2.one; - Input._totalTouchCount = 0; - return Input; - }()); - es.Input = Input; -})(es || (es = {})); -var KeyboardUtils = (function () { - function KeyboardUtils() { - } - KeyboardUtils.init = function () { - KeyboardUtils.keyDownDict = {}; - KeyboardUtils.keyUpDict = {}; - document.addEventListener("keydown", KeyboardUtils.onKeyDonwHander); - document.addEventListener("keyup", KeyboardUtils.onKeyUpHander); - }; - KeyboardUtils.registerKey = function (key, fun, thisObj, type) { - if (type === void 0) { type = 0; } - var args = []; - for (var _i = 4; _i < arguments.length; _i++) { - args[_i - 4] = arguments[_i]; - } - var keyDict = type ? this.keyUpDict : this.keyDownDict; - keyDict[key] = { "fun": fun, args: args, "thisObj": thisObj }; - }; - KeyboardUtils.unregisterKey = function (key, type) { - if (type === void 0) { type = 0; } - var keyDict = type ? this.keyUpDict : this.keyDownDict; - delete keyDict[key]; - }; - KeyboardUtils.destroy = function () { - KeyboardUtils.keyDownDict = null; - KeyboardUtils.keyUpDict = null; - document.removeEventListener("keydown", this.onKeyDonwHander); - document.removeEventListener("keyup", this.onKeyUpHander); - }; - KeyboardUtils.onKeyDonwHander = function (event) { - if (!KeyboardUtils.keyDownDict) - return; - var key = KeyboardUtils.keyCodeToString(event.keyCode); - var o = KeyboardUtils.keyDownDict[key]; - if (o) { - var fun = o["fun"]; - var thisObj = o["thisObj"]; - var args = o["args"]; - fun.apply(thisObj, args); - } - }; - KeyboardUtils.onKeyUpHander = function (event) { - if (!KeyboardUtils.keyUpDict) - return; - var key = KeyboardUtils.keyCodeToString(event.keyCode); - var o = KeyboardUtils.keyUpDict[key]; - if (o) { - var fun = o["fun"]; - var thisObj = o["thisObj"]; - var args = o["args"]; - fun.apply(thisObj, args); - } - }; - KeyboardUtils.keyCodeToString = function (keyCode) { - switch (keyCode) { - case 8: - return this.BACK_SPACE; - case 9: - return this.TAB; - case 13: - return this.ENTER; - case 16: - return this.SHIFT; - case 17: - return this.CTRL; - case 19: - return this.PAUSE_BREAK; - case 20: - return this.CAPS_LOCK; - case 27: - return this.ESC; - case 32: - return this.SPACE; - case 33: - return this.PAGE_UP; - case 34: - return this.PAGE_DOWN; - case 35: - return this.END; - case 36: - return this.HOME; - case 37: - return this.LEFT; - case 38: - return this.UP; - case 39: - return this.RIGHT; - case 40: - return this.DOWN; - case 45: - return this.INSERT; - case 46: - return this.DELETE; - case 91: - return this.WINDOWS; - case 112: - return this.F1; - case 113: - return this.F2; - case 114: - return this.F3; - case 115: - return this.F4; - case 116: - return this.F5; - case 117: - return this.F6; - case 118: - return this.F7; - case 119: - return this.F8; - case 120: - return this.F9; - case 122: - return this.F11; - case 123: - return this.F12; - case 144: - return this.NUM_LOCK; - case 145: - return this.SCROLL_LOCK; - default: - return String.fromCharCode(keyCode); - } - }; - KeyboardUtils.TYPE_KEY_DOWN = 0; - KeyboardUtils.TYPE_KEY_UP = 1; - KeyboardUtils.A = "A"; - KeyboardUtils.B = "B"; - KeyboardUtils.C = "C"; - KeyboardUtils.D = "D"; - KeyboardUtils.E = "E"; - KeyboardUtils.F = "F"; - KeyboardUtils.G = "G"; - KeyboardUtils.H = "H"; - KeyboardUtils.I = "I"; - KeyboardUtils.J = "J"; - KeyboardUtils.K = "K"; - KeyboardUtils.L = "L"; - KeyboardUtils.M = "M"; - KeyboardUtils.N = "N"; - KeyboardUtils.O = "O"; - KeyboardUtils.P = "P"; - KeyboardUtils.Q = "Q"; - KeyboardUtils.R = "R"; - KeyboardUtils.S = "S"; - KeyboardUtils.T = "T"; - KeyboardUtils.U = "U"; - KeyboardUtils.V = "V"; - KeyboardUtils.W = "W"; - KeyboardUtils.X = "X"; - KeyboardUtils.Y = "Y"; - KeyboardUtils.Z = "Z"; - KeyboardUtils.ESC = "Esc"; - KeyboardUtils.F1 = "F1"; - KeyboardUtils.F2 = "F2"; - KeyboardUtils.F3 = "F3"; - KeyboardUtils.F4 = "F4"; - KeyboardUtils.F5 = "F5"; - KeyboardUtils.F6 = "F6"; - KeyboardUtils.F7 = "F7"; - KeyboardUtils.F8 = "F8"; - KeyboardUtils.F9 = "F9"; - KeyboardUtils.F10 = "F10"; - KeyboardUtils.F11 = "F11"; - KeyboardUtils.F12 = "F12"; - KeyboardUtils.NUM_1 = "1"; - KeyboardUtils.NUM_2 = "2"; - KeyboardUtils.NUM_3 = "3"; - KeyboardUtils.NUM_4 = "4"; - KeyboardUtils.NUM_5 = "5"; - KeyboardUtils.NUM_6 = "6"; - KeyboardUtils.NUM_7 = "7"; - KeyboardUtils.NUM_8 = "8"; - KeyboardUtils.NUM_9 = "9"; - KeyboardUtils.NUM_0 = "0"; - KeyboardUtils.TAB = "Tab"; - KeyboardUtils.CTRL = "Ctrl"; - KeyboardUtils.ALT = "Alt"; - KeyboardUtils.SHIFT = "Shift"; - KeyboardUtils.CAPS_LOCK = "Caps Lock"; - KeyboardUtils.ENTER = "Enter"; - KeyboardUtils.SPACE = "Space"; - KeyboardUtils.BACK_SPACE = "Back Space"; - KeyboardUtils.INSERT = "Insert"; - KeyboardUtils.DELETE = "Page Down"; - KeyboardUtils.HOME = "Home"; - KeyboardUtils.END = "Page Down"; - KeyboardUtils.PAGE_UP = "Page Up"; - KeyboardUtils.PAGE_DOWN = "Page Down"; - KeyboardUtils.LEFT = "Left"; - KeyboardUtils.RIGHT = "Right"; - KeyboardUtils.UP = "Up"; - KeyboardUtils.DOWN = "Down"; - KeyboardUtils.PAUSE_BREAK = "Pause Break"; - KeyboardUtils.NUM_LOCK = "Num Lock"; - KeyboardUtils.SCROLL_LOCK = "Scroll Lock"; - KeyboardUtils.WINDOWS = "Windows"; - return KeyboardUtils; -}()); -var es; (function (es) { var ListPool = (function () { function ListPool() { @@ -11097,6 +10737,651 @@ var es; es.MarkerLog = MarkerLog; })(es || (es = {})); var es; +(function (es) { + var TouchState = (function () { + function TouchState() { + this.x = 0; + this.y = 0; + this.touchPoint = -1; + this.touchDown = false; + } + Object.defineProperty(TouchState.prototype, "position", { + get: function () { + return new es.Vector2(this.x, this.y); + }, + enumerable: true, + configurable: true + }); + TouchState.prototype.reset = function () { + this.x = 0; + this.y = 0; + this.touchDown = false; + this.touchPoint = -1; + }; + return TouchState; + }()); + es.TouchState = TouchState; + var Input = (function () { + function Input() { + } + Object.defineProperty(Input, "gameTouchs", { + get: function () { + return this._gameTouchs; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Input, "resolutionScale", { + get: function () { + return this._resolutionScale; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Input, "totalTouchCount", { + get: function () { + return this._totalTouchCount; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Input, "touchPosition", { + get: function () { + if (!this._gameTouchs[0]) + return es.Vector2.zero; + return this._gameTouchs[0].position; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Input, "maxSupportedTouch", { + get: function () { + return es.Core._instance.stage.maxTouches; + }, + set: function (value) { + es.Core._instance.stage.maxTouches = value; + this.initTouchCache(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Input, "touchPositionDelta", { + get: function () { + var delta = es.Vector2.subtract(this.touchPosition, this._previousTouchState.position); + if (delta.length() > 0) { + this.setpreviousTouchState(this._gameTouchs[0]); + } + return delta; + }, + enumerable: true, + configurable: true + }); + Input.initialize = function () { + if (this._init) + return; + this._init = true; + es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.touchBegin, this); + es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.touchMove, this); + es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.touchEnd, this); + es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.touchEnd, this); + es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.touchEnd, this); + this.initTouchCache(); + }; + Input.update = function () { + KeyboardUtils.update(); + for (var i = 0; i < this._virtualInputs.length; i++) + this._virtualInputs[i].update(); + }; + Input.scaledPosition = function (position) { + var scaledPos = new es.Vector2(position.x - this._resolutionOffset.x, position.y - this._resolutionOffset.y); + return es.Vector2.multiply(scaledPos, this.resolutionScale); + }; + Input.isKeyPressed = function (key) { + return KeyboardUtils.currentKeys.contains(key) && !KeyboardUtils.previousKeys.contains(key); + }; + Input.isKeyPressedBoth = function (keyA, keyB) { + return this.isKeyPressed(keyA) || this.isKeyPressed(keyB); + }; + Input.isKeyDown = function (key) { + return KeyboardUtils.currentKeys.contains(key); + }; + Input.isKeyDownBoth = function (keyA, keyB) { + return this.isKeyDown(keyA) || this.isKeyDown(keyB); + }; + Input.isKeyReleased = function (key) { + return !KeyboardUtils.currentKeys.contains(key) && KeyboardUtils.previousKeys.contains(key); + }; + Input.isKeyReleasedBoth = function (keyA, keyB) { + return this.isKeyReleased(keyA) || this.isKeyReleased(keyB); + }; + Input.initTouchCache = function () { + this._totalTouchCount = 0; + this._touchIndex = 0; + this._gameTouchs.length = 0; + for (var i = 0; i < this.maxSupportedTouch; i++) { + this._gameTouchs.push(new TouchState()); + } + }; + Input.touchBegin = function (evt) { + if (this._touchIndex < this.maxSupportedTouch) { + this._gameTouchs[this._touchIndex].touchPoint = evt.touchPointID; + this._gameTouchs[this._touchIndex].touchDown = evt.touchDown; + this._gameTouchs[this._touchIndex].x = evt.stageX; + this._gameTouchs[this._touchIndex].y = evt.stageY; + if (this._touchIndex == 0) { + this.setpreviousTouchState(this._gameTouchs[0]); + } + this._touchIndex++; + this._totalTouchCount++; + } + }; + Input.touchMove = function (evt) { + if (evt.touchPointID == this._gameTouchs[0].touchPoint) { + this.setpreviousTouchState(this._gameTouchs[0]); + } + var touchIndex = this._gameTouchs.findIndex(function (touch) { return touch.touchPoint == evt.touchPointID; }); + if (touchIndex != -1) { + var touchData = this._gameTouchs[touchIndex]; + touchData.x = evt.stageX; + touchData.y = evt.stageY; + } + }; + Input.touchEnd = function (evt) { + var touchIndex = this._gameTouchs.findIndex(function (touch) { return touch.touchPoint == evt.touchPointID; }); + if (touchIndex != -1) { + var touchData = this._gameTouchs[touchIndex]; + touchData.reset(); + if (touchIndex == 0) + this._previousTouchState.reset(); + this._totalTouchCount--; + if (this.totalTouchCount == 0) { + this._touchIndex = 0; + } + } + }; + Input.setpreviousTouchState = function (touchState) { + this._previousTouchState = new TouchState(); + this._previousTouchState.x = touchState.position.x; + this._previousTouchState.y = touchState.position.y; + this._previousTouchState.touchPoint = touchState.touchPoint; + this._previousTouchState.touchDown = touchState.touchDown; + }; + Input._init = false; + Input._previousTouchState = new TouchState(); + Input._resolutionOffset = new es.Vector2(); + Input._touchIndex = 0; + Input._gameTouchs = []; + Input._resolutionScale = es.Vector2.one; + Input._totalTouchCount = 0; + Input._virtualInputs = []; + return Input; + }()); + es.Input = Input; +})(es || (es = {})); +var Keys = es.Keys; +var KeyboardUtils = (function () { + function KeyboardUtils() { + } + KeyboardUtils.init = function () { + document.addEventListener("keydown", KeyboardUtils.onKeyDownHandler); + document.addEventListener("keyup", KeyboardUtils.onKeyUpHandler); + }; + KeyboardUtils.update = function () { + KeyboardUtils.previousKeys.length = 0; + for (var _i = 0, _a = KeyboardUtils.currentKeys; _i < _a.length; _i++) { + var key = _a[_i]; + KeyboardUtils.previousKeys.push(key); + KeyboardUtils.currentKeys.remove(key); + } + KeyboardUtils.currentKeys.length = 0; + for (var _b = 0, _c = KeyboardUtils.keyStatusKeys; _b < _c.length; _b++) { + var key = _c[_b]; + KeyboardUtils.currentKeys.push(key); + } + }; + KeyboardUtils.destroy = function () { + KeyboardUtils.currentKeys.length = 0; + document.removeEventListener("keyup", KeyboardUtils.onKeyUpHandler); + document.removeEventListener("keypress", KeyboardUtils.onKeyDownHandler); + }; + KeyboardUtils.onKeyDownHandler = function (event) { + if (!KeyboardUtils.keyStatusKeys.contains(event.keyCode)) + KeyboardUtils.keyStatusKeys.push(event.keyCode); + }; + KeyboardUtils.onKeyUpHandler = function (event) { + if (KeyboardUtils.keyStatusKeys.contains(event.keyCode)) + KeyboardUtils.keyStatusKeys.remove(event.keyCode); + }; + KeyboardUtils.currentKeys = []; + KeyboardUtils.previousKeys = []; + KeyboardUtils.keyStatusKeys = []; + return KeyboardUtils; +}()); +var es; +(function (es) { + var Keys; + (function (Keys) { + Keys[Keys["none"] = 0] = "none"; + Keys[Keys["back"] = 8] = "back"; + Keys[Keys["tab"] = 9] = "tab"; + Keys[Keys["enter"] = 13] = "enter"; + Keys[Keys["capsLock"] = 20] = "capsLock"; + Keys[Keys["escape"] = 27] = "escape"; + Keys[Keys["space"] = 32] = "space"; + Keys[Keys["pageUp"] = 33] = "pageUp"; + Keys[Keys["pageDown"] = 34] = "pageDown"; + Keys[Keys["end"] = 35] = "end"; + Keys[Keys["home"] = 36] = "home"; + Keys[Keys["left"] = 37] = "left"; + Keys[Keys["up"] = 38] = "up"; + Keys[Keys["right"] = 39] = "right"; + Keys[Keys["down"] = 40] = "down"; + Keys[Keys["select"] = 41] = "select"; + Keys[Keys["print"] = 42] = "print"; + Keys[Keys["execute"] = 43] = "execute"; + Keys[Keys["printScreen"] = 44] = "printScreen"; + Keys[Keys["insert"] = 45] = "insert"; + Keys[Keys["delete"] = 46] = "delete"; + Keys[Keys["help"] = 47] = "help"; + Keys[Keys["d0"] = 48] = "d0"; + Keys[Keys["d1"] = 49] = "d1"; + Keys[Keys["d2"] = 50] = "d2"; + Keys[Keys["d3"] = 51] = "d3"; + Keys[Keys["d4"] = 52] = "d4"; + Keys[Keys["d5"] = 53] = "d5"; + Keys[Keys["d6"] = 54] = "d6"; + Keys[Keys["d7"] = 55] = "d7"; + Keys[Keys["d8"] = 56] = "d8"; + Keys[Keys["d9"] = 57] = "d9"; + Keys[Keys["a"] = 65] = "a"; + Keys[Keys["b"] = 66] = "b"; + Keys[Keys["c"] = 67] = "c"; + Keys[Keys["d"] = 68] = "d"; + Keys[Keys["e"] = 69] = "e"; + Keys[Keys["f"] = 70] = "f"; + Keys[Keys["g"] = 71] = "g"; + Keys[Keys["h"] = 72] = "h"; + Keys[Keys["i"] = 73] = "i"; + Keys[Keys["j"] = 74] = "j"; + Keys[Keys["k"] = 75] = "k"; + Keys[Keys["l"] = 76] = "l"; + Keys[Keys["m"] = 77] = "m"; + Keys[Keys["n"] = 78] = "n"; + Keys[Keys["o"] = 79] = "o"; + Keys[Keys["p"] = 80] = "p"; + Keys[Keys["q"] = 81] = "q"; + Keys[Keys["r"] = 82] = "r"; + Keys[Keys["s"] = 83] = "s"; + Keys[Keys["t"] = 84] = "t"; + Keys[Keys["u"] = 85] = "u"; + Keys[Keys["v"] = 86] = "v"; + Keys[Keys["w"] = 87] = "w"; + Keys[Keys["x"] = 88] = "x"; + Keys[Keys["y"] = 89] = "y"; + Keys[Keys["z"] = 90] = "z"; + Keys[Keys["leftWindows"] = 91] = "leftWindows"; + Keys[Keys["rightWindows"] = 92] = "rightWindows"; + Keys[Keys["apps"] = 93] = "apps"; + Keys[Keys["sleep"] = 95] = "sleep"; + Keys[Keys["numPad0"] = 96] = "numPad0"; + Keys[Keys["numPad1"] = 97] = "numPad1"; + Keys[Keys["numPad2"] = 98] = "numPad2"; + Keys[Keys["numPad3"] = 99] = "numPad3"; + Keys[Keys["numPad4"] = 100] = "numPad4"; + Keys[Keys["numPad5"] = 101] = "numPad5"; + Keys[Keys["numPad6"] = 102] = "numPad6"; + Keys[Keys["numPad7"] = 103] = "numPad7"; + Keys[Keys["numPad8"] = 104] = "numPad8"; + Keys[Keys["numPad9"] = 105] = "numPad9"; + Keys[Keys["multiply"] = 106] = "multiply"; + Keys[Keys["add"] = 107] = "add"; + Keys[Keys["seperator"] = 108] = "seperator"; + Keys[Keys["subtract"] = 109] = "subtract"; + Keys[Keys["decimal"] = 110] = "decimal"; + Keys[Keys["divide"] = 111] = "divide"; + Keys[Keys["f1"] = 112] = "f1"; + Keys[Keys["f2"] = 113] = "f2"; + Keys[Keys["f3"] = 114] = "f3"; + Keys[Keys["f4"] = 115] = "f4"; + Keys[Keys["f5"] = 116] = "f5"; + Keys[Keys["f6"] = 117] = "f6"; + Keys[Keys["f7"] = 118] = "f7"; + Keys[Keys["f8"] = 119] = "f8"; + Keys[Keys["f9"] = 120] = "f9"; + Keys[Keys["f10"] = 121] = "f10"; + Keys[Keys["f11"] = 122] = "f11"; + Keys[Keys["f12"] = 123] = "f12"; + Keys[Keys["f13"] = 124] = "f13"; + Keys[Keys["f14"] = 125] = "f14"; + Keys[Keys["f15"] = 126] = "f15"; + Keys[Keys["f16"] = 127] = "f16"; + Keys[Keys["f17"] = 128] = "f17"; + Keys[Keys["f18"] = 129] = "f18"; + Keys[Keys["f19"] = 130] = "f19"; + Keys[Keys["f20"] = 131] = "f20"; + Keys[Keys["f21"] = 132] = "f21"; + Keys[Keys["f22"] = 133] = "f22"; + Keys[Keys["f23"] = 134] = "f23"; + Keys[Keys["f24"] = 135] = "f24"; + Keys[Keys["numLock"] = 144] = "numLock"; + Keys[Keys["scroll"] = 145] = "scroll"; + Keys[Keys["leftShift"] = 160] = "leftShift"; + Keys[Keys["rightShift"] = 161] = "rightShift"; + Keys[Keys["leftControl"] = 162] = "leftControl"; + Keys[Keys["rightControl"] = 163] = "rightControl"; + Keys[Keys["leftAlt"] = 164] = "leftAlt"; + Keys[Keys["rightAlt"] = 165] = "rightAlt"; + Keys[Keys["browserBack"] = 166] = "browserBack"; + Keys[Keys["browserForward"] = 167] = "browserForward"; + })(Keys = es.Keys || (es.Keys = {})); +})(es || (es = {})); +var es; +(function (es) { + var OverlapBehavior; + (function (OverlapBehavior) { + OverlapBehavior[OverlapBehavior["cancelOut"] = 0] = "cancelOut"; + OverlapBehavior[OverlapBehavior["takeOlder"] = 1] = "takeOlder"; + OverlapBehavior[OverlapBehavior["takeNewer"] = 2] = "takeNewer"; + })(OverlapBehavior = es.OverlapBehavior || (es.OverlapBehavior = {})); + var VirtualInput = (function () { + function VirtualInput() { + es.Input._virtualInputs.push(this); + } + VirtualInput.prototype.deregister = function () { + es.Input._virtualInputs.remove(this); + }; + return VirtualInput; + }()); + es.VirtualInput = VirtualInput; + var VirtualInputNode = (function () { + function VirtualInputNode() { + } + VirtualInputNode.prototype.update = function () { }; + return VirtualInputNode; + }()); + es.VirtualInputNode = VirtualInputNode; +})(es || (es = {})); +var es; +(function (es) { + var VirtualIntegerAxis = (function (_super) { + __extends(VirtualIntegerAxis, _super); + function VirtualIntegerAxis() { + var nodes = []; + for (var _i = 0; _i < arguments.length; _i++) { + nodes[_i] = arguments[_i]; + } + var _this = _super.call(this) || this; + _this.nodes = []; + _this.nodes.concat(nodes); + return _this; + } + Object.defineProperty(VirtualIntegerAxis.prototype, "value", { + get: function () { + for (var i = 0; i < this.nodes.length; i++) { + var val = this.nodes[i].value; + if (val != 0) + return Math.sign(val); + } + return 0; + }, + enumerable: true, + configurable: true + }); + VirtualIntegerAxis.prototype.update = function () { + for (var i = 0; i < this.nodes.length; i++) + this.nodes[i].update(); + }; + VirtualIntegerAxis.prototype.addKeyboardKeys = function (overlapBehavior, negative, positive) { + this.nodes.push(new es.KeyboardKeys(overlapBehavior, negative, positive)); + return this; + }; + return VirtualIntegerAxis; + }(es.VirtualInput)); + es.VirtualIntegerAxis = VirtualIntegerAxis; + var VirtualAxisNode = (function (_super) { + __extends(VirtualAxisNode, _super); + function VirtualAxisNode() { + return _super !== null && _super.apply(this, arguments) || this; + } + return VirtualAxisNode; + }(es.VirtualInputNode)); + es.VirtualAxisNode = VirtualAxisNode; +})(es || (es = {})); +var es; +(function (es) { + var VirtualAxis = (function (_super) { + __extends(VirtualAxis, _super); + function VirtualAxis() { + var nodes = []; + for (var _i = 0; _i < arguments.length; _i++) { + nodes[_i] = arguments[_i]; + } + var _this = _super.call(this) || this; + _this.nodes = []; + _this.nodes.concat(nodes); + return _this; + } + Object.defineProperty(VirtualAxis.prototype, "value", { + get: function () { + for (var i = 0; i < this.nodes.length; i++) { + var val = this.nodes[i].value; + if (val != 0) + return val; + } + return 0; + }, + enumerable: true, + configurable: true + }); + VirtualAxis.prototype.update = function () { + for (var i = 0; i < this.nodes.length; i++) + this.nodes[i].update(); + }; + return VirtualAxis; + }(es.VirtualInput)); + es.VirtualAxis = VirtualAxis; + var KeyboardKeys = (function (_super) { + __extends(KeyboardKeys, _super); + function KeyboardKeys(overlapBehavior, negative, positive) { + var _this = _super.call(this) || this; + _this._value = 0; + _this.overlapBehavior = overlapBehavior; + _this.negative = negative; + _this.positive = positive; + return _this; + } + KeyboardKeys.prototype.update = function () { + if (es.Input.isKeyDown(this.positive)) { + if (es.Input.isKeyDown(this.negative)) { + switch (this.overlapBehavior) { + default: + case es.OverlapBehavior.cancelOut: + this._value = 0; + break; + case es.OverlapBehavior.takeNewer: + if (!this._turned) { + this._value *= -1; + this._turned = true; + } + break; + case es.OverlapBehavior.takeOlder: + break; + } + } + else { + this._turned = false; + this._value = 1; + } + } + else if (es.Input.isKeyDown(this.negative)) { + this._turned = false; + this._value = -1; + } + else { + this._turned = false; + this._value = 0; + } + }; + Object.defineProperty(KeyboardKeys.prototype, "value", { + get: function () { + return this._value; + }, + enumerable: true, + configurable: true + }); + return KeyboardKeys; + }(es.VirtualAxisNode)); + es.KeyboardKeys = KeyboardKeys; +})(es || (es = {})); +var es; +(function (es) { + var VirtualButton = (function (_super) { + __extends(VirtualButton, _super); + function VirtualButton(bufferTime) { + if (bufferTime === void 0) { bufferTime = 0; } + var nodes = []; + for (var _i = 1; _i < arguments.length; _i++) { + nodes[_i - 1] = arguments[_i]; + } + var _this = _super.call(this) || this; + _this.nodes = []; + _this.bufferTime = 0; + _this.firstRepeatTime = 0; + _this.mutiRepeatTime = 0; + _this._bufferCounter = 0; + _this._repeatCounter = 0; + _this.nodes = nodes; + _this.bufferTime = bufferTime; + return _this; + } + VirtualButton.prototype.setRepeat = function (firstRepeatTime, mutiRepeatTime) { + if (mutiRepeatTime === void 0) { mutiRepeatTime = firstRepeatTime; } + this.firstRepeatTime = firstRepeatTime; + this.mutiRepeatTime = mutiRepeatTime; + this._willRepeat = this.firstRepeatTime > 0; + if (!this._willRepeat) + this.isRepeating = false; + }; + VirtualButton.prototype.update = function () { + this._bufferCounter -= es.Time.unscaledDeltaTime; + this.isRepeating = false; + var check = false; + for (var i = 0; i < this.nodes.length; i++) { + this.nodes[i].update(); + if (this.nodes[i].isPressed) { + this._bufferCounter = this.bufferTime; + check = true; + } + else if (this.nodes[i].isDown) { + check = true; + } + } + if (!check) { + this._repeatCounter = 0; + this._bufferCounter = 0; + } + else if (this._willRepeat) { + if (this._repeatCounter == 0) { + this._repeatCounter = this.firstRepeatTime; + } + else { + this._repeatCounter -= es.Time.unscaledDeltaTime; + if (this._repeatCounter <= 0) { + this.isRepeating = true; + this._repeatCounter = this.mutiRepeatTime; + } + } + } + }; + Object.defineProperty(VirtualButton.prototype, "isDown", { + get: function () { + for (var _i = 0, _a = this.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.isDown) + return true; + } + return false; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(VirtualButton.prototype, "isPressed", { + get: function () { + if (this._bufferCounter > 0 || this.isRepeating) + return true; + for (var _i = 0, _a = this.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.isPressed) + return true; + } + return false; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(VirtualButton.prototype, "isReleased", { + get: function () { + for (var _i = 0, _a = this.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.isReleased) + return true; + } + return false; + }, + enumerable: true, + configurable: true + }); + VirtualButton.prototype.consumeBuffer = function () { + this._bufferCounter = 0; + }; + VirtualButton.prototype.addKeyboardKey = function (key) { + this.nodes.push(new KeyboardKey(key)); + return this; + }; + return VirtualButton; + }(es.VirtualInput)); + es.VirtualButton = VirtualButton; + var Node = (function (_super) { + __extends(Node, _super); + function Node() { + return _super !== null && _super.apply(this, arguments) || this; + } + return Node; + }(es.VirtualInputNode)); + es.Node = Node; + var KeyboardKey = (function (_super) { + __extends(KeyboardKey, _super); + function KeyboardKey(key) { + var _this = _super.call(this) || this; + _this.key = key; + return _this; + } + Object.defineProperty(KeyboardKey.prototype, "isDown", { + get: function () { + return es.Input.isKeyDown(this.key); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(KeyboardKey.prototype, "isPressed", { + get: function () { + return es.Input.isKeyPressed(this.key); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(KeyboardKey.prototype, "isReleased", { + get: function () { + return es.Input.isKeyReleased(this.key); + }, + enumerable: true, + configurable: true + }); + return KeyboardKey; + }(Node)); + es.KeyboardKey = KeyboardKey; +})(es || (es = {})); +var es; (function (es) { var Bitmap = egret.Bitmap; var AssetPacker = (function () { diff --git a/source/bin/framework.min.js b/source/bin/framework.min.js index 4c0da89f..5b173882 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 i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};return function(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();var transform,__awaiter=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))(function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){t.done?r(t.value):new i(function(e){e(t.value)}).then(s,a)}h((n=n.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){var i,n,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(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=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++,n=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 i=t.findIndex(e);return-1==i?null:t[i]}(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(i,n,r){return e.call(arguments[2],n,r,t)&&i.push(n),i},[]);for(var i=[],n=0,r=t.length;n=0&&t.splice(i,1)}while(i>=0)}(this,t)},Array.prototype.remove=function(t){return function(t,e){var i=t.findIndex(function(t){return t===e});return i>=0&&(t.splice(i,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,i){t.splice(e,i)}(this,t,e)},Array.prototype.select=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(i,n,r){return i.push(e.call(arguments[2],n,r,t)),i},[]);for(var i=[],n=0,r=t.length;no?1:-1}),t}(this,t,e)},Array.prototype.orderByDescending=function(t,e){return function(t,e,i){return t.sort(function(t,n){var r=e(t),o=e(n);return i?-i(r,o):r0;){if("break"===l())break}return s?this.recontructPath(a,n,r):null},e.recontructPath=function(t,e,i){var n=[],r=i;for(n.push(i);r!=e;)r=this.getKey(t,r),n.push(r);return n.reverse(),n},e.hasKey=function(t,e){for(var i,n=t.keys();!(i=n.next()).done;)if(JSON.stringify(i.value)==JSON.stringify(e))return!0;return!1},e.getKey=function(t,e){for(var i,n,r=t.keys(),o=t.values();i=r.next(),n=o.next(),!i.done;)if(JSON.stringify(i.value)==JSON.stringify(e))return n.value;return null},e}();t.AStarPathfinder=e;var i=function(t){function e(e){var i=t.call(this)||this;return i.data=e,i}return __extends(e,t),e}(t.PriorityQueueNode);t.AStarNode=i}(es||(es={})),function(t){var e=function(){function e(e,i){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=i}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,i)?this.cascadeUp(t):this.cascadeDown(t)},t.prototype.cascadeDown=function(t){for(var e,i=t.queueIndex;;){e=t;var n=2*i;if(n>this._numNodes){t.queueIndex=i,this._nodes[i]=t;break}var r=this._nodes[n];this.hasHigherPriority(r,e)&&(e=r);var o=n+1;if(o<=this._numNodes){var s=this._nodes[o];this.hasHigherPriority(s,e)&&(e=s)}if(e==t){t.queueIndex=i,this._nodes[i]=t;break}this._nodes[i]=e;var a=e.queueIndex;e.queueIndex=i,i=a}},t.prototype.cascadeUp=function(t){for(var e=Math.floor(t.queueIndex/2);e>=1;){var i=this._nodes[e];if(this.hasHigherPriority(i,t))break;this.swap(t,i),e=Math.floor(t.queueIndex/2)}},t.prototype.swap=function(t,e){this._nodes[t.queueIndex]=e,this._nodes[e.queueIndex]=t;var i=t.queueIndex;t.queueIndex=e.queueIndex,e.queueIndex=i},t.prototype.hasHigherPriority=function(t,e){return t.priority0;){if("break"===h())break}return o?t.AStarPathfinder.recontructPath(a,i,n):null},e.hasKey=function(t,e){for(var i,n=t.keys();!(i=n.next()).done;)if(JSON.stringify(i.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 new e(0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"one",{get:function(){return new e(1,1)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitX",{get:function(){return new e(1,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitY",{get:function(){return new e(0,1)},enumerable:!0,configurable:!0}),e.add=function(t,i){var n=new e(0,0);return n.x=t.x+i.x,n.y=t.y+i.y,n},e.divide=function(t,i){var n=new e(0,0);return n.x=t.x/i.x,n.y=t.y/i.y,n},e.multiply=function(t,i){var n=new e(0,0);return n.x=t.x*i.x,n.y=t.y*i.y,n},e.subtract=function(t,i){var n=new e(0,0);return n.x=t.x-i.x,n.y=t.y-i.y,n},e.normalize=function(t){var i=new e(t.x,t.y),n=1/Math.sqrt(i.x*i.x+i.y*i.y);return i.x*=n,i.y*=n,i},e.dot=function(t,e){return t.x*e.x+t.y*e.y},e.distanceSquared=function(t,e){var i=t.x-e.x,n=t.y-e.y;return i*i+n*n},e.clamp=function(i,n,r){return new e(t.MathHelper.clamp(i.x,n.x,r.x),t.MathHelper.clamp(i.y,n.y,r.y))},e.lerp=function(i,n,r){return new e(t.MathHelper.lerp(i.x,n.x,r),t.MathHelper.lerp(i.y,n.y,r))},e.transform=function(t,i){return new e(t.x*i.m11+t.y*i.m21+i.m31,t.x*i.m12+t.y*i.m22+i.m32)},e.distance=function(t,e){var i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)},e.angle=function(i,n){return i=e.normalize(i),n=e.normalize(n),Math.acos(t.MathHelper.clamp(e.dot(i,n),-1,1))*t.MathHelper.Rad2Deg},e.negate=function(t){var i=new e;return i.x=-t.x,i.y=-t.y,i},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);this.x*=t,this.y*=t},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}();t.Vector2=e}(es||(es={})),function(t){var e=function(){function e(t,i,n){void 0===n&&(n=!1),this.walls=[],this._neighbors=new Array(4),this._width=t,this._hegiht=i,this._dirs=n?e.COMPASS_DIRS:e.CARDINAL_DIRS}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x0;){if("break"===l())break}return s?this.recontructPath(a,n,r):null},i.recontructPath=function(t,e,i){var n=[],r=i;for(n.push(i);r!=e;)r=this.getKey(t,r),n.push(r);return n.reverse(),n},i.hasKey=function(t,e){for(var i,n=t.keys();!(i=n.next()).done;)if(JSON.stringify(i.value)==JSON.stringify(e))return!0;return!1},i.getKey=function(t,e){for(var i,n,r=t.keys(),o=t.values();i=r.next(),n=o.next(),!i.done;)if(JSON.stringify(i.value)==JSON.stringify(e))return n.value;return null},i}();t.WeightedPathfinder=i}(es||(es={})),function(t){var e=function(e){function i(){var n=e.call(this)||this;return n._globalManagers=[],n._timerManager=new t.TimerManager,i._instance=n,i.emitter=new t.Emitter,i.content=new t.ContentManager,n.addEventListener(egret.Event.ADDED_TO_STAGE,n.onAddToStage,n),i.registerGlobalManager(n._timerManager),n}return __extends(i,e),Object.defineProperty(i,"Instance",{get:function(){return this._instance},enumerable:!0,configurable:!0}),Object.defineProperty(i,"scene",{get:function(){return this._instance?this._instance._scene:null},set:function(t){t?null==this._instance._scene?(this._instance.addChild(t),this._instance._scene=t,this._instance._scene.begin(),i.Instance.onSceneChanged()):this._instance._nextScene=t:console.error("场景不能为空")},enumerable:!0,configurable:!0}),i.startSceneTransition=function(t){if(!this._instance._sceneTransition)return this._instance._sceneTransition=t,t;console.warn("在前一个场景完成之前,不能开始一个新的场景转换。")},i.registerGlobalManager=function(t){this._instance._globalManagers.push(t),t.enabled=!0},i.unregisterGlobalManager=function(t){this._instance._globalManagers.remove(t),t.enabled=!1},i.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._scene.parent&&this._scene.parent.removeChild(this._scene),this._scene.end(),this._scene=this._nextScene,this._nextScene=null,this.onSceneChanged(),[4,this._scene.begin()]):[3,2];case 1:i.sent(),this.addChild(this._scene),i.label=2;case 2:return this.endDebugUpdate(),[4,this.draw()];case 3:return i.sent(),[2]}})})},i.prototype.onAddToStage=function(){i.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(),KeyboardUtils.init(),this.initialize()},i.debugRenderEndabled=!1,i}(egret.DisplayObjectContainer);t.Core=e}(es||(es={})),function(t){var e=function(){function t(){}return t.renderableBounds=16776960,t.renderableCenter=10040012,t.colliderBounds=5592405,t.colliderEdge=9109504,t.colliderPosition=16776960,t.colliderCenter=16711680,t}();t.Colors=e;var i=function(){function e(){}return Object.defineProperty(e,"lineSizeMultiplier",{get:function(){return Math.max(Math.ceil(t.Core.scene.x/t.Core.scene.width),1)},enumerable:!0,configurable:!0}),e}();t.Size=i;var n=function(){function e(){}return e.drawHollowRect=function(e,i,n){void 0===n&&(n=0),this._debugDrawItems.push(new t.DebugDrawItem(e,i,n))},e.render=function(){if(this._debugDrawItems.length>0){var e=new egret.Shape;t.Core.scene&&t.Core.scene.addChild(e);for(var i=this._debugDrawItems.length-1;i>=0;i--){this._debugDrawItems[i].draw(e)&&this._debugDrawItems.removeAt(i)}}},e._debugDrawItems=[],e}();t.Debug=n}(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 i=function(){function i(t,i,n){this.rectangle=t,this.color=i,this.duration=n,this.drawType=e.hollowRectangle}return i.prototype.draw=function(i){switch(this.drawType){case e.line:case e.hollowRectangle:case e.pixel:case e.text:}return this.duration-=t.Time.deltaTime,this.duration<0},i}();t.DebugDrawItem=i}(es||(es={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateInterval=1,e.debugDisplayObject=new egret.DisplayObjectContainer,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){!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(i){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=i,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()},i.prototype.render=function(){if(0!=this._renderers.length)for(var t=0;te.x?-1:1,n=t.Vector2.normalize(t.Vector2.subtract(this.position,e));this.rotation=i*Math.acos(t.Vector2.dot(n,t.Vector2.unitY))},n.prototype.setLocalRotation=function(t){return this._localRotation=t,this._localDirty=this._positionDirty=this._localPositionDirty=this._localRotationDirty=this._localScaleDirty=!0,this.setDirty(e.rotationDirty),this},n.prototype.setLocalRotationDegrees=function(e){return this.setLocalRotation(t.MathHelper.toRadians(e))},n.prototype.setScale=function(e){return this._scale=e,this.parent?this.localScale=t.Vector2.divide(e,this.parent._scale):this.localScale=e,this},n.prototype.setLocalScale=function(t){return this._localScale=t,this._localDirty=this._positionDirty=this._localScaleDirty=!0,this.setDirty(e.scaleDirty),this},n.prototype.roundPosition=function(){this.position=this._position.round()},n.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)},n.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 i=0;it&&(this._zoom=t),this._maximumZoom=t,this;console.error("maximumZoom must be greater than zero")},n.prototype.forceMatrixUpdate=function(){this._areMatrixedDirty=!0},n.prototype.onEntityTransformChanged=function(t){this._areMatrixedDirty=!0},n.prototype.zoomIn=function(t){this.zoom+=t},n.prototype.zoomOut=function(t){this.zoom-=t},n.prototype.worldToScreenPoint=function(e){return this.updateMatrixes(),e=t.Vector2Ext.transformR(e,this._transformMatrix)},n.prototype.screenToWorldPoint=function(e){return this.updateMatrixes(),e=t.Vector2Ext.transformR(e,this._inverseTransformMatrix)},n.prototype.onSceneRenderTargetSizeChanged=function(e,i){this._isProjectionMatrixDirty=!0;var n=this._origin;this.origin=new t.Vector2(e/2,i/2),this.entity.transform.position.add(t.Vector2.subtract(this._origin,n))},n.prototype.mouseToWorldPoint=function(){return this.screenToWorldPoint(t.Input.touchPosition)},n.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)},n}(t.Component);t.Camera=i}(es||(es={})),function(t){var e=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i._shakeDirection=t.Vector2.zero,i._shakeOffset=t.Vector2.zero,i._shakeIntensity=0,i._shakeDegredation=.95,i}return __extends(i,e),i.prototype.shake=function(e,i,n){void 0===e&&(e=15),void 0===i&&(i=.9),void 0===n&&(n=t.Vector2.zero),this.enabled=!0,this._shakeIntensity=1)&&(i=.95),this._shakeDegredation=i)},i.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)},i}(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(t){t[t.lockOn=0]="lockOn",t[t.cameraWindow=1]="cameraWindow"}(e=t.CameraStyle||(t.CameraStyle={}));var i=function(i){function n(n,r,o){void 0===n&&(n=null),void 0===r&&(r=null),void 0===o&&(o=e.lockOn);var s=i.call(this)||this;return s.followLerp=.1,s.deadzone=new t.Rectangle,s.focusOffset=t.Vector2.zero,s.mapLockEnabled=!1,s.mapSize=new t.Rectangle,s._desiredPositionDelta=new t.Vector2,s._worldSpaceDeadZone=new t.Rectangle,s.rectShape=new egret.Shape,s._targetEntity=n,s._cameraStyle=o,s.camera=r,s}return __extends(n,i),n.prototype.onAddedToEntity=function(){this.camera||(this.camera=this.entity.scene.camera),this.follow(this._targetEntity,this._cameraStyle),t.Core.emitter.addObserver(t.CoreEvents.GraphicsDeviceReset,this.onGraphicsDeviceReset,this)},n.prototype.onGraphicsDeviceReset=function(){t.Core.schedule(0,!1,this,function(t){var e=t.context;e.follow(e._targetEntity,e._cameraStyle)})},n.prototype.update=function(){var e=t.Vector2.multiply(this.camera.bounds.size,new t.Vector2(.5));this._worldSpaceDeadZone.x=this.camera.position.x-e.x*t.Core.scene.scaleX+this.deadzone.x+this.focusOffset.x,this._worldSpaceDeadZone.y=this.camera.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.camera.position=t.Vector2.lerp(this.camera.position,t.Vector2.add(this.camera.position,this._desiredPositionDelta),this.followLerp),this.entity.transform.roundPosition(),this.mapLockEnabled&&(this.camera.position=this.clampToMapSize(this.camera.position),this.entity.transform.roundPosition())},n.prototype.debugRender=function(){this.rectShape||this.debugDisplayObject.addChild(this.rectShape),this.rectShape.graphics.clear(),this._cameraStyle==e.lockOn?(this.rectShape.graphics.beginFill(9109504,0),this.rectShape.graphics.lineStyle(1,9109504),this.rectShape.graphics.drawRect(this._worldSpaceDeadZone.x-5,this._worldSpaceDeadZone.y-5,this._worldSpaceDeadZone.width,this._worldSpaceDeadZone.height),this.rectShape.graphics.endFill()):(this.rectShape.graphics.beginFill(9109504,0),this.rectShape.graphics.lineStyle(1,9109504),this.rectShape.graphics.drawRect(this._worldSpaceDeadZone.x,this._worldSpaceDeadZone.y,this._worldSpaceDeadZone.width,this._worldSpaceDeadZone.height),this.rectShape.graphics.endFill())},n.prototype.clampToMapSize=function(e){var i=t.Vector2.multiply(this.camera.bounds.size,new t.Vector2(.5)).add(new t.Vector2(this.mapSize.x,this.mapSize.y)),n=new t.Vector2(this.mapSize.width-i.x,this.mapSize.height-i.y);return t.Vector2.clamp(e,i,n)},n.prototype.follow=function(i,n){void 0===n&&(n=e.cameraWindow),this._targetEntity=i,this._cameraStyle=n;var r=this.camera.bounds;switch(this._cameraStyle){case e.cameraWindow:var o=r.width/6,s=r.height/3;this.deadzone=new t.Rectangle((r.width-o)/2,(r.height-s)/2,o,s);break;case e.lockOn:this.deadzone=new t.Rectangle(r.width/2,r.height/2,10,10)}},n.prototype.updateFollow=function(){if(this._desiredPositionDelta.x=this._desiredPositionDelta.y=0,this._cameraStyle==e.lockOn){var i=this._targetEntity.transform.position.x,n=this._targetEntity.transform.position.y;this._worldSpaceDeadZone.x>i?this._desiredPositionDelta.x=i-this._worldSpaceDeadZone.x:this._worldSpaceDeadZone.xn&&(this._desiredPositionDelta.y=n-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))}},n.prototype.setCenteredDeadzone=function(e,i){if(this.camera){var n=this.camera.bounds;this.deadzone=new t.Rectangle((n.width-e)/2,(n.height-i)/2,e,i)}else console.error("相机是null。我们不能得到它的边界。请等到该组件添加到实体之后")},n}(t.Component);t.FollowCamera=i}(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 i(){var i=null!==e&&e.apply(this,arguments)||this;return i.displayObject=new egret.DisplayObject,i.hollowShape=new egret.Shape,i.pixelShape=new egret.Shape,i.color=0,i._areBoundsDirty=!0,i.debugRenderEnabled=!0,i._localOffset=t.Vector2.zero,i._renderLayer=0,i._bounds=new t.Rectangle,i}return __extends(i,e),Object.defineProperty(i.prototype,"width",{get:function(){return this.bounds.width},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this.bounds.height},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"localOffset",{get:function(){return this._localOffset},set:function(t){this.setLocalOffset(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"renderLayer",{get:function(){return this._renderLayer},set:function(t){this.setRenderLayer(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.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(i.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}),i.prototype.onEntityTransformChanged=function(t){this._areBoundsDirty=!0},i.prototype.debugRender=function(){if(this.debugRenderEnabled){this.hollowShape.parent||this.debugDisplayObject.addChild(this.hollowShape),this.pixelShape.parent||this.debugDisplayObject.addChild(this.pixelShape);var e=t.Vector2.add(this.entity.transform.position,this._localOffset);this.pixelShape.graphics.clear(),this.pixelShape.graphics.beginFill(t.Colors.renderableCenter,0),this.pixelShape.graphics.lineStyle(4,t.Colors.renderableCenter),this.pixelShape.graphics.lineTo(e.x,e.y),this.pixelShape.graphics.moveTo(e.x,e.y),this.pixelShape.graphics.endFill()}},i.prototype.isVisibleFromCamera=function(t){return!!t&&(this.isVisible=t.bounds.intersects(this.bounds),this.isVisible)},i.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},i.prototype.setColor=function(t){return this.color=t,this},i.prototype.setLocalOffset=function(t){return this._localOffset!=t&&(this._localOffset=t),this},i.prototype.sync=function(e){var i=new t.Vector2(this.entity.position.x+this.localOffset.x-e.position.x+e.origin.x,this.entity.position.y+this.localOffset.y-e.position.y+e.origin.y);this.displayObject.x!=i.x&&(this.displayObject.x=i.x),this.displayObject.y!=i.y&&(this.displayObject.y=i.y),this.displayObject.scaleX!=this.entity.scale.x&&(this.displayObject.scaleX=this.entity.scale.x),this.displayObject.scaleY!=this.entity.scale.y&&(this.displayObject.scaleY=this.entity.scale.y),this.displayObject.rotation!=this.entity.rotation&&(this.displayObject.rotation=this.entity.rotation)},i.prototype.toString=function(){return"[RenderableComponent] renderLayer: "+this.renderLayer},i.prototype.onBecameVisible=function(){this.displayObject.visible=this.isVisible,this.debugDisplayObject.visible=this.isVisible},i.prototype.onBecameInvisible=function(){this.displayObject.visible=this.isVisible,this.debugDisplayObject.visible=this.isVisible},i}(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,i=function(i){function n(e){void 0===e&&(e=null);var n=i.call(this)||this;return e instanceof t.Sprite?n.setSprite(e):e instanceof egret.Texture&&n.setSprite(new t.Sprite(e)),n}return __extends(n,i),Object.defineProperty(n.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(n.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(n.prototype,"origin",{get:function(){return this._origin},set:function(t){this.setOrigin(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"sprite",{get:function(){return this._sprite},set:function(t){this.setSprite(t)},enumerable:!0,configurable:!0}),n.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},n.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},n.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},n.prototype.render=function(e){this.sync(e);var i=new t.Vector2(this.entity.position.x+this.localOffset.x-this.origin.x-e.position.x+e.origin.x,this.entity.position.y+this.localOffset.y-this.origin.y-e.position.y+e.origin.y);this.displayObject.x!=i.x&&(this.displayObject.x=i.x),this.displayObject.y!=i.y&&(this.displayObject.y=i.y)},n}(t.RenderableComponent);t.SpriteRenderer=i}(es||(es={})),function(t){var e=egret.Bitmap,i=egret.RenderTexture,n=function(n){function r(e){var i=n.call(this,e)||this;return i._textureScale=t.Vector2.one,i._inverseTexScale=t.Vector2.one,i._gapX=0,i._gapY=0,i._sourceRect=e.sourceRect,i.displayObject.$fillMode=egret.BitmapFillMode.REPEAT,i}return __extends(r,n),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 n=new i,r=this.sprite.sourceRect;r.x=0,r.y=0,r.width+=this._gapX,r.height+=this._gapY,n.drawToTexture(this.displayObject,r),this.displayObject?this.displayObject.texture=n:this.displayObject=new e(n)},enumerable:!0,configurable:!0}),r.prototype.setGapXY=function(t){return this.gapXY=t,this},r.prototype.render=function(t){n.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=n}(es||(es={})),function(t){var e=function(e){function i(t){var i=e.call(this,t)||this;return i.scrollSpeedX=15,i.scroolSpeedY=0,i._scrollX=0,i._scrollY=0,i._scrollWidth=0,i._scrollHeight=0,i._scrollWidth=i.width,i._scrollHeight=i.height,i}return __extends(i,e),Object.defineProperty(i.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(i.prototype,"scrollWidth",{get:function(){return this._scrollWidth},set:function(t){this._scrollWidth=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scrollHeight",{get:function(){return this._scrollHeight},set:function(t){this._scrollHeight=t},enumerable:!0,configurable:!0}),i.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))},i}(t.TiledSpriteRenderer);t.ScrollingSpriteRenderer=e}(es||(es={})),function(t){var e=egret.SpriteSheet,i=function(){function i(e,i,n){void 0===i&&(i=new t.Rectangle(0,0,e.textureWidth,e.textureHeight)),void 0===n&&(n=i.getHalfSize()),this.uvs=new t.Rectangle,this.texture2D=e,this.sourceRect=i,this.center=new t.Vector2(.5*i.width,.5*i.height),this.origin=n;var r=1/e.textureWidth,o=1/e.textureHeight;this.uvs.x=i.x*r,this.uvs.y=i.y*o,this.uvs.width=i.width*r,this.uvs.height=i.height*o}return i.spritesFromAtlas=function(t,n,r,o,s){void 0===o&&(o=0),void 0===s&&(s=Number.MAX_VALUE);for(var a=[],h=t.textureWidth/n,c=t.textureHeight/r,l=0,u=new e(t),p=0;po||this._loopMode==e.pingPongOnce&&s>2*o)return this.animationState=i.completed,this._elapsedTime=0,this.currentFrame=0,void(this.displayObject.texture=n.sprites[this.currentFrame].texture2D);var a=Math.floor(s/r),h=n.sprites.length;if(h>2&&(this._loopMode==e.pingPong||this._loopMode==e.pingPongOnce)){var c=h-1;this.currentFrame=c-Math.abs(c-a%(2*c))}else this.currentFrame=a%h;this.displayObject.texture=n.sprites[this.currentFrame].texture2D}},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,n){void 0===n&&(n=null),this.currentAnimation=this._animations[t],this.currentAnimationName=t,this.currentFrame=0,this.animationState=i.running,this.displayObject.texture=this.currentAnimation.sprites[0].texture2D,this._elapsedTime=0,this._loopMode=n||e.loop},r.prototype.isAnimationActive=function(t){return this.currentAnimation&&this.currentAnimationName==t},r.prototype.pause=function(){this.animationState=i.paused},r.prototype.unPause=function(){this.animationState=i.running},r.prototype.stop=function(){this.currentAnimation=null,this.currentAnimationName=null,this.currentFrame=0,this.animationState=i.none},r}(t.SpriteRenderer);t.SpriteAnimator=n}(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 i=function(e){function i(){var t=e.call(this)||this;return t.colliderHorizontalInset=2,t.colliderVerticalInset=6,t}return __extends(i,e),i.prototype.testCollisions=function(e,i,n){this._boxColliderBounds=i,n.wasGroundedLastFrame=n.below,n.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,n,0)?(e.x=0-t.RectangleExt.getSide(i,o),n.left=o==t.Edge.left,n.right=o==t.Edge.right,n._movementRemainderX.reset()):(n.left=!1,n.right=!1)}},i.prototype.testMapCollision=function(e,i,n,r){var o=t.EdgeExt.oppositeEdge(i);t.EdgeExt.isVertical(o)?e.center.x:e.center.y,t.RectangleExt.getSide(e,i),t.EdgeExt.isVertical(o)},i.prototype.collisionRectForSide=function(e,i){var n;return n=t.EdgeExt.isHorizontal(e)?t.RectangleExt.getRectEdgePortion(this._boxColliderBounds,e):t.RectangleExt.getHalfRect(this._boxColliderBounds,e),t.EdgeExt.isVertical(e)?t.RectangleExt.contract(n,this.colliderHorizontalInset,0):t.RectangleExt.contract(n,0,this.colliderVerticalInset),t.RectangleExt.expandSide(n,e,i),n},i}(t.Component);t.TiledMapMover=i}(es||(es={})),function(t){var e=function(e){function i(t,i,n){void 0===i&&(i=null),void 0===n&&(n=!0);var r=e.call(this)||this;return r.physicsLayer=1,r.toContainer=!1,r.tiledMap=t,r._shouldCreateColliders=n,r.displayObject=new egret.DisplayObjectContainer,i&&(r.collisionLayer=t.tileLayers[i]),r}return __extends(i,e),Object.defineProperty(i.prototype,"width",{get:function(){return this.tiledMap.width*this.tiledMap.tileWidth},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this.tiledMap.height*this.tiledMap.tileHeight},enumerable:!0,configurable:!0}),i.prototype.setLayerToRender=function(t){this.layerIndicesToRender=[],this.layerIndicesToRender[0]=this.getLayerIndex(t)},i.prototype.setLayersToRender=function(){for(var t=[],e=0;e=2){this.polygonShape.graphics.beginFill(t.Colors.colliderEdge,0),this.polygonShape.graphics.lineStyle(t.Size.lineSizeMultiplier,t.Colors.colliderEdge);for(var i=0;i>6;0!=(e&t.LONG_MASK)&&i++,this._bits=new Array(i)}return t.prototype.and=function(t){for(var e,i=Math.min(this._bits.length,t._bits.length),n=0;n=0;)this._bits[e]&=~t._bits[e]},t.prototype.cardinality=function(){for(var t=0,e=this._bits.length-1;e>=0;e--){var i=this._bits[e];if(0!=i)if(-1!=i){var n=((i=((i=(i>>1&0x5555555555555400)+(0x5555555555555400&i))>>2&0x3333333333333400)+(0x3333333333333400&i))>>32)+i;t+=((n=((n=(n>>4&252645135)+(252645135&n))>>8&16711935)+(16711935&n))>>16&65535)+(65535&n)}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,i=1<>6;this.ensure(i),this._bits[i]|=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 i=0;i0){i=0;for(var n=this._componentsToAdd.length;i0){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,i=[],n=0;n0){for(var t=0,i=this._unsortedRenderLayers.length;t=e)return t;var n=!1;"-"==t.substr(0,1)&&(n=!0,t=t.substr(1));for(var r=e-i,o=0;o1?this.reverse(t.substring(1))+t.substring(0,1):t},t.cutOff=function(t,e,i,n){void 0===n&&(n=!0),e=Math.floor(e),i=Math.floor(i);var r=t.length;e>r&&(e=r);var o,s=e,a=e+i;return n?o=t.substring(0,s)+t.substr(a,r):(a=(s=r-1-e-i)+i,o=t.substring(0,s+1)+t.substr(a+1,r)),o},t.strReplace=function(t,e){for(var i=0,n=e.length;i",">",'"',""","'","'","®","®","©","©","™","™"],t}();!function(t){var e=function(){function e(){}return e.convertImageToCanvas=function(e,i){this.sharedCanvas||(this.sharedCanvas=egret.sys.createCanvas(),this.sharedContext=this.sharedCanvas.getContext("2d"));var n=e.$getTextureWidth(),r=e.$getTextureHeight();i||((i=egret.$TempRectangle).x=0,i.y=0,i.width=n,i.height=r),i.x=Math.min(i.x,n-1),i.y=Math.min(i.y,r-1),i.width=Math.min(i.width,n-i.x),i.height=Math.min(i.height,r-i.y);var o=Math.floor(i.width),s=Math.floor(i.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 h=void 0;e.$renderBuffer?h=e:(egret.sys.systemRenderer.renderClear&&egret.sys.systemRenderer.renderClear(),(h=new egret.RenderTexture).drawToTexture(new egret.Bitmap(e)));for(var c=h.$renderBuffer.getPixels(i.x,i.y,o,s),l=0,u=0,p=0;p=0?"png":"jpg"});return wx.getFileSystemManager().saveFile({tempFilePath:o,filePath:wx.env.USER_DATA_PATH+"/"+i,success:function(t){}}),o},e.getPixel32=function(t,e,i){return egret.$warn(1041,"getPixel32","getPixels"),t.getPixels(e,i)},e.getPixels=function(t,e,i,n,r){if(void 0===n&&(n=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,i,n,r)}try{this.convertImageToCanvas(t);return this.sharedContext.getImageData(e,i,n,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(),i=t.getMonth()+1;return parseInt(e+(i<10?"0":"")+i)},t.dateId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getMonth()+1,i=e<10?"0":"",n=t.getDate(),r=n<10?"0":"";return parseInt(t.getFullYear()+i+e+r+n)},t.weekId=function(t,e){void 0===t&&(t=null),void 0===e&&(e=!0),t=t||new Date;var i=new Date;i.setTime(t.getTime()),i.setDate(1),i.setMonth(0);var n=i.getFullYear(),r=i.getDay();0==r&&(r=7);var o=!1;r<=4?(o=r>1,i.setDate(i.getDate()-(r-1))):i.setDate(i.getDate()+7-r+1);var s=this.diffDay(t,i,!1);if(s<0)return i.setDate(1),i.setMonth(0),i.setDate(i.getDate()-1),this.weekId(i,!1);var a=s/7,h=Math.floor(a)+1;if(53==h){i.setTime(t.getTime()),i.setDate(i.getDate()-1);var c=i.getDay();if(0==c&&(c=7),e&&(!o||c<4))return i.setFullYear(i.getFullYear()+1),i.setDate(1),i.setMonth(0),this.weekId(i,!1)}return parseInt(n+"00"+(h>9?"":"0")+h)},t.diffDay=function(t,e,i){void 0===i&&(i=!1);var n=(t.getTime()-e.getTime())/864e5;return i?Math.ceil(n):Math.floor(n)},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(),i=t.getMonth()+1;i=i<10?"0"+i:i;var n=t.getDate();return e+"-"+i+"-"+(n=n<10?"0"+n:n)},t.formatDateTime=function(t){var e=t.getFullYear(),i=t.getMonth()+1;i=i<10?"0"+i:i;var n=t.getDate();n=n<10?"0"+n:n;var r=t.getHours(),o=t.getMinutes();o=o<10?"0"+o:o;var s=t.getSeconds();return e+"-"+i+"-"+n+" "+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,i){void 0===t&&(t=0),void 0===e&&(e=":"),void 0===i&&(i=!0);var n=Math.floor(t/3600),r=Math.floor(t%3600/60),o=Math.floor(t%3600%60),s=n.toString(),a=r.toString(),h=o.toString();return n<10&&(s="0"+s),r<10&&(a="0"+a),o<10&&(h="0"+h),i?s+e+a+e+h:a+e+h},t.timeToMillisecond=function(t,e){void 0===e&&(e=":");for(var i=t.split(e),n=0,r=i.length,o=0;o-1?this.os="iOS":n.indexOf("android")>-1&&(this.os="Android");var r=i.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,i,n){this._x=t,this._y=e,this._width=i,this._height=n,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 i(){return e.call(this,t.PostProcessor.default_vert,i.blur_frag,{screenWidth:t.Core.graphicsDevice.viewport.width,screenHeight:t.Core.graphicsDevice.viewport.height})||this}return __extends(i,e),i.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}",i}(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 i(){return null!==e&&e.apply(this,arguments)||this}return __extends(i,e),i.prototype.onAddedToScene=function(i){e.prototype.onAddedToScene.call(this,i),this.effect=new t.GaussianBlurEffect},i}(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.shouldDebugRender=!0,this.camera=e,this.renderOrder=t}return Object.defineProperty(t.prototype,"wantsToRenderToSceneRenderTarget",{get:function(){return!!this.renderTexture},enumerable:!0,configurable:!0}),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.prototype.debugRender=function(t,e){for(var i=0;ii?i:t},e.pointOnCirlce=function(i,n,r){var o=e.toRadians(r);return new t.Vector2(Math.cos(o)*o+i.x,Math.sin(o)*o+i.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.approach=function(t,e,i){return tn&&(n=s.x),s.yr&&(r=s.y)}return this.fromMinMax(e,i,n,r)},i.prototype.intersects=function(t){return t.leftthis.x+this.width)return!1}else{var n=1/t.direction.x,r=(this.x-t.start.x)*n,o=(this.x+this.width-t.start.x)*n;if(r>o){var s=r;r=o,o=s}if(e.value=Math.max(r,e.value),i=Math.min(o,i),e.value>i)return!1}if(Math.abs(t.direction.y)<1e-6){if(t.start.ythis.y+this.height)return!1}else{var a=1/t.direction.y,h=(this.y-t.start.y)*a,c=(this.y+this.height-t.start.y)*a;if(h>c){var l=h;h=c,c=l}if(e.value=Math.max(h,e.value),i=Math.max(c,i),e.value>i)return!1}return!0},i.prototype.containsRect=function(t){return this.x<=t.x&&t.x1)return!1;var l=(h.x*o.y-h.y*o.x)/a;return!(l<0||l>1)},i.lineToLineIntersection=function(e,i,n,r){var o=new t.Vector2(0,0),s=t.Vector2.subtract(i,e),a=t.Vector2.subtract(r,n),h=s.x*a.y-s.y*a.x;if(0==h)return o;var c=t.Vector2.subtract(n,e),l=(c.x*a.y-c.y*a.x)/h;if(l<0||l>1)return o;var u=(c.x*s.y-c.y*s.x)/h;return u<0||u>1?o:o=t.Vector2.add(e,new t.Vector2(l*s.x,l*s.y))},i.closestPointOnLine=function(e,i,n){var r=t.Vector2.subtract(i,e),o=t.Vector2.subtract(n,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))},i.isCircleToCircle=function(e,i,n,r){return t.Vector2.distanceSquared(e,n)<(i+r)*(i+r)},i.isCircleToLine=function(e,i,n,r){return t.Vector2.distanceSquared(e,this.closestPointOnLine(n,r,e))=t&&r.y>=e&&r.x=t+n&&(s|=e.right),o.y=i+r&&(s|=e.bottom),s},i}();t.Collisions=i}(es||(es={})),function(t){var e=function(){function e(e,i,n,r,o){this.fraction=0,this.distance=0,this.point=t.Vector2.zero,this.normal=t.Vector2.zero,this.collider=e,this.fraction=i,this.distance=n,this.point=r,this.centroid=t.Vector2.zero}return e.prototype.setValues=function(t,e,i,n){this.collider=t,this.fraction=e,this.distance=i,this.point=n},e.prototype.setValuesNonCollider=function(t,e,i,n){this.fraction=t,this.distance=e,this.point=i,this.normal=n},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 e(){}return e.reset=function(){this._spatialHash=new t.SpatialHash(this.spatialHashCellSize)},e.clear=function(){this._spatialHash.clear()},e.overlapCircleAll=function(t,e,i,n){if(void 0===n&&(n=-1),0!=i.length)return this._spatialHash.overlapCircle(t,e,i,n);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,i){return void 0===i&&(i=this.allLayers),this._spatialHash.aabbBroadphase(e,t,i)},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.linecast=function(t,i,n){return void 0===n&&(n=e.allLayers),this._hitArray[0].reset(),this.linecastAll(t,i,this._hitArray,n),this._hitArray[0]},e.linecastAll=function(t,i,n,r){return void 0===r&&(r=e.allLayers),0==n.length?(console.warn("传入了一个空的hits数组。没有点击会被返回"),0):this._spatialHash.linecast(t,i,n,r)},e.debugDraw=function(t){this._spatialHash.debugDraw(t,2)},e.spatialHashCellSize=100,e.allLayers=-1,e.raycastsHitTriggers=!1,e.raycastsStartInColliders=!1,e._hitArray=[new t.RaycastHit],e}();t.Physics=e}(es||(es={})),function(t){var e=function(){return function(e,i){this.start=e,this.end=i,this.direction=t.Vector2.subtract(this.end,this.start)}}();t.Ray2D=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 i(t,i){var n=e.call(this)||this;return n._areEdgeNormalsDirty=!0,n.isUnrotated=!0,n.setPoints(t),n.isBox=i,n}return __extends(i,e),Object.defineProperty(i.prototype,"edgeNormals",{get:function(){return this._areEdgeNormalsDirty&&this.buildEdgeNormals(),this._edgeNormals},enumerable:!0,configurable:!0}),i.prototype.setPoints=function(t){this.points=t,this.recalculateCenterAndEdgeNormals(),this._originalPoints=[];for(var e=0;e=this.points.length?this.points[0]:this.points[n+1];var o=t.Vector2Ext.perpendicular(r,e);t.Vector2Ext.normalize(o),this._edgeNormals[n]=o}},i.buildSymmetricalPolygon=function(e,i){for(var n=new Array(e),r=0;rr&&(r=s,n=o)}return e[n]},i.getClosestPointOnPolygonToPoint=function(e,i,n,r){n.value=Number.MAX_VALUE,r.x=0,r.y=0;for(var o,s=new t.Vector2(0,0),a=0;at.y!=this.points[n].y>t.y&&t.x<(this.points[n].x-this.points[i].x)*(t.y-this.points[i].y)/(this.points[n].y-this.points[i].y)+this.points[i].x&&(e=!e);return e},i.prototype.pointCollidesWithShape=function(e,i){return t.ShapeCollisions.pointToPoly(e,this,i)},i}(t.Shape);t.Polygon=e}(es||(es={})),function(t){var e=function(e){function i(t,n){var r=e.call(this,i.buildBox(t,n),!0)||this;return r.width=t,r.height=n,r}return __extends(i,e),i.buildBox=function(e,i){var n=e/2,r=i/2,o=new Array(4);return o[0]=new t.Vector2(-n,-r),o[1]=new t.Vector2(n,-r),o[2]=new t.Vector2(n,r),o[3]=new t.Vector2(-n,r),o},i.prototype.updateBox=function(e,i){this.width=e,this.height=i;var n=e/2,r=i/2;this.points[0]=new t.Vector2(-n,-r),this.points[1]=new t.Vector2(n,-r),this.points[2]=new t.Vector2(n,r),this.points[3]=new t.Vector2(-n,r);for(var o=0;o1)return!1;var a,h=t.Vector2.add(s.start,t.Vector2.add(s.direction,new t.Vector2(r.value))),c=0;h.xi.bounds.right&&(c|=1),h.yi.bounds.bottom&&(c|=2);var l=a+c;return 3==l&&console.log("m == 3. corner "+t.Time.frameCount),!0},e}();t.RealtimeCollisions=e}(es||(es={})),function(t){var e=function(){function e(){}return e.polygonToPolygon=function(e,i,n){for(var r,o=!0,s=e.edgeNormals,a=i.edgeNormals,h=Number.POSITIVE_INFINITY,c=new t.Vector2,l=t.Vector2.subtract(e.position,i.position),u=0;u0&&(o=!1),!o)return!1;(y=Math.abs(y))r&&(r=o);return{min:n,max:r}},e.circleToPolygon=function(e,i,n){var r,o=t.Vector2.subtract(e.position,i.position),s=new t.Ref(0),a=t.Polygon.getClosestPointOnPolygonToPoint(i.points,o,s,n.normal),h=i.containsPoint(e.position);if(s.value>e.radius*e.radius&&!h)return!1;if(h)r=t.Vector2.multiply(n.normal,new t.Vector2(Math.sqrt(s.value)-e.radius));else if(0==s.value)r=t.Vector2.multiply(n.normal,new t.Vector2(e.radius));else{var c=Math.sqrt(s.value);r=t.Vector2.multiply(new t.Vector2(-t.Vector2.subtract(o,a)),new t.Vector2((e.radius-s.value)/c))}return n.minimumTranslationVector=r,n.point=t.Vector2.add(a,i.position),!0},e.circleToBox=function(e,i,n){var r=i.bounds.getClosestPointOnRectangleBorderToPoint(e.position,n.normal);if(i.containsPoint(e.position)){n.point=r;var o=t.Vector2.add(r,t.Vector2.multiply(n.normal,new t.Vector2(e.radius)));return n.minimumTranslationVector=t.Vector2.subtract(e.position,o),!0}var s=t.Vector2.distanceSquared(r,e.position);if(0==s)n.minimumTranslationVector=t.Vector2.multiply(n.normal,new t.Vector2(e.radius));else if(s<=e.radius*e.radius){n.normal=t.Vector2.subtract(e.position,r);var a=n.normal.length()-e.radius;return n.point=r,t.Vector2Ext.normalize(n.normal),n.minimumTranslationVector=t.Vector2.multiply(new t.Vector2(a),n.normal),!0}return!1},e.pointToCircle=function(e,i,n){var r=t.Vector2.distanceSquared(e,i.position),o=1+i.radius;if(r1)return!1;var u=(c.x*s.y-c.y*s.x)/h;return!(u<0||u>1)&&(o=o.add(e).add(t.Vector2.multiply(new t.Vector2(l),s)),!0)},e.lineToCircle=function(e,i,n,r){var o=t.Vector2.distance(e,i),s=t.Vector2.divide(t.Vector2.subtract(i,e),new t.Vector2(o)),a=t.Vector2.subtract(e,n.position),h=t.Vector2.dot(a,s),c=t.Vector2.dot(a,a)-n.radius*n.radius;if(c>0&&h>0)return!1;var l=h*h-c;return!(l<0)&&(r.fraction=-h-Math.sqrt(l),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,n.position)),r.fraction=r.distance/o,!0)},e.boxToBoxCast=function(e,i,n,r){var o=this.minkowskiDifference(e,i);if(o.contains(0,0)){var s=o.getClosestPointOnBoundsToOrigin();return!s.equals(t.Vector2.zero)&&(r.normal=new t.Vector2(-s.x),r.normal.normalize(),r.distance=0,r.fraction=0,!0)}var a=new t.Ray2D(t.Vector2.zero,new t.Vector2(-n.x)),h=new t.Ref(0);return!!(o.rayIntersects(a,h)&&h.value<=1)&&(r.fraction=h.value,r.distance=n.length()*h.value,r.normal=new t.Vector2(-n.x,-n.y),r.normal.normalize(),r.centroid=t.Vector2.add(e.bounds.center,t.Vector2.multiply(n,new t.Vector2(h.value))),!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 i,this._tempHashSet=[],this._cellSize=e,this._inverseCellSize=1/this._cellSize,this._raycastParser=new n}return e.prototype.register=function(e){var i=e.bounds;e.registeredPhysicsBounds=i;var n=this.cellCoords(i.x,i.y),r=this.cellCoords(i.right,i.bottom);this.gridBounds.contains(n.x,n.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,n)),this.gridBounds.contains(r.x,r.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,r));for(var o=n.x;o<=r.x;o++)for(var s=n.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,i=this.cellCoords(e.x,e.y),n=this.cellCoords(e.right,e.bottom),r=i.x;r<=n.x;r++)for(var o=i.y;o<=n.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 i=this.gridBounds.x;i<=this.gridBounds.right;i++)for(var n=this.gridBounds.y;n<=this.gridBounds.bottom;n++){var r=this.cellAtPosition(i,n);r&&r.length>0&&this.debugDrawCellDetails(i,n,r.length,t,e)}},e.prototype.aabbBroadphase=function(e,i,n){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 h=this.cellAtPosition(s,a);if(h)for(var c=function(r){var o=h[r];if(o==i||!t.Flags.isFlagSet(n,o.physicsLayer))return"continue";e.intersects(o.bounds)&&(l._tempHashSet.firstOrDefault(function(t){return t.hashCode==o.hashCode})||l._tempHashSet.push(o))},l=this,u=0;u=0&&(e.push(this.findBoundsRect(i,o,r,t)),i=-1)}i>=0&&(e.push(this.findBoundsRect(i,this.map.width,r,t)),i=-1)}return e},e.prototype.findBoundsRect=function(e,i,n,r){for(var o=-1,s=n+1;sthis.tileHeight||this.maxTileWidth>this.tileWidth},enumerable:!0,configurable:!0}),i.prototype.getTilesetForTileGid=function(t){if(0==t)return null;for(var e=this.tilesets.length-1;e>=0;e--)if(this.tilesets[e].firstGid<=t)return this.tilesets[e];console.error("tile gid"+t+"未在任何tileset中找到")},i.prototype.worldToTilePositionX=function(e,i){void 0===i&&(i=!0);var n=Math.floor(e/this.tileWidth);return i?t.MathHelper.clamp(n,0,this.width-1):n},i.prototype.worldToTilePositionY=function(e,i){void 0===i&&(i=!0);var n=Math.floor(e/this.tileHeight);return i?t.MathHelper.clamp(n,0,this.height-1):n},i.prototype.getLayer=function(t){return this.layers[t]},i.prototype.update=function(){this.tilesets.forEach(function(t){t.update()})},i.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)},i}(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 i=function(){return function(){this.shape=new egret.Shape,this.textField=new egret.TextField}}();t.TmxObject=i;var n=function(){return function(){}}();t.TmxText=n;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(){function e(){}return e.loadTmxMap=function(t,e){var i=RES.getRes(e);return this.loadTmxMapData(t,i,RES.getResourceInfo(e))},e.loadTmxMapData=function(e,i,n){return __awaiter(this,void 0,void 0,function(){var r,o,s,a;return __generator(this,function(h){switch(h.label){case 0:e.version=i.version,e.tiledVersion=i.tiledversion,e.width=i.width,e.height=i.height,e.tileWidth=i.tilewidth,e.tileHeight=i.tileheight,e.hexSideLength=i.hexsidelength,e.orientation=this.parseOrientationType(i.orientation),e.staggerAxis=this.parseStaggerAxisType(i.staggeraxis),e.staggerIndex=this.parseStaggerIndexType(i.staggerindex),e.renderOrder=this.parseRenderOrderType(i.renderorder),e.nextObjectID=i.nextobjectid,e.backgroundColor=t.TmxUtils.color16ToUnit(i.color),e.properties=this.parsePropertyDict(i.properties),e.maxTileWidth=e.tileWidth,e.maxTileHeight=e.tileHeight,e.tmxDirectory=n.root+n.url.replace(".","_").replace(n.name,""),e.tilesets=[],r=0,o=i.tilesets,h.label=1;case 1:return rt.map.maxTileWidth&&(t.map.maxTileWidth=e.image.width),e.image.height>t.map.maxTileHeight&&(t.map.maxTileHeight=e.image.height))}),t.tileRegions.forEach(function(e){var i=e.width,n=e.height;i>t.map.maxTileWidth&&(t.map.maxTileWidth=i),i>t.map.maxTileHeight&&(t.map.maxTileHeight=n)})},e.parseOrientationType=function(e){return"unknown"==e?t.OrientationType.unknown:"orthogonal"==e?t.OrientationType.orthogonal:"isometric"==e?t.OrientationType.isometric:"staggered"==e?t.OrientationType.staggered:"hexagonal"==e?t.OrientationType.hexagonal:t.OrientationType.unknown},e.parseStaggerAxisType=function(e){return"y"==e?t.StaggerAxisType.y:t.StaggerAxisType.x},e.parseStaggerIndexType=function(e){return"even"==e?t.StaggerIndexType.even:t.StaggerIndexType.odd},e.parseRenderOrderType=function(e){return"right-up"==e?t.RenderOrderType.rightUp:"left-down"==e?t.RenderOrderType.leftDown:"left-up"==e?t.RenderOrderType.leftUp:t.RenderOrderType.rightDown},e.parsePropertyDict=function(e){if(!e)return null;for(var i=new Map,n=0,r=e;n=e.columns));m+=e.tileWidth+e.spacing);else e.tiles.forEach(function(i,n){e.tileRegions.set(n,new t.Rectangle(0,0,i.image.width,i.image.height))});return[2,e]}})})},e.loadTmxTilesetTile=function(e,i,n,r,o){return __awaiter(this,void 0,void 0,function(){var s,a,h,c,l,u,p,d,f,g,y,m,_;return __generator(this,function(v){switch(v.label){case 0:if(e.tileset=i,e.id=n.id,s=n.terrain)for(e.terrainEdges=new Array(4),a=0,h=0,c=s;h0){a.shape.x=h.x,a.shape.y=h.y,i.addChild(a.shape),a.shape.graphics.clear(),a.shape.graphics.lineStyle(1,10526884);for(u=0;u0&&(l=u.currentAnimationFrameGid);var p=i.tileset.tileRegions.get(l),d=Math.floor(i.x)*s,f=Math.floor(i.y)*a;i.horizontalFlip&&i.verticalFlip?(d+=a+(p.height*o.y-a),f-=p.width*o.x-s):i.horizontalFlip?d+=s+(p.height*o.y-a):i.verticalFlip?f+=s-p.width*o.x:f+=a-p.height*o.y;var g=new t.Vector2(d,f).add(r);if(i.tileset.image){if(n){var y=i.tileset.image.bitmap.getTexture(""+l);y||(y=i.tileset.image.bitmap.createTexture(""+l,p.x,p.y,p.width,p.height)),i.tileset.image.texture=new e(y),n.addChild(i.tileset.image.texture),i.tileset.image.texture.x!=g.x&&(i.tileset.image.texture.x=g.x),i.tileset.image.texture.y!=g.y&&(i.tileset.image.texture.y=g.y),i.verticalFlip&&i.horizontalFlip?(i.tileset.image.texture.scaleX=-1,i.tileset.image.texture.scaleY=-1):i.verticalFlip?(i.tileset.image.texture.scaleX=o.x,i.tileset.image.texture.scaleY=-1):i.horizontalFlip?(i.tileset.image.texture.scaleX=-1,i.tileset.image.texture.scaleY=o.y):(i.tileset.image.texture.scaleX=o.x,i.tileset.image.texture.scaleY=o.y),0!=i.tileset.image.texture.rotation&&(i.tileset.image.texture.rotation=0),0!=i.tileset.image.texture.anchorOffsetX&&(i.tileset.image.texture.anchorOffsetX=0),0!=i.tileset.image.texture.anchorOffsetY&&(i.tileset.image.texture.anchorOffsetY=0)}}else u.image.texture&&(u.image.bitmap.getTexture(l.toString())||(u.image.texture=new e(u.image.bitmap.createTexture(l.toString(),p.x,p.y,p.width,p.height)),n.addChild(u.image.texture)),u.image.texture.x=g.x,u.image.texture.y=g.y,u.image.texture.scaleX=o.x,u.image.texture.scaleY=o.y,u.image.texture.rotation=0,u.image.texture.anchorOffsetX=0,u.image.texture.anchorOffsetY=0,u.image.texture.filters=[h])},i}();t.TiledRendering=i}(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 i=function(){return function(){}}();t.TmxTileOffset=i;var n=function(){return function(){}}();t.TmxTerrain=n}(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 i=function(){return function(){}}();t.TmxAnimationFrame=i}(es||(es={})),function(t){var e=function(){function e(){}return e.decode=function(e,i,n){switch(n=n||"none",i=i||"none"){case"base64":var r=t.Base64Utils.decodeBase64AsArray(e,4);return"none"===n?r:t.Base64Utils.decompress(e,r,n);case"csv":return t.Base64Utils.decodeCSV(e);case"none":for(var o=[],s=0;si;n--)if(t[n]0&&t[r-1]>n;r--)t[r]=t[r-1];t[r]=n}},t.binarySearch=function(t,e){for(var i=0,n=t.length,r=i+n>>1;i=t[r]&&(i=r+1),r=i+n>>1;return t[i]==e?i:-1},t.findElementIndex=function(t,e){for(var i=t.length,n=0;nt[e]&&(e=n);return e},t.getMinElementIndex=function(t){for(var e=0,i=t.length,n=1;n=0;--r)i.unshift(e[r]);return i},t.getDifferAry=function(t,e){t=this.getUniqueAry(t),e=this.getUniqueAry(e);for(var i=t.concat(e),n={},r=[],o=i.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 i=t.length;if(i!=e.length)return!1;for(;i--;)if(t[i]!=e[i])return!1;return!0},t.insert=function(t,e,i){if(!t)return null;var n=t.length;if(e>n&&(e=n),e<0&&(e=0),e==n)t.push(i);else if(0==e)t.unshift(i);else{for(var r=n-1;r>=e;r-=1)t[r+1]=t[r];t[e]=i}return i},t}();!function(t){var e=function(){function t(){}return Object.defineProperty(t,"nativeBase64",{get:function(){return"function"==typeof window.atob},enumerable:!0,configurable:!0}),t.decode=function(t){if(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,""),this.nativeBase64)return window.atob(t);for(var e,i,n,r,o,s,a=[],h=0;h>4,i=(15&r)<<4|(o=this._keyStr.indexOf(t.charAt(h++)))>>2,n=(3&o)<<6|(s=this._keyStr.indexOf(t.charAt(h++))),a.push(String.fromCharCode(e)),64!==o&&a.push(String.fromCharCode(i)),64!==s&&a.push(String.fromCharCode(n));return a=a.join("")},t.encode=function(t){if(t=t.replace(/\r\n/g,"\n"),!this.nativeBase64){for(var e,i,n,r,o,s,a,h=[],c=0;c>2,o=(3&e)<<4|(i=t.charCodeAt(c++))>>4,s=(15&i)<<2|(n=t.charCodeAt(c++))>>6,a=63&n,isNaN(i)?s=a=64:isNaN(n)&&(a=64),h.push(this._keyStr.charAt(r)),h.push(this._keyStr.charAt(o)),h.push(this._keyStr.charAt(s)),h.push(this._keyStr.charAt(a));return h=h.join("")}window.btoa(t)},t.decodeBase64AsArray=function(e,i){i=i||1;var n,r,o,s=t.decode(e),a=new Uint32Array(s.length/i);for(n=0,o=s.length/i;n=0;--r)a[n]+=s.charCodeAt(n*i+r)<<(r<<3);return a},t.decompress=function(t,e,i){throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!")},t.decodeCSV=function(t){for(var e=t.replace("\n","").trim().split(","),i=[],n=0;n>16},set:function(t){this._packedValue=4278255615&this._packedValue|t<<16},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"g",{get:function(){return this._packedValue>>8},set:function(t){this._packedValue=4294902015&this._packedValue|t<<8},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"r",{get:function(){return this._packedValue},set:function(t){this._packedValue=4294967040&this._packedValue|t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"a",{get:function(){return this._packedValue>>24},set:function(t){this._packedValue=16777215&this._packedValue|t<<24},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"packedValue",{get:function(){return this._packedValue},set:function(t){this._packedValue=t},enumerable:!0,configurable:!0}),e.prototype.equals=function(t){return this._packedValue==t._packedValue},e}();t.Color=e}(es||(es={})),function(t){var e=function(){function t(){this.loadedAssets=new Map}return t.prototype.loadRes=function(t,e){var i=this;return void 0===e&&(e=!0),new Promise(function(n,r){var o=i.loadedAssets.get(t);o?n(o):e?RES.getResAsync(t).then(function(e){i.loadedAssets.set(t,e),n(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)}):RES.getResByUrl(t).then(function(e){i.loadedAssets.set(t,e),n(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)})})},t.prototype.dispose=function(){this.loadedAssets.forEach(function(t){var e=t;RES.destroyRes(e)&&e.dispose()}),this.loadedAssets.clear()},t}();t.ContentManager=e}(es||(es={})),function(t){var e=function(){function t(){}return t.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)},t}();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 i=function(){function t(){this._messageTable=new Map}return t.prototype.addObserver=function(t,i,n){var r=this._messageTable.get(t);r||(r=[],this._messageTable.set(t,r)),-1!=r.findIndex(function(t){return t.func==i})&&console.warn("您试图添加相同的观察者两次"),r.push(new e(i,n))},t.prototype.removeObserver=function(t,e){var i=this._messageTable.get(t),n=i.findIndex(function(t){return t.func==e});-1!=n&&i.removeAt(n)},t.prototype.emit=function(t,e){var i=this._messageTable.get(t);if(i)for(var n=i.length-1;n>=0;n--)i[n].func.call(i[n].context,e)},t}();t.Emitter=i}(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 i=[];e--;)i.push(t);return i},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 i=function(){function i(){}return Object.defineProperty(i,"gameTouchs",{get:function(){return this._gameTouchs},enumerable:!0,configurable:!0}),Object.defineProperty(i,"resolutionScale",{get:function(){return this._resolutionScale},enumerable:!0,configurable:!0}),Object.defineProperty(i,"totalTouchCount",{get:function(){return this._totalTouchCount},enumerable:!0,configurable:!0}),Object.defineProperty(i,"touchPosition",{get:function(){return this._gameTouchs[0]?this._gameTouchs[0].position:t.Vector2.zero},enumerable:!0,configurable:!0}),Object.defineProperty(i,"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(i,"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}),i.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())},i.scaledPosition=function(e){var i=new t.Vector2(e.x-this._resolutionOffset.x,e.y-this._resolutionOffset.y);return t.Vector2.multiply(i,this.resolutionScale)},i.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={})),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,i){if(void 0===i&&(i=1),0==i)throw new Error("step 不能为 0");var n=e-t;if(0==n)throw new Error("没有可用的范围("+t+","+e+")");n<0&&(n=t-e);var r=Math.floor((n+i-1)/i);return Math.floor(this.random()*r)*i+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 i=t.length;if(e<=0||i=0;)s=Math.floor(this.random()*i);n.push(t[s]),r.push(s)}return n},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,i){switch(i){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,i){var n=new t.Rectangle(i.x,i.y,0,0),r=new t.Rectangle;return r.x=Math.min(e.x,n.x),r.y=Math.min(e.y,n.y),r.width=Math.max(e.right,n.right)-r.x,r.height=Math.max(e.bottom,r.bottom)-r.y,r},e.getHalfRect=function(e,i){switch(i){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,i,n){switch(void 0===n&&(n=1),i){case t.Edge.top:return new t.Rectangle(e.x,e.y,e.width,n);case t.Edge.bottom:return new t.Rectangle(e.x,e.y+e.height-n,e.width,n);case t.Edge.left:return new t.Rectangle(e.x,e.y,n,e.height);case t.Edge.right:return new t.Rectangle(e.x+e.width-n,e.y,n,e.height)}},e.expandSide=function(e,i,n){switch(n=Math.abs(n),i){case t.Edge.top:e.y-=n,e.height+=n;break;case t.Edge.bottom:e.height+=n;break;case t.Edge.left:e.x-=n,e.width+=n;break;case t.Edge.right:e.width+=n}},e.contract=function(t,e,i){t.x+=e,t.y+=i,t.width-=2*e,t.height-=2*i},e}();t.RectangleExt=e}(es||(es={})),function(t){var e=function(){return function(t){this.value=t}}();t.Ref=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,i,n,r){return!(t.Vector2Ext.cross(t.Vector2.subtract(e,i),t.Vector2.subtract(n,i))<0)&&(!(t.Vector2Ext.cross(t.Vector2.subtract(e,n),t.Vector2.subtract(r,n))<0)&&!(t.Vector2Ext.cross(t.Vector2.subtract(e,r),t.Vector2.subtract(i,r))<0))},e.prototype.triangulate=function(i,n){void 0===n&&(n=!0);var r=i.length;this.initialize(r);for(var o=0,s=0;r>3&&o<500;){o++;var a=!0,h=i[this._triPrev[s]],c=i[s],l=i[this._triNext[s]];if(t.Vector2Ext.isTriangleCCW(h,c,l)){var u=this._triNext[this._triNext[s]];do{if(e.testPointTriangle(i[u],h,c,l)){a=!1;break}u=this._triNext[u]}while(u!=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]),n||this.triangleIndices.reverse()},e.prototype.initialize=function(t){this.triangleIndices.length=0,this._triNext.lengtht.MathHelper.Epsilon?e.divide(new t.Vector2(i)):e.x=e.y=0},e.transformA=function(t,e,i,n,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},i}();t.Layout=i,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,i=function(){function t(t){void 0===t&&(t=n),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=(i=this.getSystemTime())-this._stopSystemTime;this._stopDuration+=e,this._stopSystemTime=void 0}else if(void 0===this._startSystemTime){var i=this.getSystemTime();this._startSystemTime=i,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=i,function(t){t.IDLE="IDLE",t.RUNNING="RUNNING",t.STOPPED="STOPPED"}(e||(e={})),t.setDefaultSystemTimeGetter=function(t){void 0===t&&(t=Date.now),n=t};var n=Date.now}(stopwatch||(stopwatch={})),function(t){var e=function(){function e(){this.showLog=!1,this.markers=[],this.stopwacth=new stopwatch.Stopwatch,this._markerNameToIdMap=new Map,this._rectShape1=new egret.Shape,this._rectShape2=new egret.Shape,this._rectShape3=new egret.Shape,this._rectShape4=new egret.Shape,this._rectShape5=new egret.Shape,this._rectShape6=new egret.Shape,this._logs=new Array(2);for(var e=0;e=e.logSnapDuration&&(l.logs[n].snapMin=l.logs[n].min,l.logs[n].snapMax=l.logs[n].max,l.logs[n].snapAvg=l.logs[n].avg,l.logs[n].samples=0)):(l.logs[n].min=h,l.logs[n].max=h,l.logs[n].avg=h,l.logs[n].initialized=!0)}o.markCount=r.nestCount,o.nestCount=r.nestCount}this.stopwacth.reset(),this.stopwacth.start()}},e.prototype.beginMark=function(t,i,n){if(void 0===n&&(n=0),n<0||n>=e.maxBars)throw new Error("barIndex argument out of range");var r=this._curLog.bars[n];if(r.markCount>=e.maxSamples)throw new Error("exceeded sample count. either set larger number to timeruler.maxsaple or lower sample count");if(r.nestCount>=e.maxNestCall)throw new Error("exceeded nest count. either set larger number to timeruler.maxnestcall or lower nest calls");var o=this._markerNameToIdMap.get(t);isNaN(o)&&(o=this.markers.length,this._markerNameToIdMap.set(t,o)),r.markerNests[r.nestCount++]=r.markCount,r.markers[r.markCount].markerId=o,r.markers[r.markCount].color=i,r.markers[r.markCount].beginTime=this.stopwacth.getTime(),r.markers[r.markCount].endTime=-1},e.prototype.endMark=function(t,i){if(void 0===i&&(i=0),i<0||i>=e.maxBars)throw new Error("barIndex argument out of range");var n=this._curLog.bars[i];if(n.nestCount<=0)throw new Error("call beginMark method before calling endMark method");var r=this._markerNameToIdMap.get(t);if(isNaN(r))throw new Error("Marker "+t+" is not registered. Make sure you specifed same name as you used for beginMark method");var o=n.markerNests[--n.nestCount];if(n.markers[o].markerId!=r)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).");n.markers[o].endTime=this.stopwacth.getTime()},e.prototype.getAverageTime=function(t,i){if(t<0||t>=e.maxBars)throw new Error("barIndex argument out of range");var n=0,r=this._markerNameToIdMap.get(i);return r&&(n=this.markers[r].logs[t].avg),n},e.prototype.resetLog=function(){this.markers.forEach(function(t){for(var e=0;e0&&(r+=e.barHeight+2*e.barPadding,o=Math.max(o,t.markers[t.markCount-1].endTime))});var s=this.sampleFrames*(1/60*1e3);this._frameAdjust=o>s?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,o/(1/60*1e3)+1),this._frameAdjust=0);var a=n/s,h=i.y-(r-e.barHeight),c=h,l=new t.Rectangle(i.x,c,n,r);this._rectShape1.graphics.clear(),this._rectShape1.graphics.beginFill(0,128/255),this._rectShape1.graphics.drawRect(l.x,l.y,l.width,l.height),this._rectShape1.graphics.endFill(),l.height=e.barHeight,this._rectShape2.graphics.clear();for(var u=0,p=this._prevLog.bars;u0)for(var f=0;fa||i[c].height>a)throw new Error("一个纹理的大小比图集的大小大");h.push(new t.Rectangle(0,0,i[c].width,i[c].height))}for(;h.length>0;){var l=new egret.RenderTexture,u=new t.RectanglePacker(a,a,1);for(c=0;c0){for(var p=new t.IntegerRectangle,d=[],f=[],g=[],y=[],m=0;m0;)this.freeRectangle(this._insertedRectangles.pop());for(;this._freeAreas.length>0;)this.freeRectangle(this._freeAreas.pop());for(this._width=t,this._height=e,this._packedWidth=0,this._packedHeight=0,this._freeAreas.push(this.allocateRectangle(0,0,this._width,this._height));this._insertedRectangles.length>0;)this.freeSize(this._insertList.pop());this._padding=i},e.prototype.insertRectangle=function(t,e,i){var n=this.allocateSize(t,e,i);this._insertList.push(n)},e.prototype.packRectangles=function(t){for(void 0===t&&(t=!0),t&&this._insertList.sort(function(t,e){return t.width-e.width});this._insertList.length>0;){var e=this._insertList.pop(),i=e.width,n=e.height,r=this.getFreeAreaIndex(i,n);if(r>=0){var o=this._freeAreas[r],s=this.allocateRectangle(o.x,o.y,i,n);for(s.id=e.id,this.generateNewFreeAreas(s,this._freeAreas,this._newFreeAreas);this._newFreeAreas.length>0;)this._freeAreas.push(this._newFreeAreas.pop());this._insertedRectangles.push(s),s.right>this._packedWidth&&(this._packedWidth=s.right),s.bottom>this._packedHeight&&(this._packedHeight=s.bottom)}this.freeSize(e)}return this.rectangleCount},e.prototype.getRectangle=function(t,e){var i=this._insertedRectangles[t];return e.x=i.x,e.y=i.y,e.width=i.width,e.height=i.height,e},e.prototype.getRectangleId=function(t){return this._insertedRectangles[t].id},e.prototype.generateNewFreeAreas=function(t,e,i){var n=t.x,r=t.y,o=t.right+1+this._padding,s=t.bottom+1+this._padding,a=null;0==this._padding&&(a=t);for(var h=e.length-1;h>=0;h--){var c=e[h];if(!(n>=c.right||o<=c.x||r>=c.bottom||s<=c.y)){null==a&&(a=this.allocateRectangle(t.x,t.y,t.width+this._padding,t.height+this._padding)),this.generateDividedAreas(a,c,i);var l=e.pop();h=0;e--)for(var i=t[e],n=t.length-1;n>=0;n--)if(e!=n){var r=t[n];if(i.x>=r.x&&i.y>=r.y&&i.right<=r.right&&i.bottom<=r.bottom){this.freeRectangle(i);var o=t.pop();e0&&(i.push(this.allocateRectangle(t.right,e.y,r,e.height)),n++);var o=t.x-e.x;o>0&&(i.push(this.allocateRectangle(e.x,e.y,o,e.height)),n++);var s=e.bottom-t.bottom;s>0&&(i.push(this.allocateRectangle(e.x,t.bottom,e.width,s)),n++);var a=t.y-e.y;a>0&&(i.push(this.allocateRectangle(e.x,e.y,e.width,a)),n++),0==n&&(t.width=0;s--){var a=this._freeAreas[s];if(a.x0){var r=this._sortableSizeStack.pop();return r.width=e,r.height=i,r.id=n,r}return new t.SortableSize(e,i,n)},e.prototype.freeSize=function(t){this._sortableSizeStack.push(t)},e.prototype.allocateRectangle=function(e,i,n,r){if(this._rectangleStack.length>0){var o=this._rectangleStack.pop();return o.x=e,o.y=i,o.width=n,o.height=r,o.right=e+n,o.bottom=i+r,o}return new t.IntegerRectangle(e,i,n,r)},e.prototype.freeRectangle=function(t){this._rectangleStack.push(t)},e}();t.RectanglePacker=e}(es||(es={})),function(t){var e=function(){return function(t,e,i){this.width=t,this.height=e,this.id=i}}();t.SortableSize=e}(es||(es={})),function(t){var e=function(){return function(t){this.assets=t}}();t.TextureAssets=e;var i=function(){return function(){}}();t.TextureAsset=i}(es||(es={})),function(t){var e=function(){return function(t,e){this.texture=t,this.id=e}}();t.TextureToPack=e}(es||(es={})),function(t){var e=function(){function e(){this._timeInSeconds=0,this._repeats=!1,this._isDone=!1,this._elapsedTime=0}return e.prototype.getContext=function(){return this.context},e.prototype.reset=function(){this._elapsedTime=0},e.prototype.stop=function(){this._isDone=!0},e.prototype.tick=function(){return!this._isDone&&this._elapsedTime>this._timeInSeconds&&(this._elapsedTime-=this._timeInSeconds,this._onTime(this),this._isDone||this._repeats||(this._isDone=!0)),this._elapsedTime+=t.Time.deltaTime,this._isDone},e.prototype.initialize=function(t,e,i,n){this._timeInSeconds=t,this._repeats=e,this.context=i,this._onTime=n},e.prototype.unload=function(){this.context=null,this._onTime=null},e}();t.Timer=e}(es||(es={})),function(t){var e=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t._timers=[],t}return __extends(i,e),i.prototype.update=function(){for(var t=this._timers.length-1;t>=0;t--)this._timers[t].tick()&&(this._timers[t].unload(),this._timers.removeAt(t))},i.prototype.schedule=function(e,i,n,r){var o=new t.Timer;return o.initialize(e,i,n,r),this._timers.push(o),o},i}(t.GlobalManager);t.TimerManager=e}(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 i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};return function(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();var transform,__awaiter=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))(function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){t.done?r(t.value):new i(function(e){e(t.value)}).then(s,a)}h((n=n.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){var i,n,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(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=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++,n=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 i=t.findIndex(e);return-1==i?null:t[i]}(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(i,n,r){return e.call(arguments[2],n,r,t)&&i.push(n),i},[]);for(var i=[],n=0,r=t.length;n=0&&t.splice(i,1)}while(i>=0)}(this,t)},Array.prototype.remove=function(t){return function(t,e){var i=t.findIndex(function(t){return t===e});return i>=0&&(t.splice(i,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,i){t.splice(e,i)}(this,t,e)},Array.prototype.select=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(i,n,r){return i.push(e.call(arguments[2],n,r,t)),i},[]);for(var i=[],n=0,r=t.length;no?1:-1}),t}(this,t,e)},Array.prototype.orderByDescending=function(t,e){return function(t,e,i){return t.sort(function(t,n){var r=e(t),o=e(n);return i?-i(r,o):r0;){if("break"===l())break}return s?this.recontructPath(a,n,r):null},e.recontructPath=function(t,e,i){var n=[],r=i;for(n.push(i);r!=e;)r=this.getKey(t,r),n.push(r);return n.reverse(),n},e.hasKey=function(t,e){for(var i,n=t.keys();!(i=n.next()).done;)if(JSON.stringify(i.value)==JSON.stringify(e))return!0;return!1},e.getKey=function(t,e){for(var i,n,r=t.keys(),o=t.values();i=r.next(),n=o.next(),!i.done;)if(JSON.stringify(i.value)==JSON.stringify(e))return n.value;return null},e}();t.AStarPathfinder=e;var i=function(t){function e(e){var i=t.call(this)||this;return i.data=e,i}return __extends(e,t),e}(t.PriorityQueueNode);t.AStarNode=i}(es||(es={})),function(t){var e=function(){function e(e,i){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=i}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,i)?this.cascadeUp(t):this.cascadeDown(t)},t.prototype.cascadeDown=function(t){for(var e,i=t.queueIndex;;){e=t;var n=2*i;if(n>this._numNodes){t.queueIndex=i,this._nodes[i]=t;break}var r=this._nodes[n];this.hasHigherPriority(r,e)&&(e=r);var o=n+1;if(o<=this._numNodes){var s=this._nodes[o];this.hasHigherPriority(s,e)&&(e=s)}if(e==t){t.queueIndex=i,this._nodes[i]=t;break}this._nodes[i]=e;var a=e.queueIndex;e.queueIndex=i,i=a}},t.prototype.cascadeUp=function(t){for(var e=Math.floor(t.queueIndex/2);e>=1;){var i=this._nodes[e];if(this.hasHigherPriority(i,t))break;this.swap(t,i),e=Math.floor(t.queueIndex/2)}},t.prototype.swap=function(t,e){this._nodes[t.queueIndex]=e,this._nodes[e.queueIndex]=t;var i=t.queueIndex;t.queueIndex=e.queueIndex,e.queueIndex=i},t.prototype.hasHigherPriority=function(t,e){return t.priority0;){if("break"===h())break}return o?t.AStarPathfinder.recontructPath(a,i,n):null},e.hasKey=function(t,e){for(var i,n=t.keys();!(i=n.next()).done;)if(JSON.stringify(i.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 new e(0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"one",{get:function(){return new e(1,1)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitX",{get:function(){return new e(1,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitY",{get:function(){return new e(0,1)},enumerable:!0,configurable:!0}),e.add=function(t,i){var n=new e(0,0);return n.x=t.x+i.x,n.y=t.y+i.y,n},e.divide=function(t,i){var n=new e(0,0);return n.x=t.x/i.x,n.y=t.y/i.y,n},e.multiply=function(t,i){var n=new e(0,0);return n.x=t.x*i.x,n.y=t.y*i.y,n},e.subtract=function(t,i){var n=new e(0,0);return n.x=t.x-i.x,n.y=t.y-i.y,n},e.normalize=function(t){var i=new e(t.x,t.y),n=1/Math.sqrt(i.x*i.x+i.y*i.y);return i.x*=n,i.y*=n,i},e.dot=function(t,e){return t.x*e.x+t.y*e.y},e.distanceSquared=function(t,e){var i=t.x-e.x,n=t.y-e.y;return i*i+n*n},e.clamp=function(i,n,r){return new e(t.MathHelper.clamp(i.x,n.x,r.x),t.MathHelper.clamp(i.y,n.y,r.y))},e.lerp=function(i,n,r){return new e(t.MathHelper.lerp(i.x,n.x,r),t.MathHelper.lerp(i.y,n.y,r))},e.transform=function(t,i){return new e(t.x*i.m11+t.y*i.m21+i.m31,t.x*i.m12+t.y*i.m22+i.m32)},e.distance=function(t,e){var i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)},e.angle=function(i,n){return i=e.normalize(i),n=e.normalize(n),Math.acos(t.MathHelper.clamp(e.dot(i,n),-1,1))*t.MathHelper.Rad2Deg},e.negate=function(t){var i=new e;return i.x=-t.x,i.y=-t.y,i},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);this.x*=t,this.y*=t},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}();t.Vector2=e}(es||(es={})),function(t){var e=function(){function e(t,i,n){void 0===n&&(n=!1),this.walls=[],this._neighbors=new Array(4),this._width=t,this._hegiht=i,this._dirs=n?e.COMPASS_DIRS:e.CARDINAL_DIRS}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x0;){if("break"===l())break}return s?this.recontructPath(a,n,r):null},i.recontructPath=function(t,e,i){var n=[],r=i;for(n.push(i);r!=e;)r=this.getKey(t,r),n.push(r);return n.reverse(),n},i.hasKey=function(t,e){for(var i,n=t.keys();!(i=n.next()).done;)if(JSON.stringify(i.value)==JSON.stringify(e))return!0;return!1},i.getKey=function(t,e){for(var i,n,r=t.keys(),o=t.values();i=r.next(),n=o.next(),!i.done;)if(JSON.stringify(i.value)==JSON.stringify(e))return n.value;return null},i}();t.WeightedPathfinder=i}(es||(es={})),function(t){var e=function(e){function i(){var n=e.call(this)||this;return n._globalManagers=[],n._timerManager=new t.TimerManager,i._instance=n,i.emitter=new t.Emitter,i.content=new t.ContentManager,n.addEventListener(egret.Event.ADDED_TO_STAGE,n.onAddToStage,n),i.registerGlobalManager(n._timerManager),n}return __extends(i,e),Object.defineProperty(i,"Instance",{get:function(){return this._instance},enumerable:!0,configurable:!0}),Object.defineProperty(i,"scene",{get:function(){return this._instance?this._instance._scene:null},set:function(t){t?null==this._instance._scene?(this._instance.addChild(t),this._instance._scene=t,this._instance._scene.begin(),i.Instance.onSceneChanged()):this._instance._nextScene=t:console.error("场景不能为空")},enumerable:!0,configurable:!0}),i.startSceneTransition=function(t){if(!this._instance._sceneTransition)return this._instance._sceneTransition=t,t;console.warn("在前一个场景完成之前,不能开始一个新的场景转换。")},i.registerGlobalManager=function(t){this._instance._globalManagers.push(t),t.enabled=!0},i.unregisterGlobalManager=function(t){this._instance._globalManagers.remove(t),t.enabled=!1},i.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._scene.parent&&this._scene.parent.removeChild(this._scene),this._scene.end(),this._scene=this._nextScene,this._nextScene=null,this.onSceneChanged(),[4,this._scene.begin()]):[3,2];case 1:i.sent(),this.addChild(this._scene),i.label=2;case 2:return this.endDebugUpdate(),[4,this.draw()];case 3:return i.sent(),[2]}})})},i.prototype.onAddToStage=function(){i.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(),KeyboardUtils.init(),this.initialize()},i.debugRenderEndabled=!1,i}(egret.DisplayObjectContainer);t.Core=e}(es||(es={})),function(t){var e=function(){function t(){}return t.renderableBounds=16776960,t.renderableCenter=10040012,t.colliderBounds=5592405,t.colliderEdge=9109504,t.colliderPosition=16776960,t.colliderCenter=16711680,t}();t.Colors=e;var i=function(){function e(){}return Object.defineProperty(e,"lineSizeMultiplier",{get:function(){return Math.max(Math.ceil(t.Core.scene.x/t.Core.scene.width),1)},enumerable:!0,configurable:!0}),e}();t.Size=i;var n=function(){function e(){}return e.drawHollowRect=function(e,i,n){void 0===n&&(n=0),this._debugDrawItems.push(new t.DebugDrawItem(e,i,n))},e.render=function(){if(this._debugDrawItems.length>0){var e=new egret.Shape;t.Core.scene&&t.Core.scene.addChild(e);for(var i=this._debugDrawItems.length-1;i>=0;i--){this._debugDrawItems[i].draw(e)&&this._debugDrawItems.removeAt(i)}}},e._debugDrawItems=[],e}();t.Debug=n}(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 i=function(){function i(t,i,n){this.rectangle=t,this.color=i,this.duration=n,this.drawType=e.hollowRectangle}return i.prototype.draw=function(i){switch(this.drawType){case e.line:case e.hollowRectangle:case e.pixel:case e.text:}return this.duration-=t.Time.deltaTime,this.duration<0},i}();t.DebugDrawItem=i}(es||(es={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateInterval=1,e.debugDisplayObject=new egret.DisplayObjectContainer,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}(egret.HashObject);t.Component=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(i){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=i,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()},i.prototype.render=function(){if(0!=this._renderers.length)for(var t=0;te.x?-1:1,n=t.Vector2.normalize(t.Vector2.subtract(this.position,e));this.rotation=i*Math.acos(t.Vector2.dot(n,t.Vector2.unitY))},n.prototype.setLocalRotation=function(t){return this._localRotation=t,this._localDirty=this._positionDirty=this._localPositionDirty=this._localRotationDirty=this._localScaleDirty=!0,this.setDirty(e.rotationDirty),this},n.prototype.setLocalRotationDegrees=function(e){return this.setLocalRotation(t.MathHelper.toRadians(e))},n.prototype.setScale=function(e){return this._scale=e,this.parent?this.localScale=t.Vector2.divide(e,this.parent._scale):this.localScale=e,this},n.prototype.setLocalScale=function(t){return this._localScale=t,this._localDirty=this._positionDirty=this._localScaleDirty=!0,this.setDirty(e.scaleDirty),this},n.prototype.roundPosition=function(){this.position=this._position.round()},n.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)},n.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 i=0;it&&(this._zoom=t),this._maximumZoom=t,this;console.error("maximumZoom must be greater than zero")},n.prototype.forceMatrixUpdate=function(){this._areMatrixedDirty=!0},n.prototype.onEntityTransformChanged=function(t){this._areMatrixedDirty=!0},n.prototype.zoomIn=function(t){this.zoom+=t},n.prototype.zoomOut=function(t){this.zoom-=t},n.prototype.worldToScreenPoint=function(e){return this.updateMatrixes(),e=t.Vector2Ext.transformR(e,this._transformMatrix)},n.prototype.screenToWorldPoint=function(e){return this.updateMatrixes(),e=t.Vector2Ext.transformR(e,this._inverseTransformMatrix)},n.prototype.onSceneRenderTargetSizeChanged=function(e,i){this._isProjectionMatrixDirty=!0;var n=this._origin;this.origin=new t.Vector2(e/2,i/2),this.entity.transform.position.add(t.Vector2.subtract(this._origin,n))},n.prototype.mouseToWorldPoint=function(){return this.screenToWorldPoint(t.Input.touchPosition)},n.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)},n}(t.Component);t.Camera=i}(es||(es={})),function(t){var e=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i._shakeDirection=t.Vector2.zero,i._shakeOffset=t.Vector2.zero,i._shakeIntensity=0,i._shakeDegredation=.95,i}return __extends(i,e),i.prototype.shake=function(e,i,n){void 0===e&&(e=15),void 0===i&&(i=.9),void 0===n&&(n=t.Vector2.zero),this.enabled=!0,this._shakeIntensity=1)&&(i=.95),this._shakeDegredation=i)},i.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)},i}(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(t){t[t.lockOn=0]="lockOn",t[t.cameraWindow=1]="cameraWindow"}(e=t.CameraStyle||(t.CameraStyle={}));var i=function(i){function n(n,r,o){void 0===n&&(n=null),void 0===r&&(r=null),void 0===o&&(o=e.lockOn);var s=i.call(this)||this;return s.followLerp=.1,s.deadzone=new t.Rectangle,s.focusOffset=t.Vector2.zero,s.mapLockEnabled=!1,s.mapSize=new t.Rectangle,s._desiredPositionDelta=new t.Vector2,s._worldSpaceDeadZone=new t.Rectangle,s.rectShape=new egret.Shape,s._targetEntity=n,s._cameraStyle=o,s.camera=r,s}return __extends(n,i),n.prototype.onAddedToEntity=function(){this.camera||(this.camera=this.entity.scene.camera),this.follow(this._targetEntity,this._cameraStyle),t.Core.emitter.addObserver(t.CoreEvents.GraphicsDeviceReset,this.onGraphicsDeviceReset,this)},n.prototype.onGraphicsDeviceReset=function(){t.Core.schedule(0,!1,this,function(t){var e=t.context;e.follow(e._targetEntity,e._cameraStyle)})},n.prototype.update=function(){var e=t.Vector2.multiply(this.camera.bounds.size,new t.Vector2(.5));this._worldSpaceDeadZone.x=this.camera.position.x-e.x*t.Core.scene.scaleX+this.deadzone.x+this.focusOffset.x,this._worldSpaceDeadZone.y=this.camera.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.camera.position=t.Vector2.lerp(this.camera.position,t.Vector2.add(this.camera.position,this._desiredPositionDelta),this.followLerp),this.entity.transform.roundPosition(),this.mapLockEnabled&&(this.camera.position=this.clampToMapSize(this.camera.position),this.entity.transform.roundPosition())},n.prototype.debugRender=function(){this.rectShape||this.debugDisplayObject.addChild(this.rectShape),this.rectShape.graphics.clear(),this._cameraStyle==e.lockOn?(this.rectShape.graphics.beginFill(9109504,0),this.rectShape.graphics.lineStyle(1,9109504),this.rectShape.graphics.drawRect(this._worldSpaceDeadZone.x-5,this._worldSpaceDeadZone.y-5,this._worldSpaceDeadZone.width,this._worldSpaceDeadZone.height),this.rectShape.graphics.endFill()):(this.rectShape.graphics.beginFill(9109504,0),this.rectShape.graphics.lineStyle(1,9109504),this.rectShape.graphics.drawRect(this._worldSpaceDeadZone.x,this._worldSpaceDeadZone.y,this._worldSpaceDeadZone.width,this._worldSpaceDeadZone.height),this.rectShape.graphics.endFill())},n.prototype.clampToMapSize=function(e){var i=t.Vector2.multiply(this.camera.bounds.size,new t.Vector2(.5)).add(new t.Vector2(this.mapSize.x,this.mapSize.y)),n=new t.Vector2(this.mapSize.width-i.x,this.mapSize.height-i.y);return t.Vector2.clamp(e,i,n)},n.prototype.follow=function(i,n){void 0===n&&(n=e.cameraWindow),this._targetEntity=i,this._cameraStyle=n;var r=this.camera.bounds;switch(this._cameraStyle){case e.cameraWindow:var o=r.width/6,s=r.height/3;this.deadzone=new t.Rectangle((r.width-o)/2,(r.height-s)/2,o,s);break;case e.lockOn:this.deadzone=new t.Rectangle(r.width/2,r.height/2,10,10)}},n.prototype.updateFollow=function(){if(this._desiredPositionDelta.x=this._desiredPositionDelta.y=0,this._cameraStyle==e.lockOn){var i=this._targetEntity.transform.position.x,n=this._targetEntity.transform.position.y;this._worldSpaceDeadZone.x>i?this._desiredPositionDelta.x=i-this._worldSpaceDeadZone.x:this._worldSpaceDeadZone.xn&&(this._desiredPositionDelta.y=n-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))}},n.prototype.setCenteredDeadzone=function(e,i){if(this.camera){var n=this.camera.bounds;this.deadzone=new t.Rectangle((n.width-e)/2,(n.height-i)/2,e,i)}else console.error("相机是null。我们不能得到它的边界。请等到该组件添加到实体之后")},n}(t.Component);t.FollowCamera=i}(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 i(){var i=null!==e&&e.apply(this,arguments)||this;return i.displayObject=new egret.DisplayObject,i.hollowShape=new egret.Shape,i.pixelShape=new egret.Shape,i.color=0,i._areBoundsDirty=!0,i.debugRenderEnabled=!0,i._localOffset=t.Vector2.zero,i._renderLayer=0,i._bounds=new t.Rectangle,i}return __extends(i,e),Object.defineProperty(i.prototype,"width",{get:function(){return this.bounds.width},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this.bounds.height},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"localOffset",{get:function(){return this._localOffset},set:function(t){this.setLocalOffset(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"renderLayer",{get:function(){return this._renderLayer},set:function(t){this.setRenderLayer(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.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(i.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}),i.prototype.onEntityTransformChanged=function(t){this._areBoundsDirty=!0},i.prototype.debugRender=function(){if(this.debugRenderEnabled){this.hollowShape.parent||this.debugDisplayObject.addChild(this.hollowShape),this.pixelShape.parent||this.debugDisplayObject.addChild(this.pixelShape);var e=t.Vector2.add(this.entity.transform.position,this._localOffset);this.pixelShape.graphics.clear(),this.pixelShape.graphics.beginFill(t.Colors.renderableCenter,0),this.pixelShape.graphics.lineStyle(4,t.Colors.renderableCenter),this.pixelShape.graphics.lineTo(e.x,e.y),this.pixelShape.graphics.moveTo(e.x,e.y),this.pixelShape.graphics.endFill()}},i.prototype.isVisibleFromCamera=function(t){return!!t&&(this.isVisible=t.bounds.intersects(this.bounds),this.isVisible)},i.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},i.prototype.setColor=function(t){return this.color=t,this},i.prototype.setLocalOffset=function(t){return this._localOffset!=t&&(this._localOffset=t),this},i.prototype.sync=function(e){var i=new t.Vector2(this.entity.position.x+this.localOffset.x-e.position.x+e.origin.x,this.entity.position.y+this.localOffset.y-e.position.y+e.origin.y);this.displayObject.x!=i.x&&(this.displayObject.x=i.x),this.displayObject.y!=i.y&&(this.displayObject.y=i.y),this.displayObject.scaleX!=this.entity.scale.x&&(this.displayObject.scaleX=this.entity.scale.x),this.displayObject.scaleY!=this.entity.scale.y&&(this.displayObject.scaleY=this.entity.scale.y),this.displayObject.rotation!=this.entity.rotation&&(this.displayObject.rotation=this.entity.rotation)},i.prototype.toString=function(){return"[RenderableComponent] renderLayer: "+this.renderLayer},i.prototype.onBecameVisible=function(){this.displayObject.visible=this.isVisible,this.debugDisplayObject.visible=this.isVisible},i.prototype.onBecameInvisible=function(){this.displayObject.visible=this.isVisible,this.debugDisplayObject.visible=this.isVisible},i}(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,i=function(i){function n(e){void 0===e&&(e=null);var n=i.call(this)||this;return e instanceof t.Sprite?n.setSprite(e):e instanceof egret.Texture&&n.setSprite(new t.Sprite(e)),n}return __extends(n,i),Object.defineProperty(n.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(n.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(n.prototype,"origin",{get:function(){return this._origin},set:function(t){this.setOrigin(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"sprite",{get:function(){return this._sprite},set:function(t){this.setSprite(t)},enumerable:!0,configurable:!0}),n.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},n.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},n.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},n.prototype.render=function(e){this.sync(e);var i=new t.Vector2(this.entity.position.x+this.localOffset.x-this.origin.x-e.position.x+e.origin.x,this.entity.position.y+this.localOffset.y-this.origin.y-e.position.y+e.origin.y);this.displayObject.x!=i.x&&(this.displayObject.x=i.x),this.displayObject.y!=i.y&&(this.displayObject.y=i.y)},n}(t.RenderableComponent);t.SpriteRenderer=i}(es||(es={})),function(t){var e=egret.Bitmap,i=egret.RenderTexture,n=function(n){function r(e){var i=n.call(this,e)||this;return i._textureScale=t.Vector2.one,i._inverseTexScale=t.Vector2.one,i._gapX=0,i._gapY=0,i._sourceRect=e.sourceRect,i.displayObject.$fillMode=egret.BitmapFillMode.REPEAT,i}return __extends(r,n),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 n=new i,r=this.sprite.sourceRect;r.x=0,r.y=0,r.width+=this._gapX,r.height+=this._gapY,n.drawToTexture(this.displayObject,r),this.displayObject?this.displayObject.texture=n:this.displayObject=new e(n)},enumerable:!0,configurable:!0}),r.prototype.setGapXY=function(t){return this.gapXY=t,this},r.prototype.render=function(t){n.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=n}(es||(es={})),function(t){var e=function(e){function i(t){var i=e.call(this,t)||this;return i.scrollSpeedX=15,i.scroolSpeedY=0,i._scrollX=0,i._scrollY=0,i._scrollWidth=0,i._scrollHeight=0,i._scrollWidth=i.width,i._scrollHeight=i.height,i}return __extends(i,e),Object.defineProperty(i.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(i.prototype,"scrollWidth",{get:function(){return this._scrollWidth},set:function(t){this._scrollWidth=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scrollHeight",{get:function(){return this._scrollHeight},set:function(t){this._scrollHeight=t},enumerable:!0,configurable:!0}),i.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))},i}(t.TiledSpriteRenderer);t.ScrollingSpriteRenderer=e}(es||(es={})),function(t){var e=egret.SpriteSheet,i=function(){function i(e,i,n){void 0===i&&(i=new t.Rectangle(0,0,e.textureWidth,e.textureHeight)),void 0===n&&(n=i.getHalfSize()),this.uvs=new t.Rectangle,this.texture2D=e,this.sourceRect=i,this.center=new t.Vector2(.5*i.width,.5*i.height),this.origin=n;var r=1/e.textureWidth,o=1/e.textureHeight;this.uvs.x=i.x*r,this.uvs.y=i.y*o,this.uvs.width=i.width*r,this.uvs.height=i.height*o}return i.spritesFromAtlas=function(t,n,r,o,s){void 0===o&&(o=0),void 0===s&&(s=Number.MAX_VALUE);for(var a=[],h=t.textureWidth/n,c=t.textureHeight/r,l=0,u=new e(t),p=0;po||this._loopMode==e.pingPongOnce&&s>2*o)return this.animationState=i.completed,this._elapsedTime=0,this.currentFrame=0,void(this.displayObject.texture=n.sprites[this.currentFrame].texture2D);var a=Math.floor(s/r),h=n.sprites.length;if(h>2&&(this._loopMode==e.pingPong||this._loopMode==e.pingPongOnce)){var c=h-1;this.currentFrame=c-Math.abs(c-a%(2*c))}else this.currentFrame=a%h;this.displayObject.texture=n.sprites[this.currentFrame].texture2D}},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,n){void 0===n&&(n=null),this.currentAnimation=this._animations[t],this.currentAnimationName=t,this.currentFrame=0,this.animationState=i.running,this.displayObject.texture=this.currentAnimation.sprites[0].texture2D,this._elapsedTime=0,this._loopMode=n||e.loop},r.prototype.isAnimationActive=function(t){return this.currentAnimation&&this.currentAnimationName==t},r.prototype.pause=function(){this.animationState=i.paused},r.prototype.unPause=function(){this.animationState=i.running},r.prototype.stop=function(){this.currentAnimation=null,this.currentAnimationName=null,this.currentFrame=0,this.animationState=i.none},r}(t.SpriteRenderer);t.SpriteAnimator=n}(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 i=function(e){function i(){var t=e.call(this)||this;return t.colliderHorizontalInset=2,t.colliderVerticalInset=6,t}return __extends(i,e),i.prototype.testCollisions=function(e,i,n){this._boxColliderBounds=i,n.wasGroundedLastFrame=n.below,n.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,n,0)?(e.x=0-t.RectangleExt.getSide(i,o),n.left=o==t.Edge.left,n.right=o==t.Edge.right,n._movementRemainderX.reset()):(n.left=!1,n.right=!1)}},i.prototype.testMapCollision=function(e,i,n,r){var o=t.EdgeExt.oppositeEdge(i);t.EdgeExt.isVertical(o)?e.center.x:e.center.y,t.RectangleExt.getSide(e,i),t.EdgeExt.isVertical(o)},i.prototype.collisionRectForSide=function(e,i){var n;return n=t.EdgeExt.isHorizontal(e)?t.RectangleExt.getRectEdgePortion(this._boxColliderBounds,e):t.RectangleExt.getHalfRect(this._boxColliderBounds,e),t.EdgeExt.isVertical(e)?t.RectangleExt.contract(n,this.colliderHorizontalInset,0):t.RectangleExt.contract(n,0,this.colliderVerticalInset),t.RectangleExt.expandSide(n,e,i),n},i}(t.Component);t.TiledMapMover=i}(es||(es={})),function(t){var e=function(e){function i(i,n,r){void 0===n&&(n=null),void 0===r&&(r=!0);var o=e.call(this)||this;return o.physicsLayer=new t.Ref(1),o.toContainer=!1,o.tiledMap=i,o._shouldCreateColliders=r,o.displayObject=new egret.DisplayObjectContainer,n&&(o.collisionLayer=i.tileLayers.find(function(t){return t.name==n})),o}return __extends(i,e),Object.defineProperty(i.prototype,"width",{get:function(){return this.tiledMap.width*this.tiledMap.tileWidth},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this.tiledMap.height*this.tiledMap.tileHeight},enumerable:!0,configurable:!0}),i.prototype.setLayerToRender=function(t){this.layerIndicesToRender=[],this.layerIndicesToRender[0]=this.getLayerIndex(t)},i.prototype.setLayersToRender=function(){for(var t=[],e=0;e=2){this.polygonShape.graphics.beginFill(t.Colors.colliderEdge,0),this.polygonShape.graphics.lineStyle(t.Size.lineSizeMultiplier,t.Colors.colliderEdge);for(var i=0;i>6;0!=(e&t.LONG_MASK)&&i++,this._bits=new Array(i)}return t.prototype.and=function(t){for(var e,i=Math.min(this._bits.length,t._bits.length),n=0;n=0;)this._bits[e]&=~t._bits[e]},t.prototype.cardinality=function(){for(var t=0,e=this._bits.length-1;e>=0;e--){var i=this._bits[e];if(0!=i)if(-1!=i){var n=((i=((i=(i>>1&0x5555555555555400)+(0x5555555555555400&i))>>2&0x3333333333333400)+(0x3333333333333400&i))>>32)+i;t+=((n=((n=(n>>4&252645135)+(252645135&n))>>8&16711935)+(16711935&n))>>16&65535)+(65535&n)}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,i=1<>6;this.ensure(i),this._bits[i]|=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 i=0;i0){i=0;for(var n=this._componentsToAdd.length;i0){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,i=[],n=0;n0){for(var t=0,i=this._unsortedRenderLayers.length;t=e)return t;var n=!1;"-"==t.substr(0,1)&&(n=!0,t=t.substr(1));for(var r=e-i,o=0;o1?this.reverse(t.substring(1))+t.substring(0,1):t},t.cutOff=function(t,e,i,n){void 0===n&&(n=!0),e=Math.floor(e),i=Math.floor(i);var r=t.length;e>r&&(e=r);var o,s=e,a=e+i;return n?o=t.substring(0,s)+t.substr(a,r):(a=(s=r-1-e-i)+i,o=t.substring(0,s+1)+t.substr(a+1,r)),o},t.strReplace=function(t,e){for(var i=0,n=e.length;i",">",'"',""","'","'","®","®","©","©","™","™"],t}();!function(t){var e=function(){function e(){}return e.convertImageToCanvas=function(e,i){this.sharedCanvas||(this.sharedCanvas=egret.sys.createCanvas(),this.sharedContext=this.sharedCanvas.getContext("2d"));var n=e.$getTextureWidth(),r=e.$getTextureHeight();i||((i=egret.$TempRectangle).x=0,i.y=0,i.width=n,i.height=r),i.x=Math.min(i.x,n-1),i.y=Math.min(i.y,r-1),i.width=Math.min(i.width,n-i.x),i.height=Math.min(i.height,r-i.y);var o=Math.floor(i.width),s=Math.floor(i.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 h=void 0;e.$renderBuffer?h=e:(egret.sys.systemRenderer.renderClear&&egret.sys.systemRenderer.renderClear(),(h=new egret.RenderTexture).drawToTexture(new egret.Bitmap(e)));for(var c=h.$renderBuffer.getPixels(i.x,i.y,o,s),l=0,u=0,p=0;p=0?"png":"jpg"});return wx.getFileSystemManager().saveFile({tempFilePath:o,filePath:wx.env.USER_DATA_PATH+"/"+i,success:function(t){}}),o},e.getPixel32=function(t,e,i){return egret.$warn(1041,"getPixel32","getPixels"),t.getPixels(e,i)},e.getPixels=function(t,e,i,n,r){if(void 0===n&&(n=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,i,n,r)}try{this.convertImageToCanvas(t);return this.sharedContext.getImageData(e,i,n,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(),i=t.getMonth()+1;return parseInt(e+(i<10?"0":"")+i)},t.dateId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getMonth()+1,i=e<10?"0":"",n=t.getDate(),r=n<10?"0":"";return parseInt(t.getFullYear()+i+e+r+n)},t.weekId=function(t,e){void 0===t&&(t=null),void 0===e&&(e=!0),t=t||new Date;var i=new Date;i.setTime(t.getTime()),i.setDate(1),i.setMonth(0);var n=i.getFullYear(),r=i.getDay();0==r&&(r=7);var o=!1;r<=4?(o=r>1,i.setDate(i.getDate()-(r-1))):i.setDate(i.getDate()+7-r+1);var s=this.diffDay(t,i,!1);if(s<0)return i.setDate(1),i.setMonth(0),i.setDate(i.getDate()-1),this.weekId(i,!1);var a=s/7,h=Math.floor(a)+1;if(53==h){i.setTime(t.getTime()),i.setDate(i.getDate()-1);var c=i.getDay();if(0==c&&(c=7),e&&(!o||c<4))return i.setFullYear(i.getFullYear()+1),i.setDate(1),i.setMonth(0),this.weekId(i,!1)}return parseInt(n+"00"+(h>9?"":"0")+h)},t.diffDay=function(t,e,i){void 0===i&&(i=!1);var n=(t.getTime()-e.getTime())/864e5;return i?Math.ceil(n):Math.floor(n)},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(),i=t.getMonth()+1;i=i<10?"0"+i:i;var n=t.getDate();return e+"-"+i+"-"+(n=n<10?"0"+n:n)},t.formatDateTime=function(t){var e=t.getFullYear(),i=t.getMonth()+1;i=i<10?"0"+i:i;var n=t.getDate();n=n<10?"0"+n:n;var r=t.getHours(),o=t.getMinutes();o=o<10?"0"+o:o;var s=t.getSeconds();return e+"-"+i+"-"+n+" "+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,i){void 0===t&&(t=0),void 0===e&&(e=":"),void 0===i&&(i=!0);var n=Math.floor(t/3600),r=Math.floor(t%3600/60),o=Math.floor(t%3600%60),s=n.toString(),a=r.toString(),h=o.toString();return n<10&&(s="0"+s),r<10&&(a="0"+a),o<10&&(h="0"+h),i?s+e+a+e+h:a+e+h},t.timeToMillisecond=function(t,e){void 0===e&&(e=":");for(var i=t.split(e),n=0,r=i.length,o=0;o-1?this.os="iOS":n.indexOf("android")>-1&&(this.os="Android");var r=i.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,i,n){this._x=t,this._y=e,this._width=i,this._height=n,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 i(){return e.call(this,t.PostProcessor.default_vert,i.blur_frag,{screenWidth:t.Core.graphicsDevice.viewport.width,screenHeight:t.Core.graphicsDevice.viewport.height})||this}return __extends(i,e),i.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}",i}(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 i(){return null!==e&&e.apply(this,arguments)||this}return __extends(i,e),i.prototype.onAddedToScene=function(i){e.prototype.onAddedToScene.call(this,i),this.effect=new t.GaussianBlurEffect},i}(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.shouldDebugRender=!0,this.camera=e,this.renderOrder=t}return Object.defineProperty(t.prototype,"wantsToRenderToSceneRenderTarget",{get:function(){return!!this.renderTexture},enumerable:!0,configurable:!0}),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.prototype.debugRender=function(t,e){for(var i=0;ii?i:t},e.pointOnCirlce=function(i,n,r){var o=e.toRadians(r);return new t.Vector2(Math.cos(o)*o+i.x,Math.sin(o)*o+i.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.approach=function(t,e,i){return tn&&(n=s.x),s.yr&&(r=s.y)}return this.fromMinMax(e,i,n,r)},i.prototype.intersects=function(t){return t.leftthis.x+this.width)return!1}else{var n=1/t.direction.x,r=(this.x-t.start.x)*n,o=(this.x+this.width-t.start.x)*n;if(r>o){var s=r;r=o,o=s}if(e.value=Math.max(r,e.value),i=Math.min(o,i),e.value>i)return!1}if(Math.abs(t.direction.y)<1e-6){if(t.start.ythis.y+this.height)return!1}else{var a=1/t.direction.y,h=(this.y-t.start.y)*a,c=(this.y+this.height-t.start.y)*a;if(h>c){var l=h;h=c,c=l}if(e.value=Math.max(h,e.value),i=Math.max(c,i),e.value>i)return!1}return!0},i.prototype.containsRect=function(t){return this.x<=t.x&&t.x1)return!1;var l=(h.x*o.y-h.y*o.x)/a;return!(l<0||l>1)},i.lineToLineIntersection=function(e,i,n,r){var o=new t.Vector2(0,0),s=t.Vector2.subtract(i,e),a=t.Vector2.subtract(r,n),h=s.x*a.y-s.y*a.x;if(0==h)return o;var c=t.Vector2.subtract(n,e),l=(c.x*a.y-c.y*a.x)/h;if(l<0||l>1)return o;var u=(c.x*s.y-c.y*s.x)/h;return u<0||u>1?o:o=t.Vector2.add(e,new t.Vector2(l*s.x,l*s.y))},i.closestPointOnLine=function(e,i,n){var r=t.Vector2.subtract(i,e),o=t.Vector2.subtract(n,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))},i.circleToCircle=function(e,i,n,r){return t.Vector2.distanceSquared(e,n)<(i+r)*(i+r)},i.circleToLine=function(e,i,n,r){return t.Vector2.distanceSquared(e,this.closestPointOnLine(n,r,e))=t&&r.y>=e&&r.x=t+n&&(s|=e.right),o.y=i+r&&(s|=e.bottom),s},i}();t.Collisions=i}(es||(es={})),function(t){var e=function(){function e(e,i,n,r,o){this.fraction=0,this.distance=0,this.point=t.Vector2.zero,this.normal=t.Vector2.zero,this.collider=e,this.fraction=i,this.distance=n,this.point=r,this.centroid=t.Vector2.zero}return e.prototype.setValues=function(t,e,i,n){this.collider=t,this.fraction=e,this.distance=i,this.point=n},e.prototype.setValuesNonCollider=function(t,e,i,n){this.fraction=t,this.distance=e,this.point=i,this.normal=n},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 e(){}return e.reset=function(){this._spatialHash=new t.SpatialHash(this.spatialHashCellSize)},e.clear=function(){this._spatialHash.clear()},e.overlapCircleAll=function(t,e,i,n){if(void 0===n&&(n=-1),0!=i.length)return this._spatialHash.overlapCircle(t,e,i,n);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,i){return void 0===i&&(i=this.allLayers),this._spatialHash.aabbBroadphase(e,t,i)},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.linecast=function(t,i,n){return void 0===n&&(n=e.allLayers),this._hitArray[0].reset(),this.linecastAll(t,i,this._hitArray,n),this._hitArray[0]},e.linecastAll=function(t,i,n,r){return void 0===r&&(r=e.allLayers),0==n.length?(console.warn("传入了一个空的hits数组。没有点击会被返回"),0):this._spatialHash.linecast(t,i,n,r)},e.debugDraw=function(t){this._spatialHash.debugDraw(t,2)},e.spatialHashCellSize=100,e.allLayers=-1,e.raycastsHitTriggers=!1,e.raycastsStartInColliders=!1,e._hitArray=[new t.RaycastHit],e}();t.Physics=e}(es||(es={})),function(t){var e=function(){return function(e,i){this.start=e,this.end=i,this.direction=t.Vector2.subtract(this.end,this.start)}}();t.Ray2D=e}(es||(es={})),function(t){var e=function(){return function(){}}();t.Shape=e}(es||(es={})),function(t){var e=function(e){function i(t,i){var n=e.call(this)||this;return n._areEdgeNormalsDirty=!0,n.isUnrotated=!0,n.setPoints(t),n.isBox=i,n}return __extends(i,e),Object.defineProperty(i.prototype,"edgeNormals",{get:function(){return this._areEdgeNormalsDirty&&this.buildEdgeNormals(),this._edgeNormals},enumerable:!0,configurable:!0}),i.prototype.setPoints=function(t){this.points=t,this.recalculateCenterAndEdgeNormals(),this._originalPoints=[];for(var e=0;e=this.points.length?this.points[0]:this.points[n+1];var o=t.Vector2Ext.perpendicular(r,e);t.Vector2Ext.normalize(o),this._edgeNormals[n]=o}},i.buildSymmetricalPolygon=function(e,i){for(var n=new Array(e),r=0;rr&&(r=s,n=o)}return e[n]},i.getClosestPointOnPolygonToPoint=function(e,i,n,r){n.value=Number.MAX_VALUE,r.x=0,r.y=0;for(var o=new t.Vector2(0,0),s=0,a=0;at.y!=this.points[n].y>t.y&&t.x<(this.points[n].x-this.points[i].x)*(t.y-this.points[i].y)/(this.points[n].y-this.points[i].y)+this.points[i].x&&(e=!e);return e},i.prototype.pointCollidesWithShape=function(e,i){return t.ShapeCollisions.pointToPoly(e,this,i)},i}(t.Shape);t.Polygon=e}(es||(es={})),function(t){var e=function(e){function i(t,n){var r=e.call(this,i.buildBox(t,n),!0)||this;return r.width=t,r.height=n,r}return __extends(i,e),i.buildBox=function(e,i){var n=e/2,r=i/2,o=new Array(4);return o[0]=new t.Vector2(-n,-r),o[1]=new t.Vector2(n,-r),o[2]=new t.Vector2(n,r),o[3]=new t.Vector2(-n,r),o},i.prototype.updateBox=function(e,i){this.width=e,this.height=i;var n=e/2,r=i/2;this.points[0]=new t.Vector2(-n,-r),this.points[1]=new t.Vector2(n,-r),this.points[2]=new t.Vector2(n,r),this.points[3]=new t.Vector2(-n,r);for(var o=0;o1)return!1;var a,h=t.Vector2.add(s.start,t.Vector2.add(s.direction,new t.Vector2(r.value))),c=0;h.xi.bounds.right&&(c|=1),h.yi.bounds.bottom&&(c|=2);var l=a+c;return 3==l&&console.log("m == 3. corner "+t.Time.frameCount),!0},e}();t.RealtimeCollisions=e}(es||(es={})),function(t){var e=function(){function e(){}return e.polygonToPolygon=function(e,i,n){for(var r,o=!0,s=e.edgeNormals,a=i.edgeNormals,h=Number.POSITIVE_INFINITY,c=new t.Vector2,l=t.Vector2.subtract(e.position,i.position),u=0;u0&&(o=!1),!o)return!1;(y=Math.abs(y))r&&(r=o);return{min:n,max:r}},e.circleToPolygon=function(e,i,n){var r,o=t.Vector2.subtract(e.position,i.position),s=new t.Ref(0),a=t.Polygon.getClosestPointOnPolygonToPoint(i.points,o,s,n.normal),h=i.containsPoint(e.position);if(s.value>e.radius*e.radius&&!h)return!1;if(h)r=t.Vector2.multiply(n.normal,new t.Vector2(Math.sqrt(s.value)-e.radius));else if(0==s.value)r=t.Vector2.multiply(n.normal,new t.Vector2(e.radius));else{var c=Math.sqrt(s.value);r=t.Vector2.multiply(new t.Vector2(-t.Vector2.subtract(o,a)),new t.Vector2((e.radius-s.value)/c))}return n.minimumTranslationVector=r,n.point=t.Vector2.add(a,i.position),!0},e.circleToBox=function(e,i,n){var r=i.bounds.getClosestPointOnRectangleBorderToPoint(e.position,n.normal);if(i.containsPoint(e.position)){n.point=r;var o=t.Vector2.add(r,t.Vector2.multiply(n.normal,new t.Vector2(e.radius)));return n.minimumTranslationVector=t.Vector2.subtract(e.position,o),!0}var s=t.Vector2.distanceSquared(r,e.position);if(0==s)n.minimumTranslationVector=t.Vector2.multiply(n.normal,new t.Vector2(e.radius));else if(s<=e.radius*e.radius){n.normal=t.Vector2.subtract(e.position,r);var a=n.normal.length()-e.radius;return n.point=r,t.Vector2Ext.normalize(n.normal),n.minimumTranslationVector=t.Vector2.multiply(new t.Vector2(a),n.normal),!0}return!1},e.pointToCircle=function(e,i,n){var r=t.Vector2.distanceSquared(e,i.position),o=1+i.radius;if(r1)return!1;var u=(c.x*s.y-c.y*s.x)/h;return!(u<0||u>1)&&(o=o.add(e).add(t.Vector2.multiply(new t.Vector2(l),s)),!0)},e.lineToCircle=function(e,i,n,r){var o=t.Vector2.distance(e,i),s=t.Vector2.divide(t.Vector2.subtract(i,e),new t.Vector2(o)),a=t.Vector2.subtract(e,n.position),h=t.Vector2.dot(a,s),c=t.Vector2.dot(a,a)-n.radius*n.radius;if(c>0&&h>0)return!1;var l=h*h-c;return!(l<0)&&(r.fraction=-h-Math.sqrt(l),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,n.position)),r.fraction=r.distance/o,!0)},e.boxToBoxCast=function(e,i,n,r){var o=this.minkowskiDifference(e,i);if(o.contains(0,0)){var s=o.getClosestPointOnBoundsToOrigin();return!s.equals(t.Vector2.zero)&&(r.normal=new t.Vector2(-s.x),r.normal.normalize(),r.distance=0,r.fraction=0,!0)}var a=new t.Ray2D(t.Vector2.zero,new t.Vector2(-n.x)),h=new t.Ref(0);return!!(o.rayIntersects(a,h)&&h.value<=1)&&(r.fraction=h.value,r.distance=n.length()*h.value,r.normal=new t.Vector2(-n.x,-n.y),r.normal.normalize(),r.centroid=t.Vector2.add(e.bounds.center,t.Vector2.multiply(n,new t.Vector2(h.value))),!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 i,this._tempHashSet=[],this._cellSize=e,this._inverseCellSize=1/this._cellSize,this._raycastParser=new n}return e.prototype.register=function(e){var i=e.bounds;e.registeredPhysicsBounds=i;var n=this.cellCoords(i.x,i.y),r=this.cellCoords(i.right,i.bottom);this.gridBounds.contains(n.x,n.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,n)),this.gridBounds.contains(r.x,r.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,r));for(var o=n.x;o<=r.x;o++)for(var s=n.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,i=this.cellCoords(e.x,e.y),n=this.cellCoords(e.right,e.bottom),r=i.x;r<=n.x;r++)for(var o=i.y;o<=n.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 i=this.gridBounds.x;i<=this.gridBounds.right;i++)for(var n=this.gridBounds.y;n<=this.gridBounds.bottom;n++){var r=this.cellAtPosition(i,n);r&&r.length>0&&this.debugDrawCellDetails(i,n,r.length,t,e)}},e.prototype.aabbBroadphase=function(e,i,n){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 h=this.cellAtPosition(s,a);if(h)for(var c=function(r){var o=h[r];if(o==i||!t.Flags.isFlagSet(n,o.physicsLayer.value))return"continue";e.intersects(o.bounds)&&(l._tempHashSet.firstOrDefault(function(t){return t.hashCode==o.hashCode})||l._tempHashSet.push(o))},l=this,u=0;u=0&&(e.push(this.findBoundsRect(i,o,r,t)),i=-1)}i>=0&&(e.push(this.findBoundsRect(i,this.map.width,r,t)),i=-1)}return e},e.prototype.findBoundsRect=function(e,i,n,r){for(var o=-1,s=n+1;sthis.tileHeight||this.maxTileWidth>this.tileWidth},enumerable:!0,configurable:!0}),i.prototype.getTilesetForTileGid=function(t){if(0==t)return null;for(var e=this.tilesets.length-1;e>=0;e--)if(this.tilesets[e].firstGid<=t)return this.tilesets[e];console.error("tile gid"+t+"未在任何tileset中找到")},i.prototype.worldToTilePositionX=function(e,i){void 0===i&&(i=!0);var n=Math.floor(e/this.tileWidth);return i?t.MathHelper.clamp(n,0,this.width-1):n},i.prototype.worldToTilePositionY=function(e,i){void 0===i&&(i=!0);var n=Math.floor(e/this.tileHeight);return i?t.MathHelper.clamp(n,0,this.height-1):n},i.prototype.getLayer=function(t){return this.layers[t]},i.prototype.update=function(){this.tilesets.forEach(function(t){t.update()})},i.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)},i}(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 i=function(){return function(){this.shape=new egret.Shape,this.textField=new egret.TextField}}();t.TmxObject=i;var n=function(){return function(){}}();t.TmxText=n;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(){function e(){}return e.loadTmxMap=function(t,e){var i=RES.getRes(e);return this.loadTmxMapData(t,i,RES.getResourceInfo(e))},e.loadTmxMapData=function(e,i,n){return __awaiter(this,void 0,void 0,function(){var r,o,s,a;return __generator(this,function(h){switch(h.label){case 0:e.version=i.version,e.tiledVersion=i.tiledversion,e.width=i.width,e.height=i.height,e.tileWidth=i.tilewidth,e.tileHeight=i.tileheight,e.hexSideLength=i.hexsidelength,e.orientation=this.parseOrientationType(i.orientation),e.staggerAxis=this.parseStaggerAxisType(i.staggeraxis),e.staggerIndex=this.parseStaggerIndexType(i.staggerindex),e.renderOrder=this.parseRenderOrderType(i.renderorder),e.nextObjectID=i.nextobjectid,e.backgroundColor=t.TmxUtils.color16ToUnit(i.color),e.properties=this.parsePropertyDict(i.properties),e.maxTileWidth=e.tileWidth,e.maxTileHeight=e.tileHeight,e.tmxDirectory=n.root+n.url.replace(".","_").replace(n.name,""),e.tilesets=[],r=0,o=i.tilesets,h.label=1;case 1:return rt.map.maxTileWidth&&(t.map.maxTileWidth=e.image.width),e.image.height>t.map.maxTileHeight&&(t.map.maxTileHeight=e.image.height))}),t.tileRegions.forEach(function(e){var i=e.width,n=e.height;i>t.map.maxTileWidth&&(t.map.maxTileWidth=i),i>t.map.maxTileHeight&&(t.map.maxTileHeight=n)})},e.parseOrientationType=function(e){return"unknown"==e?t.OrientationType.unknown:"orthogonal"==e?t.OrientationType.orthogonal:"isometric"==e?t.OrientationType.isometric:"staggered"==e?t.OrientationType.staggered:"hexagonal"==e?t.OrientationType.hexagonal:t.OrientationType.unknown},e.parseStaggerAxisType=function(e){return"y"==e?t.StaggerAxisType.y:t.StaggerAxisType.x},e.parseStaggerIndexType=function(e){return"even"==e?t.StaggerIndexType.even:t.StaggerIndexType.odd},e.parseRenderOrderType=function(e){return"right-up"==e?t.RenderOrderType.rightUp:"left-down"==e?t.RenderOrderType.leftDown:"left-up"==e?t.RenderOrderType.leftUp:t.RenderOrderType.rightDown},e.parsePropertyDict=function(e){if(!e)return null;for(var i=new Map,n=0,r=e;n=e.columns));m+=e.tileWidth+e.spacing);else e.tiles.forEach(function(i,n){e.tileRegions.set(n,new t.Rectangle(0,0,i.image.width,i.image.height))});return[2,e]}})})},e.loadTmxTilesetTile=function(e,i,n,r,o){return __awaiter(this,void 0,void 0,function(){var s,a,h,c,l,u,p,d,f,g,y,m,_;return __generator(this,function(v){switch(v.label){case 0:if(e.tileset=i,e.id=n.id,s=n.terrain)for(e.terrainEdges=new Array(4),a=0,h=0,c=s;h0){a.shape.x=h.x,a.shape.y=h.y,i.addChild(a.shape),a.shape.graphics.clear(),a.shape.graphics.lineStyle(1,10526884);for(u=0;u0&&(l=u.currentAnimationFrameGid);var p=i.tileset.tileRegions.get(l),d=Math.floor(i.x)*s,f=Math.floor(i.y)*a;i.horizontalFlip&&i.verticalFlip?(d+=a+(p.height*o.y-a),f-=p.width*o.x-s):i.horizontalFlip?d+=s+(p.height*o.y-a):i.verticalFlip?f+=s-p.width*o.x:f+=a-p.height*o.y;var g=new t.Vector2(d,f).add(r);if(i.tileset.image){if(n){var y=i.tileset.image.bitmap.getTexture(""+l);y||(y=i.tileset.image.bitmap.createTexture(""+l,p.x,p.y,p.width,p.height)),i.tileset.image.texture=new e(y),n.addChild(i.tileset.image.texture),i.tileset.image.texture.x!=g.x&&(i.tileset.image.texture.x=g.x),i.tileset.image.texture.y!=g.y&&(i.tileset.image.texture.y=g.y),i.verticalFlip&&i.horizontalFlip?(i.tileset.image.texture.scaleX=-1,i.tileset.image.texture.scaleY=-1):i.verticalFlip?(i.tileset.image.texture.scaleX=o.x,i.tileset.image.texture.scaleY=-1):i.horizontalFlip?(i.tileset.image.texture.scaleX=-1,i.tileset.image.texture.scaleY=o.y):(i.tileset.image.texture.scaleX=o.x,i.tileset.image.texture.scaleY=o.y),0!=i.tileset.image.texture.rotation&&(i.tileset.image.texture.rotation=0),0!=i.tileset.image.texture.anchorOffsetX&&(i.tileset.image.texture.anchorOffsetX=0),0!=i.tileset.image.texture.anchorOffsetY&&(i.tileset.image.texture.anchorOffsetY=0)}}else u.image.texture&&(u.image.bitmap.getTexture(l.toString())||(u.image.texture=new e(u.image.bitmap.createTexture(l.toString(),p.x,p.y,p.width,p.height)),n.addChild(u.image.texture)),u.image.texture.x=g.x,u.image.texture.y=g.y,u.image.texture.scaleX=o.x,u.image.texture.scaleY=o.y,u.image.texture.rotation=0,u.image.texture.anchorOffsetX=0,u.image.texture.anchorOffsetY=0,u.image.texture.filters=[h])},i}();t.TiledRendering=i}(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 i=function(){return function(){}}();t.TmxTileOffset=i;var n=function(){return function(){}}();t.TmxTerrain=n}(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 i=function(){return function(){}}();t.TmxAnimationFrame=i}(es||(es={})),function(t){var e=function(){function e(){}return e.decode=function(e,i,n){switch(n=n||"none",i=i||"none"){case"base64":var r=t.Base64Utils.decodeBase64AsArray(e,4);return"none"===n?r:t.Base64Utils.decompress(e,r,n);case"csv":return t.Base64Utils.decodeCSV(e);case"none":for(var o=[],s=0;si;n--)if(t[n]0&&t[r-1]>n;r--)t[r]=t[r-1];t[r]=n}},t.binarySearch=function(t,e){for(var i=0,n=t.length,r=i+n>>1;i=t[r]&&(i=r+1),r=i+n>>1;return t[i]==e?i:-1},t.findElementIndex=function(t,e){for(var i=t.length,n=0;nt[e]&&(e=n);return e},t.getMinElementIndex=function(t){for(var e=0,i=t.length,n=1;n=0;--r)i.unshift(e[r]);return i},t.getDifferAry=function(t,e){t=this.getUniqueAry(t),e=this.getUniqueAry(e);for(var i=t.concat(e),n={},r=[],o=i.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 i=t.length;if(i!=e.length)return!1;for(;i--;)if(t[i]!=e[i])return!1;return!0},t.insert=function(t,e,i){if(!t)return null;var n=t.length;if(e>n&&(e=n),e<0&&(e=0),e==n)t.push(i);else if(0==e)t.unshift(i);else{for(var r=n-1;r>=e;r-=1)t[r+1]=t[r];t[e]=i}return i},t}();!function(t){var e=function(){function t(){}return Object.defineProperty(t,"nativeBase64",{get:function(){return"function"==typeof window.atob},enumerable:!0,configurable:!0}),t.decode=function(t){if(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,""),this.nativeBase64)return window.atob(t);for(var e,i,n,r,o,s,a=[],h=0;h>4,i=(15&r)<<4|(o=this._keyStr.indexOf(t.charAt(h++)))>>2,n=(3&o)<<6|(s=this._keyStr.indexOf(t.charAt(h++))),a.push(String.fromCharCode(e)),64!==o&&a.push(String.fromCharCode(i)),64!==s&&a.push(String.fromCharCode(n));return a=a.join("")},t.encode=function(t){if(t=t.replace(/\r\n/g,"\n"),!this.nativeBase64){for(var e,i,n,r,o,s,a,h=[],c=0;c>2,o=(3&e)<<4|(i=t.charCodeAt(c++))>>4,s=(15&i)<<2|(n=t.charCodeAt(c++))>>6,a=63&n,isNaN(i)?s=a=64:isNaN(n)&&(a=64),h.push(this._keyStr.charAt(r)),h.push(this._keyStr.charAt(o)),h.push(this._keyStr.charAt(s)),h.push(this._keyStr.charAt(a));return h=h.join("")}window.btoa(t)},t.decodeBase64AsArray=function(e,i){i=i||1;var n,r,o,s=t.decode(e),a=new Uint32Array(s.length/i);for(n=0,o=s.length/i;n=0;--r)a[n]+=s.charCodeAt(n*i+r)<<(r<<3);return a},t.decompress=function(t,e,i){throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!")},t.decodeCSV=function(t){for(var e=t.replace("\n","").trim().split(","),i=[],n=0;n>16},set:function(t){this._packedValue=4278255615&this._packedValue|t<<16},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"g",{get:function(){return this._packedValue>>8},set:function(t){this._packedValue=4294902015&this._packedValue|t<<8},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"r",{get:function(){return this._packedValue},set:function(t){this._packedValue=4294967040&this._packedValue|t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"a",{get:function(){return this._packedValue>>24},set:function(t){this._packedValue=16777215&this._packedValue|t<<24},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"packedValue",{get:function(){return this._packedValue},set:function(t){this._packedValue=t},enumerable:!0,configurable:!0}),e.prototype.equals=function(t){return this._packedValue==t._packedValue},e}();t.Color=e}(es||(es={})),function(t){var e=function(){function t(){this.loadedAssets=new Map}return t.prototype.loadRes=function(t,e){var i=this;return void 0===e&&(e=!0),new Promise(function(n,r){var o=i.loadedAssets.get(t);o?n(o):e?RES.getResAsync(t).then(function(e){i.loadedAssets.set(t,e),n(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)}):RES.getResByUrl(t).then(function(e){i.loadedAssets.set(t,e),n(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)})})},t.prototype.dispose=function(){this.loadedAssets.forEach(function(t){var e=t;RES.destroyRes(e)&&e.dispose()}),this.loadedAssets.clear()},t}();t.ContentManager=e}(es||(es={})),function(t){var e=function(){function t(){}return t.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)},t}();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 i=function(){function t(){this._messageTable=new Map}return t.prototype.addObserver=function(t,i,n){var r=this._messageTable.get(t);r||(r=[],this._messageTable.set(t,r)),-1!=r.findIndex(function(t){return t.func==i})&&console.warn("您试图添加相同的观察者两次"),r.push(new e(i,n))},t.prototype.removeObserver=function(t,e){var i=this._messageTable.get(t),n=i.findIndex(function(t){return t.func==e});-1!=n&&i.removeAt(n)},t.prototype.emit=function(t,e){var i=this._messageTable.get(t);if(i)for(var n=i.length-1;n>=0;n--)i[n].func.call(i[n].context,e)},t}();t.Emitter=i}(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 i=[];e--;)i.push(t);return i},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 t(){}return t.warmCache=function(t){if((t-=this._objectQueue.length)>0)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={})),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,i){if(void 0===i&&(i=1),0==i)throw new Error("step 不能为 0");var n=e-t;if(0==n)throw new Error("没有可用的范围("+t+","+e+")");n<0&&(n=t-e);var r=Math.floor((n+i-1)/i);return Math.floor(this.random()*r)*i+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 i=t.length;if(e<=0||i=0;)s=Math.floor(this.random()*i);n.push(t[s]),r.push(s)}return n},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,i){switch(i){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,i){var n=new t.Rectangle(i.x,i.y,0,0),r=new t.Rectangle;return r.x=Math.min(e.x,n.x),r.y=Math.min(e.y,n.y),r.width=Math.max(e.right,n.right)-r.x,r.height=Math.max(e.bottom,r.bottom)-r.y,r},e.getHalfRect=function(e,i){switch(i){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,i,n){switch(void 0===n&&(n=1),i){case t.Edge.top:return new t.Rectangle(e.x,e.y,e.width,n);case t.Edge.bottom:return new t.Rectangle(e.x,e.y+e.height-n,e.width,n);case t.Edge.left:return new t.Rectangle(e.x,e.y,n,e.height);case t.Edge.right:return new t.Rectangle(e.x+e.width-n,e.y,n,e.height)}},e.expandSide=function(e,i,n){switch(n=Math.abs(n),i){case t.Edge.top:e.y-=n,e.height+=n;break;case t.Edge.bottom:e.height+=n;break;case t.Edge.left:e.x-=n,e.width+=n;break;case t.Edge.right:e.width+=n}},e.contract=function(t,e,i){t.x+=e,t.y+=i,t.width-=2*e,t.height-=2*i},e}();t.RectangleExt=e}(es||(es={})),function(t){var e=function(){return function(t){this.value=t}}();t.Ref=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,i,n,r){return!(t.Vector2Ext.cross(t.Vector2.subtract(e,i),t.Vector2.subtract(n,i))<0)&&(!(t.Vector2Ext.cross(t.Vector2.subtract(e,n),t.Vector2.subtract(r,n))<0)&&!(t.Vector2Ext.cross(t.Vector2.subtract(e,r),t.Vector2.subtract(i,r))<0))},e.prototype.triangulate=function(i,n){void 0===n&&(n=!0);var r=i.length;this.initialize(r);for(var o=0,s=0;r>3&&o<500;){o++;var a=!0,h=i[this._triPrev[s]],c=i[s],l=i[this._triNext[s]];if(t.Vector2Ext.isTriangleCCW(h,c,l)){var u=this._triNext[this._triNext[s]];do{if(e.testPointTriangle(i[u],h,c,l)){a=!1;break}u=this._triNext[u]}while(u!=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]),n||this.triangleIndices.reverse()},e.prototype.initialize=function(t){this.triangleIndices.length=0,this._triNext.lengtht.MathHelper.Epsilon?e.divide(new t.Vector2(i)):e.x=e.y=0},e.transformA=function(t,e,i,n,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},i}();t.Layout=i,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,i=function(){function t(t){void 0===t&&(t=n),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=(i=this.getSystemTime())-this._stopSystemTime;this._stopDuration+=e,this._stopSystemTime=void 0}else if(void 0===this._startSystemTime){var i=this.getSystemTime();this._startSystemTime=i,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=i,function(t){t.IDLE="IDLE",t.RUNNING="RUNNING",t.STOPPED="STOPPED"}(e||(e={})),t.setDefaultSystemTimeGetter=function(t){void 0===t&&(t=Date.now),n=t};var n=Date.now}(stopwatch||(stopwatch={})),function(t){var e=function(){function e(){this.showLog=!1,this.markers=[],this.stopwacth=new stopwatch.Stopwatch,this._markerNameToIdMap=new Map,this._rectShape1=new egret.Shape,this._rectShape2=new egret.Shape,this._rectShape3=new egret.Shape,this._rectShape4=new egret.Shape,this._rectShape5=new egret.Shape,this._rectShape6=new egret.Shape,this._logs=new Array(2);for(var e=0;e=e.logSnapDuration&&(l.logs[n].snapMin=l.logs[n].min,l.logs[n].snapMax=l.logs[n].max,l.logs[n].snapAvg=l.logs[n].avg,l.logs[n].samples=0)):(l.logs[n].min=h,l.logs[n].max=h,l.logs[n].avg=h,l.logs[n].initialized=!0)}o.markCount=r.nestCount,o.nestCount=r.nestCount}this.stopwacth.reset(),this.stopwacth.start()}},e.prototype.beginMark=function(t,i,n){if(void 0===n&&(n=0),n<0||n>=e.maxBars)throw new Error("barIndex argument out of range");var r=this._curLog.bars[n];if(r.markCount>=e.maxSamples)throw new Error("exceeded sample count. either set larger number to timeruler.maxsaple or lower sample count");if(r.nestCount>=e.maxNestCall)throw new Error("exceeded nest count. either set larger number to timeruler.maxnestcall or lower nest calls");var o=this._markerNameToIdMap.get(t);isNaN(o)&&(o=this.markers.length,this._markerNameToIdMap.set(t,o)),r.markerNests[r.nestCount++]=r.markCount,r.markers[r.markCount].markerId=o,r.markers[r.markCount].color=i,r.markers[r.markCount].beginTime=this.stopwacth.getTime(),r.markers[r.markCount].endTime=-1},e.prototype.endMark=function(t,i){if(void 0===i&&(i=0),i<0||i>=e.maxBars)throw new Error("barIndex argument out of range");var n=this._curLog.bars[i];if(n.nestCount<=0)throw new Error("call beginMark method before calling endMark method");var r=this._markerNameToIdMap.get(t);if(isNaN(r))throw new Error("Marker "+t+" is not registered. Make sure you specifed same name as you used for beginMark method");var o=n.markerNests[--n.nestCount];if(n.markers[o].markerId!=r)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).");n.markers[o].endTime=this.stopwacth.getTime()},e.prototype.getAverageTime=function(t,i){if(t<0||t>=e.maxBars)throw new Error("barIndex argument out of range");var n=0,r=this._markerNameToIdMap.get(i);return r&&(n=this.markers[r].logs[t].avg),n},e.prototype.resetLog=function(){this.markers.forEach(function(t){for(var e=0;e0&&(r+=e.barHeight+2*e.barPadding,o=Math.max(o,t.markers[t.markCount-1].endTime))});var s=this.sampleFrames*(1/60*1e3);this._frameAdjust=o>s?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,o/(1/60*1e3)+1),this._frameAdjust=0);var a=n/s,h=i.y-(r-e.barHeight),c=h,l=new t.Rectangle(i.x,c,n,r);this._rectShape1.graphics.clear(),this._rectShape1.graphics.beginFill(0,128/255),this._rectShape1.graphics.drawRect(l.x,l.y,l.width,l.height),this._rectShape1.graphics.endFill(),l.height=e.barHeight,this._rectShape2.graphics.clear();for(var u=0,p=this._prevLog.bars;u0)for(var f=0;f0&&this.setpreviousTouchState(this._gameTouchs[0]),e},enumerable:!0,configurable:!0}),i.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())},i.update=function(){KeyboardUtils.update();for(var t=0;t0,this._willRepeat||(this.isRepeating=!1)},i.prototype.update=function(){this._bufferCounter-=t.Time.unscaledDeltaTime,this.isRepeating=!1;for(var e=!1,i=0;i0||this.isRepeating)return!0;for(var t=0,e=this.nodes;ta||i[c].height>a)throw new Error("一个纹理的大小比图集的大小大");h.push(new t.Rectangle(0,0,i[c].width,i[c].height))}for(;h.length>0;){var l=new egret.RenderTexture,u=new t.RectanglePacker(a,a,1);for(c=0;c0){for(var p=new t.IntegerRectangle,d=[],f=[],g=[],y=[],m=0;m0;)this.freeRectangle(this._insertedRectangles.pop());for(;this._freeAreas.length>0;)this.freeRectangle(this._freeAreas.pop());for(this._width=t,this._height=e,this._packedWidth=0,this._packedHeight=0,this._freeAreas.push(this.allocateRectangle(0,0,this._width,this._height));this._insertedRectangles.length>0;)this.freeSize(this._insertList.pop());this._padding=i},e.prototype.insertRectangle=function(t,e,i){var n=this.allocateSize(t,e,i);this._insertList.push(n)},e.prototype.packRectangles=function(t){for(void 0===t&&(t=!0),t&&this._insertList.sort(function(t,e){return t.width-e.width});this._insertList.length>0;){var e=this._insertList.pop(),i=e.width,n=e.height,r=this.getFreeAreaIndex(i,n);if(r>=0){var o=this._freeAreas[r],s=this.allocateRectangle(o.x,o.y,i,n);for(s.id=e.id,this.generateNewFreeAreas(s,this._freeAreas,this._newFreeAreas);this._newFreeAreas.length>0;)this._freeAreas.push(this._newFreeAreas.pop());this._insertedRectangles.push(s),s.right>this._packedWidth&&(this._packedWidth=s.right),s.bottom>this._packedHeight&&(this._packedHeight=s.bottom)}this.freeSize(e)}return this.rectangleCount},e.prototype.getRectangle=function(t,e){var i=this._insertedRectangles[t];return e.x=i.x,e.y=i.y,e.width=i.width,e.height=i.height,e},e.prototype.getRectangleId=function(t){return this._insertedRectangles[t].id},e.prototype.generateNewFreeAreas=function(t,e,i){var n=t.x,r=t.y,o=t.right+1+this._padding,s=t.bottom+1+this._padding,a=null;0==this._padding&&(a=t);for(var h=e.length-1;h>=0;h--){var c=e[h];if(!(n>=c.right||o<=c.x||r>=c.bottom||s<=c.y)){null==a&&(a=this.allocateRectangle(t.x,t.y,t.width+this._padding,t.height+this._padding)),this.generateDividedAreas(a,c,i);var l=e.pop();h=0;e--)for(var i=t[e],n=t.length-1;n>=0;n--)if(e!=n){var r=t[n];if(i.x>=r.x&&i.y>=r.y&&i.right<=r.right&&i.bottom<=r.bottom){this.freeRectangle(i);var o=t.pop();e0&&(i.push(this.allocateRectangle(t.right,e.y,r,e.height)),n++);var o=t.x-e.x;o>0&&(i.push(this.allocateRectangle(e.x,e.y,o,e.height)),n++);var s=e.bottom-t.bottom;s>0&&(i.push(this.allocateRectangle(e.x,t.bottom,e.width,s)),n++);var a=t.y-e.y;a>0&&(i.push(this.allocateRectangle(e.x,e.y,e.width,a)),n++),0==n&&(t.width=0;s--){var a=this._freeAreas[s];if(a.x0){var r=this._sortableSizeStack.pop();return r.width=e,r.height=i,r.id=n,r}return new t.SortableSize(e,i,n)},e.prototype.freeSize=function(t){this._sortableSizeStack.push(t)},e.prototype.allocateRectangle=function(e,i,n,r){if(this._rectangleStack.length>0){var o=this._rectangleStack.pop();return o.x=e,o.y=i,o.width=n,o.height=r,o.right=e+n,o.bottom=i+r,o}return new t.IntegerRectangle(e,i,n,r)},e.prototype.freeRectangle=function(t){this._rectangleStack.push(t)},e}();t.RectanglePacker=e}(es||(es={})),function(t){var e=function(){return function(t,e,i){this.width=t,this.height=e,this.id=i}}();t.SortableSize=e}(es||(es={})),function(t){var e=function(){return function(t){this.assets=t}}();t.TextureAssets=e;var i=function(){return function(){}}();t.TextureAsset=i}(es||(es={})),function(t){var e=function(){return function(t,e){this.texture=t,this.id=e}}();t.TextureToPack=e}(es||(es={})),function(t){var e=function(){function e(){this._timeInSeconds=0,this._repeats=!1,this._isDone=!1,this._elapsedTime=0}return e.prototype.getContext=function(){return this.context},e.prototype.reset=function(){this._elapsedTime=0},e.prototype.stop=function(){this._isDone=!0},e.prototype.tick=function(){return!this._isDone&&this._elapsedTime>this._timeInSeconds&&(this._elapsedTime-=this._timeInSeconds,this._onTime(this),this._isDone||this._repeats||(this._isDone=!0)),this._elapsedTime+=t.Time.deltaTime,this._isDone},e.prototype.initialize=function(t,e,i,n){this._timeInSeconds=t,this._repeats=e,this.context=i,this._onTime=n},e.prototype.unload=function(){this.context=null,this._onTime=null},e}();t.Timer=e}(es||(es={})),function(t){var e=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t._timers=[],t}return __extends(i,e),i.prototype.update=function(){for(var t=this._timers.length-1;t>=0;t--)this._timers[t].tick()&&(this._timers[t].unload(),this._timers.removeAt(t))},i.prototype.schedule=function(e,i,n,r){var o=new t.Timer;return o.initialize(e,i,n,r),this._timers.push(o),o},i}(t.GlobalManager);t.TimerManager=e}(es||(es={})); \ No newline at end of file diff --git a/source/src/ECS/Component.ts b/source/src/ECS/Component.ts index b51c82ec..c936f548 100644 --- a/source/src/ECS/Component.ts +++ b/source/src/ECS/Component.ts @@ -127,15 +127,5 @@ module es { return this; } - - /** - * 创建此组件的克隆 - */ - public clone(): Component { - let component = ObjectUtils.clone(this); - component.entity = null; - - return component; - } } } diff --git a/source/src/ECS/Components/Physics/Colliders/BoxCollider.ts b/source/src/ECS/Components/Physics/Colliders/BoxCollider.ts index a1ef4586..169bace5 100644 --- a/source/src/ECS/Components/Physics/Colliders/BoxCollider.ts +++ b/source/src/ECS/Components/Physics/Colliders/BoxCollider.ts @@ -8,12 +8,24 @@ module es { /** * 零参数构造函数要求RenderableComponent在实体上,这样碰撞器可以在实体被添加到场景时调整自身的大小。 */ - constructor() { + constructor(x?: number, y?: number, width?: number, height?: number) { super(); - // 我们在这里插入一个1x1框作为占位符,直到碰撞器在下一阵被添加到实体并可以获得更精确的自动调整大小数据 - this.shape = new Box(1, 1); - this._colliderRequiresAutoSizing = true; + if (x == undefined && y == undefined){ + if (width == undefined && height == undefined){ + // 我们在这里插入一个1x1框作为占位符,直到碰撞器在下一阵被添加到实体并可以获得更精确的自动调整大小数据 + this.shape = new Box(1, 1); + this._colliderRequiresAutoSizing = true; + }else if (width != undefined && height != undefined){ + x = -width / 2; + y = -height / 2; + this._localOffset = new Vector2(x + width / 2, y + height / 2); + this.shape = new Box(width, height); + } + }else if (x != undefined && y != undefined && width != undefined && height != undefined){ + this._localOffset = new Vector2(x + width / 2, y + height / 2); + this.shape = new Box(width, height); + } } public get width() { @@ -32,20 +44,6 @@ module es { this.setHeight(value); } - /** - * 创建一个BoxCollider并使用x/y组件作为localOffset - * @param x - * @param y - * @param width - * @param height - */ - public createBoxRect(x: number, y: number, width: number, height: number): BoxCollider{ - this._localOffset = new Vector2(x + width / 2, y + width / 2); - this.shape = new Box(width, height); - this._colliderRequiresAutoSizing = false; - return this; - } - /** * 设置BoxCollider的大小 * @param width @@ -110,11 +108,11 @@ module es { if (!this.pixelShape2.parent) this.debugDisplayObject.addChild(this.pixelShape2); - // this.hollowShape.graphics.clear(); - // this.hollowShape.graphics.beginFill(Colors.colliderBounds, 0); - // this.hollowShape.graphics.lineStyle(Size.lineSizeMultiplier, Colors.colliderBounds); - // this.hollowShape.graphics.drawRect(this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height); - // this.hollowShape.graphics.endFill(); + this.hollowShape.graphics.clear(); + this.hollowShape.graphics.beginFill(Colors.colliderBounds, 0); + this.hollowShape.graphics.lineStyle(Size.lineSizeMultiplier, Colors.colliderBounds); + this.hollowShape.graphics.drawRect(this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height); + this.hollowShape.graphics.endFill(); this.polygonShape.graphics.clear(); if (poly.points.length >= 2){ diff --git a/source/src/ECS/Components/Physics/Colliders/CircleCollider.ts b/source/src/ECS/Components/Physics/Colliders/CircleCollider.ts index e50c9a31..5f15a8c4 100644 --- a/source/src/ECS/Components/Physics/Colliders/CircleCollider.ts +++ b/source/src/ECS/Components/Physics/Colliders/CircleCollider.ts @@ -13,11 +13,14 @@ module es { constructor(radius?: number) { super(); - if (radius) + if (radius == undefined){ + // 我们在这里插入一个1px的圆圈作为占位符 + // 直到碰撞器被添加到实体并可以获得更精确的自动调整大小数据的下一帧 + this.shape = new Circle(1); this._colliderRequiresAutoSizing = true; - // 我们在这里插入一个1px的圆圈作为占位符 - // 直到碰撞器被添加到实体并可以获得更精确的自动调整大小数据的下一帧 - this.shape = new Circle(radius ? radius : 1); + }else{ + this.shape = new Circle(radius); + } } public get radius(): number { diff --git a/source/src/ECS/Components/Physics/Colliders/Collider.ts b/source/src/ECS/Components/Physics/Colliders/Collider.ts index ada2ce55..adfa3476 100644 --- a/source/src/ECS/Components/Physics/Colliders/Collider.ts +++ b/source/src/ECS/Components/Physics/Colliders/Collider.ts @@ -1,6 +1,5 @@ module es { export abstract class Collider extends Component { - public debug /** * 对撞机的基本形状 */ @@ -12,12 +11,12 @@ module es { /** * 在处理冲突时,physicsLayer可以用作过滤器。Flags类有帮助位掩码的方法 */ - public physicsLayer = 1 << 0; + public physicsLayer = new Ref(1 << 0); /** * 碰撞器在使用移动器移动时应该碰撞的层 * 默认为所有层 */ - public collidesWithLayers = Physics.allLayers; + public collidesWithLayers: Ref = new Ref(Physics.allLayers); /** * 如果为true,碰撞器将根据附加的变换缩放和旋转 */ @@ -124,8 +123,8 @@ module es { let renderableBounds = renderable.bounds; // 这里我们需要大小*反尺度,因为当我们自动调整碰撞器的大小时,它需要没有缩放的渲染 - let width = renderableBounds.width / this.entity.scale.x; - let height = renderableBounds.height / this.entity.scale.y; + let width = renderableBounds.width / this.entity.transform.scale.x; + let height = renderableBounds.height / this.entity.transform.scale.y; // 圆碰撞器需要特别注意原点 if (this instanceof CircleCollider) { this.radius = Math.max(width, height) * 0.5; @@ -214,7 +213,7 @@ module es { public collidesWith(collider: Collider, motion: Vector2, result: CollisionResult): boolean { // 改变形状的位置,使它在移动后的位置,这样我们可以检查重叠 let oldPosition = this.entity.position; - this.entity.position = this.entity.position.add(motion); + this.entity.position.add(motion); let didCollide = this.shape.collidesWithShape(collider.shape, result); if (didCollide) @@ -225,15 +224,5 @@ module es { return didCollide; } - - public clone(): Component { - let collider = ObjectUtils.clone(this); - collider.entity = null; - - if (this.shape) - collider.shape = this.shape.clone(); - - return collider; - } } } diff --git a/source/src/ECS/Components/Physics/Mover.ts b/source/src/ECS/Components/Physics/Mover.ts index a13c1132..3cec508d 100644 --- a/source/src/ECS/Components/Physics/Mover.ts +++ b/source/src/ECS/Components/Physics/Mover.ts @@ -36,7 +36,7 @@ module es { let bounds = collider.bounds; bounds.x += motion.x; bounds.y += motion.y; - let neighbors = Physics.boxcastBroadphaseExcludingSelf(collider, bounds, collider.collidesWithLayers); + let neighbors = Physics.boxcastBroadphaseExcludingSelf(collider, bounds, collider.collidesWithLayers.value); for (let j = 0; j < neighbors.length; j++) { let neighbor = neighbors[j]; diff --git a/source/src/ECS/Components/Physics/ProjectileMover.ts b/source/src/ECS/Components/Physics/ProjectileMover.ts index a12d4e87..32b79c20 100644 --- a/source/src/ECS/Components/Physics/ProjectileMover.ts +++ b/source/src/ECS/Components/Physics/ProjectileMover.ts @@ -24,13 +24,12 @@ module es { let didCollide = false; // 获取我们在新位置可能发生碰撞的任何东西 - this.entity.position = Vector2.add(this.entity.position, motion); + this.entity.position.add(motion); // 获取任何可能在新位置发生碰撞的东西 - let neighbors = Physics.boxcastBroadphase(this._collider.bounds, this._collider.collidesWithLayers); - for (let i = 0; i < neighbors.length; i++) { - let neighbor = neighbors[i]; - if (this._collider.overlaps(neighbor) && neighbor.enabled) { + let neighbors = Physics.boxcastBroadphase(this._collider.bounds, this._collider.collidesWithLayers.value); + for (let neighbor of neighbors){ + if (this._collider.overlaps(neighbor) && neighbor.enabled){ didCollide = true; this.notifyTriggerListeners(this._collider, neighbor); } diff --git a/source/src/ECS/Components/SpriteAnimation.ts b/source/src/ECS/Components/SpriteAnimation.ts index b5f81b75..179b485a 100644 --- a/source/src/ECS/Components/SpriteAnimation.ts +++ b/source/src/ECS/Components/SpriteAnimation.ts @@ -3,7 +3,7 @@ module es { public readonly sprites: Sprite[]; public readonly frameRate: number; - constructor(sprites: Sprite[], frameRate: number) { + constructor(sprites: Sprite[], frameRate: number = 10) { this.sprites = sprites; this.frameRate = frameRate; } diff --git a/source/src/ECS/Components/TiledMapRenderer.ts b/source/src/ECS/Components/TiledMapRenderer.ts index d4711fb1..09c6fa22 100644 --- a/source/src/ECS/Components/TiledMapRenderer.ts +++ b/source/src/ECS/Components/TiledMapRenderer.ts @@ -1,7 +1,7 @@ module es { export class TiledMapRenderer extends RenderableComponent { public tiledMap: TmxMap; - public physicsLayer: number = 1 << 0; + public physicsLayer: Ref = new Ref(1 << 0); /** * 如果空,所有层将被渲染 */ @@ -27,7 +27,7 @@ module es { this.displayObject = new egret.DisplayObjectContainer(); if (collisionLayerName) { - this.collisionLayer = tiledMap.tileLayers[collisionLayerName]; + this.collisionLayer = tiledMap.tileLayers.find(layer => layer.name == collisionLayerName); } } @@ -123,7 +123,7 @@ module es { // 为我们收到的矩形创建碰撞器 this._colliders = []; for (let i = 0; i < collisionRects.length; i++) { - let collider = new BoxCollider().createBoxRect(collisionRects[i].x + this._localOffset.x, + let collider = new BoxCollider(collisionRects[i].x + this._localOffset.x, collisionRects[i].y + this._localOffset.y, collisionRects[i].width, collisionRects[i].height); collider.physicsLayer = this.physicsLayer; collider.entity = this.entity; diff --git a/source/src/ECS/Core.ts b/source/src/ECS/Core.ts index af66a5bf..ea7a13e6 100644 --- a/source/src/ECS/Core.ts +++ b/source/src/ECS/Core.ts @@ -200,6 +200,7 @@ module es { // 更新我们所有的系统管理器 Time.update(egret.getTimer()); + Input.update(); if (this._scene) { for (let i = this._globalManagers.length - 1; i >= 0; i--) { diff --git a/source/src/ECS/Entity.ts b/source/src/ECS/Entity.ts index 81b9f35b..91e88d06 100644 --- a/source/src/ECS/Entity.ts +++ b/source/src/ECS/Entity.ts @@ -280,20 +280,6 @@ module es { } } - /** - * 创建此实体的深层克隆。子类可以重写此方法来复制任何自定义字段。 - * 当重写时,应该调用CopyFrom方法,它将为您克隆所有组件、碰撞器和转换子组件。 - * 注意克隆的实体不会被添加到任何场景中!你必须自己添加它们! - * @param position - */ - public clone(position: Vector2 = new Vector2()): Entity { - let entity = new Entity(this.name + "(clone)"); - entity.copyFrom(this); - entity.transform.position = position; - - return entity; - } - /** * 在提交了所有挂起的实体更改后,将此实体添加到场景时调用 */ @@ -413,31 +399,5 @@ module es { public toString(): string { return `[Entity: name: ${this.name}, tag: ${this.tag}, enabled: ${this.enabled}, depth: ${this.updateOrder}]`; } - - /** - * 将实体的属性、组件和碰撞器复制到此实例 - * @param entity - */ - protected copyFrom(entity: Entity) { - this.tag = entity.tag; - this.updateInterval = entity.updateInterval; - this.updateOrder = entity.updateOrder; - this.enabled = entity.enabled; - - this.transform.scale = entity.transform.scale; - this.transform.rotation = entity.transform.rotation; - - for (let i = 0; i < entity.components.count; i++) - this.addComponent(entity.components.buffer[i].clone()); - for (let i = 0; i < entity.components._componentsToAdd.length; i++) - this.addComponent(entity.components._componentsToAdd[i].clone()); - - for (let i = 0; i < entity.transform.childCount; i++) { - let child = entity.transform.getChild(i).entity; - let childClone = child.clone(); - childClone.transform.copyFrom(child.transform); - childClone.transform.parent = this.transform; - } - } } } diff --git a/source/src/Math/Flags.ts b/source/src/Math/Flags.ts index 55e473af..77c5d335 100644 --- a/source/src/Math/Flags.ts +++ b/source/src/Math/Flags.ts @@ -30,8 +30,8 @@ module es { * @param self * @param flag */ - public static setFlagExclusive(self: number, flag: number) { - return 1 << flag; + public static setFlagExclusive(self: Ref, flag: number) { + self.value = 1 << flag; } /** @@ -39,8 +39,8 @@ module es { * @param self * @param flag */ - public static setFlag(self: number, flag: number) { - return (self | 1 << flag); + public static setFlag(self: Ref, flag: number) { + self.value = (self.value | 1 << flag); } /** @@ -48,17 +48,17 @@ module es { * @param self * @param flag */ - public static unsetFlag(self: number, flag: number) { + public static unsetFlag(self: Ref, flag: number) { flag = 1 << flag; - return (self & (~flag)); + self.value = (self.value & (~flag)); } /** * 反转数值集合位 * @param self */ - public static invertFlags(self: number) { - return ~self; + public static invertFlags(self: Ref) { + self.value = ~self.value; } } } diff --git a/source/src/Physics/Collision.ts b/source/src/Physics/Collision.ts index dc82e398..874e5c8f 100644 --- a/source/src/Physics/Collision.ts +++ b/source/src/Physics/Collision.ts @@ -67,28 +67,51 @@ module es { return Vector2.add(lineA, new Vector2(v.x * t, v.y * t)); } - public static isCircleToCircle(circleCenter1: Vector2, circleRadius1: number, circleCenter2: Vector2, circleRadius2: number): boolean { + public static circleToCircle(circleCenter1: Vector2, circleRadius1: number, circleCenter2: Vector2, circleRadius2: number): boolean { return Vector2.distanceSquared(circleCenter1, circleCenter2) < (circleRadius1 + circleRadius2) * (circleRadius1 + circleRadius2); } - public static isCircleToLine(circleCenter: Vector2, radius: number, lineFrom: Vector2, lineTo: Vector2): boolean { + public static circleToLine(circleCenter: Vector2, radius: number, lineFrom: Vector2, lineTo: Vector2): boolean { return Vector2.distanceSquared(circleCenter, this.closestPointOnLine(lineFrom, lineTo, circleCenter)) < radius * radius; } - public static isCircleToPoint(circleCenter: Vector2, radius: number, point: Vector2): boolean { + public static circleToPoint(circleCenter: Vector2, radius: number, point: Vector2): boolean { return Vector2.distanceSquared(circleCenter, point) < radius * radius; } - public static isRectToCircle(rect: egret.Rectangle, cPosition: Vector2, cRadius: number): boolean { - let ew = rect.width * 0.5; - let eh = rect.height * 0.5; - let vx = Math.max(0, Math.max(cPosition.x - rect.x) - ew); - let vy = Math.max(0, Math.max(cPosition.y - rect.y) - eh); + public static rectToCircle(rect: egret.Rectangle, cPosition: Vector2, cRadius: number): boolean { + if (this.rectToPoint(rect.x, rect.y, rect.width, rect.height, cPosition)) + return true; - return vx * vx + vy * vy < cRadius * cRadius; + let edgeFrom: Vector2 = Vector2.zero; + let edgeTo: Vector2 = Vector2.zero; + let sector = this.getSector(rect.x, rect.y, rect.width, rect.height, cPosition); + + if ((sector & PointSectors.top) != 0){ + edgeFrom = new Vector2(rect.x, rect.y); + edgeTo = new Vector2(rect.x + rect.width, rect.y); + if (this.circleToLine(cPosition, cRadius, edgeFrom, edgeTo)) + return true; + } + + if ((sector & PointSectors.bottom) != 0){ + edgeFrom = new Vector2(rect.x, rect.y + rect.width); + edgeTo = new Vector2(rect.x + rect.width, rect.y + rect.height); + if (this.circleToLine(cPosition, cRadius, edgeFrom, edgeTo)) + return true; + } + + if ((sector & PointSectors.left) != 0){ + edgeFrom = new Vector2(rect.x + rect.width, rect.y); + edgeTo = new Vector2(rect.x + rect.width, rect.y + rect.height); + if (this.circleToLine(cPosition, cRadius, edgeFrom, edgeTo)) + return true; + } + + return false; } - public static isRectToLine(rect: Rectangle, lineFrom: Vector2, lineTo: Vector2) { + public static rectToLine(rect: Rectangle, lineFrom: Vector2, lineTo: Vector2) { let fromSector = this.getSector(rect.x, rect.y, rect.width, rect.height, lineFrom); let toSector = this.getSector(rect.x, rect.y, rect.width, rect.height, lineTo); @@ -134,7 +157,7 @@ module es { return false; } - public static isRectToPoint(rX: number, rY: number, rW: number, rH: number, point: Vector2) { + public static rectToPoint(rX: number, rY: number, rW: number, rH: number, point: Vector2) { return point.x >= rX && point.y >= rY && point.x < rX + rW && point.y < rY + rH; } diff --git a/source/src/Physics/Shapes/Box.ts b/source/src/Physics/Shapes/Box.ts index ea9ef7b2..0bfd88cc 100644 --- a/source/src/Physics/Shapes/Box.ts +++ b/source/src/Physics/Shapes/Box.ts @@ -60,7 +60,7 @@ module es { return this.bounds.intersects(other.bounds); if (other instanceof Circle) - return Collisions.isRectToCircle(this.bounds, other.position, other.radius); + return Collisions.rectToCircle(this.bounds, other.position, other.radius); } return super.overlaps(other); diff --git a/source/src/Physics/Shapes/Circle.ts b/source/src/Physics/Shapes/Circle.ts index e90182c3..b506eff5 100644 --- a/source/src/Physics/Shapes/Circle.ts +++ b/source/src/Physics/Shapes/Circle.ts @@ -25,21 +25,21 @@ module es { // 为了处理偏移原点的旋转,我们只需要将圆心围绕(0,0)在一个圆上移动,我们的偏移量就是0角 let offsetAngle = Math.atan2(collider.localOffset.y, collider.localOffset.x) * MathHelper.Rad2Deg; let offsetLength = hasUnitScale ? collider._localOffsetLength : Vector2.multiply(collider.localOffset, collider.entity.transform.scale).length(); - this.center = MathHelper.pointOnCirlce(Vector2.zero, offsetLength, collider.entity.transform.rotation + offsetAngle); + this.center = MathHelper.pointOnCirlce(Vector2.zero, offsetLength, collider.entity.transform.rotationDegrees + offsetAngle); } } - this.position = Vector2.add(collider.transform.position, this.center); + this.position = Vector2.add(collider.entity.transform.position, this.center); this.bounds = new Rectangle(this.position.x - this.radius, this.position.y - this.radius, this.radius * 2, this.radius * 2); } public overlaps(other: Shape) { let result: CollisionResult = new CollisionResult(); if (other instanceof Box && (other as Box).isUnrotated) - return Collisions.isRectToCircle(other.bounds, this.position, this.radius); + return Collisions.rectToCircle(other.bounds, this.position, this.radius); if (other instanceof Circle) - return Collisions.isCircleToCircle(this.position, this.radius, other.position, (other as Circle).radius); + return Collisions.circleToCircle(this.position, this.radius, other.position, (other as Circle).radius); if (other instanceof Polygon) return ShapeCollisions.circleToPolygon(this, other, result); diff --git a/source/src/Physics/Shapes/Polygon.ts b/source/src/Physics/Shapes/Polygon.ts index 72e6899e..20614b29 100644 --- a/source/src/Physics/Shapes/Polygon.ts +++ b/source/src/Physics/Shapes/Polygon.ts @@ -76,7 +76,7 @@ module es { public buildEdgeNormals() { // 对于box 我们只需要两条边,因为另外两条边是平行的 let totalEdges = this.isBox ? 2 : this.points.length; - if (this._edgeNormals == null || this._edgeNormals.length != totalEdges) + if (this._edgeNormals == undefined || this._edgeNormals.length != totalEdges) this._edgeNormals = new Array(totalEdges); let p2: Vector2; @@ -169,7 +169,7 @@ module es { edgeNormal.y = 0; let closestPoint = new Vector2(0, 0); - let tempDistanceSquared; + let tempDistanceSquared = 0; for (let i = 0; i < points.length; i++) { let j = i + 1; if (j == points.length) @@ -200,9 +200,9 @@ module es { * @param originalPoints * @param rotatedPoints */ - public static rotatePolygonVerts(radians: number, originalPoints: Vector2[], rotatedPoints){ + public static rotatePolygonVerts(radians: number, originalPoints: Vector2[], rotatedPoints: Vector2[]){ let cos = Math.cos(radians); - let sin = Math.sign(radians); + let sin = Math.sin(radians); for (let i = 0; i < originalPoints.length; i ++){ let position = originalPoints[i]; diff --git a/source/src/Physics/Shapes/Shape.ts b/source/src/Physics/Shapes/Shape.ts index b095c1cb..949d27b1 100644 --- a/source/src/Physics/Shapes/Shape.ts +++ b/source/src/Physics/Shapes/Shape.ts @@ -26,9 +26,5 @@ module es { public abstract containsPoint(point: Vector2); public abstract pointCollidesWithShape(point: Vector2, result: CollisionResult): boolean; - - public clone(): Shape { - return ObjectUtils.clone(this); - } } } diff --git a/source/src/Physics/Verlet/SpatialHash.ts b/source/src/Physics/Verlet/SpatialHash.ts index 1692e84c..ce6e90bb 100644 --- a/source/src/Physics/Verlet/SpatialHash.ts +++ b/source/src/Physics/Verlet/SpatialHash.ts @@ -130,7 +130,7 @@ module es { let collider = cell[i]; // 如果它是自身或者如果它不匹配我们的层掩码 跳过这个碰撞器 - if (collider == excludeCollider || !Flags.isFlagSet(layerMask, collider.physicsLayer)) + if (collider == excludeCollider || !Flags.isFlagSet(layerMask, collider.physicsLayer.value)) continue; if (bounds.intersects(collider.bounds)) { @@ -364,7 +364,7 @@ module es { continue; // 确保碰撞器在图层蒙版上 - if (!Flags.isFlagSet(this._layerMask, potential.physicsLayer)) + if (!Flags.isFlagSet(this._layerMask, potential.physicsLayer.value)) continue; // TODO: rayIntersects的性能够吗?需要测试它。Collisions.rectToLine可能更快 diff --git a/source/src/Tiled/Layer.ts b/source/src/Tiled/Layer.ts index e86f596d..13015ddc 100644 --- a/source/src/Tiled/Layer.ts +++ b/source/src/Tiled/Layer.ts @@ -47,7 +47,7 @@ module es { * 返回平铺空间中的矩形列表,其中任何非空平铺组合为边界区域 */ public getCollisionRectangles(): Rectangle[] { - let checkedIndexes = []; + let checkedIndexes: boolean[] = new Array(this.tiles.length); let rectangles = []; let startCol = -1; let index = -1; @@ -55,12 +55,12 @@ module es { for (let y = 0; y < this.map.height; y ++){ for (let x = 0; x< this.map.width; x ++){ index = y * this.map.width + x; - let tile = this.getTile(x, y); + let tile = this.getTile(x, y); if (tile && !checkedIndexes[index]){ if (startCol < 0) startCol = x; checkedIndexes[index] = true; - }else if(tile || checkedIndexes[index]){ + }else if(!tile || checkedIndexes[index] == true){ if (startCol >= 0){ rectangles.push(this.findBoundsRect(startCol, x, y, checkedIndexes)); startCol = -1; @@ -90,7 +90,7 @@ module es { for (let x = startX; x < endX; x ++){ index = y * this.map.width + x; let tile = this.getTile(x, y); - if (tile || checkedIndexes[index]){ + if (!tile || checkedIndexes[index]){ // 再次将我们到目前为止在这一行中访问过的所有内容设置为false,因为它不会包含在矩形中,应该再次进行检查 for (let _x = startX; _x < x; _x++){ index = y * this.map.width + _x; @@ -132,7 +132,7 @@ module es { * TmxTilesetTile只存在于动态的tiles和带有附加属性的tiles中。 */ public get tilesetTile(): TmxTilesetTile { - if (this._tilesetTileIndex == undefined){ + if (!this._tilesetTileIndex){ this._tilesetTileIndex = -1; if (this.tileset.firstGid <= this.gid){ let tilesetTile = this.tileset.tiles.get(this.gid - this.tileset.firstGid); diff --git a/source/src/Utils/Input.ts b/source/src/Utils/Input/Input.ts similarity index 82% rename from source/src/Utils/Input.ts rename to source/src/Utils/Input/Input.ts index 7dc5e8ee..fa3f3d9c 100644 --- a/source/src/Utils/Input.ts +++ b/source/src/Utils/Input/Input.ts @@ -55,6 +55,8 @@ module es { return this._gameTouchs[0].position; } + public static _virtualInputs: VirtualInput[] = []; + /** 获取最大触摸数 */ public static get maxSupportedTouch() { return Core._instance.stage.maxTouches; @@ -91,11 +93,45 @@ module es { this.initTouchCache(); } + public static update(){ + KeyboardUtils.update(); + for (let i = 0; i < this._virtualInputs.length; i ++) + this._virtualInputs[i].update(); + } + public static scaledPosition(position: Vector2) { let scaledPos = new Vector2(position.x - this._resolutionOffset.x, position.y - this._resolutionOffset.y); return Vector2.multiply(scaledPos, this.resolutionScale); } + /** + * 只有在当前帧按下并且在上一帧没有按下时才算press + * @param key + */ + public static isKeyPressed(key: Keys): boolean{ + return KeyboardUtils.currentKeys.contains(key) && !KeyboardUtils.previousKeys.contains(key); + } + + public static isKeyPressedBoth(keyA: Keys, keyB: Keys){ + return this.isKeyPressed(keyA) || this.isKeyPressed(keyB); + } + + public static isKeyDown(key: Keys): boolean { + return KeyboardUtils.currentKeys.contains(key); + } + + public static isKeyDownBoth(keyA: Keys, keyB: Keys){ + return this.isKeyDown(keyA) || this.isKeyDown(keyB); + } + + public static isKeyReleased(key: Keys){ + return !KeyboardUtils.currentKeys.contains(key) && KeyboardUtils.previousKeys.contains(key); + } + + public static isKeyReleasedBoth(keyA: Keys, keyB: Keys){ + return this.isKeyReleased(keyA) || this.isKeyReleased(keyB); + } + private static initTouchCache() { this._totalTouchCount = 0; this._touchIndex = 0; diff --git a/source/src/Utils/Input/KeyboardUtils.ts b/source/src/Utils/Input/KeyboardUtils.ts new file mode 100644 index 00000000..1b984afb --- /dev/null +++ b/source/src/Utils/Input/KeyboardUtils.ts @@ -0,0 +1,47 @@ +import Keys = es.Keys; + +class KeyboardUtils { + /** + * 当前帧按键状态 + */ + public static currentKeys: Keys[] = []; + /** + * 上一帧按键状态 + */ + public static previousKeys: Keys[] = []; + private static keyStatusKeys: Keys[] = []; + + public static init(): void { + document.addEventListener("keydown", KeyboardUtils.onKeyDownHandler); + document.addEventListener("keyup", KeyboardUtils.onKeyUpHandler); + } + + public static update(){ + KeyboardUtils.previousKeys.length = 0; + for (let key of KeyboardUtils.currentKeys){ + KeyboardUtils.previousKeys.push(key); + KeyboardUtils.currentKeys.remove(key); + } + KeyboardUtils.currentKeys.length = 0; + for (let key of KeyboardUtils.keyStatusKeys){ + KeyboardUtils.currentKeys.push(key); + } + } + + public static destroy(): void { + KeyboardUtils.currentKeys.length = 0; + + document.removeEventListener("keyup", KeyboardUtils.onKeyUpHandler); + document.removeEventListener("keypress", KeyboardUtils.onKeyDownHandler); + } + + private static onKeyDownHandler(event: KeyboardEvent): void { + if (!KeyboardUtils.keyStatusKeys.contains(event.keyCode)) + KeyboardUtils.keyStatusKeys.push(event.keyCode); + } + + private static onKeyUpHandler(event: KeyboardEvent): void { + if (KeyboardUtils.keyStatusKeys.contains(event.keyCode)) + KeyboardUtils.keyStatusKeys.remove(event.keyCode); + } +} \ No newline at end of file diff --git a/source/src/Utils/Input/Keys.ts b/source/src/Utils/Input/Keys.ts new file mode 100644 index 00000000..2e32a9a5 --- /dev/null +++ b/source/src/Utils/Input/Keys.ts @@ -0,0 +1,116 @@ +module es { + export enum Keys { + none, + back = 8, + tab = 9, + enter = 13, + capsLock = 20, + escape = 27, + space = 32, + pageUp = 33, + pageDown = 34, + end = 35, + home = 36, + left = 37, + up = 38, + right = 39, + down = 40, + select = 41, + print = 42, + execute = 43, + printScreen = 44, + insert = 45, + delete = 46, + help = 47, + d0 = 48, + d1 = 49, + d2 = 50, + d3 = 51, + d4 = 52, + d5 = 53, + d6 = 54, + d7 = 55, + d8 = 56, + d9 = 57, + a = 65, + b = 66, + c = 67, + d = 68, + e = 69, + f = 70, + g = 71, + h = 72, + i = 73, + j = 74, + k = 75, + l = 76, + m = 77, + n = 78, + o = 79, + p = 80, + q = 81, + r = 82, + s = 83, + t = 84, + u = 85, + v = 86, + w = 87, + x = 88, + y = 89, + z = 90, + leftWindows = 91, + rightWindows = 92, + apps = 93, + sleep = 95, + numPad0 = 96, + numPad1 = 97, + numPad2 = 98, + numPad3 = 99, + numPad4 = 100, + numPad5 = 101, + numPad6 = 102, + numPad7 = 103, + numPad8 = 104, + numPad9 = 105, + multiply = 106, + add = 107, + seperator = 108, + subtract = 109, + decimal = 110, + divide = 111, + f1 = 112, + f2 = 113, + f3 = 114, + f4 = 115, + f5 = 116, + f6 = 117, + f7 = 118, + f8 = 119, + f9 = 120, + f10 = 121, + f11 = 122, + f12 = 123, + f13 = 124, + f14 = 125, + f15 = 126, + f16 = 127, + f17 = 128, + f18 = 129, + f19 = 130, + f20 = 131, + f21 = 132, + f22 = 133, + f23 = 134, + f24 = 135, + numLock = 144, + scroll = 145, + leftShift = 160, + rightShift = 161, + leftControl = 162, + rightControl = 163, + leftAlt = 164, + rightAlt = 165, + browserBack = 166, + browserForward = 167 + } +} \ No newline at end of file diff --git a/source/src/Utils/Input/Virtual/VirtualAxis.ts b/source/src/Utils/Input/Virtual/VirtualAxis.ts new file mode 100644 index 00000000..aa0e7be6 --- /dev/null +++ b/source/src/Utils/Input/Virtual/VirtualAxis.ts @@ -0,0 +1,79 @@ +/// +/// +module es { + /** + * 用-1和1之间的浮点数表示的虚拟输入 + */ + export class VirtualAxis extends VirtualInput { + public nodes: VirtualAxisNode[] = []; + + public get value() { + for (let i = 0; i < this.nodes.length; i++) { + let val = this.nodes[i].value; + if (val != 0) + return val; + } + + return 0; + } + + constructor(...nodes: VirtualAxisNode[]) { + super(); + this.nodes.concat(nodes); + } + + public update() { + for (let i = 0; i < this.nodes.length; i++) + this.nodes[i].update(); + } + } + + export class KeyboardKeys extends VirtualAxisNode { + public overlapBehavior: OverlapBehavior; + public positive: Keys; + public negative: Keys; + public _value: number = 0; + public _turned: boolean; + + constructor(overlapBehavior: OverlapBehavior, negative: Keys, positive: Keys) { + super(); + this.overlapBehavior = overlapBehavior; + this.negative = negative; + this.positive = positive; + } + + public update() { + if (Input.isKeyDown(this.positive)) { + if (Input.isKeyDown(this.negative)) { + switch (this.overlapBehavior) { + default: + case es.OverlapBehavior.cancelOut: + this._value = 0; + break; + case es.OverlapBehavior.takeNewer: + if (!this._turned) { + this._value *= -1; + this._turned = true; + } + break; + case es.OverlapBehavior.takeOlder: + break; + } + } else { + this._turned = false; + this._value = 1; + } + } else if (Input.isKeyDown(this.negative)) { + this._turned = false; + this._value = -1; + } else { + this._turned = false; + this._value = 0; + } + } + + public get value(){ + return this._value; + } + } +} \ No newline at end of file diff --git a/source/src/Utils/Input/Virtual/VirtualButton.ts b/source/src/Utils/Input/Virtual/VirtualButton.ts new file mode 100644 index 00000000..3c2db342 --- /dev/null +++ b/source/src/Utils/Input/Virtual/VirtualButton.ts @@ -0,0 +1,134 @@ +/// +module es { + /** + * 用布尔值表示的虚拟输入。除了简单地检查当前按钮状态, + * 您还可以询问它是否刚刚被按下或释放了这个框架。 + * 您还可以将按下的按钮存储在缓冲区中一段有限的时间,或者直到调用consumeBuffer()将其使用为止。 + */ + export class VirtualButton extends VirtualInput{ + public nodes: Node[] = []; + public bufferTime: number = 0; + public firstRepeatTime: number = 0; + public mutiRepeatTime: number = 0; + public isRepeating: boolean; + + public _bufferCounter: number = 0; + public _repeatCounter: number = 0; + public _willRepeat: boolean; + + constructor(bufferTime: number = 0, ...nodes: Node[]){ + super(); + this.nodes = nodes; + this.bufferTime = bufferTime; + } + + public setRepeat(firstRepeatTime: number, mutiRepeatTime: number = firstRepeatTime){ + this.firstRepeatTime = firstRepeatTime; + this.mutiRepeatTime = mutiRepeatTime; + this._willRepeat = this.firstRepeatTime > 0; + if (!this._willRepeat) + this.isRepeating = false; + } + + public update() { + this._bufferCounter -= Time.unscaledDeltaTime; + this.isRepeating = false; + + let check = false; + for (let i = 0; i < this.nodes.length; i ++){ + this.nodes[i].update(); + if (this.nodes[i].isPressed){ + this._bufferCounter = this.bufferTime; + check = true; + }else if(this.nodes[i].isDown){ + check = true; + } + } + + if (!check){ + this._repeatCounter = 0; + this._bufferCounter = 0; + }else if(this._willRepeat){ + if (this._repeatCounter == 0){ + this._repeatCounter = this.firstRepeatTime; + }else{ + this._repeatCounter -= Time.unscaledDeltaTime; + if (this._repeatCounter <= 0){ + this.isRepeating = true; + this._repeatCounter = this.mutiRepeatTime; + } + } + } + } + + public get isDown(){ + for (let node of this.nodes){ + if (node.isDown) + return true; + } + + return false; + } + + public get isPressed(){ + if (this._bufferCounter > 0 || this.isRepeating) + return true; + + for (let node of this.nodes){ + if (node.isPressed) + return true; + } + + return false; + } + + public get isReleased(){ + for (let node of this.nodes){ + if (node.isReleased) + return true; + } + return false; + } + + public consumeBuffer(){ + this._bufferCounter = 0; + } + + /** + * 添加一个键盘键到这个虚拟按钮 + * @param key + */ + public addKeyboardKey(key: Keys): VirtualButton{ + this.nodes.push(new KeyboardKey(key)); + return this; + } + } + + export abstract class Node extends VirtualInputNode { + public abstract isDown: boolean; + public abstract isPressed: boolean; + public abstract isReleased: boolean; + } + + export class KeyboardKey extends Node { + public key: Keys; + + constructor(key: Keys){ + super(); + + this.key = key; + } + + public get isDown(){ + return Input.isKeyDown(this.key); + } + + public get isPressed(){ + return Input.isKeyPressed(this.key); + } + + public get isReleased(){ + return Input.isKeyReleased(this.key); + } + } +} \ No newline at end of file diff --git a/source/src/Utils/Input/Virtual/VirtualInput.ts b/source/src/Utils/Input/Virtual/VirtualInput.ts new file mode 100644 index 00000000..a4973873 --- /dev/null +++ b/source/src/Utils/Input/Virtual/VirtualInput.ts @@ -0,0 +1,43 @@ +module es { + export enum OverlapBehavior { + /** + * 重复的输入将导致相互抵消,并且不会记录任何输入。 + * 例如:按左箭头键,按住时按右箭头键。这将导致相互抵消。 + */ + cancelOut, + /** + * 将使用找到的第一个输入 + */ + takeOlder, + /** + * 将使用找到的最后一个输入 + */ + takeNewer, + } + + /** + * 虚拟按钮,其状态由其VirtualInputNodes的状态决定 + */ + export abstract class VirtualInput { + protected constructor() { + Input._virtualInputs.push(this); + } + + /** + * 从输入系统取消虚拟输入的注册。在轮询VirtualInput之后调用这个函数 + */ + public deregister(){ + Input._virtualInputs.remove(this); + } + + public abstract update(); + } + + /** + * 将它们添加到您的VirtualInput中,以定义它如何确定当前输入状态。 + * 例如,如果你想检查一个键盘键是否被按下,创建一个VirtualButton并添加一个VirtualButton.keyboardkey + */ + export abstract class VirtualInputNode { + public update() {} + } +} \ No newline at end of file diff --git a/source/src/Utils/Input/Virtual/VirtualIntegerAxis.ts b/source/src/Utils/Input/Virtual/VirtualIntegerAxis.ts new file mode 100644 index 00000000..a1bff4cb --- /dev/null +++ b/source/src/Utils/Input/Virtual/VirtualIntegerAxis.ts @@ -0,0 +1,44 @@ +module es { + /** + * 用int(-1、0或1)表示的虚拟输入。它对应的输入可以从上到下到下, + * 如使用两个键盘键作为正/负检查。 + */ + export class VirtualIntegerAxis extends VirtualInput { + public nodes: VirtualAxisNode[] = []; + + public get value(){ + for (let i = 0; i < this.nodes.length; i ++){ + let val = this.nodes[i].value; + if (val != 0) + return Math.sign(val); + } + + return 0; + } + + constructor(...nodes: VirtualAxisNode[]){ + super(); + this.nodes.concat(nodes); + } + + public update() { + for (let i = 0; i < this.nodes.length; i ++) + this.nodes[i].update(); + } + + /** + * 添加键盘键来模拟这个虚拟输入的左/右或上/下 + * @param overlapBehavior + * @param negative + * @param positive + */ + public addKeyboardKeys(overlapBehavior: OverlapBehavior, negative: Keys, positive: Keys){ + this.nodes.push(new KeyboardKeys(overlapBehavior, negative, positive)); + return this; + } + } + + export abstract class VirtualAxisNode extends VirtualInputNode { + public abstract value: number; + } +} \ No newline at end of file diff --git a/source/src/Utils/KeyboardUtils.ts b/source/src/Utils/KeyboardUtils.ts deleted file mode 100644 index 1785a6cf..00000000 --- a/source/src/Utils/KeyboardUtils.ts +++ /dev/null @@ -1,225 +0,0 @@ -class KeyboardUtils { - /** - * 键盘事件类型 - */ - public static TYPE_KEY_DOWN: number = 0; - public static TYPE_KEY_UP: number = 1; - /** - * 键值字符串枚举 - */ - public static A: string = "A"; - public static B: string = "B"; - public static C: string = "C"; - public static D: string = "D"; - public static E: string = "E"; - public static F: string = "F"; - public static G: string = "G"; - public static H: string = "H"; - public static I: string = "I"; - public static J: string = "J"; - public static K: string = "K"; - public static L: string = "L"; - public static M: string = "M"; - public static N: string = "N"; - public static O: string = "O"; - public static P: string = "P"; - public static Q: string = "Q"; - public static R: string = "R"; - public static S: string = "S"; - public static T: string = "T"; - public static U: string = "U"; - public static V: string = "V"; - public static W: string = "W"; - public static X: string = "X"; - public static Y: string = "Y"; - public static Z: string = "Z"; - public static ESC: string = "Esc"; - public static F1: string = "F1"; - public static F2: string = "F2"; - public static F3: string = "F3"; - public static F4: string = "F4"; - public static F5: string = "F5"; - public static F6: string = "F6"; - public static F7: string = "F7"; - public static F8: string = "F8"; - public static F9: string = "F9"; - public static F10: string = "F10"; - public static F11: string = "F11"; - public static F12: string = "F12"; - public static NUM_1: string = "1"; - public static NUM_2: string = "2"; - public static NUM_3: string = "3"; - public static NUM_4: string = "4"; - public static NUM_5: string = "5"; - public static NUM_6: string = "6"; - public static NUM_7: string = "7"; - public static NUM_8: string = "8"; - public static NUM_9: string = "9"; - public static NUM_0: string = "0"; - public static TAB: string = "Tab"; - public static CTRL: string = "Ctrl"; - public static ALT: string = "Alt"; - public static SHIFT: string = "Shift"; - public static CAPS_LOCK: string = "Caps Lock"; - public static ENTER: string = "Enter"; - public static SPACE: string = "Space"; - public static BACK_SPACE: string = "Back Space"; - public static INSERT: string = "Insert"; - public static DELETE: string = "Page Down"; - public static HOME: string = "Home"; - public static END: string = "Page Down"; - public static PAGE_UP: string = "Page Up"; - public static PAGE_DOWN: string = "Page Down"; - public static LEFT: string = "Left"; - public static RIGHT: string = "Right"; - public static UP: string = "Up"; - public static DOWN: string = "Down"; - public static PAUSE_BREAK: string = "Pause Break"; - public static NUM_LOCK: string = "Num Lock"; - public static SCROLL_LOCK: string = "Scroll Lock"; - public static WINDOWS: string = "Windows"; - //存放按下注册数据的字典 - private static keyDownDict: Object; - //存放按起注册数据的字典 - private static keyUpDict: Object; - - public static init(): void { - KeyboardUtils.keyDownDict = {}; - KeyboardUtils.keyUpDict = {}; - document.addEventListener("keydown", KeyboardUtils.onKeyDonwHander); - document.addEventListener("keyup", KeyboardUtils.onKeyUpHander); - } - - /** - * 注册按键 - * @param key 键值 - * @param fun 回调方法 - * @param type 按键类型 TYPE_KEY_DOWN、TYPE_KEY_UP - */ - public static registerKey(key: string, fun: Function, thisObj: any, type: number = 0, ...args): void { - var keyDict: Object = type ? this.keyUpDict : this.keyDownDict; - keyDict[key] = {"fun": fun, args: args, "thisObj": thisObj}; - } - - /** - * 注销按键 - * @param key 键值 - * @param type 注销的类型 - */ - public static unregisterKey(key: string, type: number = 0): void { - var keyDict: Object = type ? this.keyUpDict : this.keyDownDict; - delete keyDict[key]; - } - - /** - * 销毁方法 - */ - public static destroy(): void { - KeyboardUtils.keyDownDict = null; - KeyboardUtils.keyUpDict = null; - document.removeEventListener("keydown", this.onKeyDonwHander); - document.removeEventListener("keyup", this.onKeyUpHander); - } - - private static onKeyDonwHander(event: KeyboardEvent): void { - if (!KeyboardUtils.keyDownDict) return; - var key: string = KeyboardUtils.keyCodeToString(event.keyCode); - var o: Object = KeyboardUtils.keyDownDict[key]; - if (o) { - var fun: Function = o["fun"]; - var thisObj: any = o["thisObj"]; - var args: any = o["args"]; - fun.apply(thisObj, args); - } - } - - private static onKeyUpHander(event: KeyboardEvent): void { - if (!KeyboardUtils.keyUpDict) return; - var key: string = KeyboardUtils.keyCodeToString(event.keyCode); - var o: Object = KeyboardUtils.keyUpDict[key]; - if (o) { - var fun: Function = o["fun"]; - var thisObj: any = o["thisObj"]; - var args: any = o["args"]; - fun.apply(thisObj, args); - } - } - - /** - * 根据keyCode或charCode获取相应的字符串代号 - * @param keyCode - * @return 键盘所指字符串代号 - */ - private static keyCodeToString(keyCode: number): string { - switch (keyCode) { - case 8: - return this.BACK_SPACE; - case 9: - return this.TAB; - case 13: - return this.ENTER; - case 16: - return this.SHIFT; - case 17: - return this.CTRL; - case 19: - return this.PAUSE_BREAK; - case 20: - return this.CAPS_LOCK; - case 27: - return this.ESC; - case 32: - return this.SPACE; - case 33: - return this.PAGE_UP; - case 34: - return this.PAGE_DOWN; - case 35: - return this.END; - case 36: - return this.HOME; - case 37: - return this.LEFT; - case 38: - return this.UP; - case 39: - return this.RIGHT; - case 40: - return this.DOWN; - case 45: - return this.INSERT; - case 46: - return this.DELETE; - case 91: - return this.WINDOWS; - case 112: - return this.F1; - case 113: - return this.F2; - case 114: - return this.F3; - case 115: - return this.F4; - case 116: - return this.F5; - case 117: - return this.F6; - case 118: - return this.F7; - case 119: - return this.F8; - case 120: - return this.F9; - case 122: - return this.F11; - case 123: - return this.F12; - case 144: - return this.NUM_LOCK; - case 145: - return this.SCROLL_LOCK; - default: - return String.fromCharCode(keyCode); - } - } -} \ No newline at end of file