From 358e899e8ba601cdbcb88476e44a87357628631e Mon Sep 17 00:00:00 2001 From: yhh <359807859@qq.com> Date: Fri, 28 Aug 2020 19:12:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20CoroutineManager=20?= =?UTF-8?q?=E5=8D=8F=E5=90=8C=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/libs/framework/framework.d.ts | 55 +++++ demo/libs/framework/framework.js | 192 +++++++++++++++++- demo/libs/framework/framework.min.js | 2 +- source/bin/framework.d.ts | 55 +++++ source/bin/framework.js | 192 +++++++++++++++++- source/bin/framework.min.js | 2 +- .../ECS/Components/ScrollingSpriteRenderer.ts | 4 +- .../src/ECS/Components/TiledSpriteRenderer.ts | 4 +- source/src/ECS/Core.ts | 11 + source/src/ECS/Utils/Time.ts | 2 +- source/src/Math/SubpixelFloat.ts | 2 +- source/src/Physics/Verlet/SpatialHash.ts | 4 +- source/src/Tiled/Layer.ts | 2 +- source/src/Utils/Analysis/TimeRuler.ts | 4 +- source/src/Utils/Coroutines/Coroutine.ts | 38 ++++ .../src/Utils/Coroutines/CoroutineManager.ts | 159 +++++++++++++++ source/src/Utils/Pool.ts | 67 ++++++ 17 files changed, 760 insertions(+), 35 deletions(-) create mode 100644 source/src/Utils/Coroutines/Coroutine.ts create mode 100644 source/src/Utils/Coroutines/CoroutineManager.ts create mode 100644 source/src/Utils/Pool.ts diff --git a/demo/libs/framework/framework.d.ts b/demo/libs/framework/framework.d.ts index 89818c56..522860cd 100644 --- a/demo/libs/framework/framework.d.ts +++ b/demo/libs/framework/framework.d.ts @@ -198,6 +198,7 @@ declare module es { _nextScene: Scene; _sceneTransition: SceneTransition; _globalManagers: GlobalManager[]; + _coroutineManager: CoroutineManager; _timerManager: TimerManager; constructor(); static readonly Instance: Core; @@ -207,6 +208,7 @@ declare module es { static registerGlobalManager(manager: es.GlobalManager): void; static unregisterGlobalManager(manager: es.GlobalManager): void; static getGlobalManager(type: any): T; + static startCoroutine(enumerator: IEnumerator): CoroutineImpl; static schedule(timeInSeconds: number, repeats: boolean, context: any, onTime: (timer: ITimer) => void): Timer; onOrientationChanged(): void; draw(): Promise; @@ -2064,6 +2066,19 @@ declare module es { equals(other: Pair): boolean; } } +declare module es { + class Pool { + private static _objectQueue; + static warmCache(type: any, cacheCount: number): void; + static trimCache(cacheCount: number): void; + static clearCache(): void; + static obtain(type: any): T; + static free(obj: T): void; + } + interface IPoolable { + reset(): any; + } +} declare class RandomUtils { static randrange(start: number, stop: number, step?: number): number; static randint(a: number, b: number): number; @@ -2264,6 +2279,46 @@ declare module es { initialized: boolean; } } +declare module es { + interface ICoroutine { + stop(): any; + setUseUnscaledDeltaTime(useUnscaledDeltaTime: any): ICoroutine; + } + class Coroutine { + static waitForSeconds(seconds: number): WaitForSeconds; + } + class WaitForSeconds { + static waiter: WaitForSeconds; + waitTime: number; + wait(seconds: number): WaitForSeconds; + } +} +declare module es { + class CoroutineImpl implements ICoroutine, IPoolable { + enumerator: IEnumerator; + waitTimer: number; + isDone: boolean; + waitForCoroutine: CoroutineImpl; + useUnscaledDeltaTime: boolean; + stop(): void; + setUseUnscaledDeltaTime(useUnscaledDeltaTime: any): es.ICoroutine; + prepareForuse(): void; + reset(): void; + } + interface IEnumerator { + current: any; + moveNext(): boolean; + reset(): any; + } + class CoroutineManager extends GlobalManager { + _isInUpdate: boolean; + _unblockedCoroutines: CoroutineImpl[]; + _shouldRunNextFrame: CoroutineImpl[]; + startCoroutine(enumerator: IEnumerator): CoroutineImpl; + update(): void; + tickCoroutine(coroutine: CoroutineImpl): boolean; + } +} declare module es { class TouchState { x: number; diff --git a/demo/libs/framework/framework.js b/demo/libs/framework/framework.js index f97d8df4..fb9482c3 100644 --- a/demo/libs/framework/framework.js +++ b/demo/libs/framework/framework.js @@ -966,11 +966,13 @@ var es; function Core() { var _this = _super.call(this) || this; _this._globalManagers = []; + _this._coroutineManager = new es.CoroutineManager(); _this._timerManager = new es.TimerManager(); Core._instance = _this; Core.emitter = new es.Emitter(); Core.content = new es.ContentManager(); _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.onAddToStage, _this); + Core.registerGlobalManager(_this._coroutineManager); Core.registerGlobalManager(_this._timerManager); return _this; } @@ -1028,6 +1030,9 @@ var es; } return null; }; + Core.startCoroutine = function (enumerator) { + return this._instance._coroutineManager.startCoroutine(enumerator); + }; Core.schedule = function (timeInSeconds, repeats, context, onTime) { if (repeats === void 0) { repeats = false; } if (context === void 0) { context = null; } @@ -3067,8 +3072,8 @@ var es; set: function (value) { this._textureScale = value; this._inverseTexScale = new es.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; + this._sourceRect.width = Math.floor(this._sprite.sourceRect.width * this._inverseTexScale.x); + this._sourceRect.height = Math.floor(this._sprite.sourceRect.height * this._inverseTexScale.y); }, enumerable: true, configurable: true @@ -3186,8 +3191,8 @@ var es; return; this._scrollX += this.scrollSpeedX * es.Time.deltaTime; this._scrollY += this.scroolSpeedY * es.Time.deltaTime; - this._sourceRect.x = this._scrollX; - this._sourceRect.y = this._scrollY; + this._sourceRect.x = Math.floor(this._scrollX); + this._sourceRect.y = Math.floor(this._scrollY); this._sourceRect.width = this._scrollWidth + Math.abs(this._scrollX); this._sourceRect.height = this._scrollHeight + Math.abs(this._scrollY); }; @@ -5254,7 +5259,7 @@ var es; this._timeSinceSceneLoad = 0; }; Time.checkEvery = function (interval) { - return (this._timeSinceSceneLoad / interval) > ((this._timeSinceSceneLoad - this.deltaTime) / interval); + return Math.floor(this._timeSinceSceneLoad / interval) > Math.floor((this._timeSinceSceneLoad - this.deltaTime) / interval); }; Time.deltaTime = 0; Time.timeScale = 1; @@ -6627,7 +6632,7 @@ var es; } SubpixelFloat.prototype.update = function (amount) { this.remainder += amount; - var motion = Math.trunc(this.remainder); + var motion = Math.floor(Math.trunc(this.remainder)); this.remainder -= motion; amount = motion; return amount; @@ -7808,11 +7813,11 @@ var es; } while (currentCell.x != lastCell.x || currentCell.y != lastCell.y) { if (tMaxX < tMaxY) { - currentCell.x = es.MathHelper.approach(currentCell.x, lastCell.x, Math.abs(stepX)); + currentCell.x = Math.floor(es.MathHelper.approach(currentCell.x, lastCell.x, Math.abs(stepX))); tMaxX += tDeltaX; } else { - currentCell.y = es.MathHelper.approach(currentCell.y, lastCell.y, Math.abs(stepY)); + currentCell.y = Math.floor(es.MathHelper.approach(currentCell.y, lastCell.y, Math.abs(stepY))); tMaxY += tDeltaY; } cell = this.cellAtPosition(currentCell.x, currentCell.y); @@ -8058,7 +8063,7 @@ var es; flip = (rawGid & TmxLayerTile.FLIPPED_VERTICALLY_FLAG) != 0; this.verticalFlip = flip; rawGid &= ~(TmxLayerTile.FLIPPED_HORIZONTALLY_FLAG | TmxLayerTile.FLIPPED_VERTICALLY_FLAG); - this.gid = rawGid; + this.gid = Math.floor(rawGid); this.tileset = map.getTilesetForTileGid(this.gid); } Object.defineProperty(TmxLayerTile.prototype, "position", { @@ -9949,6 +9954,42 @@ var es; }()); es.Pair = Pair; })(es || (es = {})); +var es; +(function (es) { + var Pool = (function () { + function Pool() { + } + Pool.warmCache = function (type, cacheCount) { + cacheCount -= this._objectQueue.length; + if (cacheCount > 0) { + for (var i = 0; i < cacheCount; i++) { + this._objectQueue.unshift(new type()); + } + } + }; + Pool.trimCache = function (cacheCount) { + while (cacheCount > this._objectQueue.length) + this._objectQueue.shift(); + }; + Pool.clearCache = function () { + this._objectQueue.length = 0; + }; + Pool.obtain = function (type) { + if (this._objectQueue.length > 0) + return this._objectQueue.shift(); + return new type(); + }; + Pool.free = function (obj) { + this._objectQueue.unshift(obj); + if (egret.is(obj, "IPoolable")) { + obj["reset"](); + } + }; + Pool._objectQueue = new Array(10); + return Pool; + }()); + es.Pool = Pool; +})(es || (es = {})); var RandomUtils = (function () { function RandomUtils() { } @@ -10476,7 +10517,7 @@ var es; for (var i = 0; i < this._logs.length; ++i) this._logs[i] = new FrameLog(); this.sampleFrames = this.targetSampleFrames = 1; - this.width = es.Core.graphicsDevice.viewport.width * 0.8; + this.width = Math.floor(es.Core.graphicsDevice.viewport.width * 0.8); es.Core.emitter.addObserver(es.CoreEvents.GraphicsDeviceReset, this.onGraphicsDeviceReset, this); this.onGraphicsDeviceReset(); } @@ -10629,7 +10670,7 @@ var es; } if (Math.max(this._frameAdjust) > TimeRuler.autoAdjustDelay) { this.sampleFrames = Math.min(TimeRuler.maxSampleFrames, this.sampleFrames); - this.sampleFrames = Math.max(this.targetSampleFrames, (maxTime / frameSpan) + 1); + this.sampleFrames = Math.max(this.targetSampleFrames, Math.floor(maxTime / frameSpan) + 1); this._frameAdjust = 0; } var msToPs = width / sampleSpan; @@ -10747,6 +10788,135 @@ var es; es.MarkerLog = MarkerLog; })(es || (es = {})); var es; +(function (es) { + var Coroutine = (function () { + function Coroutine() { + } + Coroutine.waitForSeconds = function (seconds) { + return WaitForSeconds.waiter.wait(seconds); + }; + return Coroutine; + }()); + es.Coroutine = Coroutine; + var WaitForSeconds = (function () { + function WaitForSeconds() { + } + WaitForSeconds.prototype.wait = function (seconds) { + WaitForSeconds.waiter.waitTime = seconds; + return WaitForSeconds.waiter; + }; + WaitForSeconds.waiter = new WaitForSeconds(); + return WaitForSeconds; + }()); + es.WaitForSeconds = WaitForSeconds; +})(es || (es = {})); +var es; +(function (es) { + var CoroutineImpl = (function () { + function CoroutineImpl() { + this.useUnscaledDeltaTime = false; + } + CoroutineImpl.prototype.stop = function () { + this.isDone = true; + }; + CoroutineImpl.prototype.setUseUnscaledDeltaTime = function (useUnscaledDeltaTime) { + this.useUnscaledDeltaTime = useUnscaledDeltaTime; + return this; + }; + CoroutineImpl.prototype.prepareForuse = function () { + this.isDone = false; + }; + CoroutineImpl.prototype.reset = function () { + this.isDone = true; + this.waitTimer = 0; + this.waitForCoroutine = null; + this.enumerator = null; + this.useUnscaledDeltaTime = false; + }; + return CoroutineImpl; + }()); + es.CoroutineImpl = CoroutineImpl; + var CoroutineManager = (function (_super) { + __extends(CoroutineManager, _super); + function CoroutineManager() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._unblockedCoroutines = []; + _this._shouldRunNextFrame = []; + return _this; + } + CoroutineManager.prototype.startCoroutine = function (enumerator) { + var coroutine = es.Pool.obtain(CoroutineImpl); + coroutine.prepareForuse(); + coroutine.enumerator = enumerator; + var shouldContinueCoroutine = this.tickCoroutine(coroutine); + if (!shouldContinueCoroutine) + return null; + if (this._isInUpdate) + this._shouldRunNextFrame.push(coroutine); + else + this._unblockedCoroutines.push(coroutine); + return coroutine; + }; + CoroutineManager.prototype.update = function () { + this._isInUpdate = true; + for (var i = 0; i < this._unblockedCoroutines.length; i++) { + var coroutine = this._unblockedCoroutines[i]; + if (coroutine.isDone) { + es.Pool.free(coroutine); + continue; + } + if (coroutine.waitForCoroutine != null) { + if (coroutine.waitForCoroutine.isDone) { + coroutine.waitForCoroutine = null; + } + else { + this._shouldRunNextFrame.push(coroutine); + continue; + } + } + if (coroutine.waitTimer > 0) { + coroutine.waitTimer -= coroutine.useUnscaledDeltaTime ? es.Time.unscaledDeltaTime : es.Time.deltaTime; + this._shouldRunNextFrame.push(coroutine); + continue; + } + if (this.tickCoroutine(coroutine)) + this._shouldRunNextFrame.push(coroutine); + } + this._unblockedCoroutines.length = 0; + this._unblockedCoroutines.concat(this._shouldRunNextFrame); + this._shouldRunNextFrame.length = 0; + this._isInUpdate = false; + }; + CoroutineManager.prototype.tickCoroutine = function (coroutine) { + if (!coroutine.enumerator.moveNext() || coroutine.isDone) { + es.Pool.free(coroutine); + return false; + } + if (coroutine.enumerator.current == null) { + return true; + } + if (coroutine.enumerator.current instanceof es.WaitForSeconds) { + coroutine.waitTimer = coroutine.enumerator.current.waitTime; + return true; + } + if (coroutine.enumerator.current instanceof Number) { + console.warn("协同程序检查返回一个Number类型,请不要在生产环境使用"); + coroutine.waitTimer = Number(coroutine.enumerator.current); + return true; + } + if (coroutine.enumerator.current instanceof CoroutineImpl) { + coroutine.waitForCoroutine = coroutine.enumerator.current; + return true; + } + else { + return true; + } + }; + return CoroutineManager; + }(es.GlobalManager)); + es.CoroutineManager = CoroutineManager; +})(es || (es = {})); +var es; (function (es) { var TouchState = (function () { function TouchState() { diff --git a/demo/libs/framework/framework.min.js b/demo/libs/framework/framework.min.js index 17599caa..8cdeed62 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(t){},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(),t.Vector2Ext.transformR(e,this._transformMatrix,e),e},n.prototype.screenToWorldPoint=function(e){return this.updateMatrixes(),t.Vector2Ext.transformR(e,this._inverseTransformMatrix,e),e},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(Math.floor(this._origin.x),Math.floor(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(t){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-t.bounds.x,this._worldSpaceDeadZone.y-5-t.bounds.y,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-t.bounds.x,this._worldSpaceDeadZone.y-t.bounds.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(e){if(this.debugRenderEnabled){this.hollowShape.parent||this.debugDisplayObject.addChild(this.hollowShape),this.pixelShape.parent||this.debugDisplayObject.addChild(this.pixelShape),this.entity.getComponent(t.Collider)||(this.hollowShape.graphics.clear(),this.hollowShape.graphics.beginFill(t.Colors.renderableBounds,0),this.hollowShape.graphics.lineStyle(1,t.Colors.renderableBounds),this.hollowShape.graphics.drawRect(this.bounds.x-e.bounds.x,this.bounds.y-e.bounds.y,this.bounds.width,this.bounds.height),this.hollowShape.graphics.endFill());var i=t.Vector2.add(this.entity.transform.position,this._localOffset).subtract(e.bounds.location);this.pixelShape.graphics.clear(),this.pixelShape.graphics.beginFill(t.Colors.renderableCenter,0),this.pixelShape.graphics.lineStyle(4,t.Colors.renderableCenter),this.pixelShape.graphics.moveTo(i.x,i.y),this.pixelShape.graphics.lineTo(i.x,i.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(t){this.displayObject.x!=this.bounds.x-t.bounds.y&&(this.displayObject.x=this.bounds.x-t.bounds.y),this.displayObject.y!=this.bounds.y-t.bounds.y&&(this.displayObject.y=this.bounds.y-t.bounds.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.rotationDegrees&&(this.displayObject.rotation=this.entity.rotationDegrees)},i.prototype.compareTo=function(t){return t.renderLayer-this.renderLayer},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(t){this.sync(t),this.displayObject.x!=this.bounds.x-t.bounds.x&&(this.displayObject.x=this.bounds.x-t.bounds.x),this.displayObject.y!=this.bounds.y-t.bounds.y&&(this.displayObject.y=this.bounds.y-t.bounds.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 n=0;n>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 +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"===u())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"===u())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._coroutineManager=new t.CoroutineManager,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._coroutineManager),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(t){},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(),t.Vector2Ext.transformR(e,this._transformMatrix,e),e},n.prototype.screenToWorldPoint=function(e){return this.updateMatrixes(),t.Vector2Ext.transformR(e,this._inverseTransformMatrix,e),e},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(Math.floor(this._origin.x),Math.floor(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(t){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-t.bounds.x,this._worldSpaceDeadZone.y-5-t.bounds.y,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-t.bounds.x,this._worldSpaceDeadZone.y-t.bounds.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(e){if(this.debugRenderEnabled){this.hollowShape.parent||this.debugDisplayObject.addChild(this.hollowShape),this.pixelShape.parent||this.debugDisplayObject.addChild(this.pixelShape),this.entity.getComponent(t.Collider)||(this.hollowShape.graphics.clear(),this.hollowShape.graphics.beginFill(t.Colors.renderableBounds,0),this.hollowShape.graphics.lineStyle(1,t.Colors.renderableBounds),this.hollowShape.graphics.drawRect(this.bounds.x-e.bounds.x,this.bounds.y-e.bounds.y,this.bounds.width,this.bounds.height),this.hollowShape.graphics.endFill());var i=t.Vector2.add(this.entity.transform.position,this._localOffset).subtract(e.bounds.location);this.pixelShape.graphics.clear(),this.pixelShape.graphics.beginFill(t.Colors.renderableCenter,0),this.pixelShape.graphics.lineStyle(4,t.Colors.renderableCenter),this.pixelShape.graphics.moveTo(i.x,i.y),this.pixelShape.graphics.lineTo(i.x,i.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(t){this.displayObject.x!=this.bounds.x-t.bounds.y&&(this.displayObject.x=this.bounds.x-t.bounds.y),this.displayObject.y!=this.bounds.y-t.bounds.y&&(this.displayObject.y=this.bounds.y-t.bounds.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.rotationDegrees&&(this.displayObject.rotation=this.entity.rotationDegrees)},i.prototype.compareTo=function(t){return t.renderLayer-this.renderLayer},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(t){this.sync(t),this.displayObject.x!=this.bounds.x-t.bounds.x&&(this.displayObject.x=this.bounds.x-t.bounds.x),this.displayObject.y!=this.bounds.y-t.bounds.y&&(this.displayObject.y=this.bounds.y-t.bounds.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=Math.floor(this._sprite.sourceRect.width*this._inverseTexScale.x),this._sourceRect.height=Math.floor(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=Math.floor(this._scrollX),this._sourceRect.y=Math.floor(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,u=0,l=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 n=0;n>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),u=0,l=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 Math.floor(this._timeSinceSceneLoad/t)>Math.floor((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 u=h;h=c,c=u}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 u=(h.x*o.y-h.y*o.x)/a;return!(u<0||u>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),u=(c.x*a.y-c.y*a.x)/h;if(u<0||u>1)return o;var l=(c.x*s.y-c.y*s.x)/h;return l<0||l>1?o:o=t.Vector2.add(e,new t.Vector2(u*s.x,u*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 u=a+c;return 3==u&&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,u=t.Vector2.subtract(e.position,i.position),l=0;l0&&(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 l=(c.x*s.y-c.y*s.x)/h;return!(l<0||l>1)&&(o=o.add(e).add(t.Vector2.multiply(new t.Vector2(u),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 u=h*h-c;return!(u<0)&&(r.fraction=-h-Math.sqrt(u),r.fraction<0&&(r.fraction=0),r.point=t.Vector2.add(e,t.Vector2.multiply(new t.Vector2(r.fraction),s)),r.distance=t.Vector2.distance(e,r.point),r.normal=t.Vector2.normalize(t.Vector2.subtract(r.point,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)&&(u._tempHashSet.firstOrDefault(function(t){return t.hashCode==o.hashCode})||u._tempHashSet.push(o))},u=this,l=0;l=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,u,l,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(l=0;l0&&(u=l.currentAnimationFrameGid);var p=i.tileset.tileRegions.get(u),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(""+u);y||(y=i.tileset.image.bitmap.createTexture(""+u,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 l.image.texture&&(l.image.bitmap.getTexture(u.toString())||(l.image.texture=new e(l.image.bitmap.createTexture(u.toString(),p.x,p.y,p.width,p.height)),n.addChild(l.image.texture)),l.image.texture.x=g.x,l.image.texture.y=g.y,l.image.texture.scaleX=o.x,l.image.texture.scaleY=o.y,l.image.texture.rotation=0,l.image.texture.anchorOffsetX=0,l.image.texture.anchorOffsetY=0,l.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={})),function(t){var e=function(){function t(){}return t.warmCache=function(t,e){if((e-=this._objectQueue.length)>0)for(var i=0;ithis._objectQueue.length;)this._objectQueue.shift()},t.clearCache=function(){this._objectQueue.length=0},t.obtain=function(t){return this._objectQueue.length>0?this._objectQueue.shift():new t},t.free=function(t){this._objectQueue.unshift(t),egret.is(t,"IPoolable")&&t.reset()},t._objectQueue=new Array(10),t}();t.Pool=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],u=i[this._triNext[s]];if(t.Vector2Ext.isTriangleCCW(h,c,u)){var l=this._triNext[this._triNext[s]];do{if(e.testPointTriangle(i[l],h,c,u)){a=!1;break}l=this._triNext[l]}while(l!=this._triPrev[s])}else a=!1;a?(this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),this._triNext[this._triPrev[s]]=this._triNext[s],this._triPrev[this._triNext[s]]=this._triPrev[s],r--,s=this._triPrev[s]):s=this._triNext[s]}this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),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&&(u.logs[n].snapMin=u.logs[n].min,u.logs[n].snapMax=u.logs[n].max,u.logs[n].snapAvg=u.logs[n].avg,u.logs[n].samples=0)):(u.logs[n].min=h,u.logs[n].max=h,u.logs[n].avg=h,u.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,Math.floor(o/(1/60*1e3))+1),this._frameAdjust=0);var a=n/s,h=i.y-(r-e.barHeight),c=h,u=new t.Rectangle(i.x,c,n,r);this._rectShape1.graphics.clear(),this._rectShape1.graphics.beginFill(0,128/255),this._rectShape1.graphics.drawRect(u.x,u.y,u.width,u.height),this._rectShape1.graphics.endFill(),u.height=e.barHeight,this._rectShape2.graphics.clear();for(var l=0,p=this._prevLog.bars;l0)for(var f=0;f0?(i.waitTimer-=i.useUnscaledDeltaTime?t.Time.unscaledDeltaTime:t.Time.deltaTime,this._shouldRunNextFrame.push(i)):this.tickCoroutine(i)&&this._shouldRunNextFrame.push(i)}}this._unblockedCoroutines.length=0,this._unblockedCoroutines.concat(this._shouldRunNextFrame),this._shouldRunNextFrame.length=0,this._isInUpdate=!1},n.prototype.tickCoroutine=function(i){return!i.enumerator.moveNext()||i.isDone?(t.Pool.free(i),!1):null==i.enumerator.current||(i.enumerator.current instanceof t.WaitForSeconds?(i.waitTimer=i.enumerator.current.waitTime,!0):i.enumerator.current instanceof Number?(console.warn("协同程序检查返回一个Number类型,请不要在生产环境使用"),i.waitTimer=Number(i.enumerator.current),!0):!(i.enumerator.current instanceof e)||(i.waitForCoroutine=i.enumerator.current,!0))},n}(t.GlobalManager);t.CoroutineManager=i}(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.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 u=new egret.RenderTexture,l=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 u=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/bin/framework.d.ts b/source/bin/framework.d.ts index 89818c56..522860cd 100644 --- a/source/bin/framework.d.ts +++ b/source/bin/framework.d.ts @@ -198,6 +198,7 @@ declare module es { _nextScene: Scene; _sceneTransition: SceneTransition; _globalManagers: GlobalManager[]; + _coroutineManager: CoroutineManager; _timerManager: TimerManager; constructor(); static readonly Instance: Core; @@ -207,6 +208,7 @@ declare module es { static registerGlobalManager(manager: es.GlobalManager): void; static unregisterGlobalManager(manager: es.GlobalManager): void; static getGlobalManager(type: any): T; + static startCoroutine(enumerator: IEnumerator): CoroutineImpl; static schedule(timeInSeconds: number, repeats: boolean, context: any, onTime: (timer: ITimer) => void): Timer; onOrientationChanged(): void; draw(): Promise; @@ -2064,6 +2066,19 @@ declare module es { equals(other: Pair): boolean; } } +declare module es { + class Pool { + private static _objectQueue; + static warmCache(type: any, cacheCount: number): void; + static trimCache(cacheCount: number): void; + static clearCache(): void; + static obtain(type: any): T; + static free(obj: T): void; + } + interface IPoolable { + reset(): any; + } +} declare class RandomUtils { static randrange(start: number, stop: number, step?: number): number; static randint(a: number, b: number): number; @@ -2264,6 +2279,46 @@ declare module es { initialized: boolean; } } +declare module es { + interface ICoroutine { + stop(): any; + setUseUnscaledDeltaTime(useUnscaledDeltaTime: any): ICoroutine; + } + class Coroutine { + static waitForSeconds(seconds: number): WaitForSeconds; + } + class WaitForSeconds { + static waiter: WaitForSeconds; + waitTime: number; + wait(seconds: number): WaitForSeconds; + } +} +declare module es { + class CoroutineImpl implements ICoroutine, IPoolable { + enumerator: IEnumerator; + waitTimer: number; + isDone: boolean; + waitForCoroutine: CoroutineImpl; + useUnscaledDeltaTime: boolean; + stop(): void; + setUseUnscaledDeltaTime(useUnscaledDeltaTime: any): es.ICoroutine; + prepareForuse(): void; + reset(): void; + } + interface IEnumerator { + current: any; + moveNext(): boolean; + reset(): any; + } + class CoroutineManager extends GlobalManager { + _isInUpdate: boolean; + _unblockedCoroutines: CoroutineImpl[]; + _shouldRunNextFrame: CoroutineImpl[]; + startCoroutine(enumerator: IEnumerator): CoroutineImpl; + update(): void; + tickCoroutine(coroutine: CoroutineImpl): boolean; + } +} declare module es { class TouchState { x: number; diff --git a/source/bin/framework.js b/source/bin/framework.js index f97d8df4..fb9482c3 100644 --- a/source/bin/framework.js +++ b/source/bin/framework.js @@ -966,11 +966,13 @@ var es; function Core() { var _this = _super.call(this) || this; _this._globalManagers = []; + _this._coroutineManager = new es.CoroutineManager(); _this._timerManager = new es.TimerManager(); Core._instance = _this; Core.emitter = new es.Emitter(); Core.content = new es.ContentManager(); _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.onAddToStage, _this); + Core.registerGlobalManager(_this._coroutineManager); Core.registerGlobalManager(_this._timerManager); return _this; } @@ -1028,6 +1030,9 @@ var es; } return null; }; + Core.startCoroutine = function (enumerator) { + return this._instance._coroutineManager.startCoroutine(enumerator); + }; Core.schedule = function (timeInSeconds, repeats, context, onTime) { if (repeats === void 0) { repeats = false; } if (context === void 0) { context = null; } @@ -3067,8 +3072,8 @@ var es; set: function (value) { this._textureScale = value; this._inverseTexScale = new es.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; + this._sourceRect.width = Math.floor(this._sprite.sourceRect.width * this._inverseTexScale.x); + this._sourceRect.height = Math.floor(this._sprite.sourceRect.height * this._inverseTexScale.y); }, enumerable: true, configurable: true @@ -3186,8 +3191,8 @@ var es; return; this._scrollX += this.scrollSpeedX * es.Time.deltaTime; this._scrollY += this.scroolSpeedY * es.Time.deltaTime; - this._sourceRect.x = this._scrollX; - this._sourceRect.y = this._scrollY; + this._sourceRect.x = Math.floor(this._scrollX); + this._sourceRect.y = Math.floor(this._scrollY); this._sourceRect.width = this._scrollWidth + Math.abs(this._scrollX); this._sourceRect.height = this._scrollHeight + Math.abs(this._scrollY); }; @@ -5254,7 +5259,7 @@ var es; this._timeSinceSceneLoad = 0; }; Time.checkEvery = function (interval) { - return (this._timeSinceSceneLoad / interval) > ((this._timeSinceSceneLoad - this.deltaTime) / interval); + return Math.floor(this._timeSinceSceneLoad / interval) > Math.floor((this._timeSinceSceneLoad - this.deltaTime) / interval); }; Time.deltaTime = 0; Time.timeScale = 1; @@ -6627,7 +6632,7 @@ var es; } SubpixelFloat.prototype.update = function (amount) { this.remainder += amount; - var motion = Math.trunc(this.remainder); + var motion = Math.floor(Math.trunc(this.remainder)); this.remainder -= motion; amount = motion; return amount; @@ -7808,11 +7813,11 @@ var es; } while (currentCell.x != lastCell.x || currentCell.y != lastCell.y) { if (tMaxX < tMaxY) { - currentCell.x = es.MathHelper.approach(currentCell.x, lastCell.x, Math.abs(stepX)); + currentCell.x = Math.floor(es.MathHelper.approach(currentCell.x, lastCell.x, Math.abs(stepX))); tMaxX += tDeltaX; } else { - currentCell.y = es.MathHelper.approach(currentCell.y, lastCell.y, Math.abs(stepY)); + currentCell.y = Math.floor(es.MathHelper.approach(currentCell.y, lastCell.y, Math.abs(stepY))); tMaxY += tDeltaY; } cell = this.cellAtPosition(currentCell.x, currentCell.y); @@ -8058,7 +8063,7 @@ var es; flip = (rawGid & TmxLayerTile.FLIPPED_VERTICALLY_FLAG) != 0; this.verticalFlip = flip; rawGid &= ~(TmxLayerTile.FLIPPED_HORIZONTALLY_FLAG | TmxLayerTile.FLIPPED_VERTICALLY_FLAG); - this.gid = rawGid; + this.gid = Math.floor(rawGid); this.tileset = map.getTilesetForTileGid(this.gid); } Object.defineProperty(TmxLayerTile.prototype, "position", { @@ -9949,6 +9954,42 @@ var es; }()); es.Pair = Pair; })(es || (es = {})); +var es; +(function (es) { + var Pool = (function () { + function Pool() { + } + Pool.warmCache = function (type, cacheCount) { + cacheCount -= this._objectQueue.length; + if (cacheCount > 0) { + for (var i = 0; i < cacheCount; i++) { + this._objectQueue.unshift(new type()); + } + } + }; + Pool.trimCache = function (cacheCount) { + while (cacheCount > this._objectQueue.length) + this._objectQueue.shift(); + }; + Pool.clearCache = function () { + this._objectQueue.length = 0; + }; + Pool.obtain = function (type) { + if (this._objectQueue.length > 0) + return this._objectQueue.shift(); + return new type(); + }; + Pool.free = function (obj) { + this._objectQueue.unshift(obj); + if (egret.is(obj, "IPoolable")) { + obj["reset"](); + } + }; + Pool._objectQueue = new Array(10); + return Pool; + }()); + es.Pool = Pool; +})(es || (es = {})); var RandomUtils = (function () { function RandomUtils() { } @@ -10476,7 +10517,7 @@ var es; for (var i = 0; i < this._logs.length; ++i) this._logs[i] = new FrameLog(); this.sampleFrames = this.targetSampleFrames = 1; - this.width = es.Core.graphicsDevice.viewport.width * 0.8; + this.width = Math.floor(es.Core.graphicsDevice.viewport.width * 0.8); es.Core.emitter.addObserver(es.CoreEvents.GraphicsDeviceReset, this.onGraphicsDeviceReset, this); this.onGraphicsDeviceReset(); } @@ -10629,7 +10670,7 @@ var es; } if (Math.max(this._frameAdjust) > TimeRuler.autoAdjustDelay) { this.sampleFrames = Math.min(TimeRuler.maxSampleFrames, this.sampleFrames); - this.sampleFrames = Math.max(this.targetSampleFrames, (maxTime / frameSpan) + 1); + this.sampleFrames = Math.max(this.targetSampleFrames, Math.floor(maxTime / frameSpan) + 1); this._frameAdjust = 0; } var msToPs = width / sampleSpan; @@ -10747,6 +10788,135 @@ var es; es.MarkerLog = MarkerLog; })(es || (es = {})); var es; +(function (es) { + var Coroutine = (function () { + function Coroutine() { + } + Coroutine.waitForSeconds = function (seconds) { + return WaitForSeconds.waiter.wait(seconds); + }; + return Coroutine; + }()); + es.Coroutine = Coroutine; + var WaitForSeconds = (function () { + function WaitForSeconds() { + } + WaitForSeconds.prototype.wait = function (seconds) { + WaitForSeconds.waiter.waitTime = seconds; + return WaitForSeconds.waiter; + }; + WaitForSeconds.waiter = new WaitForSeconds(); + return WaitForSeconds; + }()); + es.WaitForSeconds = WaitForSeconds; +})(es || (es = {})); +var es; +(function (es) { + var CoroutineImpl = (function () { + function CoroutineImpl() { + this.useUnscaledDeltaTime = false; + } + CoroutineImpl.prototype.stop = function () { + this.isDone = true; + }; + CoroutineImpl.prototype.setUseUnscaledDeltaTime = function (useUnscaledDeltaTime) { + this.useUnscaledDeltaTime = useUnscaledDeltaTime; + return this; + }; + CoroutineImpl.prototype.prepareForuse = function () { + this.isDone = false; + }; + CoroutineImpl.prototype.reset = function () { + this.isDone = true; + this.waitTimer = 0; + this.waitForCoroutine = null; + this.enumerator = null; + this.useUnscaledDeltaTime = false; + }; + return CoroutineImpl; + }()); + es.CoroutineImpl = CoroutineImpl; + var CoroutineManager = (function (_super) { + __extends(CoroutineManager, _super); + function CoroutineManager() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._unblockedCoroutines = []; + _this._shouldRunNextFrame = []; + return _this; + } + CoroutineManager.prototype.startCoroutine = function (enumerator) { + var coroutine = es.Pool.obtain(CoroutineImpl); + coroutine.prepareForuse(); + coroutine.enumerator = enumerator; + var shouldContinueCoroutine = this.tickCoroutine(coroutine); + if (!shouldContinueCoroutine) + return null; + if (this._isInUpdate) + this._shouldRunNextFrame.push(coroutine); + else + this._unblockedCoroutines.push(coroutine); + return coroutine; + }; + CoroutineManager.prototype.update = function () { + this._isInUpdate = true; + for (var i = 0; i < this._unblockedCoroutines.length; i++) { + var coroutine = this._unblockedCoroutines[i]; + if (coroutine.isDone) { + es.Pool.free(coroutine); + continue; + } + if (coroutine.waitForCoroutine != null) { + if (coroutine.waitForCoroutine.isDone) { + coroutine.waitForCoroutine = null; + } + else { + this._shouldRunNextFrame.push(coroutine); + continue; + } + } + if (coroutine.waitTimer > 0) { + coroutine.waitTimer -= coroutine.useUnscaledDeltaTime ? es.Time.unscaledDeltaTime : es.Time.deltaTime; + this._shouldRunNextFrame.push(coroutine); + continue; + } + if (this.tickCoroutine(coroutine)) + this._shouldRunNextFrame.push(coroutine); + } + this._unblockedCoroutines.length = 0; + this._unblockedCoroutines.concat(this._shouldRunNextFrame); + this._shouldRunNextFrame.length = 0; + this._isInUpdate = false; + }; + CoroutineManager.prototype.tickCoroutine = function (coroutine) { + if (!coroutine.enumerator.moveNext() || coroutine.isDone) { + es.Pool.free(coroutine); + return false; + } + if (coroutine.enumerator.current == null) { + return true; + } + if (coroutine.enumerator.current instanceof es.WaitForSeconds) { + coroutine.waitTimer = coroutine.enumerator.current.waitTime; + return true; + } + if (coroutine.enumerator.current instanceof Number) { + console.warn("协同程序检查返回一个Number类型,请不要在生产环境使用"); + coroutine.waitTimer = Number(coroutine.enumerator.current); + return true; + } + if (coroutine.enumerator.current instanceof CoroutineImpl) { + coroutine.waitForCoroutine = coroutine.enumerator.current; + return true; + } + else { + return true; + } + }; + return CoroutineManager; + }(es.GlobalManager)); + es.CoroutineManager = CoroutineManager; +})(es || (es = {})); +var es; (function (es) { var TouchState = (function () { function TouchState() { diff --git a/source/bin/framework.min.js b/source/bin/framework.min.js index 17599caa..8cdeed62 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(t){},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(),t.Vector2Ext.transformR(e,this._transformMatrix,e),e},n.prototype.screenToWorldPoint=function(e){return this.updateMatrixes(),t.Vector2Ext.transformR(e,this._inverseTransformMatrix,e),e},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(Math.floor(this._origin.x),Math.floor(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(t){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-t.bounds.x,this._worldSpaceDeadZone.y-5-t.bounds.y,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-t.bounds.x,this._worldSpaceDeadZone.y-t.bounds.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(e){if(this.debugRenderEnabled){this.hollowShape.parent||this.debugDisplayObject.addChild(this.hollowShape),this.pixelShape.parent||this.debugDisplayObject.addChild(this.pixelShape),this.entity.getComponent(t.Collider)||(this.hollowShape.graphics.clear(),this.hollowShape.graphics.beginFill(t.Colors.renderableBounds,0),this.hollowShape.graphics.lineStyle(1,t.Colors.renderableBounds),this.hollowShape.graphics.drawRect(this.bounds.x-e.bounds.x,this.bounds.y-e.bounds.y,this.bounds.width,this.bounds.height),this.hollowShape.graphics.endFill());var i=t.Vector2.add(this.entity.transform.position,this._localOffset).subtract(e.bounds.location);this.pixelShape.graphics.clear(),this.pixelShape.graphics.beginFill(t.Colors.renderableCenter,0),this.pixelShape.graphics.lineStyle(4,t.Colors.renderableCenter),this.pixelShape.graphics.moveTo(i.x,i.y),this.pixelShape.graphics.lineTo(i.x,i.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(t){this.displayObject.x!=this.bounds.x-t.bounds.y&&(this.displayObject.x=this.bounds.x-t.bounds.y),this.displayObject.y!=this.bounds.y-t.bounds.y&&(this.displayObject.y=this.bounds.y-t.bounds.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.rotationDegrees&&(this.displayObject.rotation=this.entity.rotationDegrees)},i.prototype.compareTo=function(t){return t.renderLayer-this.renderLayer},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(t){this.sync(t),this.displayObject.x!=this.bounds.x-t.bounds.x&&(this.displayObject.x=this.bounds.x-t.bounds.x),this.displayObject.y!=this.bounds.y-t.bounds.y&&(this.displayObject.y=this.bounds.y-t.bounds.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 n=0;n>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 +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"===u())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"===u())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._coroutineManager=new t.CoroutineManager,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._coroutineManager),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(t){},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(),t.Vector2Ext.transformR(e,this._transformMatrix,e),e},n.prototype.screenToWorldPoint=function(e){return this.updateMatrixes(),t.Vector2Ext.transformR(e,this._inverseTransformMatrix,e),e},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(Math.floor(this._origin.x),Math.floor(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(t){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-t.bounds.x,this._worldSpaceDeadZone.y-5-t.bounds.y,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-t.bounds.x,this._worldSpaceDeadZone.y-t.bounds.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(e){if(this.debugRenderEnabled){this.hollowShape.parent||this.debugDisplayObject.addChild(this.hollowShape),this.pixelShape.parent||this.debugDisplayObject.addChild(this.pixelShape),this.entity.getComponent(t.Collider)||(this.hollowShape.graphics.clear(),this.hollowShape.graphics.beginFill(t.Colors.renderableBounds,0),this.hollowShape.graphics.lineStyle(1,t.Colors.renderableBounds),this.hollowShape.graphics.drawRect(this.bounds.x-e.bounds.x,this.bounds.y-e.bounds.y,this.bounds.width,this.bounds.height),this.hollowShape.graphics.endFill());var i=t.Vector2.add(this.entity.transform.position,this._localOffset).subtract(e.bounds.location);this.pixelShape.graphics.clear(),this.pixelShape.graphics.beginFill(t.Colors.renderableCenter,0),this.pixelShape.graphics.lineStyle(4,t.Colors.renderableCenter),this.pixelShape.graphics.moveTo(i.x,i.y),this.pixelShape.graphics.lineTo(i.x,i.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(t){this.displayObject.x!=this.bounds.x-t.bounds.y&&(this.displayObject.x=this.bounds.x-t.bounds.y),this.displayObject.y!=this.bounds.y-t.bounds.y&&(this.displayObject.y=this.bounds.y-t.bounds.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.rotationDegrees&&(this.displayObject.rotation=this.entity.rotationDegrees)},i.prototype.compareTo=function(t){return t.renderLayer-this.renderLayer},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(t){this.sync(t),this.displayObject.x!=this.bounds.x-t.bounds.x&&(this.displayObject.x=this.bounds.x-t.bounds.x),this.displayObject.y!=this.bounds.y-t.bounds.y&&(this.displayObject.y=this.bounds.y-t.bounds.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=Math.floor(this._sprite.sourceRect.width*this._inverseTexScale.x),this._sourceRect.height=Math.floor(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=Math.floor(this._scrollX),this._sourceRect.y=Math.floor(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,u=0,l=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 n=0;n>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),u=0,l=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 Math.floor(this._timeSinceSceneLoad/t)>Math.floor((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 u=h;h=c,c=u}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 u=(h.x*o.y-h.y*o.x)/a;return!(u<0||u>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),u=(c.x*a.y-c.y*a.x)/h;if(u<0||u>1)return o;var l=(c.x*s.y-c.y*s.x)/h;return l<0||l>1?o:o=t.Vector2.add(e,new t.Vector2(u*s.x,u*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 u=a+c;return 3==u&&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,u=t.Vector2.subtract(e.position,i.position),l=0;l0&&(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 l=(c.x*s.y-c.y*s.x)/h;return!(l<0||l>1)&&(o=o.add(e).add(t.Vector2.multiply(new t.Vector2(u),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 u=h*h-c;return!(u<0)&&(r.fraction=-h-Math.sqrt(u),r.fraction<0&&(r.fraction=0),r.point=t.Vector2.add(e,t.Vector2.multiply(new t.Vector2(r.fraction),s)),r.distance=t.Vector2.distance(e,r.point),r.normal=t.Vector2.normalize(t.Vector2.subtract(r.point,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)&&(u._tempHashSet.firstOrDefault(function(t){return t.hashCode==o.hashCode})||u._tempHashSet.push(o))},u=this,l=0;l=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,u,l,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(l=0;l0&&(u=l.currentAnimationFrameGid);var p=i.tileset.tileRegions.get(u),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(""+u);y||(y=i.tileset.image.bitmap.createTexture(""+u,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 l.image.texture&&(l.image.bitmap.getTexture(u.toString())||(l.image.texture=new e(l.image.bitmap.createTexture(u.toString(),p.x,p.y,p.width,p.height)),n.addChild(l.image.texture)),l.image.texture.x=g.x,l.image.texture.y=g.y,l.image.texture.scaleX=o.x,l.image.texture.scaleY=o.y,l.image.texture.rotation=0,l.image.texture.anchorOffsetX=0,l.image.texture.anchorOffsetY=0,l.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={})),function(t){var e=function(){function t(){}return t.warmCache=function(t,e){if((e-=this._objectQueue.length)>0)for(var i=0;ithis._objectQueue.length;)this._objectQueue.shift()},t.clearCache=function(){this._objectQueue.length=0},t.obtain=function(t){return this._objectQueue.length>0?this._objectQueue.shift():new t},t.free=function(t){this._objectQueue.unshift(t),egret.is(t,"IPoolable")&&t.reset()},t._objectQueue=new Array(10),t}();t.Pool=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],u=i[this._triNext[s]];if(t.Vector2Ext.isTriangleCCW(h,c,u)){var l=this._triNext[this._triNext[s]];do{if(e.testPointTriangle(i[l],h,c,u)){a=!1;break}l=this._triNext[l]}while(l!=this._triPrev[s])}else a=!1;a?(this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),this._triNext[this._triPrev[s]]=this._triNext[s],this._triPrev[this._triNext[s]]=this._triPrev[s],r--,s=this._triPrev[s]):s=this._triNext[s]}this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),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&&(u.logs[n].snapMin=u.logs[n].min,u.logs[n].snapMax=u.logs[n].max,u.logs[n].snapAvg=u.logs[n].avg,u.logs[n].samples=0)):(u.logs[n].min=h,u.logs[n].max=h,u.logs[n].avg=h,u.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,Math.floor(o/(1/60*1e3))+1),this._frameAdjust=0);var a=n/s,h=i.y-(r-e.barHeight),c=h,u=new t.Rectangle(i.x,c,n,r);this._rectShape1.graphics.clear(),this._rectShape1.graphics.beginFill(0,128/255),this._rectShape1.graphics.drawRect(u.x,u.y,u.width,u.height),this._rectShape1.graphics.endFill(),u.height=e.barHeight,this._rectShape2.graphics.clear();for(var l=0,p=this._prevLog.bars;l0)for(var f=0;f0?(i.waitTimer-=i.useUnscaledDeltaTime?t.Time.unscaledDeltaTime:t.Time.deltaTime,this._shouldRunNextFrame.push(i)):this.tickCoroutine(i)&&this._shouldRunNextFrame.push(i)}}this._unblockedCoroutines.length=0,this._unblockedCoroutines.concat(this._shouldRunNextFrame),this._shouldRunNextFrame.length=0,this._isInUpdate=!1},n.prototype.tickCoroutine=function(i){return!i.enumerator.moveNext()||i.isDone?(t.Pool.free(i),!1):null==i.enumerator.current||(i.enumerator.current instanceof t.WaitForSeconds?(i.waitTimer=i.enumerator.current.waitTime,!0):i.enumerator.current instanceof Number?(console.warn("协同程序检查返回一个Number类型,请不要在生产环境使用"),i.waitTimer=Number(i.enumerator.current),!0):!(i.enumerator.current instanceof e)||(i.waitForCoroutine=i.enumerator.current,!0))},n}(t.GlobalManager);t.CoroutineManager=i}(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.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 u=new egret.RenderTexture,l=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 u=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/Components/ScrollingSpriteRenderer.ts b/source/src/ECS/Components/ScrollingSpriteRenderer.ts index accded07..217b29b9 100644 --- a/source/src/ECS/Components/ScrollingSpriteRenderer.ts +++ b/source/src/ECS/Components/ScrollingSpriteRenderer.ts @@ -58,8 +58,8 @@ module es { this._scrollX += this.scrollSpeedX * Time.deltaTime; this._scrollY += this.scroolSpeedY * Time.deltaTime; - this._sourceRect.x = this._scrollX; - this._sourceRect.y = this._scrollY; + this._sourceRect.x = Math.floor(this._scrollX); + this._sourceRect.y = Math.floor(this._scrollY); this._sourceRect.width = this._scrollWidth + Math.abs(this._scrollX); this._sourceRect.height = this._scrollHeight + Math.abs(this._scrollY); } diff --git a/source/src/ECS/Components/TiledSpriteRenderer.ts b/source/src/ECS/Components/TiledSpriteRenderer.ts index 9dac6bd7..f2abaffa 100644 --- a/source/src/ECS/Components/TiledSpriteRenderer.ts +++ b/source/src/ECS/Components/TiledSpriteRenderer.ts @@ -65,8 +65,8 @@ module es { // 重新计算我们的inverseTextureScale和源矩形大小 this._inverseTexScale = new 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; + this._sourceRect.width = Math.floor(this._sprite.sourceRect.width * this._inverseTexScale.x); + this._sourceRect.height = Math.floor(this._sprite.sourceRect.height * this._inverseTexScale.y); } /** diff --git a/source/src/ECS/Core.ts b/source/src/ECS/Core.ts index ea7a13e6..b744bbe4 100644 --- a/source/src/ECS/Core.ts +++ b/source/src/ECS/Core.ts @@ -29,6 +29,7 @@ module es { * 全局访问系统 */ public _globalManagers: GlobalManager[] = []; + public _coroutineManager: CoroutineManager = new CoroutineManager(); public _timerManager: TimerManager = new TimerManager(); constructor() { @@ -40,6 +41,7 @@ module es { this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this); + Core.registerGlobalManager(this._coroutineManager); Core.registerGlobalManager(this._timerManager); } @@ -126,6 +128,15 @@ module es { return null; } + /** + * 开始了一个协同程序。协程可以使用number延迟几秒,也可以使其他对startCoroutine的调用延迟几秒。 + * 返回null将使协程在下一帧中被执行。 + * @param enumerator + */ + public static startCoroutine(enumerator: IEnumerator){ + return this._instance._coroutineManager.startCoroutine(enumerator); + } + /** * 调度一个一次性或重复的计时器,该计时器将调用已传递的动作 * @param timeInSeconds diff --git a/source/src/ECS/Utils/Time.ts b/source/src/ECS/Utils/Time.ts index e4acc278..3867bee2 100644 --- a/source/src/ECS/Utils/Time.ts +++ b/source/src/ECS/Utils/Time.ts @@ -33,7 +33,7 @@ module es { */ public static checkEvery(interval: number) { // 我们减去了delta,因为timeSinceSceneLoad已经包含了这个update ticks delta - return (this._timeSinceSceneLoad / interval) > ((this._timeSinceSceneLoad - this.deltaTime) / interval); + return Math.floor(this._timeSinceSceneLoad / interval) > Math.floor((this._timeSinceSceneLoad - this.deltaTime) / interval); } } } diff --git a/source/src/Math/SubpixelFloat.ts b/source/src/Math/SubpixelFloat.ts index fe675739..8be15510 100644 --- a/source/src/Math/SubpixelFloat.ts +++ b/source/src/Math/SubpixelFloat.ts @@ -16,7 +16,7 @@ module es { */ public update(amount: number){ this.remainder += amount; - let motion = Math.trunc(this.remainder); + let motion = Math.floor(Math.trunc(this.remainder)); this.remainder -= motion; amount = motion; return amount; diff --git a/source/src/Physics/Verlet/SpatialHash.ts b/source/src/Physics/Verlet/SpatialHash.ts index ce6e90bb..92ac411b 100644 --- a/source/src/Physics/Verlet/SpatialHash.ts +++ b/source/src/Physics/Verlet/SpatialHash.ts @@ -191,11 +191,11 @@ module es { while (currentCell.x != lastCell.x || currentCell.y != lastCell.y){ if (tMaxX < tMaxY){ - currentCell.x = MathHelper.approach(currentCell.x, lastCell.x, Math.abs(stepX)); + currentCell.x = Math.floor(MathHelper.approach(currentCell.x, lastCell.x, Math.abs(stepX))); tMaxX += tDeltaX; }else{ - currentCell.y = MathHelper.approach(currentCell.y, lastCell.y, Math.abs(stepY)); + currentCell.y = Math.floor(MathHelper.approach(currentCell.y, lastCell.y, Math.abs(stepY))); tMaxY += tDeltaY; } diff --git a/source/src/Tiled/Layer.ts b/source/src/Tiled/Layer.ts index 13015ddc..cb5614d5 100644 --- a/source/src/Tiled/Layer.ts +++ b/source/src/Tiled/Layer.ts @@ -168,7 +168,7 @@ module es { rawGid &= ~(TmxLayerTile.FLIPPED_HORIZONTALLY_FLAG | TmxLayerTile.FLIPPED_VERTICALLY_FLAG); // 将GID保存 - this.gid = rawGid; + this.gid = Math.floor(rawGid); this.tileset = map.getTilesetForTileGid(this.gid); } } diff --git a/source/src/Utils/Analysis/TimeRuler.ts b/source/src/Utils/Analysis/TimeRuler.ts index dff630e9..8c75c57b 100644 --- a/source/src/Utils/Analysis/TimeRuler.ts +++ b/source/src/Utils/Analysis/TimeRuler.ts @@ -66,7 +66,7 @@ module es { this._logs[i] = new FrameLog(); this.sampleFrames = this.targetSampleFrames = 1; - this.width = Core.graphicsDevice.viewport.width * 0.8; + this.width = Math.floor(Core.graphicsDevice.viewport.width * 0.8); es.Core.emitter.addObserver(CoreEvents.GraphicsDeviceReset, this.onGraphicsDeviceReset, this); this.onGraphicsDeviceReset(); @@ -269,7 +269,7 @@ module es { if (Math.max(this._frameAdjust) > TimeRuler.autoAdjustDelay) { this.sampleFrames = Math.min(TimeRuler.maxSampleFrames, this.sampleFrames); - this.sampleFrames = Math.max(this.targetSampleFrames, (maxTime / frameSpan) + 1); + this.sampleFrames = Math.max(this.targetSampleFrames, Math.floor(maxTime / frameSpan) + 1); this._frameAdjust = 0; } diff --git a/source/src/Utils/Coroutines/Coroutine.ts b/source/src/Utils/Coroutines/Coroutine.ts new file mode 100644 index 00000000..6c038224 --- /dev/null +++ b/source/src/Utils/Coroutines/Coroutine.ts @@ -0,0 +1,38 @@ +module es { + /** + * startCoroutine返回的接口,提供了在执行中停止协同程序的能力 + */ + export interface ICoroutine { + /** + * 停止协同程序 + */ + stop(); + + /** + * 设置协程应该使用时间增量还是使用非缩放时间增量来计时 + * @param useUnscaledDeltaTime + */ + setUseUnscaledDeltaTime(useUnscaledDeltaTime): ICoroutine; + } + + export class Coroutine { + public static waitForSeconds(seconds: number){ + return WaitForSeconds.waiter.wait(seconds); + } + } + + /** + * 协作程序需要暂停一段时间时的助手类。 + * 返回协同程序。 + * waitForSeconds返回number。 + */ + export class WaitForSeconds { + public static waiter: WaitForSeconds = new WaitForSeconds(); + public waitTime: number; + + public wait(seconds: number): WaitForSeconds { + WaitForSeconds.waiter.waitTime = seconds; + return WaitForSeconds.waiter; + } + } +} \ No newline at end of file diff --git a/source/src/Utils/Coroutines/CoroutineManager.ts b/source/src/Utils/Coroutines/CoroutineManager.ts new file mode 100644 index 00000000..717cd36a --- /dev/null +++ b/source/src/Utils/Coroutines/CoroutineManager.ts @@ -0,0 +1,159 @@ +module es { + /** + * CoroutineManager使用的内部类,用于隐藏协同程序所需的数据 + */ + export class CoroutineImpl implements ICoroutine, IPoolable { + public enumerator: IEnumerator; + /** + * 每当产生延迟时,它就被添加到跟踪延迟的waitTimer中 + */ + public waitTimer: number; + public isDone: boolean; + public waitForCoroutine: CoroutineImpl; + public useUnscaledDeltaTime: boolean = false; + + public stop(){ + this.isDone = true; + } + + public setUseUnscaledDeltaTime(useUnscaledDeltaTime): es.ICoroutine { + this.useUnscaledDeltaTime = useUnscaledDeltaTime; + return this; + } + + public prepareForuse(){ + this.isDone = false; + } + + public reset() { + this.isDone = true; + this.waitTimer = 0; + this.waitForCoroutine = null; + this.enumerator = null; + this.useUnscaledDeltaTime = false; + } + } + + export interface IEnumerator { + current: any; + moveNext(): boolean; + reset(); + } + + /** + * 基本CoroutineManager。协同程序可以做以下事情: + * - return null(在下一帧继续执行) + * - return Coroutine.waitForSeconds(3)。等待3秒(延时3秒后再次执行) + * - return startCoroutine(another())(在再次执行之前等待另一个协程) + */ + export class CoroutineManager extends GlobalManager { + /** + * 标记来跟踪何时处于更新循环中。 + * 如果一个新的协程在更新循环期间启动,我们必须将其插入到shouldRunNextFrame列表中,以避免在迭代时修改列表。 + */ + public _isInUpdate: boolean; + + public _unblockedCoroutines: CoroutineImpl[] = []; + public _shouldRunNextFrame: CoroutineImpl[] = []; + + /** + * 将i枚举器添加到CoroutineManager。协程在每一帧调用更新之前被执行。 + * @param enumerator + */ + public startCoroutine(enumerator: IEnumerator) { + // 查找或创建CoroutineImpl + let coroutine = Pool.obtain(CoroutineImpl); + coroutine.prepareForuse(); + + // 设置协程并添加它 + coroutine.enumerator = enumerator; + let shouldContinueCoroutine = this.tickCoroutine(coroutine); + + // 防止空协程 + if (!shouldContinueCoroutine) + return null; + + if (this._isInUpdate) + this._shouldRunNextFrame.push(coroutine); + else + this._unblockedCoroutines.push(coroutine); + + return coroutine; + } + + public update() { + this._isInUpdate = true; + for (let i = 0; i < this._unblockedCoroutines.length; i ++){ + let coroutine = this._unblockedCoroutines[i]; + + // 检查已停止的协程 + if (coroutine.isDone){ + Pool.free(coroutine); + continue; + } + + // 我们是否在等待其他协程完成 + if (coroutine.waitForCoroutine != null){ + if (coroutine.waitForCoroutine.isDone){ + coroutine.waitForCoroutine = null; + }else{ + this._shouldRunNextFrame.push(coroutine); + continue; + } + } + + // 如果我们有计时器,就用它 + if (coroutine.waitTimer > 0){ + // 还有时间。递减,并再次运行下一帧,确保递减与适当的deltaTime。 + coroutine.waitTimer -= coroutine.useUnscaledDeltaTime ? Time.unscaledDeltaTime : Time.deltaTime; + this._shouldRunNextFrame.push(coroutine); + continue; + } + + if (this.tickCoroutine(coroutine)) + this._shouldRunNextFrame.push(coroutine); + } + + this._unblockedCoroutines.length = 0; + this._unblockedCoroutines.concat(this._shouldRunNextFrame); + this._shouldRunNextFrame.length = 0; + + this._isInUpdate = false; + } + + /** + * 如果协同程序在下一帧继续运行,则返回true。此方法将把完成的协程放回池中! + * @param coroutine + */ + public tickCoroutine(coroutine: CoroutineImpl){ + // 这个协同程序已经完成了 + if (!coroutine.enumerator.moveNext() || coroutine.isDone){ + Pool.free(coroutine); + return false; + } + + if (coroutine.enumerator.current == null){ + // 再运行下一帧 + return true; + } + + if (coroutine.enumerator.current instanceof WaitForSeconds){ + coroutine.waitTimer = (coroutine.enumerator.current as WaitForSeconds).waitTime; + return true; + } + + if (coroutine.enumerator.current instanceof Number){ + console.warn("协同程序检查返回一个Number类型,请不要在生产环境使用"); + coroutine.waitTimer = Number(coroutine.enumerator.current); + return true; + } + + if (coroutine.enumerator.current instanceof CoroutineImpl){ + coroutine.waitForCoroutine = coroutine.enumerator.current as CoroutineImpl; + return true; + }else { + return true; + } + } + } +} \ No newline at end of file diff --git a/source/src/Utils/Pool.ts b/source/src/Utils/Pool.ts new file mode 100644 index 00000000..6e86d47f --- /dev/null +++ b/source/src/Utils/Pool.ts @@ -0,0 +1,67 @@ +module es { + /** + * 用于池任何对象 + */ + export class Pool { + private static _objectQueue = new Array(10); + + /** + * 预热缓存,使用最大的cacheCount对象填充缓存 + * @param type + * @param cacheCount + */ + public static warmCache(type: any, cacheCount: number){ + cacheCount -= this._objectQueue.length; + if (cacheCount > 0) { + for (let i = 0; i < cacheCount; i++) { + this._objectQueue.unshift(new type()); + } + } + } + + /** + * 将缓存修剪为cacheCount项目 + * @param cacheCount + */ + public static trimCache(cacheCount: number){ + while (cacheCount > this._objectQueue.length) + this._objectQueue.shift(); + } + + /** + * 清除缓存 + */ + public static clearCache() { + this._objectQueue.length = 0; + } + + /** + * 如果可以的话,从堆栈中弹出一个项 + */ + public static obtain(type: any): T { + if (this._objectQueue.length > 0) + return this._objectQueue.shift(); + + return new type() as T; + } + + /** + * 将项推回堆栈 + * @param obj + */ + public static free(obj: T) { + this._objectQueue.unshift(obj); + + if (egret.is(obj, "IPoolable")){ + obj["reset"](); + } + } + } + + export interface IPoolable { + /** + * 重置对象以供重用。对象引用应该为空,字段可以设置为默认值 + */ + reset(); + } +} \ No newline at end of file