mirror of
https://github.com/ysoftdevs/pf2016.git
synced 2026-03-17 23:04:24 +01:00
11 lines
322 KiB
JavaScript
11 lines
322 KiB
JavaScript
var Kiwi;!function(a){var b=function(){function b(b,c,d,e){var f=this;if(void 0===b&&(b=""),void 0===c&&(c="KiwiGame"),void 0===d&&(d=null),void 0===e&&(e={}),this._startup=null,this.audio=null,this.fileStore=null,this.input=null,this.cameras=null,this.pluginManager=null,this.loader=null,this.raf=null,this.stage=null,this.states=null,this.time=null,this.tweens=null,this.rnd=null,this._frameRate=60,this._interval=1e3/60,this._delta=0,this._frame=0,a.Log.setDefaultsFromParams(e.log),a.Log.log("Kiwi.Game: "+c+" is booting using Kiwi.js "+a.VERSION,"#version"),null===a.DEVICE&&(a.DEVICE=new a.System.Device),"undefined"!==e.debug&&"number"==typeof e.debug)switch(e.debug){case a.DEBUG_ON:this._debugOption=e.debug,a.Log.log(" Kiwi.Game: Debugging turned ON.","#debugging");break;case a.DEBUG_OFF:this._debugOption=e.debug,a.Log.log(" Kiwi.Game: Debugging turned OFF.","#debugging");break;default:this._debugOption=a.DEBUG_ON,a.Log.error(" Kiwi.Game: Debug option passed, but is not a valid option. Turned ON by default.","#debugging")}else this._debugOption=a.DEBUG_ON,a.Log.log(" Kiwi.Game: Debug option not specified. Turned ON by default.","#debugging");if("undefined"!==e.bootCallback&&(this.bootCallbackOption=e.bootCallback),"undefined"!==e.deviceTarget&&"number"==typeof e.deviceTarget)switch(e.deviceTarget){case a.TARGET_BROWSER:this._deviceTargetOption=e.deviceTarget,a.Log.log(" Kiwi.Game: Targeting BROWSERS.","#target");break;case a.TARGET_COCOON:this._deviceTargetOption=e.deviceTarget,a.Log.log(" Kiwi.Game: Targeting COCOONJS.","#target");break;default:this._deviceTargetOption=a.TARGET_BROWSER,a.Log.error(" Kiwi.Game: Target device specified, but is not a valid option. Defaulting to BROWSER.","#target")}else this._deviceTargetOption=a.TARGET_BROWSER,a.Log.log(" Kiwi.Game: Targeted device not specified. Defaulting to BROWSER.","#target");var g=a.RENDERER_WEBGL,h=a.RENDERER_CANVAS;if("undefined"!==e.renderer&&"number"==typeof e.renderer)switch(e.renderer){case a.RENDERER_CANVAS:this._renderOption=e.renderer,a.Log.log(" Kiwi.Game: Rendering using CANVAS.","#renderer","#canvas");break;case a.RENDERER_WEBGL:a.DEVICE.webGL?(this._renderOption=e.renderer,a.Log.log(" Kiwi.Game: Rendering using WEBGL.","#renderer","#webgl")):(this._renderOption=h,a.Log.log(" Kiwi.Game: WEBGL renderer requested but device does not support WEBGL. Rendering using CANVAS.","#renderer","#canvas"));break;case a.RENDERER_AUTO:a.DEVICE.webGL?(this._renderOption=g,a.Log.log(" Kiwi.Game: Renderer auto-detected WEBGL.","#renderer","#webgl")):(this._renderOption=h,a.Log.log(" Kiwi.Game: Renderer auto-detected CANVAS.","#renderer","#canvas"));break;default:a.DEVICE.webGL?(this._renderOption=g,a.Log.log(" Kiwi.Game: Renderer specified, but is not a valid option. Defaulting to WEBGL.","#renderer","#webgl")):(this._renderOption=h,a.Log.log(" Kiwi.Game: Renderer specified, but is not a valid option. WEBGL renderer sought by default but device does not support WEBGL. Defaulting to CANVAS.","#renderer","#canvas"))}else a.DEVICE.webGL?(this._renderOption=g,a.Log.log(" Kiwi.Game: Renderer not specified. Defaulting to WEBGL.","#renderer","#webgl")):(this._renderOption=h,a.Log.log(" Kiwi.Game: Renderer not specified. WEBGL renderer sought by default but device does not support WEBGL. Defaulting to CANVAS.","#renderer","#canvas"));this.id=a.GameManager.register(this),this._startup=new a.System.Bootstrap,this.audio=new a.Sound.AudioManager(this),this.fileStore=new a.Files.FileStore(this),this.input=new a.Input.InputManager(this);var i=a.Stage.DEFAULT_WIDTH,j=a.Stage.DEFAULT_HEIGHT;if("undefined"!==e.width&&"number"==typeof e.width&&(i=e.width),"undefined"!==e.height&&"number"==typeof e.height&&(j=e.height),a.Log.log(" Kiwi.Game: Stage Dimensions: "+i+"x"+j,"#dimensions"),a.Utils.Common.isUndefined(e.scaleType))a.Log.log(" Kiwi.Game: Stage scaling not specified, defaulting to NONE.","#scaling"),e.scaleType=0;else switch(e.scaleType){case a.Stage.SCALE_FIT:a.Log.log(" Kiwi.Game: Stage scaling set to FIT.","#scaling");break;case a.Stage.SCALE_STRETCH:a.Log.log(" Kiwi.Game: Stage scaling set to STRETCH.","#scaling");break;case a.Stage.SCALE_NONE:a.Log.log(" Kiwi.Game: Stage scaling set to NONE.","#scaling");break;default:a.Log.log(" Kiwi.Game: Stage specified, but is not a valid option. Set to NONE.","#scaling"),e.scaleType=0}this.stage=new a.Stage(this,c,i,j,e.scaleType),this.renderer=null,this.cameras=new a.CameraManager(this),this._deviceTargetOption!==a.TARGET_COCOON&&(this.huds=new a.HUD.HUDManager(this)),this.loader=new a.Files.Loader(this),this.states=new a.StateManager(this),this.rnd=new a.Utils.RandomDataGenerator([Date.now.toString()]),this.time=new a.Time.ClockManager(this),this.tweens=new a.Animations.Tweens.TweenManager(this),null!==d?this.states.addState(d,!0):a.Log.log(" Kiwi.Game: Default State not passed.","#state"),this.pluginManager=new a.PluginManager(this,e.plugins),this.deviceTargetOption===a.TARGET_BROWSER?this._startup.boot(b,function(){return f._start()}):(""!==b&&a.Log.log(" Kiwi.Game: Not Targetting a BROWSER. DOM Parent parameter ignored.","#dom"),this._start())}return Object.defineProperty(b.prototype,"renderOption",{get:function(){return this._renderOption},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"deviceTargetOption",{get:function(){return this._deviceTargetOption},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"debugOption",{get:function(){return this._debugOption},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"debug",{get:function(){return this._debugOption===a.DEBUG_ON},enumerable:!0,configurable:!0}),b.prototype.objType=function(){return"Game"},Object.defineProperty(b.prototype,"frame",{get:function(){return this._frame},set:function(b){this._frame=a.Utils.GameMath.truncate(b)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"idealFrame",{get:function(){return this.time.elapsed()/(1e3/this._frameRate)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"frameRate",{get:function(){return this._frameRate},set:function(a){a>0&&(this._frameRate=a,this._interval=1e3/this._frameRate,this.time.setMasterInterval(this._interval))},enumerable:!0,configurable:!0}),b.prototype._start=function(){var b=this;this.stage.boot(this._startup),this.stage.renderer||a.Log.error(" Kiwi.Game: Could not create rendering context","#renderer"),this._renderOption===a.RENDERER_WEBGL&&this.stage.ctx&&(this._renderOption=a.RENDERER_CANVAS),this.renderer=this.stage.renderer,this.renderer.boot(),this.cameras.boot(),this._deviceTargetOption!==a.TARGET_COCOON&&this.huds.boot(),this.time.boot(),this.input.boot(),this.audio.boot(),this.fileStore.boot(),this.loader.boot(),this.states.boot(),this.pluginManager.boot(),this._lastTime=Date.now(),this.raf=new a.Utils.RequestAnimationFrame(function(){return b._loop()}),this.raf.start(),this.bootCallbackOption&&(a.Log.log(" Kiwi.Game: invoked boot callback","#boot"),this.bootCallbackOption(this))},b.prototype._loop=function(){this._delta=this.raf.currentTime-this._lastTime,this._delta>this._interval&&(this.time.update(),this.audio.update(),this.input.update(),this.tweens.update(),this.cameras.update(),this._deviceTargetOption!==a.TARGET_COCOON&&this.huds.update(),this.states.update(),this.pluginManager.update(),this._frame++,this._lastTime=this.raf.currentTime-this._delta%this._interval),null!==this.states.current&&(this.cameras.render(),this.states.postRender())},b}();a.Game=b}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b=function(){function b(b,c,d,e,f){this._scaleType=a.Stage.SCALE_NONE,this.offset=new a.Geom.Point,this._color=new a.Utils.Color,this.container=null,this._game=b,this.name=c,this.domReady=!1,this._alpha=1,this._x=0,this._y=0,this._width=d,this._height=e,this.color="ffffff",this._game.deviceTargetOption===a.TARGET_COCOON&&(this.color="000000"),this._scale=new a.Geom.Point(1,1),this._scaleType=f,this.onResize=new a.Signal,this.onWindowResize=new a.Signal,this.onFocus=new a.Signal,this.onBlur=new a.Signal,this.onVisibilityChange=new a.Signal,this._renderer=null}return b.prototype.objType=function(){return"Stage"},Object.defineProperty(b.prototype,"scaleType",{get:function(){return this._scaleType},set:function(a){this._scaleType=a,this._scaleContainer()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"alpha",{get:function(){return this._alpha},set:function(b){this._game.deviceTargetOption===a.TARGET_BROWSER&&(this.container.style.opacity=String(a.Utils.GameMath.clamp(b,1,0))),this._alpha=b},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"x",{get:function(){return this._x},set:function(b){this._game.deviceTargetOption===a.TARGET_BROWSER?this.container.style.left=String(b+"px"):this._game.deviceTargetOption===a.TARGET_COCOON&&(this.canvas.style.left=String(b+"px")),this._x=b},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this._y},set:function(b){this._game.deviceTargetOption===a.TARGET_BROWSER?this.container.style.top=String(b+"px"):this._game.deviceTargetOption===a.TARGET_COCOON&&(this.canvas.style.top=String(b+"px")),this._y=b},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"scale",{get:function(){return this._scale},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"scaleX",{get:function(){return this._scale.x},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"scaleY",{get:function(){return this._scale.y},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"color",{get:function(){return this._color.getHex()},set:function(b){a.Utils.Common.isArray(b)||(b=[b]),this._color.set.apply(this._color,b)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"rgbColor",{get:function(){return{r:255*this._color.r,g:255*this._color.g,b:255*this._color.b}},set:function(a){this._color.r255=a.r,this._color.g255=a.g,this._color.b255=a.b},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"rgbaColor",{get:function(){return{r:255*this._color.r,g:255*this._color.g,b:255*this._color.b,a:255*this._color.a}},set:function(a){this._color.r255=a.r,this._color.g255=a.g,this._color.b255=a.b,this._color.a255=a.a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"normalizedColor",{get:function(){return{r:this._color.r,g:this._color.g,b:this._color.b,a:this._color.a}},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"renderer",{get:function(){return this._renderer},enumerable:!0,configurable:!0}),b.prototype.boot=function(b){var c=this,d=this;this.domReady=!0,this.container=b.container,this._game.deviceTargetOption===a.TARGET_BROWSER&&(this.offset=this.getOffsetPoint(this.container),this._x=this.offset.x,this._y=this.offset.y,window.addEventListener("resize",function(a){return c._windowResized(a)},!0),this._createFocusEvents()),this._createCompositeCanvas(),this._game.deviceTargetOption===a.TARGET_COCOON?(this._scaleContainer(),window.addEventListener("orientationchange",function(a){return d._orientationChanged(a)},!0)):this._calculateContainerScale()},b.prototype.getOffsetPoint=function(b,c){void 0===c&&(c=new a.Geom.Point);var d=b.getBoundingClientRect(),e=b.clientTop||document.body.clientTop||0,f=b.clientLeft||document.body.clientLeft||0,g=window.pageYOffset||b.scrollTop||document.body.scrollTop,h=window.pageXOffset||b.scrollLeft||document.body.scrollLeft;return c.setTo(d.left+h-f,d.top+g-e)},b.prototype._windowResized=function(){this._calculateContainerScale(),this.onWindowResize.dispatch()},b.prototype._orientationChanged=function(){this.onResize.dispatch(window.innerWidth,window.innerHeight)},b.prototype._calculateContainerScale=function(){this._scaleContainer(),this._scaleContainer(),this.offset=this.getOffsetPoint(this.container),this._scale.x=this._width/this.container.clientWidth,this._scale.y=this._height/this.container.clientHeight},b.prototype._createCompositeCanvas=function(){this._game.deviceTargetOption==a.TARGET_COCOON?this.canvas=document.createElement(navigator.isCocoonJS?"screencanvas":"canvas"):(this.canvas=document.createElement("canvas"),this.canvas.style.width="100%",this.canvas.style.height="100%"),this.canvas.id=this._game.id+"compositeCanvas",this.canvas.style.position="absolute",this.canvas.width=this.width,this.canvas.height=this.height,this._game.renderOption===a.RENDERER_CANVAS?(this.ctx=this.canvas.getContext("2d"),this.ctx.fillStyle="#fff",this.gl=null):this._game.renderOption===a.RENDERER_WEBGL&&(this.gl=this.canvas.getContext("webgl"),this.gl||(this.gl=this.canvas.getContext("experimental-webgl"),this.gl?a.Log.warn("Kiwi.Stage: 'webgl' context is not available. Using 'experimental-webgl'","#renderer"):(a.Log.warn("Kiwi.Stage: WebGL rendering is not available despite the device apparently supporting it. Reverting to CANVAS.","#renderer"),this.ctx=this.canvas.getContext("2d"),this.ctx.fillStyle="#fff",this.gl=null)),this.gl&&(this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT),this.ctx=null)),this.ctx?this._renderer=new a.Renderers.CanvasRenderer(this._game):this.gl&&(this._renderer=new a.Renderers.GLRenderManager(this._game)),this._game.deviceTargetOption===a.TARGET_BROWSER?this.container.appendChild(this.canvas):document.body.appendChild(this.canvas)},b.prototype.resize=function(b,c){this.canvas.height=c,this.canvas.width=b,this._height=c,this._width=b,this._game.deviceTargetOption===a.TARGET_BROWSER&&this._calculateContainerScale(),this.onResize.dispatch(this._width,this._height)},b.prototype.setRGBColor=function(a,b,c){return this.rgbColor={r:a,g:b,b:c},this.rgbColor},b.prototype.createDebugCanvas=function(){0!=a.Utils.Common.isUndefined(this.debugCanvas)&&(this._game.deviceTargetOption===a.TARGET_COCOON&&a.Log.log("Debug canvas not supported in cocoon, creating canvas and context anyway","#debug-canvas"),this.debugCanvas=document.createElement("canvas"),this.debugCanvas.id=this._game.id+"debugCanvas",this.debugCanvas.style.position="absolute",this.debugCanvas.width=this.width,this.debugCanvas.height=this.height,this.debugCanvas.style.width="100%",this.debugCanvas.style.height="100%",this.dctx=this.debugCanvas.getContext("2d"),this.clearDebugCanvas(),this._game.deviceTargetOption===a.TARGET_BROWSER&&this.container.appendChild(this.debugCanvas))},b.prototype.clearDebugCanvas=function(a){this.dctx.fillStyle=a||"rgba(255,0,0,.2)",this.dctx.clearRect(0,0,this.width,this.height),this.dctx.fillRect(0,0,this.width,this.height)},b.prototype.toggleDebugCanvas=function(){this.debugCanvas.style.display="none"===this.debugCanvas.style.display?"block":"none"},b.prototype._scaleContainer=function(){if(this._game.deviceTargetOption==a.TARGET_BROWSER){var b=this.container.clientWidth;this.container.style.width=String(this._width+"px"),this.container.style.height=String(this._height+"px"),this._scaleType==a.Stage.SCALE_NONE&&(this.container.style.maxWidth="",this.container.style.minWidth=""),(this._scaleType==a.Stage.SCALE_STRETCH||this._scaleType==a.Stage.SCALE_FIT)&&(this.container.style.minWidth="100%",this.container.style.maxWidth="100%"),this._scaleType==a.Stage.SCALE_STRETCH?(this.container.style.minHeight="100%",this.container.style.maxHeight="100%"):(this.container.style.minHeight="",this.container.style.maxHeight=""),this._scaleType==a.Stage.SCALE_FIT&&(this.container.style.height=String(b/this._width*this._height)+"px")}if(this._game.deviceTargetOption==a.TARGET_COCOON)switch(this._scaleType){case a.Stage.SCALE_FIT:this.canvas.style.cssText="idtkscale:ScaleAspectFit";break;case a.Stage.SCALE_STRETCH:this.canvas.style.cssText="idtkscale:ScaleToFill";break;case a.Stage.SCALE_NONE:this.canvas.style.cssText=""}},Object.defineProperty(b.prototype,"visibility",{get:function(){return this._visibility?!document[this._visibility]:!0},enumerable:!0,configurable:!0}),b.prototype._checkVisibility=function(a){return"focus"===a.type||"pageshow"===a.type?void this.onFocus.dispatch(a):"pagehide"===a.type||"blur"===a.type?void this.onBlur.dispatch(a):"visibilitychange"===a.type||"mozvisibilitychange"===a.type||"webkitvisibilitychange"===a.type||"msvisibilitychange"===a.type?void this.onVisibilityChange.dispatch():void 0},b.prototype._createFocusEvents=function(){this._visibility="hidden",this._visibilityChange=this._checkVisibility.bind(this),"hidden"in document?document.addEventListener("visibilitychange",this._visibilityChange):(this._visibility="mozHidden")in document?document.addEventListener("mozvisibilitychange",this._visibilityChange):(this._visibility="webkitHidden")in document?document.addEventListener("webkitvisibilitychange",this._visibilityChange):(this._visibility="msHidden")in document?document.addEventListener("msvisibilitychange",this._visibilityChange):this._visibility=null,window.addEventListener("pageshow",this._visibilityChange),window.addEventListener("pagehide",this._visibilityChange),window.addEventListener("focus",this._visibilityChange),window.addEventListener("blur",this._visibilityChange)},b.DEFAULT_WIDTH=800,b.DEFAULT_HEIGHT=600,b.SCALE_NONE=0,b.SCALE_FIT=1,b.SCALE_STRETCH=2,b}();a.Stage=b}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b=function(){function a(a,b){this._components={},this._type=a,this._owner=b}return a.prototype.objType=function(){return"ComponentManager"},a.prototype.hasComponent=function(a){return this._components[a]?!0:!1},a.prototype.hasActiveComponent=function(a){return this._components[a]&&this._components[a].active===!0?!0:!1},a.prototype.getComponent=function(a){return this._components[a]?this._components[a]:null},a.prototype.add=function(a){return this._components[a.name]=a,a},a.prototype.addBatch=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];for(var c=0;c<a.length;c++)this.add(a[c])},a.prototype.removeComponent=function(a,b){void 0===b&&(b=!0);var c=a.name;return this._components[c]?(b&&this._components[c].destroy(),delete this._components[c],!0):!1},a.prototype.removeComponentByName=function(a,b){return void 0===b&&(b=!0),this._components[a]?(b&&this._components[a].destroy(),delete this._components[a],!0):!1},a.prototype.removeAll=function(a){void 0===a&&(a=!0);for(var b in this._components)this.removeComponent(this._components[b],a)},a.prototype.preUpdate=function(){for(var a in this._components)this._components[a].active&&this._components[a].preUpdate()},a.prototype.update=function(){for(var a in this._components)this._components[a].active&&this._components[a].update()},a.prototype.postUpdate=function(){for(var a in this._components)this._components[a].active&&this._components[a].postUpdate()},a.prototype.preRender=function(){for(var a in this._components)this._components[a].active&&this._components[a].preRender()},a.prototype.render=function(){for(var a in this._components)this._components[a].active&&this._components[a].render()},a.prototype.postRender=function(){for(var a in this._components)this._components[a].active&&this._components[a].postRender()},a}();a.ComponentManager=b}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b=function(){function b(a,b){this._game=a,this._plugins=b||new Array,this._bootObjects=new Array,this.validatePlugins(),this._createPlugins()}return Object.defineProperty(b,"availablePlugins",{get:function(){for(var a=[],c=0;c<b._availablePlugins.length;c++)a.push({name:b._availablePlugins[c].name,version:b._availablePlugins[c].version});return a},enumerable:!0,configurable:!0}),b.register=function(b){if(a.Log.log("Kiwi.PluginManager: Attempting to register plugin : "+b.name,"#plugin"),-1==this._availablePlugins.indexOf(b)){for(var c=!0,d=0;d<this._availablePlugins.length;d++)b.name===this._availablePlugins[d].name&&(c=!1);c?(this._availablePlugins.push(b),a.Log.log(" Kiwi.PluginManager: Registered plugin "+b.name+": version "+b.version,"#plugin")):a.Log.warn(" Kiwi.PluginManager: A plugin with the same name has already been registered. Ignoring this plugin.","#plugin")}else a.Log.warn(" Kiwi.PluginManager: This plugin has already been registered. Ignoring second registration.","#plugin")},Object.defineProperty(b.prototype,"objType",{get:function(){return"PluginManager"},enumerable:!0,configurable:!0}),b.prototype.validatePlugins=function(){var b=new Array;a.Log.log("Kiwi.PluginManager: Validating Plugins","#plugins");for(var c=0;c<this._plugins.length;c++){var d=this._plugins[c];if("string"==typeof d||d instanceof String)if(a.Plugins.hasOwnProperty(d)&&this.pluginIsRegistered(d))if(b.push(d),a.Log.log(" Kiwi.PluginManager: Plugin '"+d+"' appears to be valid.","#plugin"),a.Log.log(" Kiwi.PluginManager: Name:"+a.Plugins[d].name,"#plugin"),a.Log.log(" Kiwi.PluginManager: Version:"+a.Plugins[d].version,"#plugin"),"undefined"!=typeof a.Plugins[d].minimumKiwiVersion){a.Log.log(" Kiwi.PluginManager: "+d+" requires minimum Kiwi version "+a.Plugins[d].minimumKiwiVersion,"#plugin");var e=a.Utils.Version.parseVersion(a.VERSION),f=a.Utils.Version.parseVersion(a.Plugins[d].minimumKiwiVersion);e.majorVersion>f.majorVersion?a.Log.warn(" Kiwi.PluginManager: This major version of Kiwi is greater than that required by '"+d+"'. It is unknown whether this plugin will work with this version of Kiwi","#plugin"):a.Utils.Version.greaterOrEqual(a.VERSION,a.Plugins[d].minimumKiwiVersion)?a.Log.log(" Kiwi.PluginManager: Kiwi version meets minimum version requirements for '"+d+"'.","#plugin"):a.Log.warn(" Kiwi.PluginManager: Kiwi version ("+a.VERSION+") does not meet minimum version requirements for the plugin ("+a.Plugins[d].minimumKiwiVersion+").","#plugin")}else a.Log.warn(" Kiwi.PluginManager: '"+d+"' is missing the minimumKiwiVersion property. It is unknown whether '"+d+"' will work with this version of Kiwi","#plugin");else a.Log.log(" Kiwi.PluginManager: Plugin '"+d+"' appears to be invalid. No property with that name exists on the Kiwi.Plugins object or the Plugin is not registered. Check that the js file containing the plugin has been included. This plugin will be ignored","#plugin");else a.Log.log(" Kiwi.PluginManager: The supplied plugin name at index "+c+"is not a string and will be ignored","#plugin")}this._plugins=b;for(var c=0;c<this._plugins.length;c++){var g=this._plugins[c],d=a.Plugins[g];if("undefined"!=typeof d.pluginDependencies)if(0===d.pluginDependencies.length)a.Log.log(" Kiwi.PluginManager: '"+g+"' does not depend on any other plugins.","#plugin");else{a.Log.log(" Kiwi.PluginManager: '"+g+"' depends on the following plugins:","#plugin","#dependencies");for(var h=0;h<d.pluginDependencies.length;h++)a.Log.log(d.pluginDependencies[h].name,d.pluginDependencies[h].minimumVersion,"#plugin","#dependencies"),this.validMinimumPluginVersionExists(d.pluginDependencies[h].name,d.pluginDependencies[h].minimumVersion)||a.Log.warn(" Kiwi.PluginManager: '"+d.pluginDependencies[h].name+" hasn't been added to this game via the config, doesn't exist, or does not meet minimum version requirement ( "+d.pluginDependencies[h].minimumVersion+").","#plugin","#dependencies")}else a.Log.log(" Kiwi.PluginManager: '"+g+"' does not depend on any other plugins.","#plugin","#dependencies")}},b.prototype.validMinimumPluginVersionExists=function(b,c){return-1!==this._plugins.indexOf(b)&&a.Utils.Version.greaterOrEqual(a.Plugins[b].version,c)?!0:!1},b.prototype.pluginIsRegistered=function(b){for(var c=!1,d=0;d<a.PluginManager._availablePlugins.length;d++)a.PluginManager._availablePlugins[d].name===b&&(c=!0);return c},b.prototype._createPlugins=function(){for(var b=0;b<this._plugins.length;b++){var c=this._plugins[b];if(a.Plugins[c].hasOwnProperty("create")){var d=a.Plugins[c].create(this._game);d&&this._bootObjects.push(d)}}},b.prototype.boot=function(){for(var b=0;b<this._bootObjects.length;b++)"boot"in this._bootObjects[b]?this._bootObjects[b].boot.call(this._bootObjects[b]):a.Log.warn("Kiwi.PluginManager: Warning! No boot function found on boot object.","#plugin")},b.prototype.update=function(){for(var a=0;a<this._bootObjects.length;a++)"update"in this._bootObjects[a]&&this._bootObjects[a].update.call(this._bootObjects[a])},b._availablePlugins=new Array,b}();a.PluginManager=b}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b=function(){function b(a){this._game=a,this._cameras=[],this._nextCameraID=0}return b.prototype.objType=function(){return"CameraManager"},b.prototype.boot=function(){this.create("defaultCamera",0,0,this._game.stage.width,this._game.stage.height),this.defaultCamera=this._cameras[0]},b.prototype.create=function(b,c,d,e,f){var g=new a.Camera(this._game,this._nextCameraID++,b,c,d,e,f);return this._cameras.push(g),g},b.prototype.remove=function(a){var b=this._cameras.indexOf(a);return-1!==b?(this._cameras.splice(b,1),!0):!1},b.prototype.update=function(){if(0===this._cameras.length)return!1;for(var a=0;a<this._cameras.length;a++)this._cameras[a].update()},b.prototype.render=function(){if(0===this._cameras.length)return!1;for(var a=0;a<this._cameras.length;a++)this._cameras[a].render()},b.prototype.removeAll=function(){this._cameras=[]},b.prototype.zeroAllCameras=function(){for(var a=0;a<this._cameras.length;a++)this.zeroCamera(this._cameras[a]);this.zeroCamera(this.defaultCamera)},b.prototype.zeroCamera=function(a){a.transform.x=0,a.transform.y=0,a.transform.rotation=0,a.transform.scaleX=1,a.transform.scaleY=1,a.transform.rotPointX=a.width/2,a.transform.rotPointY=a.height/2},b}();a.CameraManager=b}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b=function(){function a(a,b){this.name="",this.isPersistent=!1,this.isCreated=!1,this.isInitialised=!1,this.isReady=!1,this.hasPreloader=!1,this.runCount=0,this.type=0,this._state=a,this.name=b,"function"==typeof this._state.preload&&(this.hasPreloader=!0)}return a.prototype.objType=function(){return"StateConfig"},a.prototype.reset=function(){this.isReady=!1,this.isCreated=!1,this.createParams=[],this.initParams=[]},a}();a.StateConfig=b}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b=function(){function b(a){this.current=null,this._newStateKey=null,this._game=a,this._states=[]}return b.prototype.objType=function(){return"StateManager"},b.prototype.checkKeyExists=function(a){for(var b=0;b<this._states.length;b++)if(this._states[b].config.name===a)return!0;return!1},b.prototype.checkValidState=function(a){return a.game&&a.config?!0:!1},b.prototype.addState=function(b,c){void 0===c&&(c=!1),a.Log.log("Kiwi.StateManager: Adding state.","#state");var d;return d="function"==typeof b?new b:"string"==typeof b?window[b]:b,d.config.name&&this.checkKeyExists(d.config.name)===!0?(a.Log.error(" Kiwi.StateManager: Could not add "+d.config.name+" as a State with that name already exists.","#state"),!1):(d.game=this._game,this.checkValidState(d)===!1?(a.Log.error(" Kiwi.StateManager: "+d.config.name+" isn't a valid state. Make sure you are using the Kiwi.State class!","#state"),!1):(this._states.push(d),a.Log.log(" Kiwi.StateManager: "+d.config.name+" was successfully added.","#state"),c===!0&&this.switchState(d.config.name),!0))},b.prototype.boot=function(){},b.prototype.setCurrentState=function(b){return null!==this.current&&this.current.config.name===b||this.checkKeyExists(b)===!1?!1:(a.Log.log('Kiwi.StateManager: Switching to "'+b+'" State.',"#state"),this._newStateKey=b,!0)},b.prototype.bootNewState=function(){null!==this.current&&(this.current.shutDown(),this._game.input.reset(),this.current.destroy(!0),this._game.fileStore.removeStateFiles(this.current),this.current.config.reset(),this._game.cameras.zeroAllCameras()),this.current=this.getState(this._newStateKey),this._newStateKey=null,this.checkInit(),this.checkPreload()},b.prototype.switchState=function(b,c,d,e,f){if(void 0===c&&(c=null),void 0===d&&(d=null),void 0===e&&(e=null),void 0===f&&(f=null),null!==this.current&&this.current.config.isReady===!1)return a.Log.error("Kiwi.StateManager: Cannot change to a new state till the current state has finished loading!","#state"),!1;if(this.checkKeyExists(b)===!1&&null!==c&&this.addState(c,!1)===!1)return!1;if(null!==d||null!==e||null!==f){var g=this.getState(b);g.config.initParams=[],g.config.createParams=[],g.config.preloadParams=[];for(var h in d)g.config.initParams.push(d[h]);for(var i in e)g.config.createParams.push(e[i]);for(var j in f)g.config.preloadParams.push(f[j])}return this.setCurrentState(b)},b.prototype.getState=function(a){for(var b=0;b<this._states.length;b++)if(this._states[b].config.name===a)return this._states[b];return null},b.prototype.checkPreload=function(){this.rebuildLibraries(),this._game.loader.onQueueProgress.add(this.onLoadProgress,this),this._game.loader.onQueueComplete.add(this.onLoadComplete,this),this.current.preload.apply(this.current,this.current.config.preloadParams),this._game.loader.start()},b.prototype.callCreate=function(){a.Log.log("Kiwi.StateManager: Calling "+this.current.name+":Create","#state"),this.current.create.apply(this.current,this.current.config.createParams),this.current.config.runCount++,this.current.config.isCreated=!0},b.prototype.checkInit=function(){this.current.config.isInitialised===!1&&(this.current.boot(),this.current.init.apply(this.current,this.current.config.initParams),this.current.config.isInitialised=!0)},b.prototype.onLoadProgress=function(a,b,c){this.current.loadProgress(a,b,c)},b.prototype.onLoadComplete=function(){this.current.loadComplete(),this._game.loader.onQueueProgress.remove(this.onLoadProgress,this),this._game.loader.onQueueComplete.remove(this.onLoadComplete,this),this.rebuildLibraries(),this.current.config.isReady=!0,this.callCreate()},b.prototype.rebuildLibraries=function(){this.current.audioLibrary.rebuild(this._game.fileStore,this.current),this.current.dataLibrary.rebuild(this._game.fileStore,this.current),this.current.textureLibrary.rebuild(this._game.fileStore,this.current),this._game.renderOption==a.RENDERER_WEBGL&&this._game.renderer.initState(this.current)},b.prototype.update=function(){null!==this.current&&(this.current.config.isReady===!0?(this.current.preUpdate(),this.current.update(),this.current.postUpdate()):this.current.loadUpdate()),null!==this._newStateKey&&this.bootNewState()},b.prototype.postRender=function(){null!==this.current&&this.current.config.isReady===!0&&this.current.postRender()},b}();a.StateManager=b}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b=function(){function b(b,c,d){this._parent=null,this._alpha=1,this.width=0,this.height=0,this.atlas=null,this._cellIndex=0,this.name="",this._tags=[],this._clock=null,this.state=b,this.game=b.game,this.id=this.game.rnd.uuid(),this.state.addToTrackingList(this),this._clock=this.game.time.clock,this._exists=!0,this._active=!0,this._visible=!0,this.components=new a.ComponentManager(a.ENTITY,this),this.transform=new a.Geom.Transform,this.transform.x=c,this.transform.y=d}return Object.defineProperty(b.prototype,"parent",{get:function(){return this._parent},set:function(a){this.transform.parent=null!==a?a.transform:null,this._parent=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"x",{get:function(){return this.transform.x},set:function(a){this.transform.x=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this.transform.y},set:function(a){this.transform.y=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"worldX",{get:function(){return this.transform.worldX},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"worldY",{get:function(){return this.transform.worldY},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"scaleX",{get:function(){return this.transform.scaleX},set:function(a){this.transform.scaleX=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"scaleY",{get:function(){return this.transform.scaleY},set:function(a){this.transform.scaleY=a
|
|
},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"scale",{set:function(a){this.transform.scale=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"rotation",{get:function(){return this.transform.rotation},set:function(a){this.transform.rotation=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"rotPointX",{get:function(){return this.transform.rotPointX},set:function(a){this.transform.rotPointX=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"rotPointY",{get:function(){return this.transform.rotPointY},set:function(a){this.transform.rotPointY=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"anchorPointX",{get:function(){return this.transform.anchorPointX},set:function(a){this.transform.anchorPointX=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"anchorPointY",{get:function(){return this.transform.anchorPointY},set:function(a){this.transform.anchorPointY=a},enumerable:!0,configurable:!0}),b.prototype.childType=function(){return a.ENTITY},Object.defineProperty(b.prototype,"alpha",{get:function(){return this._alpha},set:function(a){0>=a&&(a=0),a>1&&(a=1),this._alpha=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"visible",{get:function(){return this._visible},set:function(a){this._visible=a},enumerable:!0,configurable:!0}),b.prototype.scaleToWidth=function(a){this.scale=a/this.width},b.prototype.scaleToHeight=function(a){this.scale=a/this.height},b.prototype.centerAnchorPoint=function(){this.anchorPointX=.5*this.width,this.anchorPointY=.5*this.height},Object.defineProperty(b.prototype,"cellIndex",{get:function(){return this._cellIndex},set:function(b){if(null!==this.atlas){var c=this.atlas.cells[b];void 0!==c?(this._cellIndex=b,this.width=c.w,this.height=c.h):a.Log.error("Could not the set the cellIndex of a Entity, to cell that does not exist on its TextureAtlas.","#entity","#cellIndex")}},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"exists",{get:function(){return this._exists},set:function(a){this._exists=a},enumerable:!0,configurable:!0}),b.prototype.addTag=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];for(var c=0;c<a.length;c++)-1==this._tags.indexOf(a[c])&&this._tags.push(a[c])},b.prototype.removeTag=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];for(var c=0;c<a.length;c++){var d=this._tags.indexOf(a[c]);-1!==d&&this._tags.splice(d,1)}},b.prototype.hasTag=function(a){for(var b=this._tags.length;b--;)if(this._tags[b]===a)return!0;return!1},Object.defineProperty(b.prototype,"active",{get:function(){return this._active},set:function(a){this._active=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"willRender",{get:function(){return this._willRender},set:function(a){this._willRender=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"inputEnabled",{get:function(){return this._inputEnabled},set:function(a){this._inputEnabled=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"clock",{get:function(){return this._clock},set:function(a){this._clock=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"dirty",{get:function(){return this._dirty},set:function(a){this._dirty=a},enumerable:!0,configurable:!0}),b.prototype.objType=function(){return"Entity"},b.prototype.update=function(){this.components.preUpdate(),this.components.update(),this.components.postUpdate()},b.prototype.render=function(){},b.prototype.renderGL=function(a,b,c){void 0===c&&(c=null)},b.prototype.destroy=function(a){void 0===a&&(a=!1),this._exists=!1,this._active=!1,this._visible=!1,a===!0&&(null!==this.parent&&"undefined"!=typeof this.parent&&this.parent.removeChild(this),this.state&&this.state.removeFromTrackingList(this),delete this._parent,delete this.transform,delete this._clock,delete this.state,delete this.game,delete this.atlas,this.components&&this.components.removeAll(!0),delete this.components)},b}();a.Entity=b}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b=function(){function a(a,b){this.active=!0,this.dirty=!1,this.owner=a,this.game=this.owner.game,this.name=b,this.owner.state?this.state=this.owner.state:"State"===this.owner.objType()&&(this.state=this.owner),this.active=!0}return a.prototype.objType=function(){return"Component"},a.prototype.preUpdate=function(){},a.prototype.update=function(){},a.prototype.postUpdate=function(){},a.prototype.destroy=function(){this.active=!1,delete this.game,delete this.owner,this.name=""},a}();a.Component=b}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b=function(){function b(b,c){void 0===c&&(c=""),this.name="",this._parent=null,this.game=null,this.state=null,this._dirty=!0,this._tags=[],this._tempRemoveChildren=null,null!==b&&(this.state=b,this.game=this.state.game,this.id=this.game.rnd.uuid(),this.state.addToTrackingList(this)),this.name=c,this.components=new a.ComponentManager(a.GROUP,this),this._exists=!0,this._active=!0,this._visible=!0,this.transform=new a.Geom.Transform,this.members=[]}return b.prototype.objType=function(){return"Group"},b.prototype.childType=function(){return a.GROUP},Object.defineProperty(b.prototype,"parent",{get:function(){return this._parent},set:function(a){this.transform.parent=null!==a?a.transform:null,this._parent=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"x",{get:function(){return this.transform.x},set:function(a){this.transform.x=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this.transform.y},set:function(a){this.transform.y=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"worldX",{get:function(){return this.transform.worldX},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"worldY",{get:function(){return this.transform.worldY},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"scaleX",{get:function(){return this.transform.scaleX},set:function(a){this.transform.scaleX=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"scaleY",{get:function(){return this.transform.scaleY},set:function(a){this.transform.scaleY=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"scale",{set:function(a){this.transform.scale=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"rotation",{get:function(){return this.transform.rotation},set:function(a){this.transform.rotation=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"rotPointX",{get:function(){return this.transform.rotPointX},set:function(a){this.transform.rotPointX=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"rotPointY",{get:function(){return this.transform.rotPointY},set:function(a){this.transform.rotPointY=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"anchorPointX",{get:function(){return this.transform.anchorPointX},set:function(a){this.transform.anchorPointX=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"anchorPointY",{get:function(){return this.transform.anchorPointY},set:function(a){this.transform.anchorPointY=a},enumerable:!0,configurable:!0}),b.prototype.numChildren=function(){return this.members.length},Object.defineProperty(b.prototype,"dirty",{get:function(){return this._dirty},set:function(a){if(void 0!==a){this._dirty=a;for(var b=0;b<this.members.length;b++)this.members[b].dirty=a}},enumerable:!0,configurable:!0}),b.prototype.contains=function(a){return-1===this.members.indexOf(a)?!1:!0},b.prototype.containsDescendant=function(b){for(var c=0;c<this.members.length;c++){var d=this.members[c];if(d.id==b.id||d.childType()==a.Group&&d.containsDesendant(b))return!0}return!1},b.prototype.containsAncestor=function(a,b){return null===a.parent||void 0===a.parent?!1:a.parent==b?!0:a.parent.containsAncestor(a.parent,b)},b.prototype.addChild=function(b){return b.childType()!==a.STATE&&b!=this?(null!==b.parent&&b.parent.removeChild(b),this.members.push(b),b.parent=this,b):void 0},b.prototype.addChildAt=function(b,c){return b.childType()!==a.STATE&&b!=this?(null!==b.parent&&b.parent.removeChild(b),this.members.splice(c,0,b),b.parent=this,b):void 0},b.prototype.addChildBefore=function(a,b){if(b.transform.parent===this.transform){null!==a.parent&&a.parent.removeChild(a);var c=this.getChildIndex(b);this.members.splice(c,0,a),a.parent=this}return a},b.prototype.addChildAfter=function(a,b){if(b.transform.parent===this.transform){null!==a.parent&&a.parent.removeChild(a);var c=this.getChildIndex(b)+1;this.members.splice(c,0,a),a.parent=this}return a},b.prototype.removeChild=function(a,b){if(void 0===b&&(b=!1),a.parent===this){var c=this.getChildIndex(a);c>-1&&(this.members.splice(c,1),a.parent=null,b&&a.destroy())}return a},b.prototype.removeChildAt=function(a){if(this.members[a]){var b=this.members[a];return this.removeChild(b)}return null},b.prototype.removeChildren=function(a,b,c){void 0===a&&(a=0),void 0===b&&(b=2147483647),void 0===c&&(c=!1),b-=a;for(var d=this.members.splice(a,b),e=0;e<d.length;e++)d[e].parent=null,c&&d[e].destroy();return d.length},b.prototype.removeFirstAlive=function(a){return void 0===a&&(a=!1),this.removeChild(this.getFirstAlive(),a)},b.prototype.getAllChildren=function(a,b){void 0===a&&(a=!0),void 0===b&&(b=[]);for(var c=0;c<this.members.length;c++)"Group"==this.members[c].objType()?(a&&b.push(this.members[c]),this.members[c].getAllChildren(a,b)):b.push(this.members[c]);return b},b.prototype.getChildAt=function(a){return this.members[a]?this.members[a]:null},b.prototype.getChildByName=function(a,b){void 0===b&&(b=!1);for(var c=0;c<this.members.length;c++){if(this.members[c].name===a)return this.members[c];if("Group"==this.members[c].objType()&&b){var d=this.members[c].getChildByName(a,!0);if(null!==d)return d}}return null},b.prototype.getChildByID=function(a,b){void 0===b&&(b=!1);for(var c=0;c<this.members.length;c++){if(this.members[c].id===a)return this.members[c];if("Group"==this.members[c].objType()&&b){var d=this.members[c].getChildByID(a,!0);if(null!==d)return d}}return null},b.prototype.getChildIndex=function(a){return this.members.indexOf(a)},b.prototype.getFirstAlive=function(){for(var a=0;a<this.members.length;a++)if(this.members[a].exists===!0)return this.members[a];return null},b.prototype.getFirstDead=function(){for(var a=0;a<this.members.length;a++)if(this.members[a].exists===!1)return this.members[a];return null},b.prototype.getRandom=function(b,c){if(void 0===b&&(b=0),void 0===c&&(c=0),0===this.members.length)return null;b=a.Utils.GameMath.clamp(b,this.members.length-1),0===c&&(c=this.members.length),this.members.length<=b+c&&(c=this.members.length-b-1);var d=b+Math.random()*c;return d=Math.floor(d),this.members[d]},b.prototype.getChildrenByTag=function(b){for(var c=[],d=0;d<this.members.length;d++)this.members[d].hasTag(b)&&c.push(this.members[d]),this.members[d].childType()==a.GROUP&&(c=c.concat(this.members[d].getChildrenByTag(b)));return c},b.prototype.getFirstChildByTag=function(b){for(var c=0;c<this.members.length;c++){if(this.members[c].hasTag(b))return this.members[c];if(this.members[c].childType()==a.GROUP){var d=this.members[c].getFirstChildByTag(b);if(d)return d}}return null},b.prototype.getLastChildByTag=function(b){for(var c=this.members.length-1;c>=0;c--){if(this.members[c].hasTag(b))return this.members[c];if(this.members[c].childType()==a.GROUP){var d=this.members[c].getLastChildByTag(b);if(d)return d}}return null},b.prototype.setChildIndex=function(a,b){return a.parent!==this||this.getChildIndex(a)===b?!1:(this.removeChild(a),this.addChildAt(a,b),!0)},b.prototype.swapChildren=function(a,b){if(a.parent!==this||b.parent!==this)return!1;var c=this.getChildIndex(a),d=this.getChildIndex(b);return-1!==c&&-1!==d&&c!==d?(this.members[c]=b,this.members[d]=a,!0):!1},b.prototype.swapChildrenAt=function(a,b){var c=this.getChildAt(a),d=this.getChildAt(b);return null!==c&&null!==d?c==d||c.parent!==this||d.parent!==this?!1:(this.members[a]=d,this.members[b]=c,!0):!1},b.prototype.replaceChild=function(a,b){if(a===b)return!1;var c=this.getChildIndex(a);return c>-1?(b.parent&&b.parent.removeChild(b),this.removeChildAt(c),this.addChildAt(b,c),b.parent=null,!0):!1},b.prototype.forEach=function(a,b){for(var c=[],d=2;d<arguments.length;d++)c[d-2]=arguments[d];this.members.length>0&&this.members.forEach(function(d){return b.apply(a,[d].concat(c))})},b.prototype.forEachAlive=function(a,b){for(var c=[],d=2;d<arguments.length;d++)c[d-2]=arguments[d];this.members.length>0&&this.members.forEach(function(d){d.exists&&b.apply(a,[d].concat(c))})},b.prototype.setAll=function(a,b,c){if(null===a)for(var d=0;d<this.members.length;d++)this.members[d][b]=c;else for(var d=0;d<this.members.length;d++)this.members[d][a][b]=c},b.prototype.callAll=function(a,b,c){if(null===a)for(var d=0;d<this.members.length;d++)this.members[d][b].apply(this.members[d],c);else for(var d=0;d<this.members.length;d++)this.members[d][a][b].apply(this.members[d][a],c)},b.prototype.update=function(){if(this.components.preUpdate(),this.components.update(),this.members.length>0)for(var a=0;a<this.members.length;a++)this.members[a].active===!0&&this.members[a].update(),this.members[a].exists===!1&&this.members[a].destroy(!0);this.components.postUpdate()},Object.defineProperty(b.prototype,"exists",{get:function(){return this._exists},set:function(a){this._exists=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"active",{get:function(){return this._active},set:function(a){this._active=a},enumerable:!0,configurable:!0}),b.prototype.render=function(){},b.prototype.countLiving=function(){for(var a=0,b=0;b<this.members.length;b++)this.members[b].exists===!0&&a++;return a},b.prototype.countDead=function(){for(var a=0,b=0;b<this.members.length;b++)this.members[b].exists===!1&&a++;return a},b.prototype.clear=function(){this.members.length=0},Object.defineProperty(b.prototype,"willRender",{get:function(){return this._willRender},set:function(a){this._willRender=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"visible",{get:function(){return this._visible},set:function(a){this._visible=a},enumerable:!0,configurable:!0}),b.prototype.addTag=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];for(var c=0;c<a.length;c++)-1==this._tags.indexOf(a[c])&&this._tags.push(a[c])},b.prototype.removeTag=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];for(var c=0;c<a.length;c++){var d=this._tags.indexOf(a[c]);-1!==d&&this._tags.splice(d,1)}},b.prototype.hasTag=function(a){for(var b=this._tags.length;b--;)if(this._tags[b]===a)return!0;return!1},b.prototype.destroy=function(a,b){if(void 0===a&&(a=!1),void 0===b&&(b=!0),this._exists=!1,this._active=!1,this._visible=!1,a===!0){if(null!==this._tempRemoveChildren&&(b=this._tempRemoveChildren),1==b)for(var c=0;c<this.members.length;c++)this.members[c].destroy(!0);else this.removeChildren();null!==this.parent&&this.parent.removeChild(this),this.state&&this.state.removeFromTrackingList(this),delete this.transform,this.components&&this.components.removeAll(),delete this.components,delete this.game,delete this.state}else this._tempRemoveChildren=b},b}();a.Group=b}(Kiwi||(Kiwi={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Kiwi;!function(a){var b=function(b){function c(c){b.call(this,null,c),this.game=null,this.config=new a.StateConfig(this,c),this.components=new a.ComponentManager(a.STATE,this),this.transform.parent=null,this._trackingList=[]}return __extends(c,b),c.prototype.objType=function(){return"State"},c.prototype.childType=function(){return a.GROUP},c.prototype.boot=function(){this.textureLibrary=new a.Textures.TextureLibrary(this.game),this.textures=this.textureLibrary.textures,this.audioLibrary=new a.Sound.AudioLibrary(this.game),this.audio=this.audioLibrary.audio,this.dataLibrary=new a.Files.DataLibrary(this.game),this.data=this.dataLibrary.data},c.prototype.setType=function(a){this.config.isInitialised===!1&&(this.config.type=a)},c.prototype.init=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b]},c.prototype.preload=function(){},c.prototype.loadProgress=function(){},c.prototype.loadComplete=function(){},c.prototype.loadUpdate=function(){for(var a=0;a<this.members.length;a++)this.members[a].active===!0&&this.members[a].update()},c.prototype.create=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b]},c.prototype.preUpdate=function(){this.components.preUpdate()},c.prototype.update=function(){this.components.update();for(var a=0;a<this.members.length;a++)this.members[a].active===!0&&this.members[a].update(),this.members[a].exists===!1&&this.members[a].destroy(!0)},c.prototype.postUpdate=function(){this.components.postUpdate()},c.prototype.postRender=function(){},c.prototype.shutDown=function(){},c.prototype.addImage=function(a,b,c,d,e,f,g){return void 0===c&&(c=!0),this.game.loader.addImage(a,b,d,e,f,g,c)},c.prototype.addSpriteSheet=function(a,b,c,d,e,f,g,h,i,j,k,l){return void 0===e&&(e=!0),this.game.loader.addSpriteSheet(a,b,c,d,f,g,h,i,j,k,l,e)},c.prototype.addTextureAtlas=function(a,b,c,d,e){return void 0===e&&(e=!0),this.game.loader.addTextureAtlas(a,b,c,d,e)},c.prototype.addJSON=function(a,b,c){return void 0===c&&(c=!0),this.game.loader.addJSON(a,b,c)},c.prototype.addAudio=function(a,b,c){return void 0===c&&(c=!0),this.game.loader.addAudio(a,b,c)},c.prototype.addToTrackingList=function(a){-1===this._trackingList.indexOf(a)&&this._trackingList.push(a)},c.prototype.removeFromTrackingList=function(a){var b=this._trackingList.indexOf(a);b>-1&&this._trackingList.splice(b,1)},c.prototype.destroyUnused=function(){for(var a=0,b=0;b<this._trackingList.length;b++)this.containsAncestor(this._trackingList[b],this)===!1&&(this._trackingList[b].destroy(),this._trackingList.splice(b,1),b--,a++);return a},c.prototype.destroy=function(a){if(void 0===a&&(a=!0),1==a){for(;this._trackingList.length>0;)this._trackingList[0].destroy(!0,!1);for(this._trackingList=[];this.members.length>0;)this.members[0].destroy(!0,!1);this.members=[]}},c.prototype._destroyChildren=function(b){if(b.childType()==a.GROUP)for(var c=0;c<b.members.length;c++)this._destroyChildren(b.members[c]);b.destroy(!0)},c}(a.Group);a.State=b}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b=function(){function b(b,c,d,e,f,g,h){this.fitToStage=!0,this._game=b,this.id=c,this.name=d,this.width=g,this.height=h,this.transform=new a.Geom.Transform(e,f),this.transform.rotPointX=e+g/2,this.transform.rotPointY=f+h/2,this._game.stage.onResize.add(this._updatedStageSize,this),this._scratchMatrix=new a.Geom.Matrix}return b.prototype.objType=function(){return"Camera"},b.prototype._updatedStageSize=function(a,b){this.width=a,this.height=b},Object.defineProperty(b.prototype,"visible",{get:function(){return this._visible},set:function(a){this._visible=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"dirty",{get:function(){return this._dirty},set:function(a){this._dirty=a},enumerable:!0,configurable:!0}),b.prototype.transformPoint=function(a){var b,c=a.clone();return this._scratchMatrix.copyFrom(this.transform.getConcatenatedMatrix()),b=this._scratchMatrix,b.append(1,0,0,1,-this.transform.rotPointX,-this.transform.rotPointY),b.invert(),b.transformPoint(c)},b.prototype.transformPointToScreen=function(a){var b,c=a.clone();return this._scratchMatrix.copyFrom(this.transform.getConcatenatedMatrix()),b=this._scratchMatrix,b.append(1,0,0,1,-this.transform.rotPointX,-this.transform.rotPointY),b.transformPoint(c)},b.prototype.update=function(){},b.prototype.render=function(){this._game.renderer.render(this)},b}();a.Camera=b}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b=function(){function b(){this._bindings=[],this._prevParams=null,this.memorize=!1,this._shouldPropagate=!0,this.active=!0}return b.prototype.objType=function(){return"Signal"},b.prototype.validateListener=function(a,b){if("function"!=typeof a)throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",b))},b.prototype._registerListener=function(b,c,d,e){var f,g=this._indexOfListener(b,d);if(-1!==g){if(f=this._bindings[g],f.isOnce()!==c)throw new Error("You cannot add"+(c?"":"Once")+"() then add"+(c?"Once":"")+"() the same listener without removing the relationship first.")}else f=new a.SignalBinding(this,b,c,d,e),this._addBinding(f);return this.memorize&&this._prevParams&&f.execute(this._prevParams),f},b.prototype._addBinding=function(a){var b=this._bindings.length;do--b;while(this._bindings[b]&&a.priority<=this._bindings[b].priority);this._bindings.splice(b+1,0,a)},b.prototype._indexOfListener=function(a,b){for(var c,d=this._bindings.length;d--;)if(c=this._bindings[d],c.getListener()===a&&c.context===b)return d;return-1},b.prototype.has=function(a,b){return void 0===b&&(b=null),-1!==this._indexOfListener(a,b)},b.prototype.add=function(a,b,c){return void 0===b&&(b=null),void 0===c&&(c=0),this.validateListener(a,"add"),this._registerListener(a,!1,b,c)},b.prototype.addOnce=function(a,b,c){return void 0===b&&(b=null),void 0===c&&(c=0),this.validateListener(a,"addOnce"),this._registerListener(a,!0,b,c)},b.prototype.remove=function(a,b){void 0===b&&(b=null),this.validateListener(a,"remove");var c=this._indexOfListener(a,b);return-1!==c&&(this._bindings[c]._destroy(),this._bindings.splice(c,1)),a},b.prototype.removeAll=function(){for(var a=this._bindings.length;a--;)this._bindings[a]._destroy();this._bindings.length=0},b.prototype.getNumListeners=function(){return this._bindings.length},b.prototype.halt=function(){this._shouldPropagate=!1},b.prototype.resume=function(){this._shouldPropagate=!0},b.prototype.dispatch=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];if(this.active){var c,d=this._bindings.length;if(this.memorize&&(this._prevParams=a),d){c=this._bindings.slice(0),this._shouldPropagate=!0;do d--;while(c[d]&&this._shouldPropagate&&c[d].execute(a)!==!1)}}},b.prototype.forget=function(){this._prevParams=null},b.prototype.dispose=function(){this.removeAll(),delete this._bindings,delete this._prevParams},b.VERSION="1.0.0",b}();a.Signal=b}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b=function(){function a(a,b,c,d,e){void 0===e&&(e=0),this.active=!0,this.params=null,this._listener=b,this._isOnce=c,this.context=d,this._signal=a,this.priority=e||0}return a.prototype.objType=function(){return"SignalBinding"},a.prototype.execute=function(a){var b,c;return this.active&&this._listener&&(c=this.params?this.params.concat(a):a,b=this._listener.apply(this.context,c),this._isOnce&&this.detach()),b},a.prototype.detach=function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},a.prototype.isBound=function(){return!!this._signal&&!!this._listener},a.prototype.isOnce=function(){return this._isOnce},a.prototype.getListener=function(){return this._listener},a.prototype.getSignal=function(){return this._signal},a.prototype._destroy=function(){delete this._signal,delete this._listener,delete this.context},a}();a.SignalBinding=b}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(c,d,e,f,g){return void 0===e&&(e=0),void 0===f&&(f=0),void 0===g&&(g=!1),b.call(this,c,e,f),a.Utils.Common.isString(d)&&(d=this.state.textures[d]),"undefined"==typeof d?(a.Log.error("A Texture Atlas was not passed when instantiating a new Sprite.","#sprite","#texture"),this.visible=!1,void(this.active=!1)):(this.game.renderOption===a.RENDERER_WEBGL&&(this.glRenderer=this.game.renderer.requestSharedRenderer("TextureAtlasRenderer")),this.atlas=d,this.name=this.atlas.name,this.cellIndex=this.atlas.cellIndex,this.width=d.cells[this.cellIndex].w,this.height=d.cells[this.cellIndex].h,this.transform.rotPointX=this.width/2,this.transform.rotPointY=this.height/2,this.box=this.components.add(new a.Components.Box(this,e,f,this.width,this.height)),this.input=this.components.add(new a.Components.Input(this,this.box,g)),void(this.atlas.type===a.Textures.TextureAtlas.SINGLE_IMAGE?(this.animation=null,this._isAnimated=!1):(this.animation=this.components.add(new a.Components.AnimationManager(this)),this._isAnimated=!0)))}return __extends(c,b),c.prototype.objType=function(){return"Sprite"},c.prototype.update=function(){b.prototype.update.call(this),this._isAnimated&&(this.width=this.atlas.cells[this.cellIndex].w,this.height=this.atlas.cells[this.cellIndex].h)},c.prototype.render=function(a){if(b.prototype.render.call(this,a),this.alpha>0){var c=this.game.stage.ctx;c.save(),this.alpha>0&&this.alpha<=1&&(c.globalAlpha=this.alpha);var d=this.transform,e=d.getConcatenatedMatrix();c.transform(e.a,e.b,e.c,e.d,e.tx,e.ty);var f=this.atlas.cells[this.cellIndex];c.drawImage(this.atlas.image,f.x,f.y,f.w,f.h,-d.rotPointX,-d.rotPointY,f.w,f.h),c.restore()}},c.prototype.renderGL=function(a,b,c){void 0===c&&(c=null),this.glRenderer.addToBatch(a,this,b)},c}(a.Entity);b.Sprite=c}(b=a.GameObjects||(a.GameObjects={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(c,d,e,f){return void 0===e&&(e=0),void 0===f&&(f=0),b.call(this,c,e,f),this.game.renderOption===a.RENDERER_WEBGL&&(this.glRenderer=this.game.renderer.requestSharedRenderer("TextureAtlasRenderer")),a.Utils.Common.isString(d)&&(d=this.state.textures[d]),"undefined"==typeof d?(a.Log.error("A Texture Atlas was not passed when instantiating a new Static Image.","#static-image","#texture"),this.visible=!1,void(this.active=!1)):(this.atlas=d,this.cellIndex=this.atlas.cellIndex,this.width=d.cells[this.cellIndex].w,this.height=d.cells[this.cellIndex].h,this.transform.rotPointX=this.width/2,this.transform.rotPointY=this.height/2,void(this.box=this.components.add(new a.Components.Box(this,e,f,this.width,this.height))))}return __extends(c,b),c.prototype.objType=function(){return"StaticImage"},c.prototype.render=function(a){if(b.prototype.render.call(this,a),this.alpha>0){var c=this.game.stage.ctx;c.save(),this.alpha>0&&this.alpha<=1&&(c.globalAlpha=this.alpha);var d=this.transform,e=d.getConcatenatedMatrix();c.transform(e.a,e.b,e.c,e.d,e.tx,e.ty);var f=this.atlas.cells[this.cellIndex];c.drawImage(this.atlas.image,f.x,f.y,f.w,f.h,-d.rotPointX,-d.rotPointY,f.w,f.h),c.restore()}},c.prototype.renderGL=function(a,b,c){void 0===c&&(c=null),this.glRenderer.addToBatch(a,this,b)},c}(a.Entity);b.StaticImage=c}(b=a.GameObjects||(a.GameObjects={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(c,d,e,f,g,h,i,j){void 0===e&&(e=0),void 0===f&&(f=0),void 0===g&&(g="#000000"),void 0===h&&(h=32),void 0===i&&(i="normal"),void 0===j&&(j="sans-serif"),b.call(this,c,e,f),this._tempDirty=!0,this._pt1=new a.Geom.Point(0,0),this._pt2=new a.Geom.Point(0,0),this._pt3=new a.Geom.Point(0,0),this._pt4=new a.Geom.Point(0,0),this.game.renderOption===a.RENDERER_WEBGL&&(this.glRenderer=this.game.renderer.requestSharedRenderer("TextureAtlasRenderer")),this._text=d,this._fontWeight=i,this._fontSize=h,this._fontColor=new a.Utils.Color(g),this._fontFamily=j,this._textAlign="left",this._baseline="top",this._tempDirty=!0,this._canvas=document.createElement("canvas"),this._canvas.width=2,this._canvas.height=2,this._ctx=this._canvas.getContext("2d"),this.atlas=new a.Textures.SingleImage(this.game.rnd.uuid(),this._canvas),this.state.textureLibrary.add(this.atlas),this.atlas.dirty=!0,this._alignWidth=0,this.box=this.components.add(new a.Components.Box(this,e,f,this.width,this.height))}return __extends(c,b),c.prototype.objType=function(){return"Textfield"},Object.defineProperty(c.prototype,"text",{get:function(){return this._text},set:function(a){this._text=a,this._tempDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"color",{get:function(){return"#"+this._fontColor.getHex()},set:function(b){a.Utils.Common.isArray(b)||(b=[b]),this._fontColor.set.apply(this._fontColor,b),this._tempDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"fontWeight",{get:function(){return this._fontWeight},set:function(a){this._fontWeight=a,this._tempDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"fontSize",{get:function(){return this._fontSize},set:function(a){this._fontSize=a,this._tempDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"fontFamily",{get:function(){return this._fontFamily},set:function(a){this._fontFamily=a,this._tempDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"textAlign",{get:function(){return this._textAlign},set:function(a){this._textAlign=a,this._tempDirty=!0},enumerable:!0,configurable:!0}),c.prototype._renderText=function(){this._ctx.font=this._fontWeight+" "+this._fontSize+"px "+this._fontFamily;var b=this._ctx.measureText(this._text),c=b.width,d=1.3*this._fontSize;if(this._alignWidth=c,-1==a.Utils.Common.base2Sizes.indexOf(c)){for(var e=0;c>a.Utils.Common.base2Sizes[e];)e++;c=a.Utils.Common.base2Sizes[e]}if(-1==a.Utils.Common.base2Sizes.indexOf(d)){for(var e=0;d>a.Utils.Common.base2Sizes[e];)e++;d=a.Utils.Common.base2Sizes[e]}this._canvas.width=c,this._canvas.height=d,this._ctx.clearRect(0,0,c,d),this._ctx.font=this._fontWeight+" "+this._fontSize+"px "+this._fontFamily,this._ctx.fillStyle=this.color.slice(0,7),this._ctx.textBaseline=this._baseline,this._ctx.fillText(this._text,0,0),this.width=this._alignWidth,this.height=this._canvas.height,this.atlas.cells[0]={x:0,y:0,w:this._canvas.width,h:this._canvas.height,hitboxes:[{x:this._textAlign===a.GameObjects.TextField.TEXT_ALIGN_LEFT?0:this._textAlign===a.GameObjects.TextField.TEXT_ALIGN_CENTER?.5*-this._alignWidth:-this._alignWidth,y:0,w:this.width,h:this.height}]},this._tempDirty=!1,this.atlas.dirty=!0},c.prototype.render=function(){if(this.alpha>0&&this.visible){var b=this.game.stage.ctx;b.save();var c=this.transform;this.alpha>0&&this.alpha<=1&&(b.globalAlpha=this.alpha),this._tempDirty&&this._renderText();var d=0;switch(this._textAlign){case a.GameObjects.TextField.TEXT_ALIGN_LEFT:d=0;break;case a.GameObjects.TextField.TEXT_ALIGN_CENTER:d=.5*this._alignWidth;break;case a.GameObjects.TextField.TEXT_ALIGN_RIGHT:d=this._alignWidth}var e=c.getConcatenatedMatrix();b.transform(e.a,e.b,e.c,e.d,e.tx,e.ty),b.drawImage(this._canvas,0,0,this._canvas.width,this._canvas.height,-c.rotPointX-d,-c.rotPointY,this._canvas.width,this._canvas.height),b.restore()}},c.prototype.renderGL=function(b,c,d){void 0===d&&(d=null),this._tempDirty&&this._renderText();var e=[],f=this.transform,g=f.getConcatenatedMatrix(),h=0;switch(this._textAlign){case a.GameObjects.TextField.TEXT_ALIGN_LEFT:h=0;break;case a.GameObjects.TextField.TEXT_ALIGN_CENTER:h=-(.5*this._alignWidth);break;case a.GameObjects.TextField.TEXT_ALIGN_RIGHT:h=-this._alignWidth}this._pt1.setTo(h-f.rotPointX,0-f.rotPointY),this._pt2.setTo(this._canvas.width+h-f.rotPointX,0-f.rotPointY),this._pt3.setTo(this._canvas.width+h-f.rotPointX,this._canvas.height-f.rotPointY),this._pt4.setTo(h-f.rotPointX,this._canvas.height-f.rotPointY),g.transformPoint(this._pt1),g.transformPoint(this._pt2),g.transformPoint(this._pt3),g.transformPoint(this._pt4),e.push(this._pt1.x,this._pt1.y,0,0,this.alpha,this._pt2.x,this._pt2.y,this._canvas.width,0,this.alpha,this._pt3.x,this._pt3.y,this._canvas.width,this._canvas.height,this.alpha,this._pt4.x,this._pt4.y,0,this._canvas.height,this.alpha),this.glRenderer.concatBatch(e)},c.TEXT_ALIGN_CENTER="center",c.TEXT_ALIGN_RIGHT="right",c.TEXT_ALIGN_LEFT="left",c}(a.Entity);b.TextField=c,b.Textfield=a.GameObjects.TextField}(b=a.GameObjects||(a.GameObjects={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(){function b(b,c,d){void 0===d&&(d=-1),this.allowCollisions=a.Components.ArcadePhysics.NONE,this.properties={},this.tilemap=b,this.index=c,this.cellIndex=d,this.offset=new a.Geom.Point(0,0)
|
|
}return b.prototype.objType=function(){return"TileType"},b}();b.TileType=c}(c=b.Tilemap||(b.Tilemap={}))}(b=a.GameObjects||(a.GameObjects={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(){function c(b,c,d,e){void 0===e&&(e=0),this.tileWidth=0,this.tileHeight=0,this.width=0,this.height=0,this.properties={},this.tileTypes=[],this.createTileType(-1),this.layers=[],this.state=b,this.game=b.game,void 0!==c&&void 0!==d?this.createFromFileStore(c,d,e):(void 0!==c||void 0!==d)&&a.Log.warn("You must pass BOTH the TileMapDataKey and TextureAtlas inorder to create a TileMap from the File Store.","#tilemap")}return Object.defineProperty(c.prototype,"widthInPixels",{get:function(){return this.width*this.tileWidth},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"heightInPixels",{get:function(){return this.height*this.tileHeight},enumerable:!0,configurable:!0}),c.prototype.createFromFileStore=function(c,d,e){void 0===e&&(e=0);var f=null;switch(a.Utils.Common.isString(d)&&(d=this.state.textures[d]),typeof c){case"string":if(0==this.game.fileStore.exists(c))return a.Log.error("The JSON file you have told to use for a TileMap does not exist.","#tilemap","#json"),!1;f=JSON.parse(this.game.fileStore.getFile(c).data);break;case"object":f=c.isData&&c.dataType===a.Files.File.JSON?a.Utils.Common.isString(c.parse)?JSON.parse(c.data):c.data:c;break;default:a.Log.error("The type of TileMapData passed could not be idenified. Please either pass a name of JSON file to use OR an object to be used.","#tilemap")}this.orientation=void 0==f.orientation?b.ORTHOGONAL:f.orientation,this.tileWidth=void 0==f.tilewidth?32:f.tilewidth,this.tileHeight=void 0==f.tileheight?32:f.tileheight,this.width=f.width,this.height=f.height;for(var g in f.properties)this.properties[g]=f.properties[g];"undefined"!==f.tilesets&&-1!==e&&this._generateTypesFromTileset(f.tilesets,d,e);for(var h=0;h<f.layers.length;h++){var i=f.layers[h];switch(f.layers[h].type){case"tilelayer":var j=void 0!==i.width?i.width:this.width,k=void 0!==i.height?i.height:this.height,l=this.createNewLayer(i.name,d,i.data,j,k,i.x*this.tileWidth,i.y*this.tileHeight);l.visible=void 0==i.visible?!0:i.visible,l.alpha=void 0==i.opacity?1:i.opacity,void 0!==i.properties&&(l.properties=i.properties);break;case"objectgroup":this.createNewObjectLayer();break;case"imagelayer":this.createNewImageLayer()}}},c.prototype._generateTypesFromTileset=function(a,b,c){for(var d=0;d<a.length;d++){for(var e=a[d],f=e.margin,g=(e.spacing,e.tilewidth),h=e.tileheight,i=e.imagewidth-f,j=e.imageheight-f,k=void 0==e.tileoffset?{x:0,y:0}:e.tileoffset,l=f;j>l;l+=h)for(var m=f;i>m;m+=g){var n=void 0==b.cells[c]?-1:c,o=this.createTileType(n);o.offset.x=k.x,o.offset.y=k.y,c++}for(var p in e.tileproperties){var o=this.tileTypes[parseInt(e.firstgid)+parseInt(p)];o.properties=e.tileproperties[p]}}},c.prototype.setTo=function(a,b,c,d){this.tileWidth=a,this.tileHeight=b,this.width=c,this.height=d},c.prototype.createTileType=function(a){void 0===a&&(a=-1);var c=new b.TileType(this,this.tileTypes.length,a);return this.tileTypes.push(c),c},c.prototype.createTileTypes=function(a){for(var b=[],c=0;c<a.length;c++)b.push(this.createTileType(a[c]));return b},c.prototype.createTileTypesByRange=function(a,b){for(var c=[],d=a;a+b>=d;d++)c.push(this.createTileType(d));return c},c.prototype.setCell=function(a,b){this.tileTypes[a].cellIndex=b},c.prototype.setCellsByRange=function(a,b,c){for(var d=a;a+c>d;d++)this.tileTypes[d].cellIndex=b,b++},c.prototype.createNewLayer=function(c,d,e,f,g,h,i,j,k,l){if(void 0===e&&(e=[]),void 0===f&&(f=this.width),void 0===g&&(g=this.height),void 0===h&&(h=0),void 0===i&&(i=0),void 0===j&&(j=this.tileWidth),void 0===k&&(k=this.tileHeight),void 0===l&&(l=this.orientation),e.length<f*g)for(var m=e.length-1;++m<f*g;)e.push(0);var n;return n=l==b.ISOMETRIC?new a.GameObjects.Tilemap.TileMapLayerIsometric(this,c,d,e,j,k,h,i,f,g):new a.GameObjects.Tilemap.TileMapLayerOrthogonal(this,c,d,e,j,k,h,i,f,g),this.layers.push(n),n},c.prototype.createNewObjectLayer=function(){a.Log.log("OBJECT GROUP layers are currently not supported.","#tilemap")},c.prototype.createNewImageLayer=function(){a.Log.log("IMAGE layers are currently not supported.","#tilemap")},c.prototype.getLayerByName=function(a){for(var b=0;b<this.layers.length;b++)if(this.layers[b].name==a)return this.layers[b];return null},c.prototype.getLayer=function(a){return void 0!==this.layers[a]?this.layers[a]:null},c.prototype.objType=function(){return"TileMap"},c}();b.TileMap=c,b.ISOMETRIC="isometric",b.ORTHOGONAL="orthogonal"}(c=b.Tilemap||(b.Tilemap={}))}(b=a.GameObjects||(a.GameObjects={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(c,d,e,f,g,h,i,j,k,l){void 0===i&&(i=0),void 0===j&&(j=0),void 0===k&&(k=0),void 0===l&&(l=0),b.call(this,c.state,i,j),this.properties={},this.orientation=null,this.game.renderOption===a.RENDERER_WEBGL&&(this.glRenderer=this.game.renderer.requestSharedRenderer("TextureAtlasRenderer")),a.Utils.Common.isString(e)&&(e=this.state.textures[e]),this.name=d,this.atlas=e,this.tilemap=c,this._data=f,this.tileWidth=g,this.tileHeight=h,this.width=k,this.height=l,this._corner1=new a.Geom.Point(0,0),this._corner2=new a.Geom.Point(0,0),this._corner3=new a.Geom.Point(0,0),this._corner4=new a.Geom.Point(0,0),this.physics=this.components.add(new a.Components.ArcadePhysics(this,null)),this.physics.immovable=!0}return __extends(c,b),c.prototype.childType=function(){return a.TILE_LAYER},c.prototype.objType=function(){return"TileMapLayer"},Object.defineProperty(c.prototype,"widthInPixels",{get:function(){return this.width*this.tilemap.tileWidth},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"heightInPixels",{get:function(){return this.height*this.tilemap.tileHeight},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"cellIndex",{get:function(){return null},set:function(){},enumerable:!0,configurable:!0}),c.prototype.scaleToWidth=function(a){this.scale=a/this.widthInPixels},c.prototype.scaleToHeight=function(a){this.scale=a/this.heightInPixels},c.prototype.centerAnchorPoint=function(){this.anchorPointX=.5*this.widthInPixels,this.anchorPointY=.5*this.heightInPixels},Object.defineProperty(c.prototype,"data",{get:function(){return this._data},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"tileData",{get:function(){return this._data},enumerable:!0,configurable:!0}),c.prototype.countTiles=function(a){for(var b=0,c=0;c<this._data.length;c++)void 0==a&&0!==this._data[c]?b++:a===this._data[c]&&b++;return b},c.prototype.getIndexFromXY=function(a,b){var c=a+b*this.width;return 0>c||c>=this._data.length?-1:c},c.prototype.getTileFromXY=function(a,b){var c=this.getIndexFromXY(a,b);return-1!==c?this.tilemap.tileTypes[this._data[c]]:null},c.prototype.getIndexesByType=function(a){for(var b=[],c=0;c<this._data.length;c++)this._data[c]==a&&b.push(c);return b},c.prototype.getTileFromIndex=function(a){return-1!==a?this.tilemap.tileTypes[this._data[a]]:null},c.prototype.getIndexFromCoords=function(){return-1},c.prototype.getTileFromCoords=function(a,b){var c=this.getIndexFromCoords(a,b);return-1!==c?this.tilemap.tileTypes[this.data[c]]:null},c.prototype.setTile=function(a,b,c){var a=this.getIndexFromXY(a,b);return-1!==a?(this._data[a]=c,!0):!1},c.prototype.setTileByIndex=function(a,b){this._data[a]=b},c.prototype.randomizeTiles=function(a,b,c,d,e){if(void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=this.width),void 0===e&&(e=this.height),void 0==a){a=[];for(var f=0;f++<this.tilemap.tileTypes.length;)a.push(f)}for(var g=c;c+e>g;g++)for(var f=b;b+d>f;f++){var h=this.getIndexFromXY(f,g);-1!==h&&(this._data[h]=this.game.rnd.pick(a))}},c.prototype.fill=function(a,b,c,d,e){void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=this.width),void 0===e&&(e=this.height);for(var f=c;c+e>f;f++)for(var g=b;b+d>g;g++){var h=this.getIndexFromXY(g,f);-1!==h&&(this._data[h]=a)}},c.prototype.replaceTiles=function(a,b,c,d,e,f){void 0===c&&(c=0),void 0===d&&(d=0),void 0===e&&(e=this.width),void 0===f&&(f=this.height);for(var g=d;d+f>g;g++)for(var h=c;c+e>h;h++){var i=this.getIndexFromXY(h,g);-1!==i&&this._data[i]==a&&(this._data[i]=b)}},c.prototype.swapTiles=function(a,b,c,d,e,f){void 0===c&&(c=0),void 0===d&&(d=0),void 0===e&&(e=this.width),void 0===f&&(f=this.height);for(var g=d;d+f>g;g++)for(var h=c;c+e>h;h++){var i=this.getIndexFromXY(h,g);-1!==i&&(this._data[i]==a?this._data[i]=b:this._data[i]==b&&(this._data[i]=a))}},c.prototype.getOverlappingTiles=function(b,c){return void 0===c&&(c=a.Components.ArcadePhysics.ANY),[]},c.prototype.getCollidableTiles=function(b,c,d,e,f){void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=this.width),void 0===e&&(e=this.height),void 0===f&&(f=a.Components.ArcadePhysics.ANY);var g=[];if(!(b>this.width||c>this.height)){0>b&&(b=0),0>c&&(c=0),b+d>this.width&&(d=this.width-b),c+e>this.height&&(e=this.height-c);for(var h=c;c+e>h;h++)for(var i=b;b+d>i;i++){var j=this.getIndexFromXY(i,h);if(-1!==j){var k=this.tileData[j];(this.tilemap.tileTypes[k].allowCollisions&f)!==a.Components.ArcadePhysics.NONE&&g.push({index:j,type:k,x:i*this.tileWidth,y:h*this.tileHeight})}}return g}},c.prototype.update=function(){b.prototype.update.call(this)},c.prototype._calculateBoundaries=function(){this._startX=0,this._startY=0,this._maxX=this.width,this._maxY=this.height},c.prototype.render=function(){},c.prototype.renderGL=function(a,b,c){void 0===c&&(c=null)},c.prototype.chartToScreen=function(a,b,c){return void 0===b&&(b=this.tileWidth/2),void 0===c&&(c=this.tileHeight),{x:a.x*b-a.y*b,y:a.x*c/2+a.y*c/2}},c.prototype.screenToChart=function(a,b,c){void 0===b&&(b=this.tileWidth/2),void 0===c&&(c=this.tileHeight);var d=Math.floor(a.x/b),e=Math.floor((a.y-d*(c/2))/c);return{x:d+e,y:e}},c}(a.Entity);b.TileMapLayer=c}(c=b.Tilemap||(b.Tilemap={}))}(b=a.GameObjects||(a.GameObjects={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(c){function d(a,d,e,f,g,h,i,j,k,l){void 0===i&&(i=0),void 0===j&&(j=0),void 0===k&&(k=0),void 0===l&&(l=0),c.call(this,a,d,e,f,g,h,i,j,k,l),this.orientation=b.ORTHOGONAL}return __extends(d,c),d.prototype.objType=function(){return"TileMapLayer"},d.prototype.getIndexFromCoords=function(b,c){if(b>this.transform.worldX+this.widthInPixels||c>this.transform.worldY+this.heightInPixels||b<this.transform.worldX||c<this.transform.worldY)return-1;var d=a.Utils.GameMath.snapToFloor(b-this.transform.worldX,this.tileWidth)/this.tileWidth,e=a.Utils.GameMath.snapToFloor(c-this.transform.worldY,this.tileHeight)/this.tileHeight;return this.getIndexFromXY(d,e)},d.prototype.getOverlappingTiles=function(b,c){if(void 0===c&&(c=a.Components.ArcadePhysics.ANY),0==b.components.hasComponent("Box"))return[];var d=b.components.getComponent("Box").worldHitbox,e=this.transform.worldX,f=this.transform.worldY;if(d.left>e+this.widthInPixels||d.right<e||d.bottom<f||d.top>f+this.heightInPixels)return[];for(var g=d.x-e,h=d.y-f,i=a.Utils.GameMath.snapToFloor(g,this.tileWidth)/this.tileWidth,j=a.Utils.GameMath.snapToFloor(h,this.tileHeight)/this.tileHeight,k=a.Utils.GameMath.snapToCeil(d.width,this.tileWidth)/this.tileWidth,l=a.Utils.GameMath.snapToCeil(d.height,this.tileHeight)/this.tileHeight,m=this.getCollidableTiles(i,j,k+1,l+1,c),n=0;n<m.length;n++){var o=m[n];(o.x+e>d.right||o.x+this.tileWidth+e<d.left||o.y+f>d.bottom||o.y+this.tileHeight+f<d.top)&&(m.splice(n,1),n--)}return m},d.prototype._calculateBoundaries=function(b,c){this._corner1.setTo(0,0),this._corner2.setTo(this.game.stage.width,0),this._corner3.setTo(this.game.stage.width,this.game.stage.height),this._corner4.setTo(0,this.game.stage.height),this._corner1=b.transformPoint(this._corner1),this._corner2=b.transformPoint(this._corner2),this._corner3=b.transformPoint(this._corner3),this._corner4=b.transformPoint(this._corner4);var d=c.clone();d.invert(),this._corner1=d.transformPoint(this._corner1),this._corner2=d.transformPoint(this._corner2),this._corner3=d.transformPoint(this._corner3),this._corner4=d.transformPoint(this._corner4),this._startX=Math.min(this._corner1.x,this._corner2.x,this._corner3.x,this._corner4.x),this._startY=Math.min(this._corner1.y,this._corner2.y,this._corner3.y,this._corner4.y),this._maxX=Math.max(this._corner1.x,this._corner2.x,this._corner3.x,this._corner4.x),this._maxY=Math.max(this._corner1.y,this._corner2.y,this._corner3.y,this._corner4.y),this._startX/=this.tileWidth,this._startY/=this.tileHeight,this._maxX/=this.tileWidth,this._maxY/=this.tileHeight,this._startX=Math.floor(this._startX),this._startY=Math.floor(this._startY),this._maxX=Math.ceil(this._maxX),this._maxY=Math.ceil(this._maxY),this._startX=a.Utils.GameMath.clamp(this._startX,this.width),this._startY=a.Utils.GameMath.clamp(this._startY,this.height),this._maxX=a.Utils.GameMath.clamp(this._maxX,this.width),this._maxY=a.Utils.GameMath.clamp(this._maxY,this.height)},d.prototype.render=function(a){if(!(this.visible===!1||this.alpha<.1||this.exists===!1)){var b=this.game.stage.ctx;b.save(),this.alpha>0&&this.alpha<=1&&(b.globalAlpha=this.alpha);var c=this.transform,d=c.getConcatenatedMatrix();b.transform(d.a,d.b,d.c,d.d,d.tx,d.ty),this._calculateBoundaries(a,d);for(var e=this._startY;e<this._maxY;e++)for(var f=this._startX;f<this._maxX;f++)if((this._temptype=this.getTileFromXY(f,e))&&-1!==this._temptype.cellIndex){var g=this.atlas.cells[this._temptype.cellIndex],h=f*this.tileWidth+this._temptype.offset.x,i=e*this.tileHeight-(g.h-this.tileHeight)+this._temptype.offset.y;b.drawImage(this.atlas.image,g.x,g.y,g.w,g.h,h,i,g.w,g.h)}return b.restore(),!0}},d.prototype.renderGL=function(a,b,c){void 0===c&&(c=null);var d=[],e=this.transform,f=e.getConcatenatedMatrix();this._calculateBoundaries(b,f);for(var g=this._startY;g<this._maxY;g++)for(var h=this._startX;h<this._maxX;h++)if(this._temptype=this.getTileFromXY(h,g),-1!=this._temptype.cellIndex){var i=this.atlas.cells[this._temptype.cellIndex],j=h*this.tileWidth+this._temptype.offset.x,k=g*this.tileHeight+this._temptype.offset.y;this._corner1.setTo(j-e.rotPointX,k-e.rotPointY-(i.h-this.tileHeight)),this._corner2.setTo(j+i.w-e.rotPointX,k-e.rotPointY-(i.h-this.tileHeight)),this._corner3.setTo(j+i.w-e.rotPointX,k+i.h-e.rotPointY-(i.h-this.tileHeight)),this._corner4.setTo(j-e.rotPointX,k+i.h-e.rotPointY-(i.h-this.tileHeight)),f.transformPoint(this._corner1),f.transformPoint(this._corner2),f.transformPoint(this._corner3),f.transformPoint(this._corner4),d.push(this._corner1.x+e.rotPointX,this._corner1.y+e.rotPointY,i.x,i.y,this.alpha,this._corner2.x+e.rotPointX,this._corner2.y+e.rotPointY,i.x+i.w,i.y,this.alpha,this._corner3.x+e.rotPointX,this._corner3.y+e.rotPointY,i.x+i.w,i.y+i.h,this.alpha,this._corner4.x+e.rotPointX,this._corner4.y+e.rotPointY,i.x,i.y+i.h,this.alpha)}this.glRenderer.concatBatch(d)},d}(b.TileMapLayer);b.TileMapLayerOrthogonal=c}(c=b.Tilemap||(b.Tilemap={}))}(b=a.GameObjects||(a.GameObjects={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b=function(b){function c(c,d,e,f,g,h,i,j,k,l){void 0===i&&(i=0),void 0===j&&(j=0),void 0===k&&(k=0),void 0===l&&(l=0),b.call(this,c,d,e,f,g,h,i,j,k,l),this.orientation=a.ISOMETRIC}return __extends(c,b),c.prototype.objType=function(){return"TileMapLayer"},c.prototype.getIndexFromCoords=function(a,b){var c=.5*this.widthInPixels;if(a>this.x+c||a<this.x-c)return-1;if(b>this.y+this.heightInPixels||b<this.y)return-1;var d=this.screenToChart({x:a,y:b});return this.getIndexFromXY(d.x,d.y)},c.prototype.chartToScreen=function(a,b,c){return void 0===b&&(b=this.tileWidth),void 0===c&&(c=this.tileHeight),{x:(a.x-a.y)*b*.5,y:(a.x+a.y)*c*.5}},c.prototype.screenToChart=function(a,b,c){void 0===b&&(b=this.tileWidth),void 0===c&&(c=this.tileHeight);var d=Math.floor(a.x/(.5*b)),e=Math.floor((a.y-d*(c/2))/c);return{x:d+e,y:e}},c.prototype.render=function(a){if(!(this.visible===!1||this.alpha<.1||this.exists===!1)){var b=this.game.stage.ctx;b.save(),this.alpha>0&&this.alpha<=1&&(b.globalAlpha=this.alpha);var c=this.transform,d=c.getConcatenatedMatrix();b.transform(d.a,d.b,d.c,d.d,d.tx,d.ty),this._calculateBoundaries(a,d);for(var e=this._startY;e<this._maxY;e++)for(var f=this._startX;f<this._maxX;f++)if((this._temptype=this.getTileFromXY(f,e))&&-1!==this._temptype.cellIndex){var g=this.atlas.cells[this._temptype.cellIndex],h=(this._temptype.offset.x,this._temptype.offset.y,this.tileWidth*(2*this.width-1),this.tileHeight*this.height,this.tileWidth/2),i=this.chartToScreen({x:f,y:e},this.tileWidth,this.tileHeight),j=i.x+this._temptype.offset.x-h,k=i.y-(g.h-this.tileHeight)+this._temptype.offset.y;b.drawImage(this.atlas.image,g.x,g.y,g.w,g.h,j,k,g.w,g.h)}return b.restore(),!0}},c.prototype.renderGL=function(a,b,c){void 0===c&&(c=null);var d=[],e=this.transform,f=e.getConcatenatedMatrix();this._calculateBoundaries(b,f);for(var g=this._startY;g<this._maxY;g++)for(var h=this._startX;h<this._maxX;h++)if(this._temptype=this.getTileFromXY(h,g),-1!=this._temptype.cellIndex){var i=this.atlas.cells[this._temptype.cellIndex],j=(this._temptype.offset.x,this._temptype.offset.y,this.tileWidth*(2*this.width-1),this.tileHeight*this.height,this.tileWidth/2),k=this.chartToScreen({x:h,y:g},this.tileWidth,this.tileHeight),l=k.x+this._temptype.offset.x-j,m=k.y+this._temptype.offset.y;this._corner1.setTo(l-e.rotPointX,m-e.rotPointY-(i.h-this.tileHeight)),this._corner2.setTo(l+i.w-e.rotPointX,m-e.rotPointY-(i.h-this.tileHeight)),this._corner3.setTo(l+i.w-e.rotPointX,m+i.h-e.rotPointY-(i.h-this.tileHeight)),this._corner4.setTo(l-e.rotPointX,m+i.h-e.rotPointY-(i.h-this.tileHeight)),f.transformPoint(this._corner1),f.transformPoint(this._corner2),f.transformPoint(this._corner3),f.transformPoint(this._corner4),d.push(this._corner1.x+e.rotPointX,this._corner1.y+e.rotPointY,i.x,i.y,this.alpha,this._corner2.x+e.rotPointX,this._corner2.y+e.rotPointY,i.x+i.w,i.y,this.alpha,this._corner3.x+e.rotPointX,this._corner3.y+e.rotPointY,i.x+i.w,i.y+i.h,this.alpha,this._corner4.x+e.rotPointX,this._corner4.y+e.rotPointY,i.x,i.y+i.h,this.alpha)}this.glRenderer.concatBatch(d)},c}(a.TileMapLayer);a.TileMapLayerIsometric=b}(b=a.Tilemap||(a.Tilemap={}))}(b=a.GameObjects||(a.GameObjects={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(c,d){if(void 0===d&&(d=!0),b.call(this,c,"Animation"),this.currentAnimation=null,this.entity=c,this._atlas=this.entity.atlas,this._animations={},1==d)for(var e=0;e<this._atlas.sequences.length;e++)this.createFromSequence(this._atlas.sequences[e],!1);if(this._animations["default"])this.currentAnimation=this._animations["default"];else{for(var f=[],e=0;e<this._atlas.cells.length;e++)f.push(e);this.currentAnimation=this.add("default",f,.1,!0,!1)}this.onChange=new a.Signal,this.onPlay=new a.Signal,this.onStop=new a.Signal,this.onUpdate=new a.Signal}return __extends(c,b),Object.defineProperty(c.prototype,"isPlaying",{get:function(){return this.currentAnimation.isPlaying},enumerable:!0,configurable:!0}),c.prototype.objType=function(){return"AnimationManager"},c.prototype.add=function(b,c,d,e,f,g){void 0===e&&(e=!1),void 0===f&&(f=!1),void 0===g&&(g=!0);var h=new a.Animations.Sequence(b,c,d,e);return 1==g&&this._atlas.sequences.push(h),this.createFromSequence(h,f)},c.prototype.createFromSequence=function(b,c){return void 0===c&&(c=!1),this._animations[b.name]=new a.Animations.Animation(b.name,b,null,this),c&&this.play(b.name),this._animations[b.name]},c.prototype.play=function(a,b){return void 0===a&&(a=this.currentAnimation.name),void 0===b&&(b=!0),0==b&&this.currentAnimation.name===a&&1==this.currentAnimation.isPlaying?this.currentAnimation:this._play(a)},c.prototype.playAt=function(a,b){return void 0===b&&(b=this.currentAnimation.name),this._play(b,a)},c.prototype._play=function(a,b){return void 0===b&&(b=null),this._setCurrentAnimation(a),null!==b?this.currentAnimation.playAt(b):this.currentAnimation.play(),this.onPlay.dispatch(this.currentAnimation),this.updateCellIndex(),this.currentAnimation},c.prototype.stop=function(){this.isPlaying===!0&&(this.currentAnimation.stop(),this.onStop.dispatch(this.currentAnimation))},c.prototype.pause=function(){this.currentAnimation.pause()},c.prototype.resume=function(){this.currentAnimation.resume()},c.prototype.switchTo=function(a,b){void 0===b&&(b=null);var c=!1;switch(typeof a){case"string":this.currentAnimation.name!==a&&(this._setCurrentAnimation(a),c=!0);break;case"number":this.currentAnimation.frameIndex=a,c=!0}(b||null===b&&this.isPlaying&&c)&&this.play(),0==b&&this.isPlaying&&this.stop(),this.updateCellIndex()},c.prototype.nextFrame=function(){this.currentAnimation.nextFrame(),this.updateCellIndex()},c.prototype.prevFrame=function(){this.currentAnimation.prevFrame(),this.updateCellIndex()},c.prototype._setCurrentAnimation=function(a,b){if(void 0===b&&(b=!0),this.currentAnimation.name!==a)if(null!==this.currentAnimation&&this.currentAnimation.stop(),this._animations[a])this.currentAnimation=this._animations[a],this.onChange.dispatch(a,this.currentAnimation);else if(b)for(var c=0;c<this._atlas.sequences.length;c++)this._atlas.sequences[c].name===a&&(this.currentAnimation=this.createFromSequence(this._atlas.sequences[c],!1),this.onChange.dispatch(a,this.currentAnimation))},c.prototype.update=function(){this.currentAnimation&&this.currentAnimation.update()},Object.defineProperty(c.prototype,"currentCell",{get:function(){return this.currentAnimation.currentCell},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"frameIndex",{get:function(){return this.currentAnimation.frameIndex},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"length",{get:function(){return this.currentAnimation.length},enumerable:!0,configurable:!0}),c.prototype.getAnimation=function(a){return this._animations[a]},c.prototype.updateCellIndex=function(){"undefined"!=typeof this.currentAnimation&&(this.entity.cellIndex=this.currentAnimation.currentCell,this.onUpdate.dispatch(this.currentAnimation))},c.prototype.destroy=function(){b.prototype.destroy.call(this);for(var a in this._animations)this._animations[a].destroy(),delete this._animations[a];delete this._animations,delete this.currentAnimation,delete this._atlas},c}(a.Component);b.AnimationManager=c}(b=a.Components||(a.Components={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(c,d,e,f,g){void 0===d&&(d=0),void 0===e&&(e=0),void 0===f&&(f=0),void 0===g&&(g=0),b.call(this,c,"Box"),this.autoUpdate=!0,this.entity=c,this._rawBounds=new a.Geom.Rectangle(d,e,f,g),this._rawCenter=new a.Geom.Point(d+f/2,e+g/2),this._rawHitbox=new a.Geom.Rectangle,this._hitboxOffset=new a.Geom.Point,this.hitbox=new a.Geom.Rectangle(0,0,f,g),this.autoUpdate=!0,this._scratchMatrix=new a.Geom.Matrix}return __extends(c,b),c.prototype.objType=function(){return"Box"},Object.defineProperty(c.prototype,"hitboxOffset",{get:function(){return 1==this.autoUpdate&&null!==this.entity.atlas&&this.entity.atlas.cells&&this.entity.atlas.cells[0].hitboxes&&(this._hitboxOffset.x=this.entity.atlas.cells[this.entity.cellIndex].hitboxes[0].x||0,this._hitboxOffset.y=this.entity.atlas.cells[this.entity.cellIndex].hitboxes[0].y||0),this._hitboxOffset},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"rawHitbox",{get:function(){if(this._rawHitbox.x=this.rawBounds.x+this.hitboxOffset.x,this._rawHitbox.y=this.rawBounds.y+this.hitboxOffset.y,1==this.autoUpdate){var a=this.entity.atlas;null!==a&&a.cells&&a.cells[0].hitboxes?(this._rawHitbox.width=a.cells[this.entity.cellIndex].hitboxes[0].w,this._rawHitbox.height=a.cells[this.entity.cellIndex].hitboxes[0].h):(this._rawHitbox.width=this.entity.width,this._rawHitbox.height=this.entity.height)}return this._rawHitbox},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"hitbox",{get:function(){return this._transformedHitbox=this._rotateHitbox(this.rawHitbox.clone()),this._transformedHitbox},set:function(a){this._hitboxOffset.x=a.x,this._hitboxOffset.y=a.y,this._rawHitbox=a,this._rawHitbox.x+=this._rawBounds.x,this._rawHitbox.y+=this._rawBounds.y,this.autoUpdate=!1},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"worldHitbox",{get:function(){return this._worldHitbox=this._rotateHitbox(this.rawHitbox.clone(),!0),this._worldHitbox},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"rawBounds",{get:function(){return this._rawBounds.x=this.entity.x,this._rawBounds.y=this.entity.y,this._rawBounds.width=this.entity.width,this._rawBounds.height=this.entity.height,this._rawBounds},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"rawCenter",{get:function(){return this._rawCenter.x=this.rawBounds.x+this.rawBounds.width/2,this._rawCenter.y=this.rawBounds.y+this.rawBounds.height/2,this._rawCenter},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"center",{get:function(){var b=this.entity.transform.getConcatenatedMatrix();return this._transformedCenter=b.transformPoint(new a.Geom.Point(this.entity.width/2-this.entity.anchorPointX,this.entity.height/2-this.entity.anchorPointY)),this._transformedCenter},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"bounds",{get:function(){return this._transformedBounds=this._rotateRect(this.rawBounds.clone()),this._transformedBounds},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"worldBounds",{get:function(){return this._worldBounds=this._rotateRect(this.rawBounds.clone(),!0),this._worldBounds},enumerable:!0,configurable:!0}),c.prototype._rotateRect=function(b,c){void 0===c&&(c=!1);var d=new a.Geom.Rectangle,e=this.entity.transform,f=this._scratchMatrix.copyFrom(e.getConcatenatedMatrix());return c||f.setTo(f.a,f.b,f.c,f.d,e.x+e.rotPointX,e.y+e.rotPointY),d=this.extents(f.transformPoint({x:-e.rotPointX,y:-e.rotPointY}),f.transformPoint({x:-e.rotPointX+b.width,y:-e.rotPointY}),f.transformPoint({x:-e.rotPointX+b.width,y:-e.rotPointY+b.height}),f.transformPoint({x:-e.rotPointX,y:-e.rotPointY+b.height}))},c.prototype._rotateHitbox=function(b,c){void 0===c&&(c=!1);var d=new a.Geom.Rectangle,e=this.entity.transform,f=this._scratchMatrix.copyFrom(e.getConcatenatedMatrix());return c||f.setTo(f.a,f.b,f.c,f.d,e.x+e.rotPointX,e.y+e.rotPointY),d=this.extents(f.transformPoint({x:-e.rotPointX+this._hitboxOffset.x,y:-e.rotPointY+this._hitboxOffset.y}),f.transformPoint({x:-e.rotPointX+b.width+this._hitboxOffset.x,y:-e.rotPointY+this._hitboxOffset.y}),f.transformPoint({x:-e.rotPointX+b.width+this._hitboxOffset.x,y:-e.rotPointY+b.height+this._hitboxOffset.y}),f.transformPoint({x:-e.rotPointX+this._hitboxOffset.x,y:-e.rotPointY+b.height+this._hitboxOffset.y}))},c.prototype.draw=function(a,b){void 0===b&&(b=this.game.cameras.defaultCamera);var c=this.entity.transform,d=b.transform;a.strokeStyle="red",a.fillRect(this.rawCenter.x+d.x-1,this.rawCenter.y+d.y-1,3,3),a.strokeRect(c.x+d.x+c.rotPointX-3,c.y+d.y+c.rotPointY-3,7,7),a.strokeStyle="blue",a.strokeRect(this.bounds.x+d.x,this.bounds.y+d.y,this.bounds.width,this.bounds.height),a.strokeStyle="green",a.strokeRect(this.hitbox.x+d.x,this.hitbox.y+d.y,this.hitbox.width,this.hitbox.height),a.strokeStyle="white",a.strokeRect(this.rawHitbox.x+d.x,this.rawHitbox.y+d.y,this.rawHitbox.width,this.rawHitbox.height),a.strokeStyle="purple",a.strokeRect(this.worldBounds.x,this.worldBounds.y,this.worldBounds.width,this.worldBounds.height),a.strokeStyle="cyan",a.strokeRect(this.worldHitbox.x,this.worldHitbox.y,this.worldHitbox.width,this.worldHitbox.height)},c.prototype.extents=function(b,c,d,e){var f=Math.min(b.x,c.x,d.x,e.x),g=Math.max(b.x,c.x,d.x,e.x),h=Math.min(b.y,c.y,d.y,e.y),i=Math.max(b.y,c.y,d.y,e.y);return new a.Geom.Rectangle(f,h,g-f,i-h)},c.prototype.destroy=function(){b.prototype.destroy.call(this),delete this.entity},c}(a.Component);b.Box=c}(b=a.Components||(a.Components={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(c,d,e){void 0===e&&(e=!1),b.call(this,c,"Input"),this._isDragging=null,this._dragEnabled=!1,this._dragSnapToCenter=!1,this._nowDown=null,this._nowUp=null,this._nowEntered=null,this._nowLeft=null,this._nowDragging=null,this._onEntered=new a.Signal,this._onLeft=new a.Signal,this._onDown=new a.Signal,this._onUp=new a.Signal,this._onDragStarted=new a.Signal,this._onDragStopped=new a.Signal,this._box=d,this._distance=new a.Geom.Point,this._withinBounds=null,this._outsideBounds=!0,this._isUp=!0,this._isDown=null,this._isDragging=null,this._justEntered=!1,this._tempDragDisabled=!1,this._tempPoint=new a.Geom.Point,this._tempCircle=new a.Geom.Circle(0,0,0),this.enabled=e}return __extends(c,b),c.prototype.objType=function(){return"Input"},Object.defineProperty(c.prototype,"onEntered",{get:function(){return 0==this.enabled&&(this.enabled=!0),this._onEntered},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"onLeft",{get:function(){return 0==this.enabled&&(this.enabled=!0),this._onLeft},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"onDown",{get:function(){return 0==this.enabled&&(this.enabled=!0),this._onDown},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"onUp",{get:function(){return 0==this.enabled&&(this.enabled=!0),this._onUp},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"onDragStarted",{get:function(){return this._onDragStarted},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"onDragStopped",{get:function(){return this._onDragStopped},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"onRelease",{get:function(){return this.onUp},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"onPress",{get:function(){return this.onDown},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"enabled",{get:function(){return this._enabled},set:function(a){this._enabled=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"isDown",{get:function(){return null!==this._isDown},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"isUp",{get:function(){return this._isUp},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"withinBounds",{get:function(){return null!==this._withinBounds},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"outsideBounds",{get:function(){return this._outsideBounds},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"isDragging",{get:function(){return null!==this._isDragging},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"dragDistance",{get:function(){return this._dragDistance},set:function(a){this._dragDistance=a},enumerable:!0,configurable:!0}),c.prototype.enableDrag=function(a,b){void 0===a&&(a=!1),void 0===b&&(b=1),0==this.enabled&&(this.enabled=!0),this._dragEnabled=!0,this._dragSnapToCenter=a,this._dragDistance=b,this._isDragging=null},c.prototype.disableDrag=function(){this._dragEnabled=!1,this._isDragging=null},c.prototype.update=function(){this.enabled!==!1&&this.game&&this.owner.active!==!1&&(this._nowDown=null,this._nowUp=null,this._nowEntered=null,this._nowLeft=null,this._nowDragging=null,a.DEVICE.touch?this._updateTouch():this._updateMouse(),this.isDragging&&(this._tempPoint=this.game.cameras.defaultCamera.transformPoint(this._isDragging.point),this._dragSnapToCenter===!1?(this.owner.transform.x=a.Utils.GameMath.snapTo(this._tempPoint.x-this._box.hitboxOffset.x-this._distance.x,this._dragDistance),this.owner.transform.y=a.Utils.GameMath.snapTo(this._tempPoint.y-this._box.hitboxOffset.y-this._distance.y,this._dragDistance)):(this.owner.transform.x=a.Utils.GameMath.snapTo(this._tempPoint.x-this._box.hitboxOffset.x-this._box.worldHitbox.width/2,this._dragDistance),this.owner.transform.y=a.Utils.GameMath.snapTo(this._tempPoint.y-this._box.hitboxOffset.y-this._box.worldHitbox.height/2,this._dragDistance))))},c.prototype._updateTouch=function(){for(var a=0;a<this.game.input.touch.maximumPointers;a++)this.game.input.touch.fingers[a].active===!0?this._evaluateTouchPointer(this.game.input.touch.fingers[a]):this.isDown===!0&&this._isDown.id===this.game.input.touch.fingers[a].id?this._nowUp=this.game.input.touch.fingers[a]:this.isDown===!1&&null===this._nowUp&&this.withinBounds===!0&&this._withinBounds.id===this.game.input.touch.fingers[a].id&&(this._nowUp=this.game.input.touch.fingers[a]);
|
|
null!==this._nowEntered&&this.withinBounds===!1&&(this._withinBounds=this._nowEntered,this._outsideBounds=!1,this._onEntered.dispatch(this.owner,this._nowEntered)),null!==this._nowLeft&&this.withinBounds===!0&&(this._withinBounds=null,this._outsideBounds=!0,this._onLeft.dispatch(this.owner,this._nowLeft)),null!==this._nowDown&&this.isDown===!1&&(this._onDown.dispatch(this.owner,this._nowDown),this._isDown=this._nowDown,this._isUp=!1,this._withinBounds=this._nowDown,this._outsideBounds=!1),1==this._dragEnabled&&this.isDragging===!1&&null!==this._nowDragging&&(this._onDragStarted.dispatch(this.owner,this._nowDragging),this._isDragging=this._nowDragging),null!==this._nowUp&&(this._onUp.dispatch(this.owner,this._nowUp),this._isDown=null,this._isUp=!0,this._withinBounds=null,this._outsideBounds=!0,this.isDragging===!0&&this._isDragging.id==this._nowUp.id&&(this._isDragging=null,this._onDragStopped.dispatch(this.owner,this._nowUp)))},c.prototype._evaluateTouchPointer=function(b){(this.isDown===!1||this._isDown.id===b.id)&&(this._tempPoint=this.game.cameras.defaultCamera.transformPoint(b.point),this._tempCircle.setTo(this._tempPoint.x,this._tempPoint.y,b.circle.diameter),a.Geom.Intersect.circleToRectangle(this._tempCircle,this._box.worldHitbox).result?((this.isDown===!0&&this._isDown.id===b.id||this.isDown===!1&&b.duration>1)&&(this._nowEntered=b),this.isDown===!1&&b.frameDuration<2&&(this._nowDown=b),this._dragEnabled&&0==this.isDragging&&1==this.isDown&&(this._distance.x=this._tempPoint.x-this._box.worldHitbox.left,this._distance.y=this._tempPoint.y-this._box.worldHitbox.top,this._nowDragging=b)):this.isDown===!0?this._nowLeft=b:this.withinBounds===!0&&this._withinBounds.id==b.id&&(this._nowLeft=b))},c.prototype._updateMouse=function(){this._evaluateMousePointer(this.game.input.mouse.cursor),null!==this._nowLeft&&this._onLeft.dispatch(this.owner,this._nowLeft),null!==this._nowEntered&&this._onEntered.dispatch(this.owner,this._nowEntered),null!==this._nowDown&&this.isDown===!1&&(this._onDown.dispatch(this.owner,this._nowDown),this._isDown=this._nowDown,this._isUp=!1),1==this._dragEnabled&&this.isDragging===!1&&null!==this._nowDragging&&(this._onDragStarted.dispatch(this.owner,this._nowDragging),this._isDragging=this._nowDragging),this.isDown===!0&&null!==this._nowUp&&this._isDown.id===this._nowUp.id&&(this._onUp.dispatch(this.owner,this._nowUp),this.isDragging===!0&&this._isDragging.id==this._nowUp.id&&(this._isDragging=null,this._onDragStopped.dispatch(this.owner,this._nowUp)),this._isDown=null,this._isUp=!0)},c.prototype._evaluateMousePointer=function(b){this._tempPoint=this.game.cameras.defaultCamera.transformPoint(b.point),a.Geom.Intersect.pointToRectangle(this._tempPoint,this._box.worldHitbox).result?(this._dragEnabled&&this.isDragging===!1&&(this._distance.x=this._tempPoint.x-this._box.worldHitbox.left,this._distance.y=this._tempPoint.y-this._box.worldHitbox.top),this.withinBounds===!1&&(this._nowEntered=b,this._withinBounds=b,this._outsideBounds=!1,this._justEntered=!0)):this.withinBounds===!0&&this.isDragging===!1&&(this._nowLeft=b,this._withinBounds=null,this._outsideBounds=!0),b.isDown===!0?(this._justEntered&&(this._isDown=b,this._isUp=!1,this._tempDragDisabled=!0),this.withinBounds===!0&&this.isDown===!1&&null===this._nowDown&&(this._nowDown=b),this._dragEnabled===!0&&0==this.isDragging&&this._tempDragDisabled===!1&&1==this.isDown&&(this._nowDragging=b)):(this._tempDragDisabled===!0&&(this._tempDragDisabled=!1),this.isDown===!0&&(this._nowUp=b)),this._justEntered&&(this._justEntered=!1)},c.prototype.destroy=function(){b.prototype.destroy.call(this),this.enabled=!1,delete this._box,delete this._isDown,delete this._isUp,delete this._isDragging,delete this._dragEnabled,this._onDown&&this._onDown.dispose(),delete this._onDown,this._onDragStarted&&this._onDragStarted.dispose(),delete this._onDragStarted,this._onUp&&this._onUp.dispose(),delete this._onUp,this._onLeft&&this._onLeft.dispose(),delete this._onLeft,this._onEntered&&this._onEntered.dispose(),delete this._onEntered,this._onDragStopped&&this._onDragStopped.dispose(),delete this._onDragStopped,delete this._dragDistance},c}(a.Component);b.Input=c}(b=a.Components||(a.Components={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(a){function b(b){a.call(this,b,"Sound"),this._audio=[]}return __extends(b,a),b.prototype.objType=function(){return"Sound"},b.prototype.addSound=function(a,b,c,d){if(void 0===c&&(c=1),void 0===d&&(d=!1),1!=this._validate(a)){var e=this.game.audio.add(b,c,d);return this._audio[a]=e,e}},b.prototype.removeSound=function(a){0!=this._validate(a)&&(this._audio[a].stop(),this._audio[a].destroy(),delete this._audio[a])},b.prototype.getSound=function(a){return 0!=this._validate(a)?this._audio[a]:void 0},b.prototype._validate=function(a){return void 0===this._audio[a]?!1:!0},b.prototype.play=function(a){0!=this._validate(a)&&this._audio[a].play()},b.prototype.stop=function(a){0!=this._validate(a)&&this._audio[a].stop()},b.prototype.pause=function(a){0!=this._validate(a)&&this._audio[a].pause()},b.prototype.resume=function(a){0!=this._validate(a)&&this._audio[a].resume()},b.prototype.destroy=function(){a.prototype.destroy.call(this);for(var b in this._audio)this._audio[b].stop(),this._audio[b].destroy(),delete this._audio[b];delete this._audio},b}(a.Component);b.Sound=c}(b=a.Components||(a.Components={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(d,e){b.call(this,d,"ArcadePhysics"),this._callbackFunction=null,this._callbackContext=null,this.parent=d,this.box=e,this.transform=this.parent.transform,this.last=new a.Geom.Point(this.transform.worldX,this.transform.worldY),this.mass=1,this.elasticity=0,this.immovable=!1,this.moves=!0,this.touching=c.NONE,this.wasTouching=c.NONE,this.allowCollisions=c.ANY,this.velocity=new a.Geom.Point,this.acceleration=new a.Geom.Point,this.drag=new a.Geom.Point,this.maxVelocity=new a.Geom.Point(1e4,1e4),this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e4}return __extends(c,b),c.prototype.isTouching=function(a){return(this.touching&a)==a},c.prototype.solid=function(a){return void 0!==a&&(this.allowCollisions=a?c.ANY:c.NONE),(this.allowCollisions&c.ANY)>c.NONE},c.prototype.setCallback=function(a,b){this._callbackFunction=a,this._callbackContext=b},c.prototype.rotateToVelocity=function(){var a=Math.atan2(this.velocity.y,this.velocity.x);return this.transform.rotation=a,a},c.separate=function(a,b){var c=this.separateX(a,b),d=this.separateY(a,b);return c||d},c.separateX=function(b,d){var e=b.components.getComponent("ArcadePhysics"),f=d.components.getComponent("ArcadePhysics");if(e.immovable&&f.immovable)return!1;var g=0,h=e.transform.worldX-e.last.x,i=f.transform.worldX-f.last.x;if(h==i)return!1;var j=h>0?h:-h,k=i>0?i:-i,l=e.box.worldHitbox,m=f.box.worldHitbox,n=new a.Geom.Rectangle(l.x-(h>0?h:0),e.last.y+e.box.hitboxOffset.y,l.width+(h>0?h:-h),l.height),o=new a.Geom.Rectangle(m.x-(i>0?i:0),f.last.y+f.box.hitboxOffset.y,m.width+(i>0?i:-i),m.height);if(n.x+n.width>o.x&&n.x<o.x+o.width&&n.y+n.height>o.y&&n.y<o.y+o.height){var p=j+k+c.OVERLAP_BIAS;h>i?(g=l.x+l.width-m.x,!(g>p)&&e.allowCollisions&c.RIGHT&&f.allowCollisions&c.LEFT?(e.touching|=c.RIGHT,f.touching|=c.LEFT):g=0):(g=l.x-m.width-m.x,!(-g>p)&&e.allowCollisions&c.LEFT&&f.allowCollisions&c.RIGHT?(e.touching|=c.LEFT,f.touching|=c.RIGHT):g=0)}if(0!=g){var q=e.velocity.x,r=f.velocity.x;if(e.immovable||f.immovable)e.immovable?f.immovable||(f.transform.x=f.transform.x+g,f.velocity.x=q-r*f.elasticity):(e.transform.x=e.transform.x-g,e.velocity.x=r-q*e.elasticity);else{g*=.5,e.transform.x=e.transform.x-g,f.transform.x=f.transform.x+g;var s=Math.sqrt(r*r*f.mass/e.mass)*(r>0?1:-1),t=Math.sqrt(q*q*e.mass/f.mass)*(q>0?1:-1),u=.5*(s+t);s-=u,t-=u,e.velocity.x=u+s*e.elasticity,f.velocity.x=u+t*f.elasticity}return!0}return!1},c.separateY=function(b,d){var e=b.components.getComponent("ArcadePhysics"),f=d.components.getComponent("ArcadePhysics");if(e.immovable&&f.immovable)return!1;var g=0,h=e.transform.worldY-e.last.y,i=f.transform.worldY-f.last.y;if(h==i)return!1;var j=h>0?h:-h,k=i>0?i:-i,l=e.box.worldHitbox,m=f.box.worldHitbox,n=new a.Geom.Rectangle(l.x,l.y-(h>0?h:0),l.width,l.height+j),o=new a.Geom.Rectangle(m.x,m.y-(i>0?i:0),m.width,m.height+k);if(n.x+n.width>o.x&&n.x<o.x+o.width&&n.y+n.height>o.y&&n.y<o.y+o.height){var p=j+k+c.OVERLAP_BIAS;if(h>i?(g=l.y+l.height-m.y,!(g>p)&&e.allowCollisions&c.DOWN&&f.allowCollisions&c.UP?(e.touching|=c.DOWN,f.touching|=c.UP):g=0):(g=l.y-m.height-m.y,!(-g>p)&&e.allowCollisions&c.UP&&f.allowCollisions&c.DOWN?(e.touching|=c.UP,f.touching|=c.DOWN):g=0),0!=g){var q=e.velocity.y,r=f.velocity.y;if(e.immovable||f.immovable)e.immovable?f.immovable||(f.transform.y=f.transform.y+g,f.velocity.y=q-r*f.elasticity,b.active&&e.moves&&i>h&&(f.transform.x=f.transform.worldX+b.transform.worldX-e.last.x)):(e.transform.y=e.transform.y-g,e.velocity.y=r-q*e.elasticity,d.active&&f.moves&&h>i&&(e.transform.x=e.transform.worldX+d.transform.worldX-f.last.x));else{g*=.5,e.transform.y=e.transform.y-g,f.transform.y=f.transform.y+g;var s=Math.sqrt(r*r*f.mass/e.mass)*(r>0?1:-1),t=Math.sqrt(q*q*e.mass/f.mass)*(q>0?1:-1),u=.5*(s+t);s-=u,t-=u,e.velocity.y=u+s*e.elasticity,f.velocity.y=u+t*f.elasticity}return!0}}return!1},c.separateTiles=function(a,b,c){if(0==a.components.hasComponent("ArcadePhysics"))return!1;if(a.components.getComponent("ArcadePhysics").immovable)return!1;for(var d=!1,e=!1,f=0;f<c.length;f++){var g=c[f];d||(d=this.separateTilesX(a,b,g)),e||(e=this.separateTilesY(a,b,g))}return d||e},c.separateTilesX=function(b,d,e){var f=b.components.getComponent("ArcadePhysics"),g=d.components.getComponent("ArcadePhysics"),h=f.transform.worldX-f.last.x,i=g.transform.worldX-g.last.x;if(h==i)return!1;var j=h>0?h:-h,k=i>0?i:-i,l=0,m=j+k+c.OVERLAP_BIAS,n=f.box.worldHitbox,o=d.tilemap.tileTypes,p=d.tileData,q=g.transform.worldX+e.x,r=new a.Geom.Rectangle(n.x-(h>0?h:0),f.last.y+f.box.hitboxOffset.y,n.width+(h>0?h:-h),n.height),s=new a.Geom.Rectangle(q-(i>0?i:0),g.last.y+e.y,d.tileWidth+(i>0?i:-i),d.tileHeight);if(r.x+r.width>s.x&&r.x<s.x+s.width&&r.y-1+r.height>s.y&&r.y-1<s.y+s.height&&(h>i?(l=n.x+n.width-q,!(l>m)&&f.allowCollisions&c.RIGHT&&o[p[e.index]].allowCollisions&c.LEFT?f.touching|=c.RIGHT:l=0):(l=n.x-d.tileWidth-q,!(-l>m)&&f.allowCollisions&c.LEFT&&o[p[e.index]].allowCollisions&c.RIGHT?f.touching|=c.LEFT:l=0),0!=l)){var t=f.velocity.x,u=g.velocity.x;return f.transform.x=f.transform.x-l,f.velocity.x=u-t*f.elasticity,!0}return!1},c.separateTilesY=function(b,d,e){var f=b.components.getComponent("ArcadePhysics"),g=d.components.getComponent("ArcadePhysics"),h=f.transform.worldY-f.last.y,i=g.transform.worldY-g.last.y;if(h==i)return!1;var j=h>0?h:-h,k=i>0?i:-i,l=0,m=j+k+c.OVERLAP_BIAS,n=f.box.worldHitbox,o=d.tilemap.tileTypes,p=d.tileData,q=d.transform.worldY+e.y,r=new a.Geom.Rectangle(n.x,n.y-(h>0?h:0),n.width,n.height+j),s=new a.Geom.Rectangle(g.transform.worldX+e.x,q-(i>0?i:0),d.tileWidth,d.tileHeight+k);if(r.x+r.width>s.x&&r.x<s.x+s.width&&r.y+r.height>s.y&&r.y<s.y+s.height&&(h>i?(l=n.y+n.height-q,!(l>m)&&f.allowCollisions&c.DOWN&&o[p[e.index]].allowCollisions&c.UP?f.touching|=c.DOWN:l=0):(l=n.y-d.tileHeight-q,!(-l>m)&&f.allowCollisions&c.UP&&o[p[e.index]].allowCollisions&c.DOWN?f.touching|=c.UP:l=0),0!=l)){var t=f.velocity.y,u=g.velocity.y;return f.transform.y=f.transform.y-l,f.velocity.y=u-t*f.elasticity,!0}return!1},c.prototype.overlapsTiles=function(b,d,e){if(void 0===d&&(d=!1),void 0===e&&(e=a.Components.ArcadePhysics.ANY),this.parent.childType()!==a.TILE_LAYER)return!1;var f=this.parent.getOverlappingTiles(b,e);return f.length>0?(d&&c.separateTiles(b,this.parent,f),!0):!1},c.prototype.overlaps=function(a,b){if(void 0===b&&(b=!1),0!=a.components.hasComponent("Box")){var d=a.components.getComponent("Box"),e=d.worldHitbox.x+d.worldHitbox.width>this.box.worldHitbox.x&&d.worldHitbox.x<this.box.worldHitbox.x+this.box.worldHitbox.width&&d.worldHitbox.y+d.worldHitbox.height>this.box.worldHitbox.y&&d.worldHitbox.y<this.box.worldHitbox.y+this.box.worldHitbox.height;return e&&(b&&c.separate(this.owner,a),null!==this._callbackFunction&&null!==this._callbackContext&&this._callbackFunction.call(this._callbackContext,this.owner,a)),e}},c.prototype.overlapsGroup=function(b,c){void 0===c&&(c=!1);for(var d=!1,e=0;e<b.members.length;e++)b.members[e].childType()===a.GROUP?this.overlapsGroup(b.members[e],c):this.overlaps(b.members[e],c)&&(null!==this._callbackContext&&null!==this._callbackFunction&&this._callbackFunction.call(this._callbackContext,this.owner,b.members[e]),d=!0);return d},c.prototype.overlapsArray=function(b,c){void 0===c&&(c=!1);for(var d=!1,e=0;e<b.length;e++)"undefined"!=typeof b[e].childType&&(b[e].childType()==a.GROUP?this.overlapsGroup(b[e],c):this.overlaps(b[e],c)&&(null!==this._callbackFunction&&null!==this._callbackContext&&this._callbackFunction.call(this._callbackContext,this.owner,b[e]),d=!0));return d},c.computeVelocity=function(a,b,d,e){return void 0===b&&(b=0),void 0===d&&(d=0),void 0===e&&(e=1e4),0!=b?a+=b*c.updateInterval:0!=d&&(d*=c.updateInterval,a-d>0?a-=d:0>a+d?a+=d:a=0),0!=a&&1e4!=e&&(a>e?a=e:-e>a&&(a=-e)),a},c.prototype.updateMotion=function(){var a,b;b=(c.computeVelocity(this.angularVelocity,this.angularAcceleration,this.angularDrag,this.maxAngular)-this.angularVelocity)/2,this.angularVelocity+=b,this.transform.rotation+=this.angularVelocity*c.updateInterval,this.angularVelocity+=b,b=(c.computeVelocity(this.velocity.x,this.acceleration.x,this.drag.x,this.maxVelocity.x)-this.velocity.x)/2,this.velocity.x+=b,a=this.velocity.x*c.updateInterval,this.velocity.x+=b,this.transform.x=this.transform.x+a,b=(c.computeVelocity(this.velocity.y,this.acceleration.y,this.drag.y,this.maxVelocity.y)-this.velocity.y)/2,this.velocity.y+=b,a=this.velocity.y*c.updateInterval,this.velocity.y+=b,this.transform.y=this.transform.y+a},c.prototype.update=function(){this.last.x=this.transform.worldX,this.last.y=this.transform.worldY,this.moves&&this.updateMotion(),this.wasTouching=this.touching,this.touching=c.NONE},c.prototype.destroy=function(){b.prototype.destroy.call(this),delete this.transform,delete this.owner,delete this._callbackContext,delete this._callbackFunction},c.prototype.objType=function(){return"ArcadePhysics"},c.collide=function(a,b,d){return void 0===d&&(d=!0),c.overlaps(a,b,d)},c.collideGroup=function(a,b,d){return void 0===d&&(d=!0),c.overlapsObjectGroup(a,b,d)},c.collideGroupGroup=function(a,b,d){return void 0===d&&(d=!0),c.overlapsGroupGroup(a,b,d)},c.overlaps=function(a,b,c){void 0===c&&(c=!0);var d=a.components.getComponent("ArcadePhysics");return d.overlaps(b,c)},c.overlapsObjectGroup=function(a,b,c){void 0===c&&(c=!0);var d=a.components.getComponent("ArcadePhysics");return d.overlapsGroup(b,c)},c.overlapsGroupGroup=function(b,d,e){void 0===e&&(e=!0);for(var f=!1,g=b.members,h=0;h<b.members.length;)g[h].childType()==a.GROUP?c.overlapsGroupGroup(g[h++],d,e)&&(f=!0):c.overlapsObjectGroup(g[h++],d,e)&&(f=!0);return f},c.overlapsArrayGroup=function(b,d,e){void 0===e&&(e=!0);for(var f=!1,g=0;g<b.length;g++)"undefined"!=typeof b[g].childType&&(b[g].childType()===a.GROUP?c.overlapsGroupGroup(b[g],d,e)&&(f=!0):c.overlapsObjectGroup(b[g],d,e)&&(f=!0));return f},c.updateInterval=.1,c.LEFT=1,c.RIGHT=16,c.UP=256,c.DOWN=4096,c.NONE=0,c.CEILING=c.UP,c.FLOOR=c.DOWN,c.WALL=c.LEFT|c.RIGHT,c.ANY=c.LEFT|c.RIGHT|c.UP|c.DOWN,c.OVERLAP_BIAS=4,c}(a.Component);b.ArcadePhysics=c}(b=a.Components||(a.Components={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._queueLoading=!1,this.percentLoaded=0,this.enableParallelLoading=!1,this._completedFiles=0,this._calculateBytes=!1,this._currentFileIndex=0,this._bytesTotal=0,this._bytesLoaded=0,this.game=a}return b.prototype.objType=function(){return"Loader"},Object.defineProperty(b.prototype,"queueLoading",{get:function(){return this._queueLoading},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this._loadingList=[],this._loadingParallel=[],this._loadingQueue=[],this.onQueueComplete=new a.Signal,this.onQueueProgress=new a.Signal},b.prototype.start=function(b){return void 0===b&&(b=null),null!==b&&(this._calculateBytes=b),this._queueLoading?void a.Log.warn("Kiwi.Files.Loader: Files in the queue are already being loaded"):(this._bytesLoaded=0,this._bytesTotal=0,this.percentLoaded=0,void(this._calculateBytes?this.calculateQueuedSize(this._startLoading,this):this._startLoading()))},b.prototype._startLoading=function(){if(this._loadingList.length<=0)return a.Log.log("Kiwi.Files.Loader: No files are to load have been found.","#loading"),this.onQueueProgress.dispatch(100,0,null),void this.onQueueComplete.dispatch();for(var b=0;b<this._loadingList.length;)this._calculateBytes&&this._loadingList[b].onProgress.add(this._updateFileListInformation,this),this._sortFile(this._loadingList[b]),this._loadingList[b].onComplete.addOnce(this._fileQueueUpdate,this),b++;this._queueLoading=!0,this._bytesLoaded=0,this._startLoadingQueue(),this._startLoadingAllParallel(),this._fileQueueUpdate(null,!0)},b.prototype.addFileToQueue=function(b){return this._queueLoading?(a.Log.warn("Kiwi.Files.Loader: File cannot be added to the queue whilst the queue is currently loading.","#loading","#filequeue"),!1):b.loading||b.complete?(a.Log.warn("Kiwi.Files.Loader: File could not be added as it is currently loading or has already loaded.","#loading","#filequeue"),!1):(this._loadingList.push(b),!0)},b.prototype.removeFileFromQueue=function(b){if(this._queueLoading)return a.Log.warn("Kiwi.Files.Loader: File cannot be remove from the queue whilst the queue is currently loading.","#loading","#filequeue"),!1;var c=this._loadingList.indexOf(b);return-1===c?!1:b.loading?(a.Log.warn("Kiwi.Files.Loader: Cannot remove the file from the list as it is currently loading.","#loading","#filequeue"),!1):(this._loadingList.splice(c,1),!0)},b.prototype.clearQueue=function(){this._queueLoading?a.Log.error("Kiwi.Files.Loader: Cannot clear the file queue whilst the files are being loaded.","#loading","#filequeue"):this._loadingList.length=0},b.prototype.loadFile=function(b){return b.loading||b.complete?void a.Log.error("Kiwi.Files.Loader: Could not add file. File is already loading or has completed loading."):void this._sortFile(b,!0)},b.prototype._sortFile=function(a,b){void 0===b&&(b=!1),this.enableParallelLoading&&a.loadInParallel?(this._loadingParallel.push(a),b&&this._startLoadingParallel(a)):(this._loadingQueue.push(a),b&&this._startLoadingQueue())},b.prototype._updateFileListInformation=function(){var a=0;for(this._completedFiles=0,this._bytesLoaded=0;a<this._loadingList.length;)this._bytesLoaded+=0===this._loadingList[a].bytesLoaded&&this._loadingList[a].success&&this._loadingList[a].detailsReceived?this._loadingList[a].size:this._loadingList[a].bytesLoaded,this._loadingList[a].complete&&this._completedFiles++,a++;this.percentLoaded=this._calculateBytes?this._bytesLoaded/this._bytesTotal*100:this._completedFiles/this._loadingList.length*100},b.prototype._fileQueueUpdate=function(a,b){void 0===b&&(b=!1),(b||-1!==this._loadingList.indexOf(a))&&(this._updateFileListInformation(),this.onQueueProgress.dispatch(this.percentLoaded,this.bytesLoaded,a),this._completedFiles>=this._loadingList.length&&(this._queueLoading=!1,this.clearQueue(),this.onQueueComplete.dispatch()))},b.prototype._startLoadingQueue=function(){return this._loadingQueue.length<=0?(a.Log.log("Kiwi.Files.Loader: No queued files to load.","#loading"),!1):this._loadingQueue[0].loading?!1:(this._loadingQueue[0].onComplete.addOnce(this._queueFileComplete,this,1),this._loadingQueue[0].load(),!0)},b.prototype._queueFileComplete=function(b){var c=this._loadingQueue.indexOf(b);return-1===c?void a.Log.warn("Something has gone wrong? The file which executed this method doesn't exist in the loadingQueue.","#loading","#error"):(this._loadingQueue.splice(c,1),void this._startLoadingQueue())},b.prototype._startLoadingParallel=function(a){a.loading||(a.onComplete.add(this._parallelFileComplete,this,1),a.load())},b.prototype._startLoadingAllParallel=function(){for(var a=this._loadingParallel.length;a--;)this._startLoadingParallel(this._loadingParallel[a])},b.prototype._parallelFileComplete=function(b){var c=this._loadingParallel.indexOf(b);return-1===c?void a.Log.warn("Something has gone wrong? The file which executed this method doesn't exist in the loadingParallel.","#loading","#error"):void this._loadingParallel.splice(c,1)},Object.defineProperty(b.prototype,"bytesTotal",{get:function(){return this._bytesTotal},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"bytesLoaded",{get:function(){return this._bytesLoaded},enumerable:!0,configurable:!0}),b.prototype.calculateQueuedSize=function(b,c){return void 0===c&&(c=null),this._queueLoading?void a.Log.warn("Kiwi.Files.Loader: Cannot calculate the size of the files in the filequeue whilst they are loading. "):(this.onSizeCallback=b,this.onSizeContext=c,this._currentFileIndex=0,this._bytesTotal=0,this._queueLoading=!0,void this._calculateNextFileSize())},b.prototype._calculateNextFileSize=function(){if(this._currentFileIndex>=this._loadingList.length)return this._queueLoading=!1,void this.onSizeCallback.call(this.onSizeContext,this._bytesTotal);var a=this._loadingList[this._currentFileIndex];if(a.detailsReceived)this._detailsReceived();else{var b=a.loadDetails(this._detailsReceived,this);b||this._detailsReceived()}},b.prototype._detailsReceived=function(){var a=this._loadingList[this._currentFileIndex];a.detailsReceived&&(this._bytesTotal+=a.size),this._currentFileIndex++,this._calculateNextFileSize()},b.prototype.addImage=function(b,c,d,e,f,g,h){void 0===h&&(h=!0);var i={type:a.Files.File.IMAGE,key:null,url:null,fileStore:this.game.fileStore,metadata:{}};if(a.Utils.Common.isObject(b)){var j=b;i.key=j.key,i.url=j.url,i.metadata={width:j.width,height:j.height,offsetX:j.offsetX,offsetY:j.offsetY},j.xhrLoading&&(i.xhrLoading=j.xhrLoading),j.state&&(i.state=j.state),j.tags&&(i.tags=j.tags)}else!h&&this.game.states.current&&(i.state=this.game.states.current),i.key=b,i.url=c,i.metadata={width:d,height:e,offsetX:f,offsetY:g};var k=new a.Files.TextureFile(this.game,i);return this.addFileToQueue(k),k},b.prototype.addSpriteSheet=function(b,c,d,e,f,g,h,i,j,k,l,m){void 0===m&&(m=!0);var n={type:a.Files.File.SPRITE_SHEET,key:null,url:null,fileStore:this.game.fileStore,metadata:{}};if(a.Utils.Common.isObject(b)){var o=b;n.key=o.key,n.url=o.url,n.metadata={frameWidth:o.frameWidth,frameHeight:o.frameHeight,numCells:o.numCells,rows:o.rows,cols:o.cols,sheetOffsetX:o.sheetOffsetX,sheetOffsetY:o.sheetOffsetY,cellOffsetX:o.cellOffsetX,cellOffsetY:o.cellOffsetY},o.xhrLoading&&(n.xhrLoading=o.xhrLoading),o.state&&(n.state=o.state),o.tags&&(n.tags=o.tags)}else!m&&this.game.states.current&&(n.state=this.game.states.current),n.key=b,n.url=c,n.metadata={frameWidth:d,frameHeight:e,numCells:f,rows:g,cols:h,sheetOffsetX:i,sheetOffsetY:j,cellOffsetX:k,cellOffsetY:l};var p=new a.Files.TextureFile(this.game,n);return this.addFileToQueue(p),p},b.prototype.addTextureAtlas=function(b,c,d,e,f){void 0===f&&(f=!0);var g={type:a.Files.File.TEXTURE_ATLAS,key:b,url:c,fileStore:this.game.fileStore,metadata:{jsonID:d}},h={type:a.Files.File.JSON,key:d,url:e,fileStore:this.game.fileStore,metadata:{imageID:b}};if(!f&&this.game.states.current&&(g.state=this.game.states.current,h.state=this.game.states.current),a.Utils.Common.isObject(b)){var i=b;g.key=i.textureAtlasKey,g.url=i.textureAtlasURL,h.key=i.jsonKey,h.url=i.jsonURL,g.metadata.jsonID=h.key,h.metadata.imageID=g.key,i.state&&(g.state=i.state,h.state=i.state),i.xhrLoading&&(g.xhrLoading=i.xhrLoading),i.tags&&(h.tags=i.tags,g.tags=i.tags)}var j=new a.Files.TextureFile(this.game,g),k=new a.Files.DataFile(this.game,h);return this.addFileToQueue(j),this.addFileToQueue(k),j},b.prototype.addAudio=function(b,c,d,e){void 0===d&&(d=!0),void 0===e&&(e=!0);var f={type:a.Files.File.AUDIO,key:null,url:null,state:null,fileStore:this.game.fileStore};a.Utils.Common.isObject(b)?(f=b,f.type=a.Files.File.AUDIO,f.fileStore=this.game.fileStore):(f.key=b,f.url=c,!d&&this.game.states.current&&(f.state=this.game.states.current));var g,h,i=0;for(g=a.Utils.Common.isString(f.url)?[f.url]:f.url;i<g.length;){if(f.url=g[i],h=this._attemptToAddAudio(f,e))return h;i++}return null},b.prototype._attemptToAddAudio=function(b,c){var d=new a.Files.AudioFile(this.game,b),e=!1;switch(d.extension){case"mp3":e=a.DEVICE.mp3;break;case"ogg":case"oga":e=a.DEVICE.ogg;break;case"m4a":e=a.DEVICE.m4a;break;case"wav":case"wave":e=a.DEVICE.wav}return 1==e||0==c?(this.addFileToQueue(d),d):(a.Log.error("Kiwi.Loader: Audio Format not supported on this Device/Browser.","#audio","#unsupported"),null)},b.prototype.addJSON=function(b,c,d){void 0===d&&(d=!0);var e={type:a.Files.File.JSON,key:b,url:c,fileStore:this.game.fileStore};if(a.Utils.Common.isObject(b)){var f=b;e.key=f.key,e.url=f.url,f.parse&&(e.parse=f.parse),f.state&&(e.state=f.state),f.tags&&(e.tags=f.tags)}else!d&&this.game.states.current&&(e.state=this.game.states.current);var g=new a.Files.DataFile(this.game,e);return this.addFileToQueue(g),g},b.prototype.addXML=function(b,c,d){void 0===d&&(d=!0);var e={type:a.Files.File.XML,key:b,url:c,fileStore:this.game.fileStore};if(a.Utils.Common.isObject(b)){var f=b;e.key=f.key,e.url=f.url,f.parse&&(e.parse=f.parse),f.state&&(e.state=f.state),f.tags&&(e.tags=f.tags)}else!d&&this.game.states.current&&(e.state=this.game.states.current);var g=new a.Files.DataFile(this.game,e);return this.addFileToQueue(g),g},b.prototype.addBinaryFile=function(b,c,d){void 0===d&&(d=!0);var e={type:a.Files.File.BINARY_DATA,key:b,url:c,fileStore:this.game.fileStore};if(a.Utils.Common.isObject(b)){var f=b;e.key=f.key,e.url=f.url,f.parse&&(e.parse=f.parse),f.state&&(e.state=f.state),f.tags&&(e.tags=f.tags)}else!d&&this.game.states.current&&(e.state=this.game.states.current);var g=new a.Files.DataFile(this.game,e);return this.addFileToQueue(g),g},b.prototype.addTextFile=function(b,c,d){void 0===d&&(d=!0);var e={type:a.Files.File.TEXT_DATA,key:b,url:c,fileStore:this.game.fileStore};if(a.Utils.Common.isObject(b)){var f=b;e.key=f.key,e.url=f.url,f.parse&&(e.parse=f.parse),f.state&&(e.state=f.state),f.tags&&(e.tags=f.tags)}else!d&&this.game.states.current&&(e.state=this.game.states.current);var g=new a.Files.DataFile(this.game,e);return this.addFileToQueue(g),g},b.prototype.destroy=function(){this.onQueueComplete.dispose(),this.onQueueProgress.dispose(),delete this.game,delete this.onQueueComplete,delete this.onQueueProgress;for(var a=0;a<this._loadingList.length;)this._loadingList[a].destroy(),a++;this._loadingList=[];for(var a=0;a<this._loadingQueue.length;)this._loadingQueue[a].destroy(),a++;this._loadingQueue=[];for(var a=0;a<this._loadingParallel.length;)this._loadingParallel[a].destroy(),a++;this._loadingParallel=[]},b.prototype.init=function(a,b,c){void 0===a&&(a=null),void 0===b&&(b=null),void 0===c&&(c=null),null!==c&&(this._calculateBytes=c),null!==a&&this.onQueueProgress.addOnce(a),null!==b&&this.onQueueComplete.addOnce(b)},b.prototype.startLoad=function(){this.start()},b.prototype.getPercentLoaded=function(){return this.percentLoaded},b.prototype.complete=function(){return 100===this.percentLoaded},b.prototype.calculateBytes=function(a){return"undefined"!=typeof a&&(this._calculateBytes=a),this._calculateBytes},b.prototype.getBytesLoaded=function(){return this.bytesLoaded},b}();b.Loader=c}(b=a.Files||(a.Files={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._game=a,this.data={}}return b.prototype.objType=function(){return"DataLibrary"},b.prototype.clear=function(){for(var a in this.data)delete this.data[a]},b.prototype.add=function(b){switch(b.dataType){case a.Files.File.JSON:case a.Files.File.XML:case a.Files.File.BINARY_DATA:case a.Files.File.TEXT_DATA:this.data[b.key]=b}},b.prototype.rebuild=function(b,c){this.clear(),a.Log.log("Kiwi.DataLibrary: Rebuilding Data Library","#rebuild");for(var d=b.keys,e=0;e<d.length;e++){var f=this._game.fileStore.getFile(d[e]);f.isData&&(a.Log.log(" Kiwi.DataLibrary: Adding Data: "+f.name,"#rebuild","#adding"),c.dataLibrary.add(f))}},b}();b.DataLibrary=c}(b=a.Files||(a.Files={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b,c){this._loadInParallel=!1,this.useTagLoader=!1,this.size=0,this.timeOutDelay=a.Files.File.TIMEOUT_DELAY,this.attemptCounter=0,this.maxLoadAttempts=a.Files.File.MAX_LOAD_ATTEMPTS,this.timeStarted=0,this.lastProgress=0,this.timeFinished=0,this.duration=0,this.hasError=!1,this.success=!1,this.loading=!1,this.complete=!1,this.percentLoaded=0,this.bytesLoaded=0,this.bytesTotal=0,this.detailsReceived=!1,this.ETag="",this.lastModified="",this.status=0,this.statusText="",this.readyState=0,this.hasTimedOut=!1,this.timedOut=0,this.game=b,this.onComplete=new a.Signal,this.onProgress=new a.Signal,a.Utils.Common.isNumeric(c)?this._parseParamsOld(c,arguments[2],arguments[3],arguments[4],arguments[5]):(this.key=c.key,this._assignFileDetails(c.url),this.parseParams(c))}return b.prototype._parseParamsOld=function(a,b,c,d,e){void 0===c&&(c=""),void 0===d&&(d=!0),void 0===e&&(e=!0),this.dataType=a,this._assignFileDetails(b),d&&(this.fileStore=this.game.fileStore),this.game.states.current&&!e&&(this.ownerState=this.game.states.current)},b.prototype.parseParams=function(c){if(this.fileStore=c.fileStore||null,this.ownerState=c.state||null,this.metadata=c.metadata||{},this.timeOutDelay=a.Utils.Common.isUndefined(c.timeout)?c.timeout:a.Files.File.TIMEOUT_DELAY,this.dataType=a.Utils.Common.isUndefined(c.type)?b.UNKNOWN:c.type,c.tags&&a.Utils.Common.isArray(c.tags))for(var d=0;d<c.tags.length;d++)this.addTag(c.tags[d])},b.prototype._assignFileDetails=function(a){this.URL=a,a.lastIndexOf("/")>-1?(this.name=a.substr(a.lastIndexOf("/")+1),this.path=a.substr(0,a.lastIndexOf("/")+1)):(this.path="",this.name=a),this.extension=a.substr(a.lastIndexOf(".")+1).toLowerCase()},b.prototype.objType=function(){return"File"},Object.defineProperty(b.prototype,"loadInParallel",{get:function(){return this._loadInParallel},enumerable:!0,configurable:!0}),b.prototype.load=function(b,c,d,e,f){return this.loading?void a.Log.error("Kiwi.Files.File: File loading is in progress. Cannot be told to load again.","#loading"):(a.Log.log("Kiwi.Files.File: Starting to load '"+this.name+"'","#file","#loading"),b&&this.onComplete.add(b),c&&this.onProgress.add(c),d&&(this.fileStore=d),"undefined"!=typeof e&&(this.maxLoadAttempts=e),"undefined"!=typeof f&&(this.timeOutDelay=f),this._start(),void this._load())},b.prototype._load=function(){this.attemptCounter++,this.xhrLoader("GET","text")},b.prototype.loadProgress=function(){this.onProgress.dispatch(this)},b.prototype.loadSuccess=function(){this.complete||(this.success=!0,this.hasError=!1,this._stop(),this.fileStore&&this.fileStore.addFile(this.key,this),this.onComplete.dispatch(this))},b.prototype.loadError=function(b){this.attemptCounter>=this.maxLoadAttempts?(a.Log.log("Kiwi.Files.File: Failed to load file '"+this.name+"'. Trying Again","#loading"),this.hasError=!0,this.success=!1,this.error=b,this._stop(),this.onComplete.dispatch(this)):(a.Log.log("Kiwi.Files.File: Failed to load file '"+this.name+"'","#loading"),this._load())},b.prototype.xhrLoader=function(a,b,c){var d=this;void 0===a&&(a="GET"),void 0===b&&(b="text"),void 0===c&&(c=this.timeOutDelay),this._xhr=new XMLHttpRequest,this._xhr.open(a,this.URL,!0),null!==c&&(this._xhr.timeout=c),this._xhr.responseType=b,this._xhr.onload=function(a){return d.xhrOnLoad(a)},this._xhr.onerror=function(a){return d.loadError(a)},this._xhr.onprogress=function(a){return d.xhrOnProgress(a)};var e=this;this._xhr.onreadystatechange=function(){e.readyState=e._xhr.readyState},this._xhr.onloadstart=function(a){e.timeStarted=a.timeStamp,e.lastProgress=a.timeStamp},this._xhr.ontimeout=function(){e.hasTimedOut=!0
|
|
},this._xhr.onloadend=function(a){e.xhrOnLoad(a)},this._xhr.send()},b.prototype.xhrOnProgress=function(a){this.bytesLoaded=parseInt(a.loaded),this.bytesTotal=parseInt(a.total),this.percentLoaded=Math.round(this.bytesLoaded/this.bytesTotal*100),this.onProgress.dispatch(this)},b.prototype.xhrOnLoad=function(a){this.status=this._xhr.status,this.statusText=this._xhr.statusText,this.status&&200===this.status||!this.status&&this._xhr.response?(this._getXhrHeaderInfo(),this.buffer=this._xhr.response,this.processXhr(this._xhr.response)):this.loadError(a)},b.prototype.processXhr=function(a){this.data=a,this.loadSuccess()},b.prototype._start=function(){this.attemptCounter=0,this.loading=!0,this.timeStarted=Date.now(),this.percentLoaded=0},b.prototype._stop=function(){this.loading=!1,this.complete=!0,this.percentLoaded=100,this.timeFinished=Date.now(),this.duration=this.timeFinished-this.timeStarted},b.prototype.loadDetails=function(b,c){return void 0===b&&(b=null),void 0===c&&(c=null),this.loading?(a.Log.error("Kiwi.Files.File: Cannot get the file details whilst the file is already loading"),!1):(b&&(this.headCompleteCallback=b),c&&(this.headCompleteContext=c),this.xhrHeadRequest(),!0)},b.prototype._getXhrHeaderInfo=function(){this._xhr&&(this.status=this._xhr.status,this.statusText=this._xhr.statusText,this.type=this._xhr.getResponseHeader("Content-Type"),this.size=parseInt(this._xhr.getResponseHeader("Content-Length")),this.lastModified=this._xhr.getResponseHeader("Last-Modified"),this.ETag=this._xhr.getResponseHeader("ETag"),this.detailsReceived=!0)},b.prototype.xhrHeadRequest=function(){var a=this;this._xhr=new XMLHttpRequest,this._xhr.open("HEAD",this.fileURL,!0),null!==this.timeOutDelay&&(this._xhr.timeout=this.timeOutDelay),this._xhr.onload=function(b){return a.xhrHeadOnLoad(b)},this._xhr.onerror=function(b){return a.xhrHeadOnError(b)},this._xhr.send()},b.prototype.xhrHeadOnError=function(){this.headCompleteCallback&&this.headCompleteCallback.call(this.headCompleteContext,!1)},b.prototype.xhrHeadOnLoad=function(){200===this._xhr.status?(this._getXhrHeaderInfo(),this.headCompleteCallback&&this.headCompleteCallback.call(this.headCompleteContext,!0)):this.xhrHeadOnError(null)},b.prototype.addTag=function(a){-1==this._tags.indexOf(a)&&this._tags.push(a)},b.prototype.removeTag=function(a){var b=this._tags.indexOf(a);-1!=b&&this._tags.splice(b,1)},b.prototype.hasTag=function(a){return-1==this._tags.indexOf(a)?!1:!0},Object.defineProperty(b.prototype,"isTexture",{get:function(){return a.Files.TextureFile.prototype.objType.call(this)===this.objType()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isAudio",{get:function(){return a.Files.AudioFile.prototype.objType.call(this)===this.objType()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isData",{get:function(){return a.Files.DataFile.prototype.objType.call(this)===this.objType()},enumerable:!0,configurable:!0}),b.prototype.destroy=function(){this.fileStore&&this.fileStore.removeFile(this.key),this.onComplete.dispose(),this.onProgress.dispose(),delete this.fileStore,delete this._xhr,delete this.data,delete this.buffer,delete this.game,delete this.error,delete this.headCompleteCallback,delete this.headCompleteContext,delete this.onComplete,delete this.onProgress,delete this.ownerState},Object.defineProperty(b.prototype,"fileName",{get:function(){return this.name},set:function(a){this.name=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"filePath",{get:function(){return this.path},set:function(a){this.path=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"fileExtension",{get:function(){return this.extension},set:function(a){this.extension=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"fileURL",{get:function(){return this.URL},set:function(a){this.URL=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"fileType",{get:function(){return this.type},set:function(a){this.type=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"fileSize",{get:function(){return this.size},set:function(a){this.size=a},enumerable:!0,configurable:!0}),b.prototype.getFileDetails=function(a,b,c){void 0===a&&(a=null),void 0===c&&(c=null),c&&(this.timeOutDelay=c),this.loadDetails(a,null)},b.TIMEOUT_DELAY=null,b.MAX_LOAD_ATTEMPTS=2,b.IMAGE=0,b.SPRITE_SHEET=1,b.TEXTURE_ATLAS=2,b.AUDIO=3,b.JSON=4,b.XML=5,b.BINARY_DATA=6,b.TEXT_DATA=7,b.UNKNOWN=8,b}();b.File=c}(b=a.Files||(a.Files={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a){this._size=0,this._game=a,this._files={}}return a.prototype.objType=function(){return"FileStore"},a.prototype.boot=function(){},a.prototype.getFile=function(a){return this._files[a]},a.prototype.getFilesByTag=function(a){var b={};for(var c in this._files)this._files[c].hasTag(a)&&(b[c]=this._files[c]);return b},a.prototype.removeFilesByTag=function(a){var b=0;for(var c in this._files)this._files[c].hasTag(a)&&(this.removeFile(c),b++);return b},Object.defineProperty(a.prototype,"keys",{get:function(){var a=new Array;for(var b in this._files)a.push(b);return a},enumerable:!0,configurable:!0}),a.prototype.size=function(){return this._size},a.prototype.addFile=function(a,b){return this._files[a]?!1:(this._files[a]=b,this._size++,!0)},a.prototype.exists=function(a){return this._files[a]?!0:!1},a.prototype.removeStateFiles=function(a){for(var b in this._files)this._files[b].ownerState===a&&this.removeFile(b)},a.prototype.removeGlobalFiles=function(){for(var a in this._files)this._files[a].ownerState||this.removeFile(a)},a.prototype.removeFile=function(a,b){void 0===b&&(b=!1);var c=this._files[a];return c?(this._files[a]=null,delete this._files[a],b&&c.destroy(),!0):!1},a.prototype.removeAllFiles=function(){for(var a in this._files)this.removeFile(a)},a}();a.FileStore=b}(b=a.Files||(a.Files={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(){this.isReady=!1,this.container=null,this.input=null}return b.prototype.objType=function(){return"Bootstrap"},b.prototype.boot=function(a,b,c){var d=this;void 0===b&&(b=null),void 0===c&&(c=!0),this._callback=b,this._domParent=a,this._createContainer=c,"complete"===document.readyState||"interactive"===document.readyState?this.ready():(document.addEventListener("DOMContentLoaded",function(){return d.ready()},!1),window.addEventListener("load",function(){return d.ready()},!1))},b.prototype.ready=function(){var b=this;this.isReady!==!0&&(document.body?(this.isReady=!0,this._createContainer===!0&&(""===this._domParent?(a.Log.log(" Kiwi.Game: No DOM parent specified. Appending the game to the body.","#dom"),this.container=document.createElement("div"),this._setupContainer("KiwiGame"+Date.now().toString()),document.body.appendChild(this.container)):document.querySelector(this._domParent)?(a.Log.log(" Kiwi.Game: Game being created inside '"+this._domParent+"'.","#dom"),this.container=document.querySelector(this._domParent),this._setupContainer()):document.getElementById(this._domParent)?(a.Log.log(" Kiwi.Game: Game being created inside '"+this._domParent+"'.","#dom"),this.container=document.getElementById(this._domParent),this._setupContainer()):(a.Log.log(" Kiwi.Game: The element '"+this._domParent+"' could not be found. Appending the game to the body.","#dom"),this.container=document.createElement("div"),this._setupContainer(this._domParent),document.body.appendChild(this.container))),null!==this._callback&&this._callback()):window.setTimeout(function(){return b.ready()},13))},b.prototype._setupContainer=function(b){void 0===b&&(b=""),b&&(this.container.id=b),this.container.style.width=a.Stage.DEFAULT_WIDTH+"px",this.container.style.height=a.Stage.DEFAULT_HEIGHT+"px",this.container.style.position="relative",this.container.style.overflow="hidden"},b}();b.Bootstrap=c}(b=a.System||(a.System={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){this.iOS=!1,this.android=!1,this.chromeOS=!1,this.linux=!1,this.macOS=!1,this.windows=!1,this.windowsPhone=!1,this.canvas=!1,this.file=!1,this.fileSystem=!1,this.localStorage=!1,this.webGL=!1,this.worker=!1,this.blob=!1,this.touch=!1,this.pointerEnabled=!1,this.arora=!1,this.chrome=!1,this.epiphany=!1,this.firefox=!1,this.ie=!1,this.ieVersion=0,this.ieMobile=!1,this.mobileSafari=!1,this.midori=!1,this.opera=!1,this.safari=!1,this.webApp=!1,this.audioData=!1,this.webaudio=!1,this.ogg=!1,this.mp3=!1,this.wav=!1,this.m4a=!1,this.iPhone=!1,this.iPhone4=!1,this.iPad=!1,this.pixelRatio=0,this._checkAudio(),this._checkBrowser(),this._checkDevice(),this._checkFeatures(),this._checkOS()}return a.prototype.objType=function(){return"Device"},a.prototype._checkOS=function(){var a=navigator.userAgent;/Android/.test(a)?this.android=!0:/CrOS/.test(a)?this.chromeOS=!0:/iP[ao]d|iPhone/i.test(a)?this.iOS=!0:/Linux/.test(a)?this.linux=!0:/Mac OS/.test(a)?this.macOS=!0:/Windows Phone/.test(a)?this.windowsPhone=!0:/Windows/.test(a)&&(this.windows=!0)},a.prototype._checkFeatures=function(){"undefined"!=typeof window.Blob&&(this.blob=!0),this.canvas=!!window.CanvasRenderingContext2D,this.webGL=!!window.WebGLRenderingContext;try{this.localStorage=!!localStorage.getItem}catch(a){this.localStorage=!1}this.file=!!(window.File&&window.FileReader&&window.FileList&&window.Blob),this.fileSystem=!!window.requestFileSystem,this.worker=!!window.Worker,("ontouchstart"in document.documentElement||window.navigator.msPointerEnabled&&window.navigator.msMaxTouchPoints>0||window.navigator.pointerEnabled&&window.navigator.maxTouchPoints>0)&&(this.touch=!0),(window.navigator.pointerEnabled||window.navigator.msPointerEnabled)&&(this.pointerEnabled=!0)},a.prototype._checkBrowser=function(){{var a=navigator.userAgent;navigator.appName}/Arora/.test(a)?this.arora=!0:/Chrome/.test(a)?this.chrome=!0:/Epiphany/.test(a)?this.epiphany=!0:/Firefox/.test(a)?this.firefox=!0:/Mobile Safari/.test(a)?this.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(a)?(this.ie=!0,this.ieVersion=parseInt(RegExp.$1),/IEMobile/.test(a)&&(this.ieMobile=!0)):/Trident/.test(a)?(this.ie=!0,/rv:(\d+\.\d+)\)/.test(a),this.ieVersion=parseInt(RegExp.$1)):/Midori/.test(a)?this.midori=!0:/Opera/.test(a)?this.opera=!0:/Safari/.test(a)&&(this.safari=!0),navigator.standalone&&(this.webApp=!0)},a.prototype._checkAudio=function(){this.audioData=!!window.Audio,this.webaudio=!(!window.webkitAudioContext&&!window.AudioContext);var a=document.createElement("audio"),b=!1;try{(b=!!a.canPlayType)&&(a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(this.ogg=!0),a.canPlayType("audio/mpeg;").replace(/^no$/,"")&&(this.mp3=!0),a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")&&(this.wav=!0),(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;").replace(/^no$/,""))&&(this.m4a=!0))}catch(c){}},a.prototype._checkDevice=function(){this.pixelRatio=window.devicePixelRatio||1,this.iPhone=-1!=navigator.userAgent.toLowerCase().indexOf("iphone"),this.iPhone4=2==this.pixelRatio&&this.iPhone,this.iPad=-1!=navigator.userAgent.toLowerCase().indexOf("ipad")},a.prototype.getAll=function(){var a="";return a=a.concat("Device\n"),a=a.concat("iPhone : "+this.iPhone+"\n"),a=a.concat("iPhone4 : "+this.iPhone4+"\n"),a=a.concat("iPad : "+this.iPad+"\n"),a=a.concat("\n"),a=a.concat("Operating System\n"),a=a.concat("iOS: "+this.iOS+"\n"),a=a.concat("Android: "+this.android+"\n"),a=a.concat("ChromeOS: "+this.chromeOS+"\n"),a=a.concat("Linux: "+this.linux+"\n"),a=a.concat("MacOS: "+this.macOS+"\n"),a=a.concat("Windows: "+this.windows+"\n"),a=a.concat("\n"),a=a.concat("Browser\n"),a=a.concat("Arora: "+this.arora+"\n"),a=a.concat("Chrome: "+this.chrome+"\n"),a=a.concat("Epiphany: "+this.epiphany+"\n"),a=a.concat("Firefox: "+this.firefox+"\n"),a=a.concat("Internet Explorer: "+this.ie+" ("+this.ieVersion+")\n"),a=a.concat("Mobile Safari: "+this.mobileSafari+"\n"),a=a.concat("Midori: "+this.midori+"\n"),a=a.concat("Opera: "+this.opera+"\n"),a=a.concat("Safari: "+this.safari+"\n"),a=a.concat("\n"),a=a.concat("Features\n"),a=a.concat("Blob: "+this.blob+"\n"),a=a.concat("Canvas: "+this.canvas+"\n"),a=a.concat("File: "+this.file+"\n"),a=a.concat("FileSystem: "+this.fileSystem+"\n"),a=a.concat("LocalStorage: "+this.localStorage+"\n"),a=a.concat("WebGL: "+this.webGL+"\n"),a=a.concat("Worker: "+this.worker+"\n"),a=a.concat("Touch: "+this.touch+"\n"),a=a.concat("\n"),a=a.concat("Audio\n"),a=a.concat("Audio Data: "+this.canvas+"\n"),a=a.concat("Web Audio: "+this.canvas+"\n"),a=a.concat("Can play OGG: "+this.canvas+"\n"),a=a.concat("Can play MP3: "+this.canvas+"\n"),a=a.concat("Can play M4A: "+this.canvas+"\n"),a=a.concat("Can play WAV: "+this.canvas+"\n")},a}();a.Device=b}(b=a.System||(a.System={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a,b,c,d,e){this.dirty=!1,this.cellIndex=0,this.name=a,this.cells=c||new Array,this.sequences=e||new Array,this.image=d,this._type=b}return b.prototype.objType=function(){return"TextureAtlas"},Object.defineProperty(b.prototype,"type",{get:function(){return this._type},enumerable:!0,configurable:!0}),b.prototype.createGLTextureWrapper=function(b,c){this.glTextureWrapper=new a.Renderers.GLTextureWrapper(b,this),c.registerTextureWrapper(b,this.glTextureWrapper)},b.prototype.enableGL=function(a,b,c){b.updateTextureSize(a,new Float32Array([this.image.width,this.image.height])),c.useTexture(a,this.glTextureWrapper),this.dirty&&this.refreshTextureGL(a)},b.prototype.refreshTextureGL=function(a){this.glTextureWrapper&&this.glTextureWrapper.refreshTexture(a),this.dirty=!1},b.prototype.readJSON=function(b){var c=JSON.parse(b);void 0!==c.name&&(this.name=c.name);for(var d=0;d<c.cells.length;d++)this.cells.push(c.cells[d]),void 0===c.cells[d].hitboxes&&(this.cells[d].hitboxes=new Array,this.cells[d].hitboxes.push({x:0,y:0,w:this.cells[d].w,h:this.cells[d].h}));if(c.sequences)for(var d=0;d<c.sequences.length;d++){var e=new a.Animations.Sequence(c.sequences[d].name,c.sequences[d].cells);void 0!==c.sequences[d].speed&&(e.speed=c.sequences[d].speed),void 0!==c.sequences[d].loop&&(e.loop=c.sequences[d].loop),this.sequences.push(e)}},b.SINGLE_IMAGE=0,b.SPRITE_SHEET=1,b.TEXTURE_ATLAS=2,b}();b.TextureAtlas=c}(b=a.Textures||(a.Textures={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._game=a,this.textures=new Object}return b.prototype.objType=function(){return"TextureLibrary"},b.prototype.clear=function(){for(var a in this.textures)delete this.textures[a]},b.prototype.add=function(b){if(this.textures[b.name]=b,this._game.renderOption===a.RENDERER_WEBGL){(-1==a.Utils.Common.base2Sizes.indexOf(b.image.width)||-1==a.Utils.Common.base2Sizes.indexOf(b.image.height))&&a.Log.log("Kiwi.TextureLibrary: Warning:Image is not of base2 size and may not render correctly.","#texture","#base2");var c=this._game.renderer;c.addTexture(this._game.stage.gl,b)}},b.prototype.addFromFile=function(b){switch(this._game.renderOption===a.RENDERER_WEBGL&&this._game.deviceTargetOption!=a.TARGET_COCOON&&(b=this._rebuildImage(b)),b.dataType){case a.Files.File.SPRITE_SHEET:this.textures[b.key]=this._buildSpriteSheet(b);break;case a.Files.File.IMAGE:this.textures[b.key]=this._buildImage(b);break;case a.Files.File.TEXTURE_ATLAS:this.textures[b.key]=this._buildTextureAtlas(b)}},b.prototype._rebuildImage=function(b){var c=a.Utils.Common.convertToBase2(b.data);return(b.data.width!==c.width||b.data.height!==c.height)&&(b.dataType===a.Files.File.SPRITE_SHEET?(b.metadata.rows||(b.metadata.rows=b.data.height/b.metadata.frameHeight),b.metadata.cols||(b.metadata.cols=b.data.width/b.metadata.frameWidth)):b.dataType===a.Files.File.IMAGE&&(b.metadata.width||(b.metadata.width=b.data.width),b.metadata.height||(b.metadata.height=b.data.height)),a.Log.log("Kiwi.TextureLibrary: "+b.name+" has been rebuilt to be base2.","#texture","#base2"),b.data=c),b},b.prototype._buildTextureAtlas=function(b){var c=new a.Textures.TextureAtlas(b.key,a.Textures.TextureAtlas.TEXTURE_ATLAS,null,b.data),d=b.metadata;try{var e=this._game.fileStore.getFile(d.jsonID).data;return e.trim(),c.readJSON(e),c}catch(f){a.Log.error(" Kiwi.Textures.TextureLibrary: Failed to extract information for '"+b.key+"' from JSON file '"+d.jsonID+"'","#error","#texture","Message: "+f.message)}return null},b.prototype._buildSpriteSheet=function(b){var c=b.metadata,d=new a.Textures.SpriteSheet(b.key,b.data,c.frameWidth,c.frameHeight,c.numCells,c.rows,c.cols,c.sheetOffsetX,c.sheetOffsetY,c.cellOffsetX,c.cellOffsetY);return d},b.prototype._buildImage=function(b){var c=b.metadata;return new a.Textures.SingleImage(b.key,b.data,c.width,c.height,c.offsetX,c.offsetY)},b.prototype.rebuild=function(b,c){this.clear(),a.Log.log("Kiwi.TextureLibrary: Rebuilding Texture Library","#texture","#rebuild");for(var d=b.keys,e=0;e<d.length;e++){var f=this._game.fileStore.getFile(d[e]);f.isTexture&&(a.Log.log(" Kiwi.TextureLibrary: Adding Texture: "+f.name,"#texture","#added"),c.textureLibrary.addFromFile(f))}},b}();b.TextureLibrary=c}(b=a.Textures||(a.Textures={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(c,d,e,f,g,h,i,j,k,l,m){this.cellWidth=e,this.cellHeight=f,this._cols=i||d.width/e,this._rows=h||d.height/f,this.numCells=g||this.cols*this.rows,this.sheetOffsetX=j||0,this.sheetOffsetY=k||0,this.cellOffsetX=l||0,this.cellOffsetY=m||0,b.call(this,c,a.Textures.TextureAtlas.SPRITE_SHEET,this.generateAtlasCells(),d,this.sequences)}return __extends(c,b),c.prototype.objType=function(){return"SpriteSheet"},Object.defineProperty(c.prototype,"rows",{get:function(){return this._rows},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"cols",{get:function(){return this._cols},enumerable:!0,configurable:!0}),c.prototype.generateAtlasCells=function(){for(var b=new Array,c=new Array,d=this.sheetOffsetX,e=this.sheetOffsetY,f=0,g=0;g<this.rows;g++){for(var h=0;h<this.cols;h++)f>=this.numCells||(b.push({x:d,y:e,w:this.cellWidth,h:this.cellHeight,hitboxes:[{x:0,y:0,w:this.cellWidth,h:this.cellHeight}]}),c.push(f++),d+=this.cellOffsetX+this.cellWidth);d=this.sheetOffsetX,e+=this.cellOffsetY+this.cellHeight}return this.sequences=new Array,this.sequences.push(new a.Animations.Sequence("default",c)),b},c}(b.TextureAtlas);b.SpriteSheet=c}(b=a.Textures||(a.Textures={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(c,d,e,f,g,h){this.width=e||d.width,this.height=f||d.height,this.offsetX=g||0,this.offsetY=h||0,b.call(this,c,a.Textures.TextureAtlas.SINGLE_IMAGE,this.generateAtlasCells(),d)}return __extends(c,b),c.prototype.objType=function(){return"SingleImage"},c.prototype.generateAtlasCells=function(){return[{x:this.offsetX,y:this.offsetY,w:this.width,h:this.height,hitboxes:[{x:0,y:0,w:this.width,h:this.height}]}]},c}(b.TextureAtlas);b.SingleImage=c}(b=a.Textures||(a.Textures={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Back"},a.In=function(a){var b=1.70158;return a*a*((b+1)*a-b)},a.Out=function(a){var b=1.70158;return--a*a*((b+1)*a+b)+1},a.InOut=function(a){var b=2.5949095;return(a*=2)<1?.5*a*a*((b+1)*a-b):.5*((a-=2)*a*((b+1)*a+b)+2)},a}();a.Back=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c;!function(b){var c=function(){function b(){}return b.prototype.objType=function(){return"Bounce"},b.In=function(b){return 1-a.Animations.Tweens.Easing.Bounce.Out(1-b)},b.Out=function(a){return 1/2.75>a?7.5625*a*a:2/2.75>a?7.5625*(a-=1.5/2.75)*a+.75:2.5/2.75>a?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375},b.InOut=function(b){return.5>b?.5*a.Animations.Tweens.Easing.Bounce.In(2*b):.5*a.Animations.Tweens.Easing.Bounce.Out(2*b-1)+.5},b}();b.Bounce=c}(c=b.Easing||(b.Easing={}))}(c=b.Tweens||(b.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Circular"},a.In=function(a){return 1-Math.sqrt(1-a*a)},a.Out=function(a){return Math.sqrt(1- --a*a)},a.InOut=function(a){return(a*=2)<1?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)},a}();a.Circular=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Cubic"},a.In=function(a){return a*a*a},a.Out=function(a){return--a*a*a+1},a.InOut=function(a){return(a*=2)<1?.5*a*a*a:.5*((a-=2)*a*a+2)},a}();a.Cubic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Elastic"},a.In=function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),-(c*Math.pow(2,10*(a-=1))*Math.sin(2*(a-b)*Math.PI/d)))},a.Out=function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),c*Math.pow(2,-10*a)*Math.sin(2*(a-b)*Math.PI/d)+1)},a.InOut=function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),(a*=2)<1?-.5*c*Math.pow(2,10*(a-=1))*Math.sin(2*(a-b)*Math.PI/d):c*Math.pow(2,-10*(a-=1))*Math.sin(2*(a-b)*Math.PI/d)*.5+1)},a}();a.Elastic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Exponential"},a.In=function(a){return 0===a?0:Math.pow(1024,a-1)},a.Out=function(a){return 1===a?1:1-Math.pow(2,-10*a)},a.InOut=function(a){return 0===a?0:1===a?1:(a*=2)<1?.5*Math.pow(1024,a-1):.5*(-Math.pow(2,-10*(a-1))+2)},a}();a.Exponential=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Linear"},a.None=function(a){return a},a}();a.Linear=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Quadratic"},a.In=function(a){return a*a},a.Out=function(a){return a*(2-a)},a.InOut=function(a){return(a*=2)<1?.5*a*a:-.5*(--a*(a-2)-1)},a}();a.Quadratic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Quartic"},a.In=function(a){return a*a*a*a},a.Out=function(a){return 1- --a*a*a*a},a.InOut=function(a){return(a*=2)<1?.5*a*a*a*a:-.5*((a-=2)*a*a*a-2)},a}();a.Quartic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Quintic"},a.In=function(a){return a*a*a*a*a},a.Out=function(a){return--a*a*a*a*a+1},a.InOut=function(a){return(a*=2)<1?.5*a*a*a*a*a:.5*((a-=2)*a*a*a*a+2)},a}();a.Quintic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Sinusoidal"},a.In=function(a){return 1-Math.cos(a*Math.PI/2)},a.Out=function(a){return Math.sin(a*Math.PI/2)},a.InOut=function(a){return.5*(1-Math.cos(Math.PI*a))},a}();a.Sinusoidal=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(){function b(a,b){this._game=a,this._tweens=[],this.clock=b||this._game.time.clock}return b.prototype.objType=function(){return"TweenManager"},b.prototype.getAll=function(){return this._tweens},b.prototype.removeAll=function(){this._tweens.length=0},b.prototype.create=function(b){var c=new a.Animations.Tween(b,this._game);return this.validateClock(),c.manager=this,c},b.prototype.add=function(a){return a.setParent(this._game),a.manager=this,this.validateClock(),this._tweens.push(a),a},b.prototype.remove=function(a){var b=this._tweens.indexOf(a);return-1!==b&&this._tweens.splice(b,1),a},b.prototype.update=function(){var a=0,b=this._tweens.length;if(0===this._tweens.length)return!1;for(;b>a;)this._tweens[a].update(1e3*this.clock.elapsed())?a++:(this._tweens.splice(a,1),b--);return!0},b.prototype.validateClock=function(){this.clock||(this.clock=this._game.time.clock,this.clock||a.Log.error("Tween manager could not find valid clock!"))},b}();b.TweenManager=c}(c=b.Tweens||(b.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b,c){void 0===c&&(c=null),this._game=null,this._manager=null,this._object=null,this._valuesStart={},this._valuesEnd={},this._duration=1e3,this._delayTime=0,this._startTime=null,this._easingFunction=a.Animations.Tweens.Easing.Linear.None,this._interpolationFunction=a.Utils.GameMath.linearInterpolation,this._chainedTweens=[],this._onStartCallback=null,this._onStartContext=null,this._onStartCallbackFired=!1,this._onUpdateCallback=null,this._onUpdateContext=null,this._onCompleteCallback=null,this._onCompleteCalled=!1,this._onCompleteContext=null,this.isRunning=!1,this._object=b,null!==c&&(this._game=c,this._manager=this._game.tweens),this.isRunning=!1}return b.prototype.objType=function(){return"Tween"},Object.defineProperty(b.prototype,"manager",{get:function(){return this._manager},set:function(a){this._manager=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"object",{get:function(){return this._object},set:function(a){var b,c={};this._object=a;for(b in this._valuesEnd)a[b]&&(c[b]=this._valuesEnd[b]);this._valuesEnd=c},enumerable:!0,configurable:!0}),b.prototype.to=function(a,b,c,d){return void 0===b&&(b=1e3),void 0===c&&(c=null),void 0===d&&(d=!1),this._duration=b,this._valuesEnd=a,null!==c&&(this._easingFunction=c),d===!0?this.start():this},b.prototype.start=function(){var a;if(null!==this._game&&null!==this._object){this.isRunning=!0,this._manager.add(this),this._onStartCallbackFired=!1,this._onCompleteCalled=!1,this._startTime=1e3*this._manager.clock.elapsed()+this._delayTime;for(var a in this._valuesEnd)if(null!==this._object[a]&&a in this._object){if(this._valuesEnd[a]instanceof Array){if(0===this._valuesEnd[a].length)continue;this._valuesEnd[a]=[this._object[a]].concat(this._valuesEnd[a])}this._valuesStart[a]="function"==typeof this._object[a]?this._object[a]():this._object[a]}return this}},b.prototype.stop=function(){return null!==this._manager&&this._manager.remove(this),this.isRunning=!1,this},b.prototype.setParent=function(a){this._game=a,this._manager=this._game.tweens},b.prototype.delay=function(a){return this._delayTime=a,this},b.prototype.easing=function(a){return this._easingFunction=a,this},b.prototype.interpolation=function(a){return this._interpolationFunction=a,this},b.prototype.chain=function(a){return this._chainedTweens.push(a),this},b.prototype.onStart=function(a,b){return this._onStartCallback=a,this._onStartContext=b,this},b.prototype.onUpdate=function(a,b){return this._onUpdateCallback=a,this._onUpdateContext=b,this},b.prototype.onComplete=function(a,b){return this._onCompleteCallback=a,this._onCompleteContext=b,this},b.prototype.update=function(a){if(a<this._startTime-this._delayTime)return!1;this._onStartCallbackFired===!1&&(null!==this._onStartCallback&&this._onStartCallback.call(this._onStartContext,this._object),this._onStartCallbackFired=!0);var b=(a-this._startTime)/this._duration;b=b>1?1:0>b?0:b;var c=this._easingFunction(b);for(var d in this._valuesStart){var e=this._valuesStart[d],f=this._valuesEnd[d];f instanceof Array?this._object[d]=this._interpolationFunction(f,c):"function"==typeof this._object[d]?this._object[d](e+(f-e)*c):this._object[d]=e+(f-e)*c}if(null!==this._onUpdateCallback&&this._onUpdateCallback.call(this._onUpdateContext,this._object,c),1===b){this.isRunning=!1,null!==this._onCompleteCallback&&this._onCompleteCalled===!1&&(this._onCompleteCalled=!0,this._onCompleteCallback.call(this._onCompleteContext,this._object));for(var g=0;g<this._chainedTweens.length;g++)this._chainedTweens[g].start();return!1}return!0},b}();b.Tween=c}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this.numDrawCalls=0,this._game=a}return b.prototype.boot=function(){},b.prototype.objType=function(){return"CanvasRenderer"},b.prototype._recurse=function(b){if(b.visible)if(b.childType()===a.GROUP)for(var c=0;c<b.members.length;c++)this._recurse(b.members[c]);else this.numDrawCalls++,b.render(this._currentCamera)},b.prototype.requestRendererInstance=function(a,b){return void 0===b&&(b=null),null},b.prototype.requestSharedRenderer=function(a,b){return void 0===b&&(b=null),null},b.prototype.initState=function(){},b.prototype.endState=function(){},b.prototype.render=function(a){var b=this._game.states.current.members,c=this._game.stage.rgbaColor;if(c.a<255&&this._game.stage.ctx.clearRect(0,0,this._game.stage.canvas.width,this._game.stage.canvas.height),this._game.stage.ctx.fillStyle="rgba("+c.r+","+c.g+","+c.b+","+c.a/255+")",this._game.stage.ctx.fillRect(0,0,this._game.stage.canvas.width,this._game.stage.canvas.height),0!=b.length){this.numDrawCalls=0,this._currentCamera=a;var d=a.transform.getConcatenatedMatrix(),e=a.transform;this._game.stage.ctx.save(),this._game.stage.ctx.setTransform(d.a,d.b,d.c,d.d,d.tx,d.ty),this._game.stage.ctx.transform(1,0,0,1,-e.rotPointX,-e.rotPointY);for(var f=0;f<b.length;f++)this._recurse(b[f]);this._game.stage.ctx.restore()}},b}();b.CanvasRenderer=c}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function c(b){this._currentRenderer=null,this._entityCount=0,this.numDrawCalls=0,this._maxItems=1e3,this._currentTextureAtlas=null,this._sharedRenderers={},this._game=b,this._currentBlendMode=new a.Renderers.GLBlendMode(this._game.stage.gl,{mode:"DEFAULT"})}return c.prototype.boot=function(){this._textureManager=new b.GLTextureManager,this._shaderManager=new a.Shaders.ShaderManager,this._init()},c.prototype.objType=function(){return"GLRenderManager"},c.prototype.addTexture=function(a,b){this._textureManager.uploadTexture(a,b)},c.prototype.addSharedRenderer=function(b,c){return void 0===c&&(c=null),!a.Renderers[b]||b in this._sharedRenderers?!1:(this._sharedRenderers[b]=new a.Renderers[b](this._game.stage.gl,this._shaderManager,c),!0)},c.prototype.addSharedRendererClone=function(b,c,d){return void 0===d&&(d=null),"undefined"==typeof d&&(d=null),!a.Renderers[b]||c in this._sharedRenderers?!1:(this._sharedRenderers[c]=new a.Renderers[b](this._game.stage.gl,this._shaderManager,d),!0)},c.prototype.requestSharedRenderer=function(b,c){void 0===c&&(c=null);var d=this._sharedRenderers[b];return d?d:this.addSharedRenderer(b,c)?this._sharedRenderers[b]:(a.Log.log("No renderer called "+b,"#renderer","#webgl"),null)},c.prototype.requestRendererInstance=function(b,c){if(void 0===c&&(c=null),b in a.Renderers){var d=new a.Renderers[b](this._game.stage.gl,this._shaderManager,c);
|
|
return d}return a.Log.log("No renderer with id "+b+" exists","#renderer","#webgl"),null},c.prototype._init=function(){a.Log.log("Initialising WebGL","#renderer","#webgl");var b=this._game.stage.gl;this._stageResolution=new Float32Array([this._game.stage.width,this._game.stage.height]),this._game.deviceTargetOption===a.TARGET_COCOON?this.scaleViewport(b,this._game.stage.scaleType,window.innerWidth,window.innerHeight):this.scaleViewport(b,a.Stage.SCALE_NONE,this._game.stage.width,this._game.stage.height),b.enable(b.BLEND),this._switchBlendMode(b,this._currentBlendMode),this._shaderManager.init(b,"TextureAtlasShader"),this.camMatrix=new Float32Array([1,0,0,0,1,0,0,0,1]),this._camMatrixOffset=new a.Geom.Matrix,this._game.stage.onResize.add(function(c,d){this._stageResolution=new Float32Array([c,d]),this.currentRenderer&&this._currentRenderer.updateStageResolution(b,this._stageResolution),this._game.deviceTargetOption===a.TARGET_COCOON?this.scaleViewport(b,this._game.stage.scaleType,window.innerWidth,window.innerHeight):this.scaleViewport(b,a.Stage.SCALE_NONE,c,d)},this)},c.prototype.scaleViewport=function(b,c,d,e){var f=new a.Geom.Point(0,0);switch(c){case a.Stage.SCALE_FIT:var g=this._game.stage.width/this._game.stage.height,h=d/e;if(h>g){var i=e*g;f.x=(d-i)/2,d=i}else{var j=d/g;f.y=(e-j)/2,e=j}break;case a.Stage.SCALE_STRETCH:break;case a.Stage.SCALE_NONE:d=this._game.stage.width,e=this._game.stage.height}b.viewport(f.x,f.y,d,e)},c.prototype.initState=function(a){this._textureManager.clearTextures(this._game.stage.gl),this._textureManager.uploadTextureLibrary(this._game.stage.gl,a.textureLibrary)},c.prototype.endState=function(){this._textureManager.clearTextures(this._game.stage.gl),a.Log.log("Ending WebGL on State","#renderer","#webgl")},c.prototype.render=function(b){var c=this._game.stage.gl,d=this._game.stage.normalizedColor;if(c.clearColor(d.r*d.a,d.g*d.a,d.b*d.a,d.a),c.clear(c.COLOR_BUFFER_BIT),this._currentRenderer=null,0!=this._game.states.current.members.length){this.numDrawCalls=0,this._textureManager.numTextureWrites=0,this._entityCount=0;var e=b.transform.getConcatenatedMatrix(),f=b.transform;this._camMatrixOffset.identity(),this._camMatrixOffset.translate(-f.anchorPointX,-f.anchorPointY),this._camMatrixOffset.prependMatrix(e),this.camMatrix[0]=this._camMatrixOffset.a,this.camMatrix[1]=this._camMatrixOffset.b,this.camMatrix[3]=this._camMatrixOffset.c,this.camMatrix[4]=this._camMatrixOffset.d,this.camMatrix[6]=this._camMatrixOffset.tx,this.camMatrix[7]=this._camMatrixOffset.ty,this._game.deviceTargetOption==a.TARGET_COCOON&&this._switchBlendMode(c,this._currentBlendMode),this.collateRenderSequence(),this.collateBatches(),this.renderBatches(c,b)}},c.prototype.collateRenderSequence=function(){this._sequence=[];var a=this._game.states.current;this.collateChild(a)},c.prototype.collateChild=function(b){if(b.visible)if(b.childType()===a.GROUP)for(var c=0;c<b.members.length;c++)this.collateChild(b.members[c]);else{var d=b;this._sequence.push({entity:d,renderer:d.glRenderer,shader:d.glRenderer.shaderPair,isBatchRenderer:d.glRenderer.isBatchRenderer,texture:d.atlas})}},c.prototype.collateBatches=function(){var a=null,b=null,c=null;this._batches=[];for(var d,e=0;e<this._sequence.length;e++){if(!this._sequence[e].isBatchRenderer||this._sequence[e].renderer!==a||this._sequence[e].shader!==b||this._sequence[e].texture!==c){var d=this._batches.push(new Array)-1;a=this._sequence[e].renderer,b=this._sequence[e].shader,c=this._sequence[e].texture}this._batches[d].push(this._sequence[e])}},c.prototype.renderBatches=function(a,b){for(var c=0;c<this._batches.length;c++)this.renderBatch(a,this._batches[c],b)},c.prototype.renderBatch=function(b,c,d){var e=!1;c[0].entity.glRenderer!==this._currentRenderer&&(e=!0,this._switchRenderer(b,c[0].entity)),this._currentRenderer.clear(b,{camMatrix:this.camMatrix});for(var f=0;f<c.length;f++)c[f].entity.renderGL(b,d);(c[0].entity.atlas!==this._currentTextureAtlas||c[0].entity.atlas.dirty||e&&c[0].entity.atlas==this._currentTextureAtlas)&&this._switchTexture(b,c[0].entity),(!this._currentBlendMode.isIdentical(c[0].entity.glRenderer.blendMode)||this._currentBlendMode.dirty||this._game.deviceTargetOption===a.TARGET_COCOON)&&this._switchBlendMode(b,c[0].entity.glRenderer.blendMode),this._currentRenderer.draw(b)},c.prototype.renderEntity=function(a,b,c){this.renderBatch(a,[b],c)},c.prototype.setupGLState=function(a,b){b.atlas!==this._currentTextureAtlas&&this._switchTexture(a,b),b.glRenderer!==this._currentRenderer&&this._switchRenderer(a,b)},c.prototype._switchRenderer=function(a,b){this._currentRenderer&&this._currentRenderer.disable(a),this._currentRenderer=b.glRenderer,this._currentRenderer.enable(a,{camMatrix:this.camMatrix,stageResolution:this._stageResolution})},c.prototype._switchTexture=function(a,b){this._currentTextureAtlas=b.atlas,b.atlas.enableGL(a,this._currentRenderer,this._textureManager)},c.prototype._switchBlendMode=function(a,b){this._currentBlendMode=b,this._currentBlendMode.apply(a)},c}();b.GLRenderManager=c}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(){this._shaderPairs={}}return Object.defineProperty(b.prototype,"currentShader",{get:function(){return this._currentShader},enumerable:!0,configurable:!0}),b.prototype.init=function(a,b){this._currentShader=this.requestShader(a,b)},b.prototype.requestShader=function(b,c,d){void 0===d&&(d=!0);var e;return c in this._shaderPairs?(e=this._shaderPairs[c],e.loaded||this._loadShader(b,e),d&&this._useShader(b,e),e):this.shaderExists(b,c)?(e=this._addShader(b,c),this._loadShader(b,e),d&&this._useShader(b,e),e):(a.Log.log("Shader "+c+" does not exist.","#renderer","#webgl"),null)},b.prototype.shaderExists=function(b,c){return c in a.Shaders},b.prototype._addShader=function(b,c){return this._shaderPairs[c]=new a.Shaders[c],this._shaderPairs[c]},b.prototype._loadShader=function(a,b){b.init(a)},b.prototype._useShader=function(a,b){b!==this._currentShader&&(this._currentShader=b),a.useProgram(b.shaderProgram)},b}();b.ShaderManager=c}(b=a.Shaders||(a.Shaders={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a,b,c){void 0===c&&(c=!1),this._created=!1,this._uploaded=!1,this.textureAtlas=b,this._image=b.image,this._numBytes=this._image.width*this._image.height*4,this.createTexture(a),c&&this.uploadTexture(a)}return Object.defineProperty(b.prototype,"numBytes",{get:function(){return this._numBytes},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"created",{get:function(){return this._created},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"uploaded",{get:function(){return this._uploaded},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"image",{get:function(){return this._image},set:function(a){this._image=a,this._numBytes=this._image.width*this._image.height*4,this._uploaded=!1},enumerable:!0,configurable:!0}),b.prototype.createTexture=function(a){return this.texture=a.createTexture(),this._created=!0,!0},b.prototype.uploadTexture=function(b){var c=!1;return this.created||this.createTexture(b),this.uploaded?a.Log.log("...not uploading:the image is already uploaded.","#renderer","#webgl"):(b.bindTexture(b.TEXTURE_2D,this.texture),b.pixelStorei(b.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,this._image),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.LINEAR),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.LINEAR),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE),b.bindTexture(b.TEXTURE_2D,null),this._uploaded=!0,c=!0),c},b.prototype.refreshTexture=function(a){this.numBytes=this._image.width*this._image.height*4,a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,this._image)},b.prototype.deleteTexture=function(a){return a.deleteTexture(this.texture),this._uploaded=!1,this._created=!1,!0},b}();b.GLTextureWrapper=c}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(){this.numTextureWrites=0,this._numTexturesUsed=0,this._usedTextureMem=0,this.maxTextureMem=1024*b.DEFAULT_MAX_TEX_MEM_MB*1024,this._textureWrapperCache=new Array}return Object.defineProperty(b.prototype,"usedTextureMem",{get:function(){return this._usedTextureMem},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"numTexturesUsed",{get:function(){return this._numTexturesUsed},enumerable:!0,configurable:!0}),b.prototype._addTextureToCache=function(a){this._textureWrapperCache.push(a)},b.prototype._deleteTexture=function(a,b){this._textureWrapperCache[b].deleteTexture(a),this._usedTextureMem-=this._textureWrapperCache[b].numBytes,this._numTexturesUsed--},b.prototype._uploadTexture=function(a,b){return b.numBytes+this._usedTextureMem<=this.maxTextureMem?(b.uploadTexture(a),this._usedTextureMem+=b.numBytes,this._numTexturesUsed++,!0):!1},b.prototype.uploadTextureLibrary=function(a,b){this._textureWrapperCache=new Array;for(var c in b.textures)b.textures[c].createGLTextureWrapper(a,this)},b.prototype.uploadTexture=function(a,b){b.createGLTextureWrapper(a,this)},b.prototype.registerTextureWrapper=function(b,c){this._addTextureToCache(c),this._uploadTexture(b,c)||a.Log.log("...skipped uploading texture due to allocated texture memory exceeded.","#renderer","#webgl")},b.prototype.clearTextures=function(a){for(var b=0;b<this._textureWrapperCache.length;b++)this._deleteTexture(a,b),this._textureWrapperCache[b].textureAtlas.glTextureWrapper=null;this._textureWrapperCache=new Array},b.prototype.useTexture=function(b,c,d){if(void 0===d&&(d=0),d=a.Utils.GameMath.clamp(a.Utils.GameMath.truncate(d),31),c.created&&c.uploaded||(this._uploadTexture(b,c)||(this._freeSpace(b,c.numBytes),this._uploadTexture(b,c)),this.numTextureWrites++),c.created&&c.uploaded){var e=b.TEXTURE0+d;return b.activeTexture(e),b.bindTexture(b.TEXTURE_2D,c.texture),!0}return!1},b.prototype._freeSpace=function(a,b){for(var c=0,d=0;d<this._textureWrapperCache.length;d++)if(this._textureWrapperCache[d].uploaded&&(c+=this._textureWrapperCache[d].numBytes,this._deleteTexture(a,d)),c>=b)return!0;return!1},b.DEFAULT_MAX_TEX_MEM_MB=1024,b}();b.GLTextureManager=c}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(b,c,d,e){void 0===e&&(e=!0),this._created=!1,this._uploaded=!1,this.items=d||a.squareVertices,this.itemSize=c||2,this.numItems=this.items.length/this.itemSize,this.createBuffer(b),e&&this.uploadBuffer(b,this.items)}return Object.defineProperty(a.prototype,"created",{get:function(){return this._created},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"uploaded",{get:function(){return this._uploaded},enumerable:!0,configurable:!0}),a.prototype.clear=function(){this.items=new Array},a.prototype.createBuffer=function(a){return this.buffer=a.createBuffer(),this._created=!0,!0},a.prototype.uploadBuffer=function(a,b){this.items=b,this.numItems=this.items.length/this.itemSize;var c=new Float32Array(this.items);return a.bindBuffer(a.ARRAY_BUFFER,this.buffer),a.bufferData(a.ARRAY_BUFFER,c,a.DYNAMIC_DRAW),this._uploaded=!0,!0},a.prototype.deleteBuffer=function(a){return a.bindBuffer(a.ARRAY_BUFFER,this.buffer),a.deleteBuffer(this.buffer),this.uploaded=!1,this.created=!1,!0},a.squareVertices=[0,0,100,0,100,100,0,100],a.squareUVs=[0,0,.1,0,.1,.1,0,.1],a.squareCols=[1,1,1,1],a}();a.GLArrayBuffer=b}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b){this.gl=a,this.dirty=!0,this._srcRGB=a.SRC_ALPHA,this._dstRGB=a.ONE_MINUS_SRC_ALPHA,this._srcAlpha=a.ONE,this._dstAlpha=a.ONE,this._modeRGB=a.FUNC_ADD,this._modeAlpha=a.FUNC_ADD,"undefined"==typeof b&&(b=null),b&&this.readConfig(b)}return a.prototype.readConfig=function(a){void 0!==a.mode?this.setMode(a.mode):(a.srcRGB=this.makeConstant(a.srcRGB),"undefined"!=typeof a.srcRGB&&(this._srcRGB=a.srcRGB),a.dstRGB=this.makeConstant(a.dstRGB),"undefined"!=typeof a.dstRGB&&(this._dstRGB=a.dstRGB),a.srcAlpha=this.makeConstant(a.srcAlpha),"undefined"!=typeof a.srcAlpha&&(this._srcAlpha=a.srcAlpha),a.dstAlpha=this.makeConstant(a.dstAlpha),"undefined"!=typeof a.dstAlpha&&(this._dstAlpha=a.dstAlpha),a.modeRGB=this.makeConstant(a.modeRGB),"undefined"!=typeof a.modeRGB&&(this._modeRGB=a.modeRGB),a.modeAlpha=this.makeConstant(a.modeAlpha),"undefined"!=typeof a.modeAlpha&&(this._modeAlpha=a.modeAlpha)),this.dirty=!0},a.prototype.makeConstant=function(a){if("number"==typeof a)return a;switch("string"==typeof a&&(a=a.toUpperCase()),a){case"ZERO":a=this.gl.ZERO;break;case"ONE":a=this.gl.ONE;break;case"SRC_COLOR":case"SRC_COLOUR":a=this.gl.SRC_COLOR;break;case"ONE_MINUS_SRC_COLOR":case"ONE_MINUS_SRC_COLOUR":a=this.gl.ONE_MINUS_SRC_COLOR;break;case"DST_COLOR":case"DST_COLOUR":a=this.gl.DST_COLOR;break;case"ONE_MINUS_DST_COLOR":case"ONE_MINUS_DST_COLOUR":a=this.gl.ONE_MINUS_DST_COLOR;break;case"SRC_ALPHA":a=this.gl.SRC_ALPHA;break;case"ONE_MINUS_SRC_ALPHA":a=this.gl.ONE_MINUS_SRC_ALPHA;break;case"DST_ALPHA":a=this.gl.DST_ALPHA;break;case"ONE_MINUS_DST_ALPHA":a=this.gl.ONE_MINUS_DST_ALPHA;break;case"SRC_ALPHA_SATURATE":a=this.gl.SRC_ALPHA_SATURATE;break;case"CONSTANT_COLOR":case"CONSTANT_COLOUR":a=this.gl.CONSTANT_COLOR;break;case"ONE_MINUS_CONSTANT_COLOR":case"ONE_MINUS_CONSTANT_COLOUR":a=this.gl.ONE_MINUS_CONSTANT_COLOR;break;case"CONSTANT_ALPHA":a=this.gl.CONSTANT_ALPHA;break;case"ONE_MINUS_CONSTANT_ALPHA":a=this.gl.ONE_MINUS_CONSTANT_ALPHA;break;case"FUNC_ADD":a=this.gl.FUNC_ADD;break;case"FUNC_SUBTRACT":a=this.gl.FUNC_SUBTRACT;break;case"FUNC_REVERSE_SUBTRACT":a=this.gl.FUNC_REVERSE_SUBTRACT;break;default:a=void 0}return a},a.prototype.setMode=function(a){switch(a=a.toUpperCase()){case"ADDITIVE":case"ADD":this._srcRGB=this.gl.SRC_ALPHA,this._dstRGB=this.gl.ONE,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_ADD,this._modeAlpha=this.gl.FUNC_ADD;break;case"SUBTRACT":case"SUBTRACTIVE":this._srcRGB=this.gl.SRC_ALPHA,this._dstRGB=this.gl.ONE,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_REVERSE_SUBTRACT,this._modeAlpha=this.gl.FUNC_ADD;break;case"ERASE":case"ERASER":this._srcRGB=this.gl.SRC_ALPHA,this._dstRGB=this.gl.ONE_MINUS_SRC_ALPHA,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_REVERSE_SUBTRACT,this._modeAlpha=this.gl.FUNC_REVERSE_SUBTRACT;break;case"BLACK":case"BLACKEN":this._srcRGB=this.gl.ZERO,this._dstRGB=this.gl.ONE_MINUS_SRC_ALPHA,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_ADD,this._modeAlpha=this.gl.FUNC_ADD;break;case"NORMAL":default:this._srcRGB=this.gl.SRC_ALPHA,this._dstRGB=this.gl.ONE_MINUS_SRC_ALPHA,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_ADD,this._modeAlpha=this.gl.FUNC_ADD}this.dirty=!0},a.prototype.isIdentical=function(a){return this==a?!0:this._srcRGB==a._srcRGB&&this._dstRGB==a._dstRGB&&this._srcAlpha==a._srcAlpha&&this._dstAlpha==a._dstAlpha&&this._modeRGB==a._modeRGB&&this._modeAlpha==a._modeAlpha?!0:!1},a.prototype.apply=function(a){a.blendEquationSeparate(this._modeRGB,this._modeAlpha),a.blendFuncSeparate(this._srcRGB,this._dstRGB,this._srcAlpha,this._dstAlpha),this.dirty=!1},a}();a.GLBlendMode=b}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(b,c,d,e){void 0===e&&(e=!0),this.indices=d||a.square,this.itemSize=c||1,this.numItems=this.indices.length/this.itemSize,e&&(this.buffer=this.init(b))}return a.prototype.clear=function(){this.indices=new Array},a.prototype.init=function(a){var b=a.createBuffer();return a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,b),a.bufferData(a.ELEMENT_ARRAY_BUFFER,new Uint16Array(this.indices),a.STATIC_DRAW),b},a.prototype.refresh=function(a){return this.numItems=this.indices.length/this.itemSize,a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.buffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,new Uint16Array(this.indices),a.STATIC_DRAW),this.buffer},a.square=[0,1,2,0,2,3],a}();a.GLElementArrayBuffer=b}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b,c,d){void 0===d&&(d=!1),this.loaded=!1,this._isBatchRenderer=!1,this.shaderManager=c,this._isBatchRenderer=d,this.loaded=!0,this.blendMode=new a.Renderers.GLBlendMode(b,{mode:"NORMAL"})}return b.prototype.enable=function(a,b){void 0===b&&(b=null)},b.prototype.disable=function(){},b.prototype.clear=function(){},b.prototype.draw=function(){},b.prototype.updateStageResolution=function(){},b.prototype.updateTextureSize=function(){},Object.defineProperty(b.prototype,"isBatchRenderer",{get:function(){return this._isBatchRenderer},enumerable:!0,configurable:!0}),b.RENDERER_ID="Renderer",b}();b.Renderer=c}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(c){function d(d,e,f){void 0===f&&(f=null),c.call(this,d,e,!0),this._shaderPairName="TextureAtlasShader",this._maxItems=1e3,this._pt1=new a.Geom.Point(0,0),this._pt2=new a.Geom.Point(0,0),this._pt3=new a.Geom.Point(0,0),this._pt4=new a.Geom.Point(0,0);var g=5;this._vertexBuffer=new b.GLArrayBuffer(d,g);var h=6;this._indexBuffer=new b.GLElementArrayBuffer(d,1,this._generateIndices(this._maxItems*h)),this.shaderPair=this.shaderManager.requestShader(d,this._shaderPairName)}return __extends(d,c),d.prototype.enable=function(a,b){void 0===b&&(b=null),this.shaderPair=this.shaderManager.requestShader(a,this._shaderPairName,!0),a.uniform1i(this.shaderPair.uniforms.uSampler.location,0),a.uniform2fv(this.shaderPair.uniforms.uResolution.location,b.stageResolution),a.uniformMatrix3fv(this.shaderPair.uniforms.uCamMatrix.location,!1,b.camMatrix)},d.prototype.disable=function(a){a.disableVertexAttribArray(this.shaderPair.attributes.aXYUV),a.disableVertexAttribArray(this.shaderPair.attributes.aAlpha)},d.prototype.clear=function(a,b){this._vertexBuffer.clear(),a.uniformMatrix3fv(this.shaderPair.uniforms.uCamMatrix.location,!1,b.camMatrix)},d.prototype.draw=function(a){this._vertexBuffer.uploadBuffer(a,this._vertexBuffer.items),a.enableVertexAttribArray(this.shaderPair.attributes.aXYUV),a.vertexAttribPointer(this.shaderPair.attributes.aXYUV,4,a.FLOAT,!1,20,0),a.enableVertexAttribArray(this.shaderPair.attributes.aAlpha),a.vertexAttribPointer(this.shaderPair.attributes.aAlpha,1,a.FLOAT,!1,20,16),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this._indexBuffer.buffer),a.drawElements(a.TRIANGLES,this._vertexBuffer.items.length/20*6,a.UNSIGNED_SHORT,0)},d.prototype._generateIndices=function(a){for(var b=new Array,c=0;a>c;c++)b.push(4*c+0,4*c+1,4*c+2,4*c+0,4*c+2,4*c+3);return b},d.prototype.updateStageResolution=function(a,b){a.uniform2fv(this.shaderPair.uniforms.uResolution.location,b)},d.prototype.updateTextureSize=function(a,b){a.uniform2fv(this.shaderPair.uniforms.uTextureSize.location,b)},d.prototype.setShaderPair=function(a){"string"==typeof a&&(this._shaderPairName=a)},d.prototype.addToBatch=function(a,b){if(!(b.alpha<=0)){var c=b.transform,d=c.getConcatenatedMatrix(),e=b.atlas.cells[b.cellIndex];this._pt1.setTo(0-c.rotPointX,0-c.rotPointY),this._pt2.setTo(e.w-c.rotPointX,0-c.rotPointY),this._pt3.setTo(e.w-c.rotPointX,e.h-c.rotPointY),this._pt4.setTo(0-c.rotPointX,e.h-c.rotPointY),d.transformPoint(this._pt1),d.transformPoint(this._pt2),d.transformPoint(this._pt3),d.transformPoint(this._pt4),this._vertexBuffer.items.push(this._pt1.x,this._pt1.y,e.x,e.y,b.alpha,this._pt2.x,this._pt2.y,e.x+e.w,e.y,b.alpha,this._pt3.x,this._pt3.y,e.x+e.w,e.y+e.h,b.alpha,this._pt4.x,this._pt4.y,e.x,e.y+e.h,b.alpha)}},d.prototype.concatBatch=function(a){this._vertexBuffer.items=this._vertexBuffer.items.concat(a)},d.RENDERER_ID="TextureAtlasRenderer",d}(b.Renderer);b.TextureAtlasRenderer=c}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){this.loaded=!1}return a.prototype.init=function(a){this.vertShader=this.compile(a,this.vertSource.join("\n"),a.VERTEX_SHADER),this.fragShader=this.compile(a,this.fragSource.join("\n"),a.FRAGMENT_SHADER),this.shaderProgram=this.attach(a,this.vertShader,this.fragShader),this.loaded=!0},a.prototype.attach=function(a,b,c){var d=a.createProgram();return a.attachShader(d,c),a.attachShader(d,b),a.linkProgram(d),d},a.prototype.compile=function(a,b,c){var d=a.createShader(c);return a.shaderSource(d,b),a.compileShader(d),a.getShaderParameter(d,a.COMPILE_STATUS)?d:null},a.prototype.setParam=function(a,b){this.uniforms[a].value=b,this.uniforms[a].dirty=!0},a.prototype.applyUniforms=function(a){for(var b in this.uniforms)this.applyUniform(a,b)},a.prototype.applyUniform=function(a,b){var c=this.uniforms[b];this.uniforms[b].dirty&&(a["uniform"+c.type](c.location,c.value),this.uniforms[b].dirty=!1)},a.prototype.initUniforms=function(a){for(var b in this.uniforms){var c=this.uniforms[b];c.location=a.getUniformLocation(this.shaderProgram,b),c.dirty=!0,c.value=null}},a.RENDERER_ID="ShaderPair",a}();a.ShaderPair=b}(b=a.Shaders||(a.Shaders={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(a){function b(){a.call(this),this.attributes={aXYUV:null,aAlpha:null},this.uniforms={uCamMatrix:{type:"mat3"},uResolution:{type:"2fv"},uTextureSize:{type:"2fv"},uSampler:{type:"1i"}},this.fragSource=["precision mediump float;","varying vec2 vTextureCoord;","varying float vAlpha;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));","gl_FragColor.a *= vAlpha;","}"],this.vertSource=["attribute vec4 aXYUV;","attribute float aAlpha;","uniform mat3 uCamMatrix;","uniform vec2 uResolution;","uniform vec2 uTextureSize;","varying vec2 vTextureCoord;","varying float vAlpha;","void main(void) {"," vec2 pos = (uCamMatrix * vec3(aXYUV.xy,1)).xy; "," gl_Position = vec4((pos / uResolution * 2.0 - 1.0) * vec2(1, -1), 0, 1);"," vTextureCoord = aXYUV.zw / uTextureSize;"," vAlpha = aAlpha;","}"]}return __extends(b,a),b.prototype.init=function(b){a.prototype.init.call(this,b),this.attributes.aXYUV=b.getAttribLocation(this.shaderProgram,"aXYUV"),this.attributes.aAlpha=b.getAttribLocation(this.shaderProgram,"aAlpha"),this.initUniforms(b)},b}(a.ShaderPair);a.TextureAtlasShader=b}(b=a.Shaders||(a.Shaders={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a,b,c,d){this._frameIndex=0,this._startTime=null,this._reverse=!1,this._isPlaying=!1,this._onStop=null,this._onPlay=null,this._onUpdate=null,this._onLoop=null,this._onComplete=null,this.name=a,this._sequence=b,this._speed=b.speed,this._loop=b.loop,this._parent=d,this._clock=c,this._lastFrameElapsed=this.clock.elapsed()}return b.prototype.objType=function(){return"Animation"},Object.defineProperty(b.prototype,"loop",{get:function(){return this._loop},set:function(a){this._loop=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"frameIndex",{get:function(){return this._frameIndex},set:function(a){a=Math.floor(a),this._validateFrame(a)&&(this._frameIndex=a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"currentCell",{get:function(){return this._sequence.cells[this.frameIndex]},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"speed",{get:function(){return this._speed},set:function(a){this._speed=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"clock",{get:function(){return this._clock?this._clock:this._parent.entity.clock},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"reverse",{get:function(){return this._reverse},set:function(a){this._reverse=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isPlaying",{get:function(){return this._isPlaying},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onStop",{get:function(){return null==this._onStop&&(this._onStop=new a.Signal),this._onStop},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onPlay",{get:function(){return null==this._onPlay&&(this._onPlay=new a.Signal),this._onPlay},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onUpdate",{get:function(){return null==this._onUpdate&&(this._onUpdate=new a.Signal),this._onUpdate},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onLoop",{get:function(){return null==this._onLoop&&(this._onLoop=new a.Signal),this._onLoop},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onComplete",{get:function(){return null==this._onComplete&&(this._onComplete=new a.Signal),this._onComplete},enumerable:!0,configurable:!0}),b.prototype._start=function(a){void 0===a&&(a=null),null!==a&&(this.frameIndex=a),(this.frameIndex>=this.length-1||this.frameIndex<0)&&(this.frameIndex=0),this._isPlaying=!0,this._startTime=this.clock.elapsed(),this._lastFrameElapsed=this.clock.elapsed(),null!==this._onPlay&&this._onPlay.dispatch()},b.prototype.play=function(){this.playAt(this._frameIndex)},b.prototype.playAt=function(a){this._start(a)},b.prototype.pause=function(){this.stop()},b.prototype.resume=function(){null!==this._startTime&&(this._isPlaying=!0)},b.prototype.stop=function(){this._isPlaying&&(this._isPlaying=!1,null!==this._onStop&&this._onStop.dispatch())},b.prototype.nextFrame=function(){this._frameIndex++,this._frameIndex>=this.length&&(this.frameIndex=0)},b.prototype.prevFrame=function(){this._frameIndex--,this._frameIndex<0&&(this.frameIndex=this.length-1)},b.prototype.update=function(){var a,b,c;if(this._isPlaying&&(a=(this.clock.elapsed()-this._lastFrameElapsed)/this._speed%(this.length+1),this._reverse&&(a*=-1),a=a>0?Math.floor(a):Math.ceil(a),0!==a)){if(this._frameIndex+=a,this._lastFrameElapsed=this.clock.elapsed(),this._loop){if(this._frameIndex>=this.length){if(c=Math.floor(this._frameIndex/this.length),this._frameIndex=this._frameIndex%this.length,null!=this._onLoop)for(b=0;c>b;b++)this._onLoop.dispatch()}else if(this._frameIndex<0&&(c=Math.ceil(Math.abs(this._frameIndex)/this.length),this._frameIndex=(this.length+this._frameIndex%this.length)%this.length,null!=this._onLoop))for(b=0;c>b;b++)this._onLoop.dispatch()}else{if(this._frameIndex<0)return this._frameIndex=(this.length+this._frameIndex%this.length)%this.length,void this._parent.stop();if(this._frameIndex>=this.length)return this._frameIndex=this._frameIndex%this.length,this._parent.stop(),void(null!=this._onComplete&&this._onComplete.dispatch())}this._parent.updateCellIndex(),null!==this._onUpdate&&this._onUpdate.dispatch()}},b.prototype._validateFrame=function(a){return a<this.length&&a>=0},Object.defineProperty(b.prototype,"length",{get:function(){return this._sequence.cells.length},enumerable:!0,configurable:!0}),b.prototype.destroy=function(){this._isPlaying=!1,delete this._clock,delete this._sequence,delete this._parent,this._onLoop&&this._onLoop.dispose(),this._onStop&&this._onStop.dispose(),this._onPlay&&this._onPlay.dispose(),this._onUpdate&&this._onUpdate.dispose(),delete this._onLoop,delete this._onStop,delete this._onPlay,delete this._onUpdate,delete this.frameIndex,delete this.loop,delete this._reverse,delete this._tick},b}();b.Animation=c}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b,c,d){void 0===c&&(c=.1),void 0===d&&(d=!0),this.name=a,this.cells=b,this.speed=c,this.loop=d}return a}();a.Sequence=b}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b,c){this.preventDefault=!1,this.isDown=!1,this.isUp=!0,this.altKey=!1,this.ctrlKey=!1,this.shiftKey=!1,this.timeDown=0,this.timeUp=0,this.repeats=0,this._manager=a,this.game=this._manager.game,this.keyCode=b,c&&this.update(c)}return a.prototype.objType=function(){return"Key"},Object.defineProperty(a.prototype,"duration",{get:function(){return this.isDown&&(this.timeDown=this.game.time.now()),this.timeDown<this.timeUp?0:this.timeDown-this.timeUp},enumerable:!0,configurable:!0}),a.prototype.update=function(a){this.keyCode=a.keyCode,this.preventDefault&&a.preventDefault(),"keydown"===a.type?(this.altKey=a.altKey,this.ctrlKey=a.ctrlKey,this.shiftKey=a.shiftKey,this.isDown===!0?(this.repeats++,this.timeDown=this.game.time.now()):(this.isDown=!0,this.isUp=!1,this.timeDown=this.game.time.now(),this.repeats=0)):"keyup"===a.type&&(this.isDown=!1,this.isUp=!0,this.timeUp=this.game.time.now())},a.prototype.justPressed=function(a){return void 0===a&&(a=this._manager.justPressedRate),this.isDown===!0&&this.timeDown+a>this.game.time.now()?!0:!1},a.prototype.justReleased=function(a){return void 0===a&&(a=this._manager.justReleasedRate),this.isUp===!0&&this.timeUp+a>this.game.time.now()?!0:!1},a.prototype.reset=function(){this.isDown=!1,this.isUp=!0,this.timeUp=0,this.timeDown=0,this.repeats=0,this.altKey=!1,this.shiftKey=!1,this.ctrlKey=!1},a}();a.Key=b}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._keys=[],this.justPressedRate=200,this.justReleasedRate=200,this.game=a}return b.prototype.objType=function(){return"Keyboard"},Object.defineProperty(b.prototype,"keys",{get:function(){return this._keys},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this.onKeyUp=new a.Signal,this.onKeyDown=new a.Signal,this.onKeyDownOnce=new a.Signal,this.start()},b.prototype.update=function(){},b.prototype.start=function(){var b=this;this.game.deviceTargetOption===a.TARGET_BROWSER&&(document.body.addEventListener("keydown",function(a){return b._keyPressed(a)},!1),document.body.addEventListener("keyup",function(a){return b._keyReleased(a)},!1))},b.prototype.stop=function(){var b=this;this.game.deviceTargetOption===a.TARGET_BROWSER&&(document.body.removeEventListener("keydown",function(a){return b._keyPressed(a)},!1),document.body.removeEventListener("keyup",function(a){return b._keyReleased(a)},!1))},b.prototype._keyPressed=function(b){this._keys[b.keyCode]?this._keys[b.keyCode].update(b):this._keys[b.keyCode]=new a.Input.Key(this,b.keyCode,b),0==this._keys[b.keyCode].repeats&&this.onKeyDownOnce.dispatch(b.keyCode,this._keys[b.keyCode]),this.onKeyDown.dispatch(b.keyCode,this._keys[b.keyCode])},b.prototype._keyReleased=function(b){this._keys[b.keyCode]?this._keys[b.keyCode].update(b):this._keys[b.keyCode]=new a.Input.Key(this,b.keyCode,b),this.onKeyUp.dispatch(b.keyCode,this._keys[b.keyCode])},b.prototype.addKey=function(b,c){void 0===c&&(c=!1);var d=new a.Input.Key(this,b);return d.preventDefault=c,this._keys[b]=d},b.prototype.justPressed=function(a,b){return void 0===b&&(b=this.justPressedRate),this._keys[a]?this._keys[a].justPressed(b):!1},b.prototype.justReleased=function(a,b){return void 0===b&&(b=this.justReleasedRate),this._keys[a]?this._keys[a].justReleased(b):!1},b.prototype.isDown=function(a){return this._keys[a]?this._keys[a].isDown:!1},b.prototype.isUp=function(a){return this._keys[a]?this._keys[a].isUp:!1},b.prototype.reset=function(){for(var a in this._keys)this._keys[a].reset()},b}();b.Keyboard=c}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Keycodes"},a.A="A".charCodeAt(0),a.B="B".charCodeAt(0),a.C="C".charCodeAt(0),a.D="D".charCodeAt(0),a.E="E".charCodeAt(0),a.F="F".charCodeAt(0),a.G="G".charCodeAt(0),a.H="H".charCodeAt(0),a.I="I".charCodeAt(0),a.J="J".charCodeAt(0),a.K="K".charCodeAt(0),a.L="L".charCodeAt(0),a.M="M".charCodeAt(0),a.N="N".charCodeAt(0),a.O="O".charCodeAt(0),a.P="P".charCodeAt(0),a.Q="Q".charCodeAt(0),a.R="R".charCodeAt(0),a.S="S".charCodeAt(0),a.T="T".charCodeAt(0),a.U="U".charCodeAt(0),a.V="V".charCodeAt(0),a.W="W".charCodeAt(0),a.X="X".charCodeAt(0),a.Y="Y".charCodeAt(0),a.Z="Z".charCodeAt(0),a.ZERO="0".charCodeAt(0),a.ONE="1".charCodeAt(0),a.TWO="2".charCodeAt(0),a.THREE="3".charCodeAt(0),a.FOUR="4".charCodeAt(0),a.FIVE="5".charCodeAt(0),a.SIX="6".charCodeAt(0),a.SEVEN="7".charCodeAt(0),a.EIGHT="8".charCodeAt(0),a.NINE="9".charCodeAt(0),a.NUMPAD_0=96,a.NUMPAD_1=97,a.NUMPAD_2=98,a.NUMPAD_3=99,a.NUMPAD_4=100,a.NUMPAD_5=101,a.NUMPAD_6=102,a.NUMPAD_7=103,a.NUMPAD_8=104,a.NUMPAD_9=105,a.NUMPAD_MULTIPLY=106,a.NUMPAD_ADD=107,a.NUMPAD_ENTER=108,a.NUMPAD_SUBTRACT=109,a.NUMPAD_DECIMAL=110,a.NUMPAD_DIVIDE=111,a.F1=112,a.F2=113,a.F3=114,a.F4=115,a.F5=116,a.F6=117,a.F7=118,a.F8=119,a.F9=120,a.F10=121,a.F11=122,a.F12=123,a.F13=124,a.F14=125,a.F15=126,a.COLON=186,a.EQUALS=187,a.UNDERSCORE=189,a.QUESTION_MARK=191,a.TILDE=192,a.OPEN_BRACKET=219,a.BACKWARD_SLASH=220,a.CLOSED_BRACKET=221,a.QUOTES=222,a.BACKSPACE=8,a.TAB=9,a.CLEAR=12,a.ENTER=13,a.SHIFT=16,a.CONTROL=17,a.ALT=18,a.CAPS_LOCK=20,a.ESC=27,a.SPACEBAR=32,a.PAGE_UP=33,a.PAGE_DOWN=34,a.END=35,a.HOME=36,a.LEFT=37,a.UP=38,a.RIGHT=39,a.DOWN=40,a.INSERT=45,a.DELETE=46,a.HELP=47,a.NUM_LOCK=144,a
|
|
}();a.Keycodes=b}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this.game=a}return b.prototype.objType=function(){return"InputManager"},Object.defineProperty(b.prototype,"pointers",{get:function(){return this._pointers},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this._pointers=[],this.mouse=new a.Input.Mouse(this.game),this.mouse.boot(),this.keyboard=new a.Input.Keyboard(this.game),this.keyboard.boot(),this.touch=new a.Input.Touch(this.game),this.touch.boot(),this.mouse.onDown.add(this._onDownEvent,this),this.mouse.onUp.add(this._onUpEvent,this),this.touch.touchDown.add(this._onDownEvent,this),this.touch.touchUp.add(this._onUpEvent,this),this._pointers=this.touch.fingers.slice(),this._pointers.push(this.mouse.cursor),this.isDown=!1,this.position=new a.Geom.Point,this.onDown=new a.Signal,this.onUp=new a.Signal},b.prototype._onDownEvent=function(a,b,c,d,e,f){this.onDown.dispatch(a,b,c,d,e,f)},b.prototype._onUpEvent=function(a,b,c,d,e,f){this.onUp.dispatch(a,b,c,d,e,f)},Object.defineProperty(b.prototype,"onPressed",{get:function(){return this.onDown},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onReleased",{get:function(){return this.onUp},enumerable:!0,configurable:!0}),b.prototype.update=function(){this.mouse.update(),this.keyboard.update(),this.touch.update(),this.touch.touchEnabled?this.position.setTo(this.touch.x,this.touch.y):this.position.setTo(this.mouse.x,this.mouse.y),this.isDown=this.mouse.isDown||this.touch.isDown},b.prototype.reset=function(){this.mouse.reset(),this.keyboard.reset(),this.touch.reset()},Object.defineProperty(b.prototype,"x",{get:function(){return this.position.x},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this.position.y},enumerable:!0,configurable:!0}),b}();b.InputManager=c}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._domElement=null,this.preventContextMenu=!1,this._game=a}return b.prototype.objType=function(){return"Mouse"},Object.defineProperty(b.prototype,"cursor",{get:function(){return this._cursor},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this._domElement=this._game.stage.container,this._cursor=new a.Input.MouseCursor(this._game),this._cursor.active=!0,this._cursor.id=1,this.onDown=new a.Signal,this.onUp=new a.Signal,this.onWheel=new a.Signal,this.onContext=new a.Signal,this.start()},Object.defineProperty(b.prototype,"isDown",{get:function(){return this._cursor.isDown},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isUp",{get:function(){return this._cursor.isUp},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"duration",{get:function(){return this._cursor.duration},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"x",{get:function(){return this._cursor.x},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this._cursor.y},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"wheelDeltaX",{get:function(){return this._cursor.wheelDeltaX},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"wheelDeltaY",{get:function(){return this._cursor.wheelDeltaY},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"ctrlKey",{get:function(){return this._cursor.ctrlKey},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"shiftKey",{get:function(){return this._cursor.shiftKey},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"altKey",{get:function(){return this._cursor.altKey},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"button",{get:function(){return this._cursor.button},enumerable:!0,configurable:!0}),b.prototype.update=function(){this._cursor.update()},b.prototype.start=function(){this._onMouseDownBind=this.onMouseDown.bind(this),this._onMouseMoveBind=this.onMouseMove.bind(this),this._onMouseUpBind=this.onMouseUp.bind(this),this._onMouseWheelBind=this.onMouseWheel.bind(this),this._onContextMenuBind=this.onContextMenu.bind(this),this._game.deviceTargetOption===a.TARGET_BROWSER?(this._domElement.addEventListener("mousedown",this._onMouseDownBind,!0),this._domElement.addEventListener("mousemove",this._onMouseMoveBind,!0),this._domElement.addEventListener("mouseup",this._onMouseUpBind,!0),this._domElement.addEventListener("mousewheel",this._onMouseWheelBind,!0),this._domElement.addEventListener("DOMMouseScroll",this._onMouseWheelBind,!0),this._domElement.addEventListener("contextmenu",this._onContextMenuBind,!0)):this._game.deviceTargetOption===a.TARGET_COCOON&&(this._game.stage.canvas.addEventListener("mousedown",this._onMouseDownBind,!0),this._game.stage.canvas.addEventListener("mousemove",this._onMouseMoveBind,!0),this._game.stage.canvas.addEventListener("mouseup",this._onMouseUpBind,!0),this._game.stage.canvas.addEventListener("mousewheel",this._onMouseWheelBind,!0),this._game.stage.canvas.addEventListener("DOMMouseScroll",this._onMouseWheelBind,!0))},b.prototype.stop=function(){this._game.deviceTargetOption===a.TARGET_BROWSER?(this._domElement.removeEventListener("mousedown",this._onMouseDownBind,!0),this._domElement.removeEventListener("mousemove",this._onMouseMoveBind,!0),this._domElement.removeEventListener("mouseup",this._onMouseUpBind,!0),this._domElement.removeEventListener("mousewheel",this._onMouseWheelBind,!0),this._domElement.removeEventListener("DOMMouseScroll",this._onMouseWheelBind,!0),this._domElement.removeEventListener("contextmenu",this._onContextMenuBind,!0)):this._game.deviceTargetOption===a.TARGET_COCOON&&(this._game.stage.canvas.removeEventListener("mousedown",this._onMouseDownBind,!0),this._game.stage.canvas.removeEventListener("mousemove",this._onMouseMoveBind,!0),this._game.stage.canvas.removeEventListener("mouseup",this._onMouseUpBind,!0),this._game.stage.canvas.removeEventListener("mousewheel",this._onMouseWheelBind,!0),this._game.stage.canvas.removeEventListener("DOMMouseScroll",this._onMouseWheelBind,!0)),delete this._onMouseDownBind,delete this._onMouseMoveBind,delete this._onMouseUpBind,delete this._onMouseWheelBind,delete this._onContextMenuBind},b.prototype.onMouseDown=function(a){this._cursor.start(a),this.onDown.dispatch(this._cursor.x,this._cursor.y,this._cursor.timeDown,this._cursor.timeUp,this.duration,this._cursor)},b.prototype.onMouseMove=function(a){a.preventDefault(),this._cursor.move(a)},b.prototype.onMouseUp=function(a){this._cursor.stop(a),this.onUp.dispatch(this._cursor.x,this._cursor.y,this._cursor.timeDown,this._cursor.timeUp,this.duration,this._cursor)},b.prototype.onMouseWheel=function(a){this._cursor.wheel(a),this.onWheel.dispatch(this._cursor.wheelDeltaX,this._cursor.wheelDeltaY,this._cursor)},b.prototype.justPressed=function(a){return void 0===a&&(a=this._cursor.justPressedRate),this._cursor.justPressed(a)},b.prototype.justReleased=function(a){return void 0===a&&(a=this._cursor.justReleasedRate),this._cursor.justReleased(a)},b.prototype.reset=function(){this._cursor.reset()},b.prototype.onContextMenu=function(a){this.preventContextMenu&&a.preventDefault(),this.onContext.dispatch(a)},b.LEFT_BUTTON=0,b.MIDDLE_BUTTON=1,b.RIGHT_BUTTON=2,b}();b.Mouse=c}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._domElement=null,this.isDown=!1,this.isUp=!0,this._maxPointers=10,this._game=a}return b.prototype.objType=function(){return"TouchManager"},Object.defineProperty(b.prototype,"fingers",{get:function(){return this._fingers},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onDown",{get:function(){return this.touchDown},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onUp",{get:function(){return this.touchUp},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onCancel",{get:function(){return this.touchCancel},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this._domElement=this._game.stage.container,this.finger1=new a.Input.Finger(this._game),this.finger2=new a.Input.Finger(this._game),this.finger3=new a.Input.Finger(this._game),this.finger4=new a.Input.Finger(this._game),this.finger5=new a.Input.Finger(this._game),this.finger6=new a.Input.Finger(this._game),this.finger7=new a.Input.Finger(this._game),this.finger8=new a.Input.Finger(this._game),this.finger9=new a.Input.Finger(this._game),this.finger10=new a.Input.Finger(this._game),this._fingers=[this.finger1,this.finger2,this.finger3,this.finger4,this.finger5,this.finger6,this.finger7,this.finger8,this.finger9,this.finger10],this.latestFinger=this.finger1,this.touchDown=new a.Signal,this.touchUp=new a.Signal,this.touchCancel=new a.Signal,this.start()},b.prototype.start=function(){var b=this;if(a.DEVICE.touch)if(this.touchEnabled=!0,this._onTouchStartBind=this.onTouchStart.bind(this),this._onTouchMoveBind=this.onTouchMove.bind(this),this._onTouchEndBind=this.onTouchEnd.bind(this),this._onTouchEnterBind=this.onTouchEnter.bind(this),this._onTouchLeaveBind=this.onTouchLeave.bind(this),this._onTouchCancelBind=this.onTouchCancel.bind(this),this._game.deviceTargetOption===a.TARGET_BROWSER)if(a.DEVICE.pointerEnabled){var c="pointerup",d="pointerdown",e="pointerenter",f="pointerleave",g="pointercancel",h="pointermove";if(window.PointerEvent);else if(window.MSPointerEvent)var c="MSPointerUp",d="MSPointerDown",e="MSPointerEnter",f="MSPointerLeave",g="MSPointerCancel",h="MSPointerMove";this._onTouchStartBind=this.onPointerStart.bind(this),this._onTouchMoveBind=this.onPointerMove.bind(this),this._onTouchEndBind=this.onPointerEnd.bind(this),this._onTouchEnterBind=this.onPointerEnter.bind(this),this._onTouchLeaveBind=this.onPointerLeave.bind(this),this._onTouchCancelBind=this.onPointerCancel.bind(this),this._domElement.addEventListener(c,this._onTouchStartBind,!1),this._domElement.addEventListener(h,this._onTouchMoveBind,!1),this._domElement.addEventListener(d,this._onTouchEndBind,!1),this._domElement.addEventListener(e,this._onTouchEnterBind,!1),this._domElement.addEventListener(f,this._onTouchLeaveBind,!1),this._domElement.addEventListener(g,this._onTouchCancelBind,!1)}else this._domElement.addEventListener("touchstart",this._onTouchStartBind,!1),this._domElement.addEventListener("touchmove",this._onTouchMoveBind,!1),this._domElement.addEventListener("touchend",this._onTouchEndBind,!1),this._domElement.addEventListener("touchenter",this._onTouchEnterBind,!1),this._domElement.addEventListener("touchleave",this._onTouchLeaveBind,!1),this._domElement.addEventListener("touchcancel",this._onTouchCancelBind,!1),document.addEventListener("touchmove",function(a){return b.consumeTouchMove(a)},!1);else this._game.deviceTargetOption===a.TARGET_COCOON&&(this._game.stage.canvas.addEventListener("touchstart",this._onTouchStartBind,!1),this._game.stage.canvas.addEventListener("touchmove",this._onTouchMoveBind,!1),this._game.stage.canvas.addEventListener("touchend",this._onTouchEndBind,!1),this._game.stage.canvas.addEventListener("touchenter",this._onTouchEnterBind,!1),this._game.stage.canvas.addEventListener("touchleave",this._onTouchLeaveBind,!1),this._game.stage.canvas.addEventListener("touchcancel",this._onTouchCancelBind,!1));else this.touchEnabled=!1},b.prototype.consumeTouchMove=function(a){a.preventDefault()},Object.defineProperty(b.prototype,"x",{get:function(){return this.latestFinger.x},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this.latestFinger.y},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"maximumPointers",{get:function(){return this._maxPointers},set:function(a){0>a&&(a=1),a>this._fingers.length&&(a=this._fingers.length),this._maxPointers=a},enumerable:!0,configurable:!0}),b.prototype._registerFinger=function(a,b){for(var c=0;c<this._maxPointers;c++)if(this._fingers[c].active===!1){this._fingers[c].id=b,this._fingers[c].start(a),this.latestFinger=this._fingers[c],this.touchDown.dispatch(this._fingers[c].x,this._fingers[c].y,this._fingers[c].timeDown,this._fingers[c].timeUp,this._fingers[c].duration,this._fingers[c]),this.isDown=!0,this.isUp=!1;break}},b.prototype._deregisterFinger=function(a,b){for(var c=null,d=0;d<this._fingers.length;d++)if(this._fingers[d].active&&this._fingers[d].id===b){this._fingers[d].stop(a),this.latestFinger=this._fingers[d],c=this._fingers[d],this.isDown=!1,this.isUp=!0;break}for(var e=0;e<this._fingers.length;e++)this._fingers[e].active===!0&&(this.isDown=!0,this.isUp=!1);null!==c&&this.touchUp.dispatch(c.x,c.y,c.timeDown,c.timeUp,c.duration,c)},b.prototype._cancelFinger=function(a,b){for(var c=0;c<this._fingers.length;c++)if(this._fingers[c].active&&this._fingers[c].id===b){this._fingers[c].stop(a),this.touchCancel.dispatch(this._fingers[c].x,this._fingers[c].y,this._fingers[c].timeDown,this._fingers[c].timeUp,this._fingers[c].duration,this._fingers[c]);break}for(var d=0;d<this._fingers.length;d++)this._fingers[d].active&&(this.isDown=!0,this.isUp=!1)},b.prototype._enterFinger=function(a,b){for(var c=0;c<this._maxPointers;c++)if(this._fingers[c].active===!1){this._fingers[c].id=b,this._fingers[c].start(a),this.latestFinger=this._fingers[c],this.isDown=!0,this.isUp=!1;break}},b.prototype._leaveFinger=function(a,b){for(var c=0;c<this._fingers.length;c++)if(this._fingers[c].active&&this._fingers[c].id===b){this._fingers[c].leave(a);break}},b.prototype._moveFinger=function(a,b){for(var c=0;c<this._fingers.length;c++)if(this._fingers[c].active&&this._fingers[c].id===b){this._fingers[c].move(a),this.latestFinger=this._fingers[c];break}},b.prototype.onTouchStart=function(a){a.preventDefault();for(var b=0;b<a.changedTouches.length;b++)this._registerFinger(a.changedTouches[b],a.changedTouches[b].identifier)},b.prototype.onTouchCancel=function(a){a.preventDefault();for(var b=0;b<a.changedTouches.length;b++)this._cancelFinger(a.changedTouches[b],a.changedTouches[b].identifier)},b.prototype.onTouchEnter=function(a){a.preventDefault();for(var b=0;b<a.changedTouches.length;b++)this._enterFinger(a.changedTouches[b],a.changedTouches[b].identifier)},b.prototype.onTouchLeave=function(a){a.preventDefault();for(var b=0;b<a.changedTouches.length;b++)this._leaveFinger(a.changedTouches[b],a.changedTouches[b].identifier)},b.prototype.onTouchMove=function(a){a.preventDefault();for(var b=0;b<a.changedTouches.length;b++)this._moveFinger(a.changedTouches[b],a.changedTouches[b].identifier)},b.prototype.onTouchEnd=function(a){a.preventDefault();for(var b=0;b<a.changedTouches.length;b++)this._deregisterFinger(a.changedTouches[b],a.changedTouches[b].identifier)},b.prototype.onPointerStart=function(a){("touch"===a.type||"pointerdown"===a.type)&&this._registerFinger(a,a.pointerId)},b.prototype.onPointerCancel=function(a){("touch"===a.type||"pointercancel"===a.type)&&this._cancelFinger(a,a.pointerId)},b.prototype.onPointerEnter=function(a){("touch"===a.type||"pointerenter"===a.type)&&this._enterFinger(a,a.pointerId)},b.prototype.onPointerLeave=function(a){("touch"===a.type||"pointerleave"===a.type)&&this._leaveFinger(a,a.pointerId)},b.prototype.onPointerMove=function(a){("touch"===a.type||"pointermove"===a.type)&&this._moveFinger(a,a.pointerId)},b.prototype.onPointerEnd=function(a){("touch"===a.type||"pointerup"===a.type)&&this._deregisterFinger(a,a.pointerId)},b.prototype.update=function(){if(this.touchEnabled&&this.isDown)for(var a=0;a<this._fingers.length;a++)this._fingers[a].active&&this._fingers[a].update()},b.prototype.stop=function(){if(this.touchEnabled){if(this._game.deviceTargetOption===a.TARGET_BROWSER)if(a.DEVICE.pointerEnabled){var b="pointerup",c="pointerdown",d="pointerenter",e="pointerleave",f="pointercancel",g="pointermove";if(window.PointerEvent);else if(window.MSPointerEvent)var b="MSPointerUp",c="MSPointerDown",d="MSPointerEnter",e="MSPointerLeave",f="MSPointerCancel",g="MSPointerMove";this._domElement.removeEventListener(b,this._onTouchStartBind,!1),this._domElement.removeEventListener(g,this._onTouchMoveBind,!1),this._domElement.removeEventListener(c,this._onTouchEndBind,!1),this._domElement.removeEventListener(d,this._onTouchEnterBind,!1),this._domElement.removeEventListener(e,this._onTouchLeaveBind,!1),this._domElement.removeEventListener(f,this._onTouchCancelBind,!1)}else this._domElement.removeEventListener("touchstart",this._onTouchStartBind,!1),this._domElement.removeEventListener("touchmove",this._onTouchMoveBind,!1),this._domElement.removeEventListener("touchend",this._onTouchEndBind,!1),this._domElement.removeEventListener("touchenter",this._onTouchEnterBind,!1),this._domElement.removeEventListener("touchleave",this._onTouchLeaveBind,!1),this._domElement.removeEventListener("touchcancel",this._onTouchCancelBind,!1);else this._game.deviceTargetOption===a.TARGET_COCOON&&(this._game.stage.canvas.removeEventListener("touchstart",this._onTouchStartBind,!1),this._game.stage.canvas.removeEventListener("touchmove",this._onTouchMoveBind,!1),this._game.stage.canvas.removeEventListener("touchend",this._onTouchEndBind,!1),this._game.stage.canvas.removeEventListener("touchenter",this._onTouchEnterBind,!1),this._game.stage.canvas.removeEventListener("touchleave",this._onTouchLeaveBind,!1),this._game.stage.canvas.removeEventListener("touchcancel",this._onTouchCancelBind,!1));delete this._onTouchStartBind,delete this._onTouchMoveBind,delete this._onTouchEndBind,delete this._onTouchEnterBind,delete this._onTouchLeaveBind,delete this._onTouchCancelBind}},b.prototype.reset=function(){for(var a=0;a<this._fingers.length;a++)this._fingers[a].reset()},b}();b.Touch=c}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b){this.x=-1,this.y=-1,this.clientX=-1,this.clientY=-1,this.pageX=-1,this.pageY=-1,this.screenX=-1,this.screenY=-1,this.isDown=!1,this.isUp=!0,this.withinGame=!1,this.active=!1,this.timeDown=0,this.timeUp=0,this.duration=0,this.frameDuration=0,this.justPressedRate=200,this.justReleasedRate=200,this._game=b,this.point=new a.Geom.Point,this.circle=new a.Geom.Circle(0,0,1),this.startPoint=new a.Geom.Point,this.endPoint=new a.Geom.Point}return b.prototype.objType=function(){return"Pointer"},Object.defineProperty(b.prototype,"game",{get:function(){return this._game},enumerable:!0,configurable:!0}),b.prototype.start=function(a){this.move(a),this.startPoint.setTo(this.x,this.y),this.frameDuration=0,this.withinGame=!0,this.isDown=!0,this.isUp=!1,this.timeDown=this.game.time.now()},b.prototype.stop=function(){this.withinGame=!1,this.endPoint.setTo(this.x,this.y),this.isDown=!1,this.isUp=!0,this.timeUp=this.game.time.now(),this.duration=this.timeUp-this.timeDown},b.prototype.move=function(a){this.clientX=a.clientX,this.clientY=a.clientY,this.pageX=a.pageX,this.pageY=a.pageY,this.screenX=a.screenX,this.screenY=a.screenY,this.x=(this.pageX-this.game.stage.offset.x)*this.game.stage.scaleX,this.y=(this.pageY-this.game.stage.offset.y)*this.game.stage.scaleY,this.point.setTo(this.x,this.y),this.circle.x=this.x,this.circle.y=this.y,this.duration=this.game.time.now()-this.timeDown},b.prototype.justPressed=function(a){return void 0===a&&(a=this.justPressedRate),this.isDown===!0&&this.timeDown+a>this._game.time.now()?!0:!1},b.prototype.justReleased=function(a){return void 0===a&&(a=this.justReleasedRate),this.isUp===!0&&this.timeUp+a>this._game.time.now()?!0:!1},Object.defineProperty(b.prototype,"pressed",{get:function(){return this.timeDown>=this._game.time.now()-this._game.time.delta()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"released",{get:function(){return this.timeUp>=this._game.time.now()-this._game.time.delta()},enumerable:!0,configurable:!0}),b.prototype.reset=function(){this.isDown=!1,this.isUp=!0,this.timeDown=0,this.timeUp=0,this.duration=0,this.frameDuration=0},b.prototype.update=function(){this.isDown===!0&&(this.frameDuration++,this.duration=this._game.time.now()-this.timeDown)},b}();b.Pointer=c}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(a){function b(){a.apply(this,arguments),this.wheelDeltaX=0,this.wheelDeltaY=0,this.preventDown=!0,this.preventUp=!0,this.preventWheel=!0}return __extends(b,a),b.prototype.objType=function(){return"MouseCursor"},b.prototype.start=function(b){this.preventDown&&b.preventDefault(),this.ctrlKey=b.ctrlKey,this.shiftKey=b.shiftKey,this.altKey=b.altKey,this.button=b.button,a.prototype.start.call(this,b)},b.prototype.stop=function(b){this.preventUp&&b.preventDefault(),this.move(b),a.prototype.stop.call(this,b)},b.prototype.wheel=function(a){this.preventWheel&&a.preventDefault(),this.wheelDeltaX=a.wheelDeltaX?a.wheelDeltaX:a.deltaX,this.wheelDeltaY=a.wheelDeltaY?a.wheelDeltaY:a.deltaY},b}(a.Pointer);a.MouseCursor=b}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(a){function b(b){a.call(this,b),this.circle.diameter=44}return __extends(b,a),b.prototype.objType=function(){return"Finger"},b.prototype.start=function(b){this.active=!0,a.prototype.start.call(this,b)},b.prototype.stop=function(b){this.active=!1,a.prototype.stop.call(this,b)},b.prototype.leave=function(a){this.withinGame=!1,this.move(a)},b.prototype.reset=function(){this.active=!1,a.prototype.reset.call(this)},b}(a.Pointer);a.Finger=b}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function b(a,b,c,d){this.cx=0,this.cy=0,this.halfWidth=0,this.halfHeight=0,this.cx=a||0,this.cy=b||0,this.halfWidth=c/2||0,this.halfHeight=d/2||0}return b.prototype.objType=function(){return"AABB"},Object.defineProperty(b.prototype,"height",{get:function(){return 2*this.halfHeight},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"width",{get:function(){return 2*this.halfWidth},enumerable:!0,configurable:!0}),b.prototype.draw=function(a){return a.beginPath(),a.moveTo(this.cx-this.halfWidth,this.cy),a.lineTo(this.cx+this.halfWidth,this.cy),a.moveTo(this.cx,this.cy-this.halfHeight),a.lineTo(this.cx,this.cy+this.halfHeight),a.stroke(),this},b.prototype.setPosition=function(a,b){return this.cx=a,this.cy=b,this},b.prototype.setPositionPoint=function(a){return this.cx=a.x,this.cy=a.y,this},b.prototype.toRect=function(){return new a.Rectangle(this.cx-this.halfWidth,this.cy-this.halfHeight,2*this.halfWidth,2*this.halfHeight)},b.prototype.fromRect=function(a){return this.halfWidth=a.width/2,this.halfHeight=a.height/2,this.cx=a.x+this.halfWidth,this.cy=a.y+this.halfHeight,this},b}();a.AABB=b}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function b(a,b,c){void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=0),this._diameter=0,this._radius=0,this.x=0,this.y=0,this.setTo(a,b,c)}return b.prototype.objType=function(){return"Circle"},Object.defineProperty(b.prototype,"diameter",{get:function(){return this._diameter},set:function(a){a>0&&(this._diameter=a,this._radius=.5*a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"radius",{get:function(){return this._radius},set:function(a){a>0&&(this._radius=a,this._diameter=2*a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"circumference",{get:function(){return 2*Math.PI*this._radius},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(a){isNaN(a)||(a<this.y?(this._radius=0,this._diameter=0):this.radius=a-this.y)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"left",{get:function(){return this.x-this._radius},set:function(a){isNaN(a)||(a<this.x?this.radius=this.x-a:(this._radius=0,this._diameter=0))},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"right",{get:function(){return this.x+this._radius},set:function(a){a&&!isNaN(a)&&(a>this.x?this.radius=a-this.x:(this._radius=0,this._diameter=0))},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"top",{get:function(){return this.y-this._radius},set:function(a){a&&!isNaN(a)&&(a>this.y?(this._radius=0,this._diameter=0):this.radius=this.y-a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"area",{get:function(){return this._radius>0?Math.PI*this._radius*this._radius:0},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isEmpty",{get:function(){return this._diameter<=0?!0:!1},enumerable:!0,configurable:!0}),b.prototype.clone=function(a){return void 0===a&&(a=new b),a.setTo(this.x,this.y,this._diameter)},b.prototype.copyFrom=function(a){return this.setTo(a.x,a.y,a.diameter)},b.prototype.copyTo=function(a){return a.copyFrom(this)},b.prototype.distanceTo=function(a,b){void 0===b&&(b=!1);var c=this.x-a.x,d=this.y-a.y;return b===!0?Math.round(Math.sqrt(c*c+d*d)):Math.sqrt(c*c+d*d)},b.prototype.equals=function(a){return this.x===a.x&&this.y===a.y&&this.diameter===a.diameter?!0:!1},b.prototype.intersects=function(a){return this.distanceTo(a,!1)<this._radius+a._radius?!0:!1},b.prototype.circumferencePoint=function(b,c,d){return void 0===c&&(c=!1),void 0===d&&(d=new a.Point),c===!0&&(b*=Math.PI/180),d.x=this.x+this._radius*Math.cos(b),d.y=this.y+this._radius*Math.sin(b),d},b.prototype.offset=function(a,b){return isNaN(a)||isNaN(b)||(this.x+=a,this.y+=b),this},b.prototype.offsetPoint=function(a){return this.offset(a.x,a.y)},b.prototype.setTo=function(a,b,c){return this.x=a,this.y=b,this._diameter=c,this._radius=.5*c,this},b.prototype.toString=function(){return"[{Circle (x="+this.x+" y="+this.y+" diameter="+this.diameter+" radius="+this.radius+")}]"},b}();a.Circle=b}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a,b,c,d){void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=0),this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.setTo(a,b,c,d)}return b.prototype.objType=function(){return"Line"},b.prototype.clone=function(a){return void 0===a&&(a=new b),a.setTo(this.x1,this.y1,this.x2,this.y2)},b.prototype.copyFrom=function(a){return this.setTo(a.x1,a.y1,a.x2,a.y2)},b.prototype.copyTo=function(a){return a.copyFrom(this)},b.prototype.setTo=function(a,b,c,d){return void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=0),this.x1=a,this.y1=b,this.x2=c,this.y2=d,this},Object.defineProperty(b.prototype,"length",{get:function(){return Math.sqrt((this.x2-this.x1)*(this.x2-this.x1)+(this.y2-this.y1)*(this.y2-this.y1))},enumerable:!0,configurable:!0}),b.prototype.getY=function(a){return this.x1==this.x2?null:this.slope*a+this.yIntercept},Object.defineProperty(b.prototype,"angle",{get:function(){return Math.atan2(this.y2-this.y1,this.x2-this.x1)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"slope",{get:function(){return(this.y2-this.y1)/(this.x2-this.x1)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"perpSlope",{get:function(){return-((this.x2-this.x1)/(this.y2-this.y1))},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"yIntercept",{get:function(){return this.y1-this.slope*this.x1},enumerable:!0,configurable:!0}),b.prototype.isPointOnLine=function(a,b){return(a-this.x1)*(this.y2-this.y1)===(this.x2-this.x1)*(b-this.y1)?!0:!1},b.prototype.isPointOnLineSegment=function(a,b){var c=Math.min(this.x1,this.x2),d=Math.max(this.x1,this.x2),e=Math.min(this.y1,this.y2),f=Math.max(this.y1,this.y2);return this.isPointOnLine(a,b)&&a>=c&&d>=a&&b>=e&&f>=b?!0:!1},b.prototype.intersectLineLine=function(b){return a.Geom.Intersect.lineToLine(this,b)},b.prototype.perp=function(a,c,d){void 0===d&&(d=new b);var e;if(this.y1===this.y2)return d.setTo(a,c,a,this.y1),d;if(this.x1===this.x2)return d.setTo(a,c,this.x1,c),d;var f=c-this.perpSlope*a;return e=this.intersectLineLine(0!==a?{x1:a,y1:c,x2:0,y2:f}:{x1:a,y1:c,x2:1,y2:f+this.perpSlope}),d.setTo(a,c,e.x,e.y),d},b.prototype.toString=function(){return"[{Line (x1="+this.x1+" y1="+this.y1+" x2="+this.x2+" y2="+this.y2+")}]"},b}();b.Line=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(a){function b(b,c,d,e){void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=0),void 0===e&&(e=0),a.call(this,b,c,d,e)}return __extends(b,a),b.prototype.objType=function(){return"Ray"},b.prototype.clone=function(a){return void 0===a&&(a=new b),a.setTo(this.x1,this.y1,this.x2,this.y2)},b.prototype.isPointOnRay=function(a,b){return(a-this.x1)*(this.y2-this.y1)===(this.x2-this.x1)*(b-this.y1)&&Math.atan2(b-this.y1,a-this.x1)==Math.atan2(this.y2-this.y1,this.x2-this.x1)?!0:!1},b.prototype.toString=function(){return"[{Ray (x1="+this.x1+" y1="+this.y1+" x2="+this.x2+" y2="+this.y2+")}]"},b}(a.Line);a.Ray=b}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function c(){}return c.prototype.objType=function(){return"Intersect"},c.distance=function(a,b,c,d){return Math.sqrt((c-a)*(c-a)+(d-b)*(d-b))},c.distanceSquared=function(a,b,c,d){return(c-a)*(c-a)+(d-b)*(d-b)},c.lineToLine=function(a,c,d){void 0===d&&(d=new b.IntersectResult),d.result=!1;var e=(a.x1-a.x2)*(c.y1-c.y2)-(a.y1-a.y2)*(c.x1-c.x2);return 0!==e&&(d.result=!0,d.x=((a.x1*a.y2-a.y1*a.x2)*(c.x1-c.x2)-(a.x1-a.x2)*(c.x1*c.y2-c.y1*c.x2))/e,d.y=((a.x1*a.y2-a.y1*a.x2)*(c.y1-c.y2)-(a.y1-a.y2)*(c.x1*c.y2-c.y1*c.x2))/e),d},c.lineToLineSegment=function(a,c,d){void 0===d&&(d=new b.IntersectResult),d.result=!1;var e=(a.x1-a.x2)*(c.y1-c.y2)-(a.y1-a.y2)*(c.x1-c.x2);if(0!==e){d.x=((a.x1*a.y2-a.y1*a.x2)*(c.x1-c.x2)-(a.x1-a.x2)*(c.x1*c.y2-c.y1*c.x2))/e,d.y=((a.x1*a.y2-a.y1*a.x2)*(c.y1-c.y2)-(a.y1-a.y2)*(c.x1*c.y2-c.y1*c.x2))/e;var f=Math.max(c.x1,c.x2),g=Math.min(c.x1,c.x2),h=Math.max(c.y1,c.y2),i=Math.min(c.y1,c.y2);(d.x<=f&&d.x>=g)==!0&&(d.y<=h&&d.y>=i)==!0&&(d.result=!0)}return d},c.lineToRawSegment=function(a,c,d,e,f,g){void 0===g&&(g=new b.IntersectResult),g.result=!1;var h=(a.x1-a.x2)*(d-f)-(a.y1-a.y2)*(c-e);if(0!==h){g.x=((a.x1*a.y2-a.y1*a.x2)*(c-e)-(a.x1-a.x2)*(c*f-d*e))/h,g.y=((a.x1*a.y2-a.y1*a.x2)*(d-f)-(a.y1-a.y2)*(c*f-d*e))/h;var i=Math.max(c,e),j=Math.min(c,e),k=Math.max(d,f),l=Math.min(d,f);g.x<=i&&g.x>=j&&g.y<=k&&g.y>=l&&(g.result=!0)}return g},c.lineSegmentToRawSegment=function(a,d,e,f,g,h){void 0===h&&(h=new b.IntersectResult),h=c.lineToRawSegment(a,d,e,f,g,h);var i=Math.max(a.x1,a.x2),j=Math.min(a.x1,a.x2),k=Math.max(a.y1,a.y2),l=Math.min(a.y1,a.y2);return h.x<=i&&h.x>=j&&h.y<=k&&h.y>=l?h:(h.result=!1,h)},c.lineToRay=function(a,c,d){void 0===d&&(d=new b.IntersectResult),d.result=!1;var e=(a.x1-a.x2)*(c.y1-c.y2)-(a.y1-a.y2)*(c.x1-c.x2);return 0!==e&&(d.x=((a.x1*a.y2-a.y1*a.x2)*(c.x1-c.x2)-(a.x1-a.x2)*(c.x1*c.y2-c.y1*c.x2))/e,d.y=((a.x1*a.y2-a.y1*a.x2)*(c.y1-c.y2)-(a.y1-a.y2)*(c.x1*c.y2-c.y1*c.x2))/e,d.result=!0,!(c.x1>=c.x2)&&d.x<c.x1&&(d.result=!1),!(c.y1>=c.y2)&&d.y<c.y1&&(d.result=!1)),d},c.lineToCircle=function(a,c,d){return void 0===d&&(d=new b.IntersectResult),d.result=!1,a.perp(c.x,c.y).length<=c.radius&&(d.result=!0),d},c.lineToRectangle=function(a,d,e){return void 0===e&&(e=new b.IntersectResult),e.result=!1,c.lineToRawSegment(a,d.x,d.y,d.right,d.y,e),e.result===!0?e:(c.lineToRawSegment(a,d.x,d.y,d.x,d.bottom,e),e.result===!0?e:(c.lineToRawSegment(a,d.x,d.bottom,d.right,d.bottom,e),e.result===!0?e:(c.lineToRawSegment(a,d.right,d.y,d.right,d.bottom,e),e)))},c.lineSegmentToLineSegment=function(a,d,e){return void 0===e&&(e=new b.IntersectResult),e.result=!1,c.lineToLineSegment(a,d,e),e.result===!0&&(e.x>=Math.min(a.x1,a.x2)&&e.x<=Math.max(a.x1,a.x2)&&e.y>=Math.min(a.y1,a.y2)&&e.y<=Math.max(a.y1,a.y2)||(e.result=!1)),e},c.lineSegmentToRay=function(a,d,e){return void 0===e&&(e=new b.IntersectResult),e.result=!1,c.lineToRay(a,d,e),e.result===!0&&(e.x>=Math.min(a.x1,a.x2)&&e.x<=Math.max(a.x1,a.x2)&&e.y>=Math.min(a.y1,a.y2)&&e.y<=Math.max(a.y1,a.y2)||(e.result=!1)),e},c.lineSegmentToCircle=function(a,d,e){void 0===e&&(e=new b.IntersectResult),e.result=!1;var f=a.perp(d.x,d.y);if(f.length<=d.radius){var g=Math.max(a.x1,a.x2),h=Math.min(a.x1,a.x2),i=Math.max(a.y1,a.y2),j=Math.min(a.y1,a.y2);
|
|
f.x2<=g&&f.x2>=h&&f.y2<=i&&f.y2>=j?e.result=!0:(c.circleContainsPoint(d,{x:a.x1,y:a.y1}).result||c.circleContainsPoint(d,{x:a.x2,y:a.y2}).result)&&(e.result=!0)}return e},c.lineSegmentToRectangle=function(a,d,e){if(void 0===e&&(e=new b.IntersectResult),e.result=!1,d.contains(a.x1,a.y1)&&d.contains(a.x2,a.y2))e.x=(a.x1+a.x2)/2,e.y=(a.y1+a.y2)/2,e.result=!0;else{if(c.lineSegmentToRawSegment(a,d.x,d.y,d.right,d.y,e),e.result===!0)return e;if(c.lineSegmentToRawSegment(a,d.x,d.y,d.x,d.bottom,e),e.result===!0)return e;if(c.lineSegmentToRawSegment(a,d.x,d.bottom,d.right,d.bottom,e),e.result===!0)return e;c.lineSegmentToRawSegment(a,d.right,d.y,d.right,d.bottom,e)}return e},c.rayToCircle=function(d,e,f){void 0===f&&(f=new b.IntersectResult);var g=e.x-d.x1,h=e.y-d.y1;return f.result=!1,Math.sqrt(g*g+h*h)<=e.radius?(f.result=!0,f):Math.abs(a.Utils.GameMath.nearestAngleBetween(d.angle,Math.atan2(h,g)))>=Math.PI/2?f:(c.lineToCircle(d,e,f),f)},c.rayToRectangle=function(a,d,e){return void 0===e&&(e=new b.IntersectResult),e.result=!1,c.lineToRectangle(a,d,e),e},c.rayToLineSegment=function(a,c,d,e,f,g,h,i,j){void 0===j&&(j=new b.IntersectResult),j.result=!1;var k,l,m;return(e-c)/(d-a)!=(i-g)/(h-f)&&(m=(d-a)*(i-g)-(e-c)*(h-f),0!=m&&(k=((c-g)*(h-f)-(a-f)*(i-g))/m,l=((c-g)*(d-a)-(a-f)*(e-c))/m,k>=0&&l>=0&&1>=l&&(j.result=!0,j.x=a+k*(d-a),c+k*(e-c)))),j},c.circleToCircle=function(a,d,e){return void 0===e&&(e=new b.IntersectResult),e.result=!1,e.result=(a.radius+d.radius)*(a.radius+d.radius)>=c.distanceSquared(a.x,a.y,d.x,d.y),e},c.circleToRectangle=function(a,c,d){void 0===d&&(d=new b.IntersectResult),d.result=!1;var e,f,g,h,i,j,k,l;return i=c.width/2,g=Math.abs(a.x-c.x-i),k=a.radius+i,g>k?(d.result=!1,d):(j=c.height/2,h=Math.abs(a.y-c.y-j),l=a.radius+j,h>l?(d.result=!1,d):i>=g||h<=c.height/2?(d.result=!0,d):(e=g-i,f=h-j,d.result=e*e+f*f<=a.radius*a.radius,d))},c.circleContainsPoint=function(a,d,e){return void 0===e&&(e=new b.IntersectResult),e.result=!1,e.result=a.radius*a.radius>=c.distanceSquared(a.x,a.y,d.x,d.y),e},c.pointToRectangle=function(a,c,d){return void 0===d&&(d=new b.IntersectResult),d.result=!1,d.setTo(a.x,a.y),d.result=c.containsPoint(a),d},c.rectangleToRectangle=function(a,c,d){void 0===d&&(d=new b.IntersectResult),d.result=!1;var e=Math.max(a.x,c.x),f=Math.min(a.right,c.right),g=Math.max(a.y,c.y),h=Math.min(a.bottom,c.bottom);d.setTo(e,g,f-e,h-g,f-e,h-g);var i=d.x+.5*d.width,j=d.y+.5*d.height;return i>a.x&&i<a.right&&j>a.y&&j<a.bottom&&(d.result=!0),d},c}();b.Intersect=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){this.result=!1}return a.prototype.objType=function(){return"IntersectResult"},a.prototype.setTo=function(a,b,c,d,e,f){void 0===c&&(c=0),void 0===d&&(d=0),void 0===e&&(e=0),void 0===f&&(f=0),this.x=a,this.y=b,this.x1=a,this.y1=b,this.x2=c,this.y2=d,this.width=e,this.height=f},a}();a.IntersectResult=b}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a,b,c,d,e,f){void 0===a&&(a=1),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=1),void 0===e&&(e=0),void 0===f&&(f=0),this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this.setTo(a,b,c,d,e,f)}return b.prototype.objType=function(){return"Matrix"},b.prototype.setTo=function(a,b,c,d,e,f){return void 0===a&&(a=1),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=1),void 0===e&&(e=0),void 0===f&&(f=0),this.a=a,this.b=b,this.c=c,this.d=d,this.tx=e,this.ty=f,this},b.prototype.setFromTransform=function(a,b,c,d,e){this.identity();var f=Math.cos(e),g=Math.sin(e);return this.append(f*c,g*c,-g*d,f*d,a,b),this},b.prototype.setFromOffsetTransform=function(a,b,c,d,e,f,g){this.identity();var h=Math.cos(e),i=Math.sin(e);return this.append(h*c,i*c,-i*d,h*d,a+f,b+g),this},b.prototype.prepend=function(a,b,c,d,e,f){void 0===a&&(a=1),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=1),void 0===e&&(e=0),void 0===f&&(f=0);var g=this.tx,h=this.a,i=this.c;return this.a=h*a+this.b*c,this.b=h*b+this.b*d,this.c=i*a+this.d*c,this.d=i*b+this.d*d,this.tx=g*a+this.ty*c+e,this.ty=g*b+this.ty*d+f,this},b.prototype.prependMatrix=function(a){var b=this.tx,c=this.a,d=this.c;return this.a=c*a.a+this.b*a.c,this.b=c*a.b+this.b*a.d,this.c=d*a.a+this.d*a.c,this.d=d*a.b+this.d*a.d,this.tx=b*a.a+this.ty*a.c+a.tx,this.ty=b*a.b+this.ty*a.d+a.ty,this},b.prototype.append=function(a,b,c,d,e,f){void 0===a&&(a=1),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=1),void 0===e&&(e=0),void 0===f&&(f=0);var g=this.a,h=this.b,i=this.c,j=this.d;return this.a=a*g+b*i,this.b=a*h+b*j,this.c=c*g+d*i,this.d=c*h+d*j,this.tx=e*g+f*i+this.tx,this.ty=e*h+f*j+this.ty,this},b.prototype.appendMatrix=function(a){var b=this.a,c=this.b,d=this.c,e=this.d;return this.a=a.a*b+a.b*d,this.b=a.a*c+a.b*e,this.c=a.c*b+a.d*d,this.d=a.c*c+a.d*e,this.tx=a.tx*b+a.ty*d+this.tx,this.ty=a.tx*c+a.ty*e+this.ty,this},b.prototype.setPosition=function(a,b){return this.tx=a,this.ty=b,this},b.prototype.setPositionPoint=function(a){return this.tx=a.x,this.ty=a.y,this},b.prototype.getPosition=function(b){return void 0===b&&(b=new a.Geom.Point),b.setTo(this.tx,this.ty)},b.prototype.identity=function(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this},b.prototype.rotate=function(a){var b=Math.cos(a),c=Math.sin(a),d=this.a,e=this.c,f=this.tx;return this.a=d*b-this.b*c,this.b=d*c+this.b*b,this.c=e*b-this.d*c,this.d=e*c+this.d*b,this.tx=f*b-this.ty*c,this.ty=f*c+this.ty*b,this},b.prototype.translate=function(a,b){return this.tx+=a,this.ty+=b,this},b.prototype.scale=function(a,b){return this.a*=a,this.d*=b,this},b.prototype.transformPoint=function(a){var b=a.x,c=a.y;return a.x=this.a*b+this.c*c+this.tx,a.y=this.b*b+this.d*c+this.ty,a},b.prototype.invert=function(){var a=this.a,b=this.b,c=this.c,d=this.d,e=this.tx,f=a*d-b*c;return this.a=d/f,this.b=-b/f,this.c=-c/f,this.d=a/f,this.tx=(c*this.ty-d*e)/f,this.ty=-(a*this.ty-b*e)/f,this},b.prototype.copyFrom=function(a){return this.a=a.a,this.b=a.b,this.c=a.c,this.d=a.d,this.tx=a.tx,this.ty=a.ty,this},b.prototype.copyTo=function(a){return a.a=this.a,a.b=this.b,a.c=this.c,a.d=this.d,a.tx=this.tx,a.ty=this.ty,this},b.prototype.clone=function(){return new a.Geom.Matrix(this.a,this.b,this.c,this.d,this.tx,this.ty)},Object.defineProperty(b.prototype,"toString",{get:function(){return"[{Matrix (a="+this.a+" b="+this.b+" c="+this.c+" d="+this.d+" tx="+this.tx+" ty="+this.ty+")}]"},enumerable:!0,configurable:!0}),b.prototype.equals=function(a){return this.a===a.a&&this.b===a.b&&this.c===a.c&&this.d===a.d&&this.tx===a.tx&&this.ty===a.ty},b}();b.Matrix=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b){void 0===a&&(a=0),void 0===b&&(b=0),this.setTo(a,b)}return a.prototype.objType=function(){return"Point"},a.prototype.polar=function(a,b){return this.x=a*Math.cos(b),this.y=a*Math.sin(b),this},a.prototype.add=function(b,c){return void 0===c&&(c=new a),c.setTo(this.x+b.x,this.y+b.y)},a.prototype.addTo=function(a,b){return void 0===a&&(a=0),void 0===b&&(b=0),this.setTo(this.x+a,this.y+b)},a.prototype.subtractFrom=function(a,b){return void 0===a&&(a=0),void 0===b&&(b=0),this.setTo(this.x-a,this.y-b)},a.prototype.invert=function(){return this.setTo(this.y,this.x)},a.prototype.clamp=function(a,b){return this.clampX(a,b),this.clampY(a,b),this},a.prototype.clampX=function(a,b){return this.x=Math.max(Math.min(this.x,b),a),this},a.prototype.clampY=function(a,b){return this.x=Math.max(Math.min(this.x,b),a),this.y=Math.max(Math.min(this.y,b),a),this},a.prototype.clone=function(b){return void 0===b&&(b=new a),b.setTo(this.x,this.y)},a.prototype.copyFrom=function(a){return this.setTo(a.x,a.y)},a.prototype.copyTo=function(a){return a.setTo(this.x,this.y)},a.prototype.angleTo=function(a){return Math.atan2(a.y-this.y,a.x-this.x)},a.prototype.angleToXY=function(a,b){return Math.atan2(b-this.y,a-this.x)},a.prototype.distanceTo=function(a,b){void 0===b&&(b=!1);var c=this.x-a.x,d=this.y-a.y;return b===!0?Math.round(Math.sqrt(c*c+d*d)):Math.sqrt(c*c+d*d)},a.prototype.distanceToXY=function(a,b,c){void 0===c&&(c=!1);var d=this.x-a,e=this.y-b;return c===!0?Math.round(Math.sqrt(d*d+e*e)):Math.sqrt(d*d+e*e)},a.distanceBetween=function(a,b,c){void 0===c&&(c=!1);var d=a.x-b.x,e=a.y-b.y;return c===!0?Math.round(Math.sqrt(d*d+e*e)):Math.sqrt(d*d+e*e)},a.polar=function(b,c){return new a(b*Math.cos(c),b*Math.sin(c))},a.prototype.distanceCompare=function(a,b){return this.distanceTo(a)>=b?!0:!1},a.prototype.equals=function(a){return this.x===a.x&&this.y===a.y?!0:!1},a.interpolate=function(b,c,d){var e=c.x-b.x,f=c.y-b.y;return new a(c.x-e*d,c.y-f*d)},a.prototype.offset=function(a,b){return this.x+=a,this.y+=b,this},a.prototype.setTo=function(a,b){return this.x=a,this.y=b,this},a.prototype.subtract=function(b,c){return void 0===c&&(c=new a),c.setTo(this.x-b.x,this.y-b.y)},a.prototype.getCSS=function(){return this.x+"px "+this.y+"px"},a.prototype.toString=function(){return"[{Point (x="+this.x+" y="+this.y+")}]"},a}();a.Point=b}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function c(a,b,c,d){void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=0),this.x=0,this.y=0,this.width=0,this.height=0,this.setTo(a,b,c,d)}return c.prototype.objType=function(){return"Rectangle"},Object.defineProperty(c.prototype,"bottom",{get:function(){return this.y+this.height},set:function(a){a&&(this.height=a<this.y?0:a)},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"center",{get:function(){var a=new b.Point;return a.setTo(Math.round(this.width/2),Math.round(this.height/2))},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"bottomRight",{get:function(){var a=new b.Point;return a.setTo(this.right,this.bottom)},set:function(a){a&&(this.right=a.x,this.bottom=a.y)},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"left",{get:function(){return this.x},set:function(a){if(a){var b=this.x-a;this.width+b<0?(this.width=0,this.x=a):(this.width+=b,this.x=a)}},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"right",{get:function(){return this.x+this.width},set:function(a){a&&(this.width=a<this.x?0:a-this.x)},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"size",{get:function(){var a=new b.Point;return a.setTo(this.width,this.height)},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"volume",{get:function(){return this.width*this.height},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"perimeter",{get:function(){return 2*this.width+2*this.height},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"top",{get:function(){return this.y},set:function(a){if(a){var b=this.y-a;this.height+b<0?(this.height=0,this.y=a):(this.height+=b,this.y=a)}},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"topLeft",{get:function(){var a=new b.Point;return a.setTo(this.x,this.y)},set:function(a){a&&(this.x=a.x,this.y=a.y)},enumerable:!0,configurable:!0}),c.prototype.clone=function(a){return void 0===a&&(a=new c),a.setTo(this.x,this.y,this.width,this.height)},c.prototype.contains=function(a,b){return a>=this.x&&a<=this.right&&b>=this.y&&b<=this.bottom?!0:!1},c.prototype.containsPoint=function(a){return this.contains(a.x,a.y)},c.prototype.containsRect=function(a){return a.volume>this.volume?!1:a.x>=this.x&&a.y>=this.y&&a.right<=this.right&&a.bottom<=this.bottom?!0:!1},c.prototype.copyFrom=function(a){return this.setTo(a.x,a.y,a.width,a.height)},c.prototype.copyTo=function(a){return void 0===a&&(a=new c),a.copyFrom(this)},c.prototype.equals=function(a){return this.x===a.x&&this.y===a.y&&this.width===a.width&&this.height===a.height?!0:!1},c.prototype.inflate=function(a,b){return isNaN(a)||isNaN(b)||(this.x-=a,this.width+=2*a,this.y-=b,this.height+=2*b),this},c.prototype.inflatePoint=function(a){return this.inflate(a.x,a.y)},c.prototype.intersection=function(a,b){return void 0===b&&(b=new c),this.intersects(a)===!0&&(b.x=Math.max(a.x,this.x),b.y=Math.max(a.y,this.y),b.width=Math.min(a.right,this.right)-b.x,b.height=Math.min(a.bottom,this.bottom)-b.y),b},c.prototype.intersects=function(a){return a.x>this.right-1?!1:a.right-1<this.x?!1:a.bottom-1<this.y?!1:a.y>this.bottom-1?!1:!0},c.prototype.overlap=function(a){var b={top:!1,bottom:!1,left:!1,right:!1,contains:!1,contained:!1},c=this.intersection(a);return c.isEmpty?b:(this.containsRect(a)&&(b.contains=!0),a.containsRect(this)&&(b.contained=!0),this.top<a.top&&(b.top=!0),this.bottom>a.bottom&&(b.bottom=!0),this.left<a.left&&(b.left=!0),this.right>a.right&&(b.right=!0),b)},c.prototype.isEmpty=function(){return this.width<1||this.height<1?!0:!1},c.prototype.offset=function(a,b){return isNaN(a)||isNaN(b)||(this.x+=a,this.y+=b),this},c.prototype.offsetPoint=function(a){return this.offset(a.x,a.y)},c.prototype.setEmpty=function(){return this.setTo(0,0,0,0)},c.prototype.setTo=function(a,b,c,d){return isNaN(a)||isNaN(b)||isNaN(c)||isNaN(d)||(this.x=a,this.y=b,c>=0&&(this.width=c),d>=0&&(this.height=d)),this},c.prototype.union=function(a,b){return void 0===b&&(b=new c),b.setTo(Math.min(a.x,this.x),Math.min(a.y,this.y),Math.max(a.right,this.right),Math.max(a.bottom,this.bottom))},c.prototype.scale=function(b,c,d){var e=new a.Geom.Transform;e.scaleX=b,e.scaleY=c,e.x=d.x,e.y=d.y;var f=this.topLeft;return e.transformPoint(f),this.topLeft=f,this.width*=b,this.height*=c,this},c.prototype.toString=function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" isEmpty="+this.isEmpty()+")}]"},c}();b.Rectangle=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function c(a,c,d,e,f,g,h){void 0===a&&(a=0),void 0===c&&(c=0),void 0===d&&(d=1),void 0===e&&(e=1),void 0===f&&(f=0),void 0===g&&(g=0),void 0===h&&(h=0),this._x=0,this._y=0,this._scaleX=1,this._scaleY=1,this._rotation=0,this._rotPointX=0,this._rotPointY=0,this._parent=null,this._locked=!1,this._ignoreParent=!1,this._ignoreChild=!1,this._dirty=!0,this.setTransform(a,c,d,e,f,g,h),this._matrix=new b.Matrix,this._cachedConcatenatedMatrix=new b.Matrix,this._matrix.setFromOffsetTransform(this._x,this._y,this._scaleX,this._scaleY,this._rotation,this._rotPointX,this._rotPointY)}return c.prototype.objType=function(){return"Transform"},Object.defineProperty(c.prototype,"x",{get:function(){return this._x},set:function(a){this._x=a,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"y",{get:function(){return this._y},set:function(a){this._y=a,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"scaleX",{get:function(){return this._scaleX},set:function(a){this._scaleX=a,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"scaleY",{get:function(){return this._scaleY},set:function(a){this._scaleY=a,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"rotation",{get:function(){return this._rotation},set:function(a){this._rotation=a,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"rotPointX",{get:function(){return this._rotPointX},set:function(a){this._rotPointX=a,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"rotPointY",{get:function(){return this._rotPointY},set:function(a){this._rotPointY=a,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"anchorPointX",{get:function(){return this.rotPointX},set:function(a){this.rotPointX=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"anchorPointY",{get:function(){return this.rotPointY},set:function(a){this.rotPointY=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"matrix",{get:function(){return this._matrix},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"worldX",{get:function(){return this.getConcatenatedMatrix().tx-this._rotPointX},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"worldY",{get:function(){return this.getConcatenatedMatrix().ty-this._rotPointY},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"parent",{get:function(){return this._parent},set:function(a){this.checkAncestor(a)||(this._parent=a,this._dirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"locked",{get:function(){return this._locked},set:function(a){this._locked=a,this._locked&&this._matrix.setFromOffsetTransform(this.x,this.y,this.scaleX,this.scaleY,this.rotation,this.anchorPointX,this.anchorPointY)},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"ignoreParent",{get:function(){return this._ignoreParent},set:function(a){this._ignoreParent=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"ignoreChild",{get:function(){return this._ignoreChild},set:function(a){this._ignoreChild=a},enumerable:!0,configurable:!0}),c.prototype.setPosition=function(a,b){return this._x=a,this._y=b,this._dirty=!0,this},c.prototype.setPositionFromPoint=function(a){return this._x=a.x,this._y=a.y,this._dirty=!0,this},c.prototype.translatePositionFromPoint=function(a){return this._x+=a.x,this._y+=a.y,this._dirty=!0,this},c.prototype.getPositionPoint=function(b){return void 0===b&&(b=new a.Geom.Point),b.setTo(this._x,this._y)},Object.defineProperty(c.prototype,"scale",{set:function(a){this._scaleX=a,this._scaleY=a,this._dirty=!0},enumerable:!0,configurable:!0}),c.prototype.setTransform=function(a,b,c,d,e,f,g){return void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=1),void 0===d&&(d=1),void 0===e&&(e=0),void 0===f&&(f=0),void 0===g&&(g=0),this._x=a,this._y=b,this._scaleX=c,this._scaleY=d,this._rotation=e,this._rotPointX=f,this._rotPointY=g,this._dirty=!0,this},c.prototype.getParentMatrix=function(){return this._parent?this._parent.getConcatenatedMatrix():null},c.prototype.getConcatenatedMatrix=function(){return this._dirty&&!this.locked&&this._matrix.setFromOffsetTransform(this.x,this.y,this.scaleX,this.scaleY,this.rotation,this.anchorPointX,this.anchorPointY),this._cachedConcatenatedMatrix.copyFrom(this._matrix),!this._parent||this._parent.ignoreChild||this.ignoreParent||(this._cachedConcatenatedMatrix.tx-=this._parent.anchorPointX,this._cachedConcatenatedMatrix.ty-=this._parent.anchorPointY,this._cachedConcatenatedMatrix.prependMatrix(this.getParentMatrix())),this._dirty=!1,this._cachedConcatenatedMatrix},c.prototype.transformPoint=function(a){var b=this.getConcatenatedMatrix();return b.transformPoint(a)},c.prototype.copyFrom=function(a){return this.setTransform(a.x,a.y,a.scaleX,a.scaleY,a.rotation,a.rotPointX,a.rotPointY),this.parent=a.parent,this._matrix=a.matrix.clone(),this},c.prototype.copyTo=function(a){return a.copyFrom(this),this},c.prototype.clone=function(a){return void 0===a&&(a=new c),a.copyFrom(this),a},c.prototype.checkAncestor=function(){return!1},Object.defineProperty(c.prototype,"toString",{get:function(){return"[{Transform (x="+this._x+" y="+this._y+" scaleX="+this._scaleX+" scaleY="+this._scaleY+" rotation="+this._rotation+" regX="+this._rotPointX+" regY="+this.rotPointY+" matrix="+this._matrix+")}]"},enumerable:!0,configurable:!0}),c}();b.Transform=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function c(a,b){void 0===a&&(a=0),void 0===b&&(b=0),this.setTo(a,b)}return c.prototype.objType=function(){return"Vector2"},c.fromAngle=function(a){return new c(Math.cos(a),Math.sin(a))},c.randomRadius=function(a){return new c(2*Math.random()-1,2*Math.random()-1).multiplyScalar(a)},c.fromPoint=function(a){return new c(a.x,a.y)},c.prototype.add=function(a){return new c(this.x+a.x,this.y+a.y)},c.prototype.addX=function(a){return new c(this.x+a.x,this.y)},c.prototype.addY=function(a){return new c(this.x,this.y+a.y)},c.prototype.subtract=function(b){return new a.Geom.Vector2(this.x-b.x,this.y-b.y)},c.prototype.multiply=function(b){return new a.Geom.Vector2(this.x*b.x,this.y*b.y)},c.prototype.multiplyScalar=function(b){return new a.Geom.Vector2(this.x*b,this.y*b)},c.prototype.dot=function(a){return this.x*a.x+this.y*a.y},c.prototype.lenSqr=function(){return this.x*this.x+this.y*this.y},c.prototype.len=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},c.prototype.unit=function(){var a=1/this.len();return this.multiplyScalar(a)},c.prototype.floor=function(){return new c(Math.floor(this.x),Math.floor(this.y))},c.prototype.ceil=function(){return new c(Math.ceil(this.x),Math.ceil(this.y))},c.prototype.round=function(){return new c(Math.round(this.x),Math.round(this.y))},c.prototype.clamp=function(a,b){return new c(Math.max(Math.min(this.x,b.x),a.x),Math.max(Math.min(this.y,b.y),a.y))},c.prototype.perp=function(){return new c(-this.y,this.x)},c.prototype.neg=function(){return new c(-this.x,-this.y)},c.prototype.equal=function(a){return this.x===a.x&&this.y===a.y},c.prototype.point=function(){return new b.Point(this.x,this.y)},c.prototype.clear=function(){return this.x=0,this.y=0,this},c.prototype.clone=function(a){return void 0===a&&(a=new c),a.setTo(this.x,this.y)},c.prototype.copyFrom=function(a){return this.x=a.x,this.y=a.y,this},c.prototype.copyTo=function(a){return a.x=this.x,a.y=this.y,a},c.prototype.setTo=function(a,b){return this.x=a,this.y=b,this},c.prototype.toString=function(){return"[{Vector2 (x="+this.x+" y="+this.y+")}]"},c}();b.Vector2=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b,c){if(this._game=b,this.name=c,this._manager=this._game.huds,this._device=this._game.deviceTargetOption,this._manager.supported){switch(this._device){case a.TARGET_BROWSER:this.container=document.createElement("div"),this.container.id="HUD-layer-"+b.rnd.uuid(),this.container.style.width="100%",this.container.style.height="100%",this.container.style.position="absolute",this._widgets=new Array}this["class"]="kiwi-display"}}return b.prototype.objType=function(){return"HUDDisplay"},b.prototype.addWidget=function(b){return this._manager.supported&&(this._widgets.push(b),this._device==a.TARGET_BROWSER)?(this.container.appendChild(b.container),!0):!1},b.prototype.removeWidget=function(a){if(this._manager.supported&&this.removeFromContainer(a)){var b=this._widgets.indexOf(a);if(-1!==b)return this._widgets.splice(b,1),!0}return!1},b.prototype.removeAllWidgets=function(){for(var a=0;a<this._widgets.length;a++)this.removeFromContainer(this._widgets[a]);this._widgets=[]},b.prototype.removeFromContainer=function(b){return this._manager.supported&&this._device==a.TARGET_BROWSER&&this.container.contains(b.container)?(this.container.removeChild(b.container),!0):!1},b.prototype.update=function(){for(var a=0;a<this._widgets.length;a++)this._widgets[a].update()},b.prototype.show=function(){this.container.style.display="block"},b.prototype.hide=function(){this.container.style.display="none"},Object.defineProperty(b.prototype,"class",{get:function(){return this._device==a.TARGET_BROWSER?this.container.className:void 0},set:function(b){this._device==a.TARGET_BROWSER&&(this.container.className=b)},enumerable:!0,configurable:!0}),b}();b.HUDDisplay=c}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._game=a,this._device=this._game.deviceTargetOption}return Object.defineProperty(b.prototype,"supported",{get:function(){return this._supported},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this._device===a.TARGET_BROWSER?(this._supported=!0,this._hudContainer=document.createElement("div"),this._hudContainer.id="HUDContainer",this._hudContainer.style.position="absolute",this._hudContainer.style.width="100%",this._hudContainer.style.height="100%",this._hudContainer.style.top="0",this._hudContainer.style.left="0",this._game.stage.container.appendChild(this._hudContainer),this._huds=new Array,this._defaultHUD=this.createHUD("defaultHUD"),this._currentHUD=this._defaultHUD,this.setHUD(this._defaultHUD)):this._supported=!1},b.prototype.objType=function(){return"HUDManager"},Object.defineProperty(b.prototype,"defaultHUD",{get:function(){return this._defaultHUD},set:function(a){this._currentHUD===this._defaultHUD&&(this._currentHUD=a,this.setHUD(this._currentHUD)),this._defaultHUD=a},enumerable:!0,configurable:!0}),b.prototype.setHUD=function(a){this.supported&&(this.hideHUD(),this._currentHUD=a,this.showHUD())},b.prototype.showHUD=function(a){void 0===a&&(a=this._currentHUD),a.show()},b.prototype.hideHUD=function(a){void 0===a&&(a=this._currentHUD),a.hide()},b.prototype.createHUD=function(b,c){if(void 0===c&&(c=!1),this.supported){var d=new a.HUD.HUDDisplay(this._game,b);return d.hide(),this.addToContainer(d),this._huds.push(d),c===!0&&this.setHUD(d),d}},b.prototype.removeHUD=function(a){if(this.supported){if(a===this._defaultHUD)return!1;this._currentHUD===a&&this.setHUD(this._defaultHUD),this.removeFromContainer(a);var b=this._huds.indexOf(a);return-1!==b&&this._huds.splice(b,1),!0}},b.prototype.addToContainer=function(b){this._device==a.TARGET_BROWSER&&this._hudContainer.appendChild(b.container)},b.prototype.removeFromContainer=function(b){this._device==a.TARGET_BROWSER&&this._hudContainer.contains(b.container)&&this._hudContainer.removeChild(b.container)},b.prototype.update=function(){if(this._supported)for(var a=0;a<this._huds.length;a++)this._huds[a].update()},b}();b.HUDManager=c}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(c,d,e,f){this._horizontalOrigin=b.LEFT,this._verticalOrigin=b.TOP,this.name=d,this.game=c,this._manager=this.game.huds,this._device=this.game.deviceTargetOption,this.components=new a.ComponentManager(a.HUD_WIDGET,this),this._manager.supported&&(this._device===a.TARGET_BROWSER&&(this.container=document.createElement("div"),this.container.id="HUD-widget-"+this.game.rnd.uuid(),this.container.className="HUD-widget",this.container.style.position="absolute"),this.onCoordsUpdate=new a.Signal,this.x=e,this.y=f)}return b.prototype.objType=function(){return"HUDWidget"},Object.defineProperty(b.prototype,"style",{get:function(){return this._device===a.TARGET_BROWSER?this.container.style:void 0},set:function(b){this._device===a.TARGET_BROWSER&&(this.container.style=b)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"x",{get:function(){return this._x},set:function(b){this._manager.supported&&(this._x=b,this._device==a.TARGET_BROWSER&&(this.container.style[this._horizontalOrigin]=this.x+"px"),this.onCoordsUpdate.dispatch(this.x,this.y))},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this._y},set:function(b){this._manager.supported&&(this._y=b,this._device==a.TARGET_BROWSER&&(this.container.style[this._verticalOrigin]=this.y+"px"),this.onCoordsUpdate.dispatch(this.x,this.y))},enumerable:!0,configurable:!0}),b.prototype.setTemplate=function(b,c){for(var d=[],e=2;e<arguments.length;e++)d[e-2]=arguments[e];if(this._device==a.TARGET_BROWSER){var f=document.getElementById(b);if(void 0===f)return;if(void 0===c)var g=f;else{var g=document.getElementById(c);if(void 0===g||f.contains(g)===!1)return}this.tempElement=g,this._tempContainer=f,this._tempParent=f.parentElement,this._tempParent.removeChild(f),this.container.appendChild(f)}},b.prototype.removeTemplate=function(){this._device==a.TARGET_BROWSER&&void 0!==this.tempElement&&(this.container.removeChild(this._tempContainer),this._tempParent.appendChild(this._tempContainer),this.tempElement=null,this._tempParent=null,this._tempContainer=null)},Object.defineProperty(b.prototype,"class",{get:function(){return this._device==a.TARGET_BROWSER?this.container.className:void 0},set:function(b){this._device==a.TARGET_BROWSER&&(this.container.className=b)},enumerable:!0,configurable:!0}),b.prototype.update=function(){this.components.update()},Object.defineProperty(b.prototype,"horizontalOrigin",{get:function(){return this._horizontalOrigin},set:function(a){this.container.style[this._horizontalOrigin]="auto",this._horizontalOrigin=a,this.container.style[this._horizontalOrigin]=this.x+"px"},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"verticalOrigin",{get:function(){return this._verticalOrigin},set:function(a){this.container.style[this._verticalOrigin]="auto",this._verticalOrigin=a,this.container.style[this._verticalOrigin]=this.y+"px"},enumerable:!0,configurable:!0}),b.prototype.destroy=function(){delete this.game,delete this._manager,delete this._device,this.onCoordsUpdate&&this.onCoordsUpdate.dispose(),delete this.onCoordsUpdate},b.TOP="top",b.BOTTOM="bottom",b.LEFT="left",b.RIGHT="right",b}();b.HUDWidget=c}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(c,d,e,f){b.call(this,c,"textField",e,f),this._prefix="",this._suffix="",this["class"]="kiwi-textfield-widget kiwi-widget",this._manager.supported&&this._device===a.TARGET_BROWSER&&(this._textField=this.container,this._textField.innerHTML=d)}return __extends(c,b),c.prototype.objType=function(){return"TextFieldWidget"},c.prototype.setTemplate=function(c,d){this._device===a.TARGET_BROWSER&&(this._textField.innerText="",b.prototype.setTemplate.call(this,c,d),void 0!==this.tempElement&&(this._textField=this.tempElement),this._textField.innerHTML=this._text)},c.prototype.removeTemplate=function(){this._device===a.TARGET_BROWSER&&(b.prototype.removeTemplate.call(this),this._device===a.TARGET_BROWSER&&(this._textField=this.container,this._textField.innerHTML=this._text))},Object.defineProperty(c.prototype,"text",{get:function(){return this._text},set:function(b){this._manager.supported&&this._device===a.TARGET_BROWSER&&(""!==this._prefix&&(b=this._prefix+b),""!==this._suffix&&(b+=this._suffix),this._text=b,this._textField.innerHTML=this._text)},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"suffix",{get:function(){return this._suffix},set:function(a){this._suffix=a,this._updateText()},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"prefix",{get:function(){return this._prefix},set:function(a){this._prefix=a,this._updateText()},enumerable:!0,configurable:!0}),c.prototype._updateText=function(){this.text=this._text},c}(a.HUD.HUDWidget);b.TextField=c}(c=b.Widget||(b.Widget={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(c,d,e,f,g,h,i,j){void 0===h&&(h=120),void 0===i&&(i=20),void 0===j&&(j="#000"),b.call(this,c,"bar",f,g),this._horizontal=!0,this["class"]="kiwi-bar-widget kiwi-widget",this._manager.supported&&(this._device==a.TARGET_BROWSER&&(this._bar=document.createElement("div"),this._bar.className="kiwi-innerbar-widget",this._bar.style.backgroundColor=j,this.bar=this._bar,this.container.appendChild(this.bar)),this.counter=this.components.add(new a.HUD.HUDComponents.Counter(this,d,e,0)),this.counter.updated.add(this.updateCSS,this),this.width=h,this.height=i,this._bar.style.height="100%",this._bar.style.width="100%",this.updateCSS())}return __extends(c,b),c.prototype.objType=function(){return"BarWidget"},Object.defineProperty(c.prototype,"width",{get:function(){return this._width},set:function(b){this._device==a.TARGET_BROWSER&&(this.container.style.width=b+"px"),this._width=b},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"height",{get:function(){return this._height},set:function(b){this._device==a.TARGET_BROWSER&&(this.container.style.height=b+"px"),this._height=b},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"horizontal",{get:function(){return this._horizontal},set:function(a){this._horizontal=a,this.updateCSS()},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"vertical",{get:function(){return!this._horizontal},set:function(a){this._horizontal=!a,this.updateCSS()},enumerable:!0,configurable:!0}),c.prototype.setTemplate=function(c,d){this._device==a.TARGET_BROWSER&&(b.prototype.setTemplate.call(this,c,d),void 0!==this.tempElement&&(this.bar=this.tempElement))
|
|
},c.prototype.removeTemplate=function(){this._device==a.TARGET_BROWSER&&(b.prototype.removeTemplate.call(this),this.bar=this._bar,this.container.appendChild(this.bar),this.updateCSS())},c.prototype.updateCSS=function(){this.horizontal===!0?(this.bar.style.width=String(this.counter.currentPercent())+"%",this.bar.style.height="100%"):(this.bar.style.height=String(this.counter.currentPercent())+"%",this.bar.style.width="100%")},c}(a.HUD.HUDWidget);b.Bar=c}(c=b.Widget||(b.Widget={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(a,c,d,e){b.call(this,a,"Icon",d,e),this._cellIndex=0,this["class"]="kiwi-icon-widget kiwi-widget",this.atlas=c,this.icon=this.container,this._applyCSS()}return __extends(c,b),Object.defineProperty(c.prototype,"cellIndex",{get:function(){return this._cellIndex},set:function(a){this._cellIndex=a,this.width=this.atlas.cells[this.cellIndex].w,this.height=this.atlas.cells[this.cellIndex].h,this._applyCSS()},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"width",{get:function(){return this.atlas.cells[this.cellIndex].w},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"height",{get:function(){return this.atlas.cells[this.cellIndex].h},enumerable:!0,configurable:!0}),c.prototype._removeCSS=function(){this.icon.style.width="",this.icon.style.height="",this.icon.style.backgroundImage="",this.icon.style.backgroundRepeat=""},c.prototype._applyCSS=function(){this.icon.style.width=this.width+"px",this.icon.style.height=this.height+"px",this.icon.style.backgroundPositionX=-this.atlas.cells[this.cellIndex].x+"px",this.icon.style.backgroundPositionY=-this.atlas.cells[this.cellIndex].y+"px",this.icon.style.backgroundRepeat="no-repeat",this.icon.style.backgroundImage=0==a.Utils.Common.isUndefined(this.atlas.image.src)?'url("'+this.atlas.image.src+'")':'url("'+this.atlas.image.toDataURL("image/png")+'")'},c.prototype.setTemplate=function(c,d){this._device==a.TARGET_BROWSER&&(this._removeCSS(),b.prototype.setTemplate.call(this,c,d),void 0!==this.tempElement&&(this.icon=this.tempElement),this._applyCSS())},c.prototype.removeTemplate=function(){this._device==a.TARGET_BROWSER&&(b.prototype.removeTemplate.call(this),this._removeCSS(),this.icon=this.container,this._applyCSS())},c}(a.HUD.HUDWidget);b.Icon=c}(c=b.Widget||(b.Widget={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(c,d,e,f,g,h){b.call(this,c,"IconBar",g,h),this.iconGap=0,this["class"]="kiwi-iconbar-widget kiwi-widget",this.atlas=d,this.width=this.atlas.cells[0].w,this.height=this.atlas.cells[0].h,this._horizontal=!0,this.counter=this.components.add(new a.HUD.HUDComponents.Counter(this,e,f,0)),this.counter.updated.add(this._amountChanged,this),this._icons=[],this._amountChanged()}return __extends(c,b),c.prototype.objType=function(){return"IconBarWidget"},c.prototype._amountChanged=function(){if(this.counter.max!==this._icons.length)if(this.counter.max>this._icons.length)for(var a=this.counter.max-this._icons.length,b=0;a>b;b++)this._addIcon();else for(var b=this.counter.max;b<this._icons.length;b++)this._removeIcon(this._icons[b]),this._icons[b].destroy(),this._icons.splice(b,1),b--;for(var b=0;b<this._icons.length;b++)this._icons[b].style.display=b>this.counter.current-1?"none":"block"},c.prototype._addIcon=function(){if(this.horizontal)var b=new a.HUD.Widget.Icon(this.game,this.atlas,this.x+(this.width+this.iconGap)*(this._icons.length-1),0);else var b=new a.HUD.Widget.Icon(this.game,this.atlas,this.x,(this.height+this.iconGap)*(this._icons.length-1));b.horizontalOrigin=this.horizontalOrigin,b.verticalOrigin=this.verticalOrigin,this._icons.push(b),this._device==a.TARGET_BROWSER&&this.container.appendChild(b.container)},c.prototype._removeIcon=function(b){this._device==a.TARGET_BROWSER&&this.container.removeChild(b.container)},Object.defineProperty(c.prototype,"horizontal",{get:function(){return this._horizontal},set:function(a){this._horizontal=a,this._amountChanged()},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"vertical",{get:function(){return!this._horizontal},set:function(a){this._horizontal=!a,this._amountChanged()},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"horizontalOrigin",{get:function(){return this._horizontalOrigin},set:function(a){this.container.style[this._horizontalOrigin]="auto",this._horizontalOrigin=a,this.container.style[this._horizontalOrigin]=this.x+"px";for(var b=0;b<this._icons.length;)this._icons[b].horizontalOrigin=a,b++},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"verticalOrigin",{get:function(){return this._verticalOrigin},set:function(a){this.container.style[this._verticalOrigin]="auto",this._verticalOrigin=a,this.container.style[this._verticalOrigin]=this.y+"px";for(var b=0;b<this._icons.length;)this._icons[b].verticalOrigin=a,b++},enumerable:!0,configurable:!0}),c}(a.HUD.HUDWidget);b.IconBar=c}(c=b.Widget||(b.Widget={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(c,d,e,f){void 0===f&&(f=0),b.call(this,c,"basicScore",d,e),this.name="basicScore",this["class"]="kiwi-basicscore-widget kiwi-widget",this.counter=this.components.add(new a.HUD.HUDComponents.Counter(this,f)),this.counter.updated.add(this._updateText,this),this._updateText()}return __extends(c,b),c.prototype.objType=function(){return"BasicScoreWidget"},c.prototype._updateText=function(){this.text=String(this.counter.current)},c}(a.HUD.Widget.TextField);b.BasicScore=c}(c=b.Widget||(b.Widget={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(c,d,e,f){b.call(this,c,d,e,f),this.name="button",this["class"]="kiwi-button-widget kiwi-widget",this.input=this.components.add(new a.HUD.HUDComponents.WidgetInput(this,this.container))}return __extends(c,b),c.prototype.objType=function(){return"ButtonWidget"},c}(a.HUD.Widget.TextField);b.Button=c}(c=b.Widget||(b.Widget={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(c,d,e,f){b.call(this,c,"time",e,f),this.name="time",this["class"]="kiwi-time-widget kiwi-widget",this.time=this.components.add(new a.HUD.HUDComponents.Time(this,d))}return __extends(c,b),c.prototype.objType=function(){return"TimeWidget"},c.prototype.pause=function(){this.time.pause()},c.prototype.stop=function(){this.time.stop()},c.prototype.start=function(){this.time.start()},c.prototype.resume=function(){this.time.resume()},c.prototype.update=function(){b.prototype.update.call(this),this.time.isRunning&&(this.text=this.time.getTime())},c}(a.HUD.Widget.TextField);b.Time=c}(c=b.Widget||(b.Widget={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(a,c,d){b.call(this,a,"menu",c,d),this._menuItems=[],this._styles=[],this["class"]="kiwi-menu-widget kiwi-widget"}return __extends(c,b),c.prototype.objType=function(){return"MenuWidget"},c.prototype.setIconStyle=function(a,b){this._styles.push({index:a,value:b});for(var c=0;c<this._menuItems.length;c++)this._menuItems[c].style[a]=b},Object.defineProperty(c.prototype,"menuItems",{get:function(){return this._menuItems},enumerable:!0,configurable:!0}),c.prototype.createMenuItem=function(b,c,d){return this.addMenuItem(new a.HUD.Widget.MenuItem(this.game,b,c,d))},c.prototype.addMenuItem=function(b){this._menuItems.push(b),b.menu=this;for(var c=0;c<this._styles.length;c++)b.style[this._styles[c].index]=this._styles[c].value;return b.verticalOrigin=this.verticalOrigin,b.horizontalOrigin=this.horizontalOrigin,this._device==a.TARGET_BROWSER&&this.container.appendChild(b.container),b},c.prototype.addMenuItems=function(a){for(var b=0;b<a.length;b++)this.addMenuItem(a[b])},c.prototype.getMenuItem=function(a){return this._menuItems[a]},c.prototype.setTemplate=function(a,b){},c.prototype.removeTemplate=function(){},c.prototype.update=function(){for(var a=0;a<this._menuItems.length;a++)this._menuItems[a].update();b.prototype.update.call(this)},Object.defineProperty(c.prototype,"horizontalOrigin",{get:function(){return this._horizontalOrigin},set:function(a){this.container.style[this._horizontalOrigin]="auto",this._horizontalOrigin=a,this.container.style[this._horizontalOrigin]=this.x+"px";for(var b=0;b<this._menuItems.length;)this._menuItems[b].horizontalOrigin=a,b++},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"verticalOrigin",{get:function(){return this._verticalOrigin},set:function(a){this.container.style[this._verticalOrigin]="auto",this._verticalOrigin=a,this.container.style[this._verticalOrigin]=this.y+"px";for(var b=0;b<this._menuItems.length;)this._menuItems[b].verticalOrigin=a,b++},enumerable:!0,configurable:!0}),c}(a.HUD.HUDWidget);b.Menu=c}(c=b.Widget||(b.Widget={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(a){function b(b,c,d,e){a.call(this,b,c,d,e),this.name="menuItem",this["class"]="kiwi-menuitem-widget kiwi-widget"}return __extends(b,a),b.prototype.objType=function(){return"MenuItem"},b}(a.HUD.Widget.Button);b.MenuItem=c}(c=b.Widget||(b.Widget={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(c,d,e,f){void 0===e&&(e=null),void 0===f&&(f=null),b.call(this,c,"counter"),this._current=d,this._max=e,this._min=f,this.updated=new a.Signal}return __extends(c,b),c.prototype.objType=function(){return"CounterComponent"},Object.defineProperty(c.prototype,"max",{get:function(){return this._max},set:function(a){this._max=a,this.updated.dispatch(this._current,this._max,this._min)},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"min",{get:function(){return this._min},set:function(a){this._min=a,this.updated.dispatch(this._current,this._max,this._min)},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"current",{get:function(){return this._current},set:function(a){this._current=null!==this._max&&a>this._max?this._max:null!==this._min&&a<this._min?this._min:a,this.updated.dispatch(this._current,this._max,this._min)},enumerable:!0,configurable:!0}),c.prototype.decrease=function(a){return void 0===a&&(a=1),(null===this._min||this._current>this._min)&&(null!==this._min&&this._current-a<this._min?this._current=this._min:this._current-=a,this.updated.dispatch(this._current,this._max,this._min)),this._current},c.prototype.increase=function(a){return void 0===a&&(a=1),(null===this._max||this._current<this._max)&&(null!==this._max&&this._current+a>this._max?this._current=this._max:this._current+=a,this.updated.dispatch(this._current,this._max,this._min)),this._current},c.prototype.currentPercent=function(){return null!==this.max?this.current/this.max*100:void 0},c}(a.Component);b.Counter=c}(c=b.HUDComponents||(b.HUDComponents={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(c,d){b.call(this,c,"WidgetInput"),this._active=!1,this._container=d,this.onUp=new a.Signal,this.onDown=new a.Signal,this.onOver=new a.Signal,this.onOut=new a.Signal,this._addEvents()}return __extends(c,b),c.prototype.objType=function(){return"WidgetInputComponent"},c.prototype.setElement=function(a){this._removeEvents(),this._container=a,this._addEvents()},c.prototype._addEvents=function(){if(!this._active){this._binds=[],this._binds.push({event:"mouseup","function":this._up.bind(this)}),this._binds.push({event:"mousedown","function":this._down.bind(this)}),this._binds.push({event:"mouseover","function":this._over.bind(this)}),this._binds.push({event:"mouseout","function":this._out.bind(this)});for(var a=0;a<this._binds.length;a++)this._container.addEventListener(this._binds[a].event,this._binds[a]["function"],!1);this._active=!0}},c.prototype._removeEvents=function(){if(this._active){for(var a=0;a<this._binds.length;a++)this._container.removeEventListener(this._binds[a].event,this._binds[a]["function"],!1);this._binds=[],this._active=!1}},c.prototype._up=function(a){this.onUp.dispatch(a)},c.prototype._down=function(a){this.onDown.dispatch(a)},c.prototype._over=function(a){this.onOver.dispatch(a)},c.prototype._out=function(a){this.onOut.dispatch(a)},c}(a.Component);b.WidgetInput=c}(c=b.HUDComponents||(b.HUDComponents={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(a){function b(b,c){void 0===c&&(c=""),a.call(this,b,"time"),this.countDown=!1,this._displayString="",this._currentTime=0,this._timeBefore=0,this.speed=1,this.clock=this.game.time.addClock(name+"-clock",1e3),this.format=c}return __extends(b,a),b.prototype.objType=function(){return"TimeComponent"},Object.defineProperty(b.prototype,"isRunning",{get:function(){return this.clock.isRunning()},enumerable:!0,configurable:!0}),b.prototype.pause=function(){this.clock.pause()},b.prototype.stop=function(){this.clock.stop()},b.prototype.start=function(){this.clock.start(),this._timeBefore=this.clock.elapsed()},b.prototype.resume=function(){this.clock.resume()},Object.defineProperty(b.prototype,"format",{get:function(){return this._format},set:function(a){this._format=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"currentTime",{get:function(){return this._currentTime},enumerable:!0,configurable:!0}),b.prototype.setTime=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=0),this._currentTime=a,0!=b&&(this._currentTime+=1e3*b),0!=c&&(this._currentTime+=60*c*1e3)},b.prototype.addTime=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=0),this._currentTime+=a,0!=b&&(this._currentTime+=1e3*b),0!=c&&(this._currentTime+=60*c*1e3)},b.prototype.removeTime=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=0),this._currentTime-=a,0!=b&&(this._currentTime-=1e3*b),0!=c&&(this._currentTime-=60*c*1e3)},b.prototype.getTime=function(){if(this.countDown?this._currentTime-=(this.clock.elapsed()-this._timeBefore)*this.speed:this._currentTime+=(this.clock.elapsed()-this._timeBefore)*this.speed,this._timeBefore=this.clock.elapsed(),""!==this._format){if(this._displayString=this._format,-1!==this._displayString.indexOf("ms")){var a=String(Math.floor(1e3*this._currentTime)%1e3);this._displayString=this._displayString.replace("ms",a)}if(-1!=this._displayString.indexOf("ss")){var a=String(Math.floor(this._currentTime)%60);a.length<2&&(a="0"+a),this._displayString=this._displayString.replace("ss",a)}if(-1!==this._displayString.indexOf("mm")){var a=String(Math.floor(this._currentTime/60)%60);a.length<2&&(a="0"+a),this._displayString=this._displayString.replace("mm",a)}if(-1!=this._displayString.indexOf("s")){var a=String(Math.floor(this._currentTime)%60);this._displayString=this._displayString.replace("s",a)}if(-1!==this._displayString.indexOf("m")){var a=String(Math.floor(this._currentTime/60)%60);this._displayString=this._displayString.replace("m",a)}return this._displayString}return String(this._currentTime.toFixed(2))},b}(a.Component);b.Time=c}(c=b.HUDComponents||(b.HUDComponents={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this.noAudio=!1,this.usingWebAudio=!1,this.usingAudioTag=!1,this.context=null,this.masterGain=null,this._unlockedSource=null,this._game=a}return b.prototype.objType=function(){return"AudioManager"},Object.defineProperty(b.prototype,"locked",{get:function(){return this._locked},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this._volume=1,this._muted=!1,this._sounds=[],a.DEVICE.iOS&&0==a.DEVICE.webaudio&&(this.channels=1),a.DEVICE.iOS&&this._game.deviceTargetOption!==a.TARGET_COCOON?(this._locked=!0,this._game.input.onUp.addOnce(this._unlocked,this),a.Log.log("Kiwi.AudioManager: Audio is currently Locked until at touch event.","#audio","#locked")):this._locked=!1,this.usingWebAudio=!0,this.usingAudioTag=!1,window.AudioContext?this.context=new window.AudioContext:window.webkitAudioContext?this.context=new window.webkitAudioContext:window.Audio?(this.usingWebAudio=!1,this.usingAudioTag=!0):(this.usingWebAudio=!1,this.noAudio=!0),null!==this.context&&(this.masterGain=void 0===this.context.createGain?this.context.createGainNode():this.context.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this.context.destination))},b.prototype._unlocked=function(){if(a.Log.log("Kiwi.AudioManager: Audio now Unlocked.","#audio","#unlocked"),this.usingAudioTag){this._locked=!1;for(var b=0;b<this._sounds.length;b++)this._sounds[b].playable=!0}else{var c=this.context.createBuffer(1,1,22050);this._unlockedSource=this.context.createBufferSource(),this._unlockedSource.buffer=c,this._unlockedSource.connect(this.context.destination),void 0===this._unlockedSource.start?this._unlockedSource.noteOn(0):this._unlockedSource.start(0)}},Object.defineProperty(b.prototype,"mute",{get:function(){return this._muted},set:function(a){if(a===!0){if(this._muted)return;if(this._muted=!0,this.usingWebAudio)this._muteVolume=this.masterGain.gain.value,this.masterGain.gain.value=0;else if(this.usingAudioTag)for(var b=0;b<this._sounds.length;b++)this._sounds[b].mute=!0}else{if(0==this._muted)return;if(this._muted=!1,this.usingWebAudio)this.masterGain.gain.value=this._muteVolume;else if(this.usingAudioTag)for(var b=0;b<this._sounds.length;b++)this._sounds[b].mute=!1}},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"volume",{get:function(){return this._volume},set:function(b){if(void 0!==b)if(b=a.Utils.GameMath.clamp(b,1,0),this._volume=b,this._muted&&(this._muteVolume=this._volume),this.usingWebAudio)this.masterGain.gain.value=b;else if(this.usingAudioTag)for(var c=0;c<this._sounds.length;c++)this._sounds[c].volume=this._sounds[c].volume},enumerable:!0,configurable:!0}),b.prototype.isRegistered=function(a){return this.noAudio?void 0:-1!==this._sounds.indexOf(a)?!0:!1},b.prototype.registerSound=function(a){return this.isRegistered(a)===!1?(a.id=this._game.rnd.uuid(),this._sounds.push(a),!0):!1},b.prototype.add=function(b,c,d){if(void 0===c&&(c=1),void 0===d&&(d=!1),!this.noAudio){var e=new a.Sound.Audio(this._game,b,c,d);return e}},b.prototype.remove=function(a,b){void 0===b&&(b=!0);for(var c=0;c<this._sounds.length;c++)if(a.id==this._sounds[c].id)return this.usingWebAudio&&a.gainNode&&a.gainNode.disconnect(),1==b&&a.destroy(),void this._sounds.splice(c,1)},b.prototype.playAll=function(){for(var a=0;a<this._sounds.length;a++)this._sounds[a]&&this._sounds[a].play()},b.prototype.stopAll=function(){for(var a=0;a<this._sounds.length;a++)this._sounds[a]&&this._sounds[a].stop()},b.prototype.pauseAll=function(){for(var a=0;a<this._sounds.length;a++)this._sounds[a]&&this._sounds[a].pause()},b.prototype.resumeAll=function(){for(var a=0;a<this._sounds.length;a++)this._sounds[a]&&this._sounds[a].resume()},b.prototype.update=function(){if(this._locked&&this.usingWebAudio&&null!==this._unlockedSource&&(this._unlockedSource.playbackState===this._unlockedSource.PLAYING_STATE||this._unlockedSource.playbackState===this._unlockedSource.FINISHED_STATE)){this._locked=!1,this._unlockedSource=null;for(var a=0;a<this._sounds.length;a++)this._sounds[a].playable=!0}if(!this.noAudio)for(var a=0;a<this._sounds.length;a++)this._sounds[a].update()},b}();b.AudioManager=c}(b=a.Sound||(a.Sound={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b,c,d,e){return this._muted=!1,this.totalDuration=0,this._buffer=null,this._decoded=!1,this._markers={},this._currentMarker="default",this.ready=!1,this._game=b,this._game.audio.registerSound(this),this._usingAudioTag=this._game.audio.usingAudioTag,this._usingWebAudio=this._game.audio.usingWebAudio,this._playable=1==this._game.audio.locked?!1:!0,this.duration=0,this._volume=d,this._muteVolume=d,this._muted=this._game.audio.mute,this._loop=e,this.key=c,!a.Utils.Common.isString(this.key)&&this.key.isAudio&&(this.key=this.key.key),this._game.audio.noAudio||this._game.fileStore.exists(this.key)===!1?void a.Log.log("Could not play Audio. Either the browser doesn't support audio or the Audio file was not found on the filestore.","#audio","#notfound"):(this._usingWebAudio?(this._setAudio(),this.ready&&(this.context=this._game.audio.context,this.masterGainNode=this._game.audio.masterGain,this.gainNode="undefined"==typeof this.context.createGain?this.context.createGainNode():this.context.createGain(),this._decode(),this.gainNode.gain.value=this.volume*this._game.audio.volume,this.gainNode.connect(this.masterGainNode))):this._usingAudioTag&&this._playable===!0&&(this._setAudio(),this.ready&&(this.totalDuration=this._sound.duration,this._sound.volume=this.volume*this._game.audio.volume,(isNaN(this.totalDuration)||0==this.totalDuration)&&(this._pending=!0))),this.addMarker("default",0,this.totalDuration,this._loop),this._currentMarker="default",this.onPlay=new a.Signal,this.onStop=new a.Signal,this.onPause=new a.Signal,this.onResume=new a.Signal,this.onLoop=new a.Signal,this.onMute=new a.Signal,void(this.onComplete=new a.Signal))}return Object.defineProperty(b.prototype,"playable",{get:function(){return this._playable},set:function(a){this._playable!==!0&&1==a&&(this._playable=a,this._setAudio(),this.ready&&this._usingAudioTag&&(this.totalDuration=this._sound.duration,this._sound.volume=this.volume*this._game.audio.volume))},enumerable:!0,configurable:!0}),b.prototype.objType=function(){return"Audio"},Object.defineProperty(b.prototype,"loop",{get:function(){return this._loop},enumerable:!0,configurable:!0}),b.prototype._setAudio=function(){this._file=this._game.fileStore.getFile(this.key),"undefined"!=typeof this._file.data&&(this._usingAudioTag?(this._sound=this._file.data.cloneNode(!0),this._game.deviceTargetOption==a.TARGET_BROWSER&&(this._sound.play(),this._sound.pause())):this._sound=this._file.data,this.ready=!0)},b.prototype._decode=function(){if(0!=this.ready&&!this._usingAudioTag){if(this._file.data.decoded===!0&&null!==this._file.data.buffer)return this._buffer=this._file.data.buffer,void(this._decoded=!0);var a=this;this.context.decodeAudioData(this._file.data.raw,function(b){a._buffer=b,a._decoded=!0})}},Object.defineProperty(b.prototype,"volume",{get:function(){return this._volume},set:function(b){this._game.audio.noAudio||this.ready===!1||(b=a.Utils.GameMath.clamp(b,1,0),this._volume=b,this._muted&&(this._muteVolume=this._volume),this._playable&&(this._usingWebAudio?this.gainNode.gain.value=this._volume*this._game.audio.volume:this._usingAudioTag&&(this._sound.volume=this._volume*this._game.audio.volume)))},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"mute",{get:function(){return this._muted},set:function(a){this._game.audio.noAudio||void 0!==a&&this._muted!==a&&(a===!0?(this._muteVolume=this._volume,this.volume=0,this._muted=!0):(this._muted=!1,this.volume=this._muteVolume),this.onMute.dispatch(this._muted))},enumerable:!0,configurable:!0}),b.prototype.addMarker=function(a,b,c,d){void 0===d&&(d=!1),this._markers[a]={start:b,stop:c,duration:c-b,loop:d}},b.prototype.removeMarker=function(a){"default"!==a&&(this.isPlaying&&this._currentMarker==a&&(this.stop(),this._currentMarker="default"),delete this._markers[a])},b.prototype.play=function(b,c){return void 0===b&&(b=this._currentMarker),void 0===c&&(c=!1),this.isPlaying&&!c||this._game.audio.noAudio||(c&&!this._pending&&this.stop(),"undefined"==typeof this._markers[b]||this._currentMarker===b&&this.isPlaying&&0==c)?void 0:(this.paused=!1,this._currentMarker=b,this.duration=1e3*this._markers[this._currentMarker].duration,this._loop=this._markers[this._currentMarker].loop,this._playable===!1?void(this._pending=!0):void(this._usingWebAudio?this._decoded===!0?(null==this._buffer&&(this._buffer=this._file.data.buffer),this._sound=this.context.createBufferSource(),this._sound.buffer=this._buffer,this._sound.connect(this.gainNode),this.totalDuration=this._sound.buffer.duration,0==this.duration&&(this.duration=1e3*this.totalDuration),void 0===this._sound.start?this._sound.noteGrainOn(0,this._markers[this._currentMarker].start,this.duration/1e3):this._sound.start(0,this._markers[this._currentMarker].start,this.duration/1e3),this.isPlaying=!0,this._startTime=this._game.time.now(),this._currentTime=0,this.onPlay.dispatch()):(this._pending=!0,this._decode()):this._usingAudioTag&&(this._sound&&4==this._sound.readyState||this._game.deviceTargetOption==a.TARGET_COCOON?((0==this.duration||isNaN(this.duration))&&(this.duration=1e3*this.totalDuration),this._sound.volume=this._muted?0:this._volume,this._sound.currentTime=this._markers[this._currentMarker].start,this._sound.play(),this.isPlaying=!0,this._startTime=this._game.time.now(),this._currentTime=0,this.paused||this.onPlay.dispatch()):this._pending=!0)))},b.prototype.stop=function(){this.isPlaying&&this._sound&&(this._usingWebAudio?void 0===this._sound.stop?this._sound.noteOff(0):this._sound.stop(0):this._usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0),this.isPlaying=!1,0==this.paused&&this.onStop.dispatch())},b.prototype.pause=function(){this.isPlaying&&(this.paused=!0,this.stop(),this.onPause.dispatch())},b.prototype.resume=function(){this.paused&&0==this.isPlaying&&(this._usingWebAudio?(null==this._buffer&&(this._buffer=this._file.data.buffer),this._sound=this.context.createBufferSource(),this._sound.buffer=this._buffer,this._sound.connect(this.gainNode),void 0===this._sound.start?this._sound.noteGrainOn(0,this._markers[this._currentMarker].start+this._currentTime/1e3,this.duration/1e3):this._sound.start(0,this._markers[this._currentMarker].start+this._currentTime/1e3,this.duration/1e3)):(this._sound.currentTime=this._markers[this._currentMarker].start+this._currentTime/1e3,this._sound.play()),this.paused=!1,this.isPlaying=!0,this.onResume.dispatch())},b.prototype.update=function(){this.ready&&(this._playable&&this._pending&&(this._decoded===!0||this._file.data&&this._file.data.decoded?(this._pending=!1,this.play()):this._usingAudioTag&&!isNaN(this._sound.duration)&&0!==this._sound.duration&&(this.totalDuration=this._sound.duration,this._markers["default"].duration=this.totalDuration,this._pending=!1,this.isPlaying&&"default"==this._currentMarker&&(this.duration=1e3*this.totalDuration))),this.isPlaying&&(this._currentTime=this._game.time.now()-this._startTime,this._currentTime>=this.duration&&(this._loop?(this.play(this._currentMarker,!0),this.onLoop.dispatch()):(this.onComplete.dispatch(),this.stop()))))},b.prototype.destroy=function(){this._game&&this._game.audio.remove(this,!1),this.onLoop&&this.onLoop.dispose(),this.onStop&&this.onStop.dispose(),this.onPlay&&this.onPlay.dispose(),this.onMute&&this.onMute.dispose(),this.onPause&&this.onPause.dispose(),this.onResume&&this.onResume.dispose(),delete this.onLoop,delete this.onStop,delete this.onPause,delete this.onMute,delete this.onPlay,delete this.onResume,delete this._game,delete this._sound,delete this._currentTime,delete this._startTime,delete this._pending,delete this.masterGainNode,delete this.gainNode,delete this.totalDuration,delete this.duration,delete this._file,delete this._buffer,delete this._decoded},b}();b.Audio=c}(b=a.Sound||(a.Sound={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._game=a,this.audio={}}return b.prototype.objType=function(){return"AudioLibrary"},b.prototype.clear=function(){for(var a in this.audio)delete this.audio[a]},b.prototype.rebuild=function(b,c){this.clear(),a.Log.log("Kiwi.AudioLibrary: Rebuilding Audio Library.","#audio","#rebuild");for(var d=b.keys,e=0;e<d.length;e++){var f=this._game.fileStore.getFile(d[e]);f.isAudio&&(a.Log.log(" Kiwi.AudioLibrary: Adding Audio: "+f.name,"#audio","#added"),c.audioLibrary.add(f))}},b.prototype.add=function(b){switch(b.dataType){case a.Files.File.AUDIO:this.audio[b.key]=b}},b}();b.AudioLibrary=c}(b=a.Sound||(a.Sound={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function c(b,c,d,e){void 0===e&&(e=1e3),this._timeFirstStarted=null,this._timeLastStarted=null,this.timeScale=1,this._elapsed=0,this.rate=1,this._maxFrameDuration=-1,this._timeLastStopped=null,this._timeLastPaused=null,this._timeLastUnpaused=null,this._totalPaused=0,this._isRunning=!1,this._isStopped=!0,this._isPaused=!1,this._elapsedState=a.Time.Clock._RUNNING,this.manager=null,this.master=null,this.delta=0,this.name=null,this.units=0,this.manager=b,this.master=c,this.name=d,this.units=e,this.timers=[],this.units<1&&(this.units=1),this._lastMasterElapsed=this.master.elapsed(),this._currentMasterElapsed=this.master.elapsed()}return c.prototype.objType=function(){return"Clock"},c.prototype.elapsedSinceFirstStarted=function(){return this._timeLastStarted?(this.master.elapsed()-this._timeFirstStarted)/this.units:null},c.prototype.started=function(){return this._timeLastStarted},Object.defineProperty(c.prototype,"maxFrameDuration",{get:function(){return this._maxFrameDuration},set:function(a){this._maxFrameDuration=a},enumerable:!0,configurable:!0}),c.prototype.elapsed=function(){return this._elapsed},c.prototype.elapsedSinceLastStopped=function(){return this._timeLastStarted?(this.master.elapsed()-this._timeLastStopped)/this.units:null},c.prototype.elapsedSinceLastPaused=function(){return this._timeLastStarted?(this.master.elapsed()-this._timeLastPaused)/this.units:null},c.prototype.elapsedSinceLastUnpaused=function(){return this._timeLastStarted?(this.master.elapsed()-this._timeLastUnpaused)/this.units:null},c.prototype.isRunning=function(){return this._isRunning},c.prototype.isStopped=function(){return this._isStopped},c.prototype.isPaused=function(){return this._isPaused},c.prototype.addTimer=function(a){return this.timers.push(a),this},c.prototype.createTimer=function(a,c,d,e){return void 0===c&&(c=1),void 0===d&&(d=0),void 0===e&&(e=!0),this.timers.push(new b.Timer(a,this,c,d)),e===!0&&this.timers[this.timers.length-1].start(),this.timers[this.timers.length-1]},c.prototype.removeTimer=function(a,b){void 0===a&&(a=null),void 0===b&&(b="");var c;if(null!==a){if(c=this.timers.indexOf(a),-1!==c)return this.timers.splice(c,1),!0}else if(""!==b)for(c=0;c<this.timers.length;c++)if(this.timers[c].name===b)return this.timers.splice(c,1),!0;return!1},c.prototype.checkExists=function(a){return this.timers[a]?!0:!1},c.prototype.stopAllTimers=function(){for(var a=0;a<this.timers.length;a++)this.timers[a].stop();return this},c.prototype.convertToMilliseconds=function(a){return a*this.units},c.prototype.update=function(){var b=this._currentMasterElapsed-this._lastMasterElapsed;this._maxFrameDuration>0&&(b=Math.min(b,this._maxFrameDuration));for(var c=0;c<this.timers.length;c++)this.timers[c].update();this._lastMasterElapsed=this._currentMasterElapsed,this._currentMasterElapsed=this.master.elapsed(),this.delta=0,this._elapsedState===a.Time.Clock._RUNNING||this._elapsedState===a.Time.Clock._RESUMED?(this.delta=this.timeScale*b/this.units,this._elapsed+=this.delta,this.rate=this.timeScale*b/this.master.idealDelta):this._elapsedState===a.Time.Clock._PAUSED?(this._totalPaused+=b,this.rate=0):this._elapsedState===a.Time.Clock._STOPPED&&(this.rate=0)},c.prototype.start=function(){return this._timeLastStarted=this.master.elapsed(),this._totalPaused=0,this._timeFirstStarted||(this._timeFirstStarted=this._timeLastStarted),this._isRunning=!0,this._isPaused=!1,this._isStopped=!1,this._elapsedState=a.Time.Clock._RUNNING,this._elapsed=0,this._lastMasterElapsed=this.master.elapsed(),this._currentMasterElapsed=this.master.elapsed(),this},c.prototype.pause=function(){return this._isRunning===!0&&(this._timeLastPaused=this.master.elapsed(),this._isRunning=!1,this._isPaused=!0,this._isStopped=!1,this._elapsedState=a.Time.Clock._PAUSED),this},c.prototype.resume=function(){return this._isPaused===!0&&(this._timeLastUnpaused=this.master.elapsed(),this._totalPaused+=this._timeLastUnpaused-this._timeLastPaused,this._isRunning=!0,this._isPaused=!1,this._isStopped=!1,this._elapsedState=a.Time.Clock._RESUMED),this
|
|
},c.prototype.stop=function(){return this._isStopped===!1&&(this._timeLastStopped=this.master.elapsed(),this._isPaused===!0&&(this._totalPaused+=this._timeLastStopped-this._timeLastPaused),this._isRunning=!1,this._isPaused=!1,this._isStopped=!0,this._elapsedState=a.Time.Clock._STOPPED),this},c.prototype.toString=function(){return"[{Clock (name="+this.name+" units="+this.units+" running="+this._isRunning+")}]"},c.prototype.setTimeout=function(a,c,d){for(var e=[],f=3;f<arguments.length;f++)e[f-3]=arguments[f];var g=this,h=this.createTimer("timeoutTimer",c/this.units);return d||(d=this),h.createTimerEvent(b.TimerEvent.TIMER_STOP,function(){a.apply(d,e),g.removeTimer(h)},d),h.start(),h},c.prototype.setInterval=function(a,c,d){for(var e=[],f=3;f<arguments.length;f++)e[f-3]=arguments[f];var g=this.createTimer("intervalTimer",c/this.units,-1);return d||(d=this),g.createTimerEvent(b.TimerEvent.TIMER_COUNT,function(){a.apply(d,e)},d),g.start(),g},c._RUNNING=0,c._PAUSED=1,c._RESUMED=2,c._STOPPED=3,c}();b.Clock=c}(b=a.Time||(a.Time={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function c(a){this._clocks=[],this.rate=1,this._game=a}return c.prototype.objType=function(){return"ClockManager"},c.prototype.boot=function(){this.master=new a.Time.MasterClock,this.clock=new b.Clock(this,this.master,"default",1e3),this.clock.start()},c.prototype.addClock=function(a,c){return void 0===c&&(c=1e3),this._clocks.push(new b.Clock(this,this.master,a,c)),this._clocks[this._clocks.length-1]},c.prototype.getClock=function(a){for(var b=0;b<this._clocks.length;b++)if(this._clocks[b].name===a)return this._clocks[b]},c.prototype.update=function(){this.master.update(),this.clock.update();for(var a=0;a<this._clocks.length;a++)this._clocks[a].update();this.rate=this.master.rate},c.prototype.now=function(){return this.master.now},c.prototype.elapsed=function(){return this.master.elapsed()},c.prototype.delta=function(){return this.master.delta},c.prototype.setMasterInterval=function(a){this.master.idealDelta=a},c}();b.ClockManager=c}(b=a.Time||(a.Time={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){this.time=0,this.now=0,this.delta=0,this.rate=1,this.idealDelta=1e3/60,this._started=Date.now(),this.now=Date.now(),this.time=this._started}return a.prototype.objType=function(){return"MasterClock"},a.prototype.elapsed=function(){return this.now-this._started},a.prototype.totalElapsedSeconds=function(){return.001*(this.now-this._started)},a.prototype.update=function(){this.now=Date.now(),this.delta=this.now-this.time,this.time=this.now,this.rate=this.delta/this.idealDelta},a.prototype.elapsedSince=function(a){return this.now-a},a.prototype.elapsedSecondsSince=function(a){return.001*(this.now-a)},a.prototype.reset=function(){this._started=this.now},a}();a.MasterClock=b}(b=a.Time||(a.Time={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function c(a,b,c,d){void 0===d&&(d=0),this._currentCount=0,this._startEvents=null,this._countEvents=null,this._stopEvents=null,this._clock=null,this._timeLastCount=null,this._isRunning=!1,this._isStopped=!0,this._isPaused=!1,this.name=null,this._delay=.016,this.repeatCount=0,this._elapsed=0,this._clock=b,this._startEvents=[],this._countEvents=[],this._stopEvents=[],this.name=a,this.delay=c,this.repeatCount=d}return c.prototype.objType=function(){return"Timer"},c.prototype.currentCount=function(){return this._currentCount},c.prototype.isRunning=function(){return this._isRunning},c.prototype.isStopped=function(){return this._isStopped},c.prototype.isPaused=function(){return this._isPaused},Object.defineProperty(c.prototype,"delay",{get:function(){return this._delay},set:function(b){b>0?this._delay=b:a.Log.error("Attempted to set timer delay",b,"but value must be greater than 0","#timer")},enumerable:!0,configurable:!0}),c.prototype.processEvents=function(a){if(a===b.TimerEvent.TIMER_START)for(var c=0;c<this._startEvents.length;c++)this._startEvents[c].run();else if(a===b.TimerEvent.TIMER_COUNT)for(var c=0;c<this._countEvents.length;c++)this._countEvents[c].run();else if(a===b.TimerEvent.TIMER_STOP)for(var c=0;c<this._stopEvents.length;c++)this._stopEvents[c].run()},c.prototype.update=function(){var a=this._clock.elapsed()-this._lastElapsed;for(this._lastElapsed=this._clock.elapsed(),this._isRunning&&(this._elapsed+=a);this._elapsed>=this.delay;)this._currentCount++,this.processEvents(b.TimerEvent.TIMER_COUNT),this._elapsed-=this.delay,-1!==this.repeatCount&&this._currentCount>=this.repeatCount&&this.stop();for(;this._elapsed<0;)this._currentCount--,this._elapsed+=this.delay,this._currentCount<0&&(this.clear(),this.stop())},c.prototype.start=function(){return this._isStopped===!0&&(this._isRunning=!0,this._isPaused=!1,this._isStopped=!1,this._currentCount=0,this._elapsed=0,this._lastElapsed=this._clock.elapsed()||0,this.processEvents(b.TimerEvent.TIMER_START)),this},c.prototype.stop=function(){return(this._isRunning===!0||this._isPaused===!0)&&(this._isRunning=!1,this._isPaused=!1,this._isStopped=!0,this.processEvents(b.TimerEvent.TIMER_STOP)),this},c.prototype.pause=function(){return this._isRunning===!0&&(this._isRunning=!1,this._isPaused=!0),this},c.prototype.resume=function(){return this._isPaused===!0&&(this._isRunning=!0,this._isPaused=!1),this},c.prototype.addTimerEvent=function(a){return a.type===b.TimerEvent.TIMER_START?this._startEvents.push(a):a.type===b.TimerEvent.TIMER_COUNT?this._countEvents.push(a):a.type===b.TimerEvent.TIMER_STOP&&this._stopEvents.push(a),a},c.prototype.createTimerEvent=function(a,c,d){return a===b.TimerEvent.TIMER_START?(this._startEvents.push(new b.TimerEvent(a,c,d)),this._startEvents[this._startEvents.length-1]):a===b.TimerEvent.TIMER_COUNT?(this._countEvents.push(new b.TimerEvent(a,c,d)),this._countEvents[this._countEvents.length-1]):a===b.TimerEvent.TIMER_STOP?(this._stopEvents.push(new b.TimerEvent(a,c,d)),this._stopEvents[this._stopEvents.length-1]):null},c.prototype.removeTimerEvent=function(a){var c=[];return a.type===b.TimerEvent.TIMER_START?c=this._startEvents.splice(this._startEvents.indexOf(a),1):a.type===b.TimerEvent.TIMER_COUNT?c=this._countEvents.splice(this._countEvents.indexOf(a),1):a.type===b.TimerEvent.TIMER_STOP&&(c=this._stopEvents.splice(this._stopEvents.indexOf(a),1)),1===c.length?!0:!1},c.prototype.clear=function(a){void 0===a&&(a=0),0===a?(this._startEvents.length=0,this._countEvents.length=0,this._stopEvents.length=0):a===b.TimerEvent.TIMER_START?this._startEvents.length=0:a===b.TimerEvent.TIMER_COUNT?this._countEvents.length=0:a===b.TimerEvent.TIMER_STOP&&(this._stopEvents.length=0)},c.prototype.toString=function(){return"[{Timer (name="+this.name+" delay="+this.delay+" repeatCount="+this.repeatCount+" running="+this._isRunning+")}]"},c}();b.Timer=c}(b=a.Time||(a.Time={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b,c){this._callback=null,this.type=0,this.type=a,this._callback=b,this._callbackContext=c}return a.prototype.objType=function(){return"TimerEvent"},a.prototype.run=function(){this._callback&&this._callback.apply(this._callbackContext)},a.TIMER_START=1,a.TIMER_COUNT=2,a.TIMER_STOP=3,a}();a.TimerEvent=b}(b=a.Time||(a.Time={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b,c,d,e){void 0===d&&(d=!0),void 0===e&&(e=!1),this.domElement=null,this.context=null,this._visible=!0,this._offScreen=!1,this._clearMode=1,this.domElement=document.createElement("canvas"),this.domElement.width=b,this.domElement.height=c,this._width=b,this._height=c,this.context=this.domElement.getContext("2d"),this._offScreen=e,this._visible=d,d===!1&&(this.domElement.style.display="none"),this._bgColor=new a.Utils.Color(0,0,0)}return Object.defineProperty(b.prototype,"width",{get:function(){return this._width},set:function(a){this._width=a,this._updatedSize()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"height",{get:function(){return this._height},set:function(a){this._height=a,this._updatedSize()},enumerable:!0,configurable:!0}),b.prototype.objType=function(){return"Canvas"},Object.defineProperty(b.prototype,"bgColor",{get:function(){return"#"+this._bgColor.getHex()},set:function(b){a.Utils.Common.isArray(b)||(b=[b]),this._bgColor.set.apply(this._bgColor,b)},enumerable:!0,configurable:!0}),b.prototype._updatedSize=function(){this.domElement.width=this._width,this.domElement.height=this._height},b.prototype.destroy=function(){this._offScreen===!1&&(this.domElement.style.display="none")},Object.defineProperty(b.prototype,"visible",{get:function(){return this._visible},set:function(a){null!==a&&a!==this._visible&&(this._visible=a,this.domElement.style.display=a===!0?"block":"none")},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"clearMode",{get:function(){return this._clearMode},set:function(b){null!==b&&b!==this._clearMode&&b>=a.Utils.Canvas.CLEARMODE_NONE&&b<=a.Utils.Canvas.CLEARMODE_FILLRECT_ALPHA&&(this._clearMode=b)},enumerable:!0,configurable:!0}),b.prototype.clear=function(){this._clearMode===b.CLEARMODE_NONE||(this._clearMode===b.CLEARMODE_CLEARRECT?this.context.clearRect(0,0,this.domElement.width,this.domElement.height):this._clearMode===b.CLEARMODE_FILLRECT?(this.context.fillStyle=this.bgColor,this.context.fillRect(0,0,this.domElement.width,this.domElement.height)):this._clearMode===b.CLEARMODE_FILLRECT_ALPHA&&(this.context.clearRect(0,0,this.domElement.width,this.domElement.height),this.context.fillStyle=this.bgColor,this.context.fillRect(0,0,this.domElement.width,this.domElement.height)))},b.prototype.saveAsPNG=function(){return this.domElement.toDataURL()},b.prototype.toString=function(){return"[{Canvas (width="+this.width+" height="+this.height+" visible="+this.visible+" offScreen="+this._offScreen+" clearMode="+this.clearMode+")}]"},b.CLEARMODE_NONE=0,b.CLEARMODE_CLEARRECT=1,b.CLEARMODE_FILLRECT=2,b.CLEARMODE_FILLRECT_ALPHA=3,b}();b.Canvas=c}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];return this._r=.5,this._g=.5,this._b=.5,this._a=1,this.set.apply(this,a),this}return a.prototype.set=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];return 3===a.length?(this.r=a[0],this.g=a[1],this.b=a[2]):4===a.length?isNaN(a[3])?"hsv"===a[3]?this.parseHsv(a[0],a[1],a[2]):"hsl"===a[3]&&this.parseHsl(a[0],a[1],a[2]):(this.r=a[0],this.g=a[1],this.b=a[2],this.a=a[3]):5===a.length?"hsv"===a[4]?this.parseHsv(a[0],a[1],a[2],a[3]):"hsl"===a[4]&&this.parseHsl(a[0],a[1],a[2],a[3]):1===a.length?"string"==typeof a[0]?this.parseString(a[0]):isNaN(a[0])||(this.r=a[0],this.g=a[0],this.b=a[0]):2===a.length&&(this.r=a[0],this.g=a[0],this.b=a[0],this.a=a[1]),this},Object.defineProperty(a.prototype,"rNorm",{get:function(){return this._r},set:function(a){isNaN(a)||(this._r=a)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"gNorm",{get:function(){return this._g},set:function(a){isNaN(a)||(this._g=a)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"bNorm",{get:function(){return this._b},set:function(a){isNaN(a)||(this._b=a)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"aNorm",{get:function(){return this._a},set:function(a){isNaN(a)||(this._a=a)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"r",{get:function(){return this._r},set:function(a){a>1?this.r255=a:this.rNorm=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"g",{get:function(){return this._g},set:function(a){a>1?this.g255=a:this.gNorm=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"b",{get:function(){return this._b},set:function(a){a>1?this.b255=a:this.bNorm=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"a",{get:function(){return this._a},set:function(a){a>1?this.a255=a:this.aNorm=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"r255",{get:function(){return Math.round(255*this._r)},set:function(a){isNaN(a)||(this._r=a/255)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"g255",{get:function(){return Math.round(255*this._g)},set:function(a){isNaN(a)||(this._g=a/255)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"b255",{get:function(){return Math.round(255*this._b)},set:function(a){isNaN(a)||(this._b=a/255)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"a255",{get:function(){return Math.round(255*this._a)},set:function(a){isNaN(a)||(this._a=a/255)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"red",{get:function(){return this.r},set:function(a){this.r=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"green",{get:function(){return this.g},set:function(a){this.g=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"blue",{get:function(){return this.b},set:function(a){this.b=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"alpha",{get:function(){return this.a},set:function(a){this.a=a},enumerable:!0,configurable:!0}),a.prototype.parseString=function(a){var b;return a=a.toLowerCase(),"rgba"===a.slice(0,4)?(a=a.replace("rgba",""),a=a.replace("(",""),a=a.replace(")",""),b=a.split(","),this.r=+b[0],this.g=+b[1],this.b=+b[2],this.a=+b[3]):"rgb"===a.slice(0,3)?(a=a.replace("rgb",""),a=a.replace("(",""),a=a.replace(")",""),b=a.split(","),this.r=+b[0],this.g=+b[1],this.b=+b[2]):"hsla"===a.slice(0,4)?(a=a.replace("hsla",""),a=a.replace("(",""),a=a.replace(")",""),b=a.split(","),this.parseHsl(+b[0],+b[1],+b[2],+b[3])):"hsl"===a.slice(0,3)?(a=a.replace("hsl",""),a=a.replace("(",""),a=a.replace(")",""),b=a.split(","),this.parseHsl(+b[0],+b[1],+b[2])):this.parseHex(a),this},a.prototype.parseHex=function(a){var b,c=this.r255,d=this.g255,e=this.b255,f=this.a255;return"#"===a.charAt(0)&&(a=a.slice(1)),"0x"===a.slice(0,2)&&(a=a.slice(2)),b=parseInt(a,16),3===a.length?(c=17*(b>>8&15),d=17*(b>>4&15),e=17*(15&b)):4===a.length?(c=17*(b>>12&15),d=17*(b>>8&15),e=17*(b>>4&15),f=17*(15&b)):6===a.length?(c=b>>16&255,d=b>>8&255,e=255&b,f=255):8===a.length&&(c=b>>24&255,d=b>>16&255,e=b>>8&255,f=255&b),this.r255=c,this.g255=d,this.b255=e,this.a255=f,this},a.prototype.getHex=function(a){void 0===a&&(a=!0);var b,c="";for(b=this.r255.toString(16);b.length<2;)b="0"+b;for(c+=b,b=this.g255.toString(16);b.length<2;)b="0"+b;for(c+=b,b=this.b255.toString(16);b.length<2;)b="0"+b;if(c+=b,a){for(b=this.a255.toString(16);b.length<2;)b="0"+b;c+=b}return c},a.prototype.parseHsv=function(a,b,c,d){void 0===d&&(d=1);var e,f,g,h,i,j,k,l;if(isNaN(a)||isNaN(b)||isNaN(c)||isNaN(d))return this;switch(a>1&&(a/=360),b>1&&(b/=100),c>1&&(c/=100),d>1&&(d/=255),h=Math.floor(6*a),i=6*a-h,j=c*(1-b),k=c*(1-i*b),l=c*(1-(1-i)*b),h%6){case 0:e=c,f=l,g=j;break;case 1:e=k,f=c,g=j;break;case 2:e=j,f=c,g=l;break;case 3:e=j,f=k,g=c;break;case 4:e=l,f=j,g=c;break;case 5:e=c,f=j,g=k}return this._r=e,this._g=f,this._b=g,this._a=d,this},a.prototype.getHsva=function(){var a,b,c,d,e=this._r,f=this._g,g=this._b,h=Math.max(e,f,g),i=Math.min(e,f,g);if(a=h,b=h,c=h,d=h-i,b=0===h?0:d/h,h===i)a=0;else{switch(h){case e:a=(f-g)/d+(g>f?6:0);break;case f:a=(g-e)/d+2;break;case g:a=(e-f)/d+4}a/=6}return{h:a,s:b,v:c,a:this._a}},a.prototype.parseHsl=function(a,b,c,d){void 0===d&&(d=1);var e,f,g=this._r,h=this._g,i=this._b;return isNaN(a)||isNaN(b)||isNaN(c)||isNaN(d)?this:(a>1&&(a/=360),b>1&&(b/=100),c>1&&(c/=100),d>1&&(d/=255),0===b?(g=c,h=c,i=c):(e=.5>c?c*(1+b):c+b-c*b,f=2*c-e,g=this._hue2rgb(f,e,a+1/3),h=this._hue2rgb(f,e,a),i=this._hue2rgb(f,e,a-1/3)),this._r=g,this._g=h,this._b=i,this._a=d,this)},a.prototype.getHsla=function(){var a,b=this._r,c=this._g,d=this._b,e=Math.max(b,c,d),f=Math.min(b,c,d),g=(e+f)/2,h=(e+f)/2,i=(e+f)/2;if(e==f)g=0,h=0;else{switch(a=e-f,h=i>.5?a/(2-e-f):a/(e+f),e){case b:g=(c-d)/a+(d>c?6:0);break;case c:g=(d-b)/a+2;break;case d:g=(b-c)/a+4}g/=6}return{h:g,s:h,l:i,a:this._a}},a.prototype._hue2rgb=function(a,b,c){return 0>c&&(c+=1),c>1&&(c-=1),1/6>c?a+6*(b-a)*c:.5>c?b:2/3>c?a+(b-a)*(2/3-c)*6:a},a}();a.Color=b}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(){}return b.defaultCompare=function(a,b){return b>a?-1:a===b?0:1},b.prototype.objType=function(){return"Common"},b.defaultEquals=function(a,b){return a===b},b.defaultToString=function(b){return null===b?"KIWI_NULL":a.Utils.Common.isUndefined(b)?"KIWI_UNDEFINED":a.Utils.Common.isString(b)?b:b.toString()},b.isBetween=function(a,b,c){return a>b&&c>a},b.isFunction=function(a){return"function"==typeof a},b.isNumeric=function(a){return!isNaN(a)},b.isUndefined=function(a){return"undefined"==typeof a},b.isString=function(a){return"[object String]"===Object.prototype.toString.call(a)},b.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)},b.isObject=function(a){return"[object Object]"===Object.prototype.toString.call(a)},b.reverseCompareFunction=function(b){return a.Utils.Common.isFunction(b)?function(a,c){return-1*b(a,c)}:function(a,b){return b>a?1:a===b?0:-1}},b.compareToEquals=function(a){return function(b,c){return 0===a(b,c)}},b.shuffleArray=function(a){for(var b=a.length-1;b>0;b--){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c],a[c]=d}return a},b.convertToBase2=function(a){var b=a.width,c=a.height;if(-1==this.base2Sizes.indexOf(b)){for(var d=0;b>this.base2Sizes[d];)d++;b=this.base2Sizes[d]}if(-1==this.base2Sizes.indexOf(c)){for(var d=0;c>this.base2Sizes[d];)d++;c=this.base2Sizes[d]}if(a.width!==b||a.height!==c){var e=document.createElement("canvas");return e.width=b,e.height=c,e.getContext("2d").drawImage(a,0,0),e}return a},b.base2Sizes=[2,4,16,32,64,128,256,512,1024,2048,4096],b}();b.Common=c}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(){}return b.prototype.objType=function(){return"GameMath"},b.computeMachineEpsilon=function(){var a=4/3,b=a-1,c=b+b+b;return Math.abs(1-c)},b.fuzzyEqual=function(a,b,c){return void 0===c&&(c=1e-4),Math.abs(a-b)<c},b.fuzzyLessThan=function(a,b,c){return void 0===c&&(c=1e-4),b+c>a},b.fuzzyGreaterThan=function(a,b,c){return void 0===c&&(c=1e-4),a>b-c},b.fuzzyCeil=function(a,b){return void 0===b&&(b=1e-4),Math.ceil(a-b)},b.fuzzyFloor=function(a,b){return void 0===b&&(b=1e-4),Math.floor(a+b)},b.average=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];for(var c=0,d=0;d<a.length;d++)c+=a[d];return c/a.length},b.slam=function(a,b,c){return void 0===c&&(c=1e-4),Math.abs(a-b)<c?b:a},b.percentageMinMax=function(a,b,c){return void 0===c&&(c=0),a-=c,b-=c,b?a/b:0},b.sign=function(a){return a?a/Math.abs(a):0},b.truncate=function(a){return a>0?Math.floor(a):Math.ceil(a)},b.shear=function(a){return a%1},b.wrap=function(a,b,c){if(void 0===c&&(c=0),a-=c,b-=c,0==b)return c;for(a%=b,a+=c;c>a;)a+=b;return a},b.arithWrap=function(a,b,c){return void 0===c&&(c=0),b-=c,0==b?c:a-b*Math.floor((a-c)/b)},b.clamp=function(a,b,c){return void 0===c&&(c=0),Math.max(c,Math.min(b,a))},b.snapTo=function(a,b,c){return void 0===c&&(c=0),0==b?a:(a-=c,a=b*Math.round(a/b),c+a)},b.snapToFloor=function(a,b,c){return void 0===c&&(c=0),0==b?a:(a-=c,a=b*Math.floor(a/b),c+a)},b.snapToCeil=function(a,b,c){return void 0===c&&(c=0),0==b?a:(a-=c,a=b*Math.ceil(a/b),c+a)},b.snapToInArray=function(a,b,c){if(void 0===c&&(c=!0),c&&b.sort(),a<b[0])return b[0];for(var d=1;b[d]<a;)d++;var e=b[d-1],f=d<b.length?b[d]:Number.POSITIVE_INFINITY;return a-e>=f-a?f:e},b.roundTo=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=10);var d=Math.pow(c,-b);return Math.round(a*d)/d},b.floorTo=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=10);var d=Math.pow(c,-b);return Math.floor(a*d)/d},b.ceilTo=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=10);var d=Math.pow(c,-b);return Math.ceil(a*d)/d},b.interpolateFloat=function(a,b,c){return(b-a)*c+a},b.radiansToDegrees=function(a){return a*b.RAD_TO_DEG},b.degreesToRadians=function(a){return a*b.DEG_TO_RAD},b.angleBetween=function(a,b,c,d){return Math.atan2(d-b,c-a)},b.normalizeAngle=function(a,c){void 0===c&&(c=!0);var d=c?b.PI:180;return b.wrap(a,d,-d)},b.nearestAngleBetween=function(a,c,d){void 0===d&&(d=!0);var e=d?b.PI:180;return a=b.normalizeAngle(a,d),c=b.normalizeAngle(c,d),-e/2>a&&c>e/2&&(a+=2*e),-e/2>c&&a>e/2&&(c+=2*e),b.normalizeAngle(c-a,d)},b.normalizeAngleToAnother=function(b,c,d){return void 0===d&&(d=!0),c+a.Utils.GameMath.nearestAngleBetween(c,b,d)},b.normalizeAngleAfterAnother=function(b,c,d){return void 0===d&&(d=!0),b=a.Utils.GameMath.normalizeAngle(b-c,d),c+b},b.normalizeAngleBeforeAnother=function(b,c,d){return void 0===d&&(d=!0),b=a.Utils.GameMath.normalizeAngle(c-b,d),c-b},b.interpolateAngles=function(b,c,d,e,f){return void 0===e&&(e=!0),void 0===f&&(f=null),b=a.Utils.GameMath.normalizeAngle(b,e),c=a.Utils.GameMath.normalizeAngleToAnother(c,b,e),"function"==typeof f?f(d,b,c-b,1):a.Utils.GameMath.interpolateFloat(b,c,d)},b.logBaseOf=function(a,b){return Math.log(a)/Math.log(b)},b.GCD=function(a,b){var c;for(a=Math.abs(a),b=Math.abs(b),b>a&&(c=a,a=b,b=c);;){if(c=a%b,!c)return b;a=b,b=c}return 1},b.LCM=function(b,c){return b*c/a.Utils.GameMath.GCD(b,c)},b.factorial=function(a){if(0==a)return 1;for(var b=a;--a;)b*=a;return b},b.gammaFunction=function(b){return a.Utils.GameMath.factorial(b-1)},b.fallingFactorial=function(b,c){return a.Utils.GameMath.factorial(b)/a.Utils.GameMath.factorial(b-c)},b.risingFactorial=function(b,c){return a.Utils.GameMath.factorial(b+c-1)/a.Utils.GameMath.factorial(b-1)},b.binCoef=function(b,c){return a.Utils.GameMath.fallingFactorial(b,c)/a.Utils.GameMath.factorial(c)},b.risingBinCoef=function(b,c){return a.Utils.GameMath.risingFactorial(b,c)/a.Utils.GameMath.factorial(c)},b.chanceRoll=function(a){return void 0===a&&(a=50),0>=a?!1:a>=100?!0:100*Math.random()>=a?!1:!0},b.maxAdd=function(a,b,c){return a+=b,a>c&&(a=c),a},b.minSub=function(a,b,c){return a-=b,c>a&&(a=c),a},b.wrapValue=function(a,b,c){var d;return a=Math.abs(a),b=Math.abs(b),c=Math.abs(c),d=(a+b)%c},b.randomSign=function(){return Math.random()>.5?1:-1},b.isOdd=function(a){return 1&a?!0:!1},b.isEven=function(a){return 1&a?!1:!0},b.wrapAngle=function(a){var b=a;return a>=-180&&180>=a?a:(b=(a+180)%360,0>b&&(b+=360),b-180)},b.angleLimit=function(a,b,c){var d=a;return a>c?d=c:b>a&&(d=b),d},b.linearInterpolation=function(b,c){var d=b.length-1,e=d*c,f=Math.floor(e);return 0>c?a.Utils.GameMath.linear(b[0],b[1],e):c>1?a.Utils.GameMath.linear(b[d],b[d-1],d-e):a.Utils.GameMath.linear(b[f],b[f+1>d?d:f+1],e-f)},b.bezierInterpolation=function(b,c){for(var d=0,e=b.length-1,f=0;e>=f;f++)d+=Math.pow(1-c,e-f)*Math.pow(c,f)*b[f]*a.Utils.GameMath.bernstein(e,f);return d},b.catmullRomInterpolation=function(b,c){var d=b.length-1,e=d*c,f=Math.floor(e);return b[0]===b[d]?(0>c&&(f=Math.floor(e=d*(1+c))),a.Utils.GameMath.catmullRom(b[(f-1+d)%d],b[f],b[(f+1)%d],b[(f+2)%d],e-f)):0>c?b[0]-(a.Utils.GameMath.catmullRom(b[0],b[0],b[1],b[1],-e)-b[0]):c>1?b[d]-(a.Utils.GameMath.catmullRom(b[d],b[d],b[d-1],b[d-1],e-d)-b[d]):a.Utils.GameMath.catmullRom(b[f?f-1:0],b[f],b[f+1>d?d:f+1],b[f+2>d?d:f+2],e-f)},b.linear=function(a,b,c){return(b-a)*c+a},b.bernstein=function(b,c){return a.Utils.GameMath.factorial(b)/a.Utils.GameMath.factorial(c)/a.Utils.GameMath.factorial(b-c)},b.catmullRom=function(a,b,c,d,e){var f=.5*(c-a),g=.5*(d-b),h=e*e,i=e*h;return(2*b-2*c+f+g)*i+(-3*b+3*c-2*f-g)*h+f*e+b},b.difference=function(a,b){return Math.abs(a-b)},b.PI=3.141592653589793,b.PI_2=1.5707963267948966,b.PI_4=.7853981633974483,b.PI_8=.39269908169872414,b.PI_16=.19634954084936207,b.TWO_PI=6.283185307179586,b.THREE_PI_2=4.71238898038469,b.E=2.71828182845905,b.LN10=2.302585092994046,b.LN2=.6931471805599453,b.LOG10E=.4342944819032518,b.LOG2E=1.4426950408889634,b.SQRT1_2=.7071067811865476,b.SQRT2=1.4142135623730951,b.DEG_TO_RAD=.017453292519943295,b.RAD_TO_DEG=57.29577951308232,b.B_16=65536,b.B_31=2147483648,b.B_32=4294967296,b.B_48=281474976710656,b.B_53=9007199254740992,b.B_64=0x10000000000000000,b.ONE_THIRD=.3333333333333333,b.TWO_THIRDS=.6666666666666666,b.ONE_SIXTH=.16666666666666666,b.COS_PI_3=.8660254037844386,b.SIN_2PI_3=.03654595,b.CIRCLE_ALPHA=.5522847498307935,b.ON=!0,b.OFF=!1,b.SHORT_EPSILON=.1,b.PERC_EPSILON=.001,b.EPSILON=1e-4,b.LONG_EPSILON=1e-8,b}();b.GameMath=c}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a){void 0===a&&(a=[]),this.c=1,this._data={lipsum:["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","nunc","sagittis","tortor","ac","mi","pretium","sed","convallis","massa","pulvinar","curabitur","non","turpis","velit","vitae","rutrum","odio","aliquam","sapien","orci","tempor","sed","elementum","sit","amet","tincidunt","sed","risus","etiam","nec","lacus","id","ante","hendrerit","malesuada","donec","porttitor","magna","eget","libero","pharetra","sollicitudin","aliquam","mattis","mattis","massa","et","porta","morbi","vitae","magna","augue","vestibulum","at","lectus","sed","tellus","facilisis","tincidunt","suspendisse","eros","magna","consequat","at","sollicitudin","ac","vestibulum","vel","dolor","in","egestas","lacus","quis","lacus","placerat","et","molestie","ipsum","scelerisque","nullam","sit","amet","tortor","dui","aenean","pulvinar","odio","nec","placerat","fringilla","neque","dolor"]},this.sow(a)}return a.prototype.objType=function(){return"RandomDataGenerator"},a.prototype.uint32=function(){return 4294967296*this.rnd.apply(this)},a.prototype.fract32=function(){return this.rnd.apply(this)+1.1102230246251565e-16*(2097152*this.rnd.apply(this)|0)},a.prototype.rnd=function(){var a=2091639*this.s0+2.3283064365386963e-10*this.c;return this.c=0|a,this.s0=this.s1,this.s1=this.s2,this.s2=a-this.c,this.s2},a.prototype.hash=function(a){var b,c,d;for(d=4022871197,a=a.toString(),c=0;c<a.length;c++)d+=a.charCodeAt(c),b=.02519603282416938*d,d=b>>>0,b-=d,b*=d,d=b>>>0,b-=d,d+=4294967296*b;return 2.3283064365386963e-10*(d>>>0)},a.prototype.sow=function(a){void 0===a&&(a=[]),this.s0=this.hash(" "),this.s1=this.hash(this.s0),this.s2=this.hash(this.s1);for(var b,c=0;b=a[c++];)this.s0-=this.hash(b),this.s0+=~~(this.s0<0),this.s1-=this.hash(b),this.s1+=~~(this.s1<0),this.s2-=this.hash(b),this.s2+=~~(this.s2<0)},a.prototype.integer=function(){return this.uint32()},a.prototype.frac=function(){return this.fract32()},a.prototype.real=function(){return this.uint32()+this.fract32()},a.prototype.integerInRange=function(a,b){return Math.floor(this.realInRange(a,b))},a.prototype.realInRange=function(a,b){return a=a||0,b=b||0,this.frac()*(b-a)+a},a.prototype.normal=function(){return 1-2*this.frac()},a.prototype.uuid=function(){var a,b;for(b=a="";a++<36;b+=~a%5|3*a&4?(15^a?8^this.frac()*(20^a?16:4):4).toString(16):"-");return b},a.prototype.pick=function(a){return a[this.integerInRange(0,a.length)]},a.prototype.weightedPick=function(a){return a[~~(Math.pow(this.frac(),2)*a.length)]},a.prototype.word=function(){return this.pick(this._data.lipsum)},a.prototype.words=function(a){void 0===a&&(a=3);for(var b=[],c=0;a>c;c++)b.push(this.pick(this._data.lipsum));return b.join(" ")},a.prototype.sentence=function(){var a;return a=this.words(this.integerInRange(2,16)).replace(/[a-z]/,function(a){return a.toUpperCase()}),a+"."},a.prototype.sentences=function(a){void 0===a&&(a=3);for(var b=[],c=0;a>c;c++)b.push(this.sentence());return b.join(" ")},a.prototype.timestamp=function(a,b){return void 0===a&&(a=9466848e5),void 0===b&&(b=1577862e6),this.realInRange(a,b)},a.prototype.angle=function(){return this.integerInRange(-180,180)},a}();a.RandomDataGenerator=b}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a){this._isSetTimeOut=!1,this.lastTime=0,this.currentTime=0,this.isRunning=!1,this._rafId=null,this._callback=a;for(var b=["ms","moz","webkit","o"],c=0;c<b.length&&!window.requestAnimationFrame;c++)window.requestAnimationFrame=window[b[c]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[b[c]+"CancelAnimationFrame"]}return a.prototype.objType=function(){return"RequestAnimationFrame"},a.prototype.setCallback=function(a){this._callback=a},a.prototype.isUsingSetTimeOut=function(){return this._isSetTimeOut},a.prototype.isUsingRAF=function(){return this._isSetTimeOut===!0?!1:!0},a.prototype.start=function(a){var b=this;void 0===a&&(a=null),a&&(this._callback=a),window.requestAnimationFrame?(this._isSetTimeOut=!1,this._rafId=window.requestAnimationFrame(function(){return b.RAFUpdate()})):(this._isSetTimeOut=!0,this._timeOutID=window.setTimeout(function(){return b.SetTimeoutUpdate()},0)),this.isRunning=!0},a.prototype.stop=function(){this._isSetTimeOut?clearTimeout(this._timeOutID):window.cancelAnimationFrame(this._rafId),this.isRunning=!1},a.prototype.RAFUpdate=function(){var a=this;this.currentTime=Date.now(),this._callback&&this._callback();var b=Math.max(0,16-(this.currentTime-this.lastTime));this._rafId=window.requestAnimationFrame(function(){return a.RAFUpdate()}),this.lastTime=this.currentTime+b},a.prototype.SetTimeoutUpdate=function(){var a=this;this.currentTime=Date.now(),this._callback&&this._callback();var b=Math.max(0,16-(this.currentTime-this.lastTime));this._timeOutID=window.setTimeout(function(){return a.SetTimeoutUpdate()},b),this.lastTime=this.currentTime+b},a}();a.RequestAnimationFrame=b}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){void 0===a&&(a={}),this.enabled=!0,this.recording=!0,this.display=!0,this.tagFilters=[],this.maxRecordings=1/0,this.recordings=[],this.setDefaultsFromParams(a)}return b.prototype.setDefaultsFromParams=function(b){void 0===b&&(b={}),a.Utils.Common.isUndefined(b.enabled)||(this.enabled=b.enabled),a.Utils.Common.isUndefined(b.recording)||(this.recording=b.recording),a.Utils.Common.isUndefined(b.display)||(this.display=b.display),a.Utils.Common.isUndefined(b.maxRecordings)||(this.maxRecordings=b.maxRecordings),a.Utils.Common.isArray(b.tagFilters)&&(this.tagFilters=b.tagFilters)},Object.defineProperty(b.prototype,"lastMessageTime",{get:function(){return this.recordings.length>0?this.recordings[this.recordings.length-1].time:0},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"numRecordings",{get:function(){return this.recordings.length},enumerable:!0,configurable:!0}),b.prototype.record=function(a,b,c){if(void 0===b&&(b=[]),void 0===c&&(c=console.log),this.recording){var d={messages:a,time:Date.now(),tags:b,logMethod:c};this.recordings.push(d)>this.maxRecordings&&this.recordings.shift()}},b.prototype.clearRecordings=function(a,b){void 0===a&&(a=0),void 0===b&&(b=this.recordings.length),this.recordings.splice(a,b)},b.prototype._execute=function(a,b,c,d){void 0===d&&(d=!1),(this.display||d)&&a.apply(b,c)},b.prototype.getTagsFromArray=function(a){for(var b=0,c=[];b<a.length;)"string"==typeof a[b]&&"#"===a[b].charAt(0)&&c.push(a[b]),b++;return c},b.prototype._filterTags=function(a,b){if(void 0===b&&(b=this.tagFilters),0===b.length)return!0;if(0==a.length)return!1;for(var c=0;c<a.length;){if(-1===b.indexOf(a[c]))return!1;c++}return!0},b.prototype.log=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];if(this.enabled){var c=this.getTagsFromArray(a);this.record(a,c,console.log),this._filterTags(c)&&this._execute(console.log,console,a)}},b.prototype.warn=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];if(this.enabled){var c=this.getTagsFromArray(a);this.record(a,c,console.warn),this._filterTags(c)&&this._execute(console.warn,console,a)}},b.prototype.error=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];if(this.enabled){var c=this.getTagsFromArray(a);this.record(a,c,console.error),this._filterTags(c)&&this._execute(console.error,console,a)}},b.prototype._show=function(a,b){if(!a.logMethod)return!1;for(var c=b.length;c--;)if(-1==a.tags.indexOf(b[c]))return!1;
|
|
return this._execute(a.logMethod,console,a.messages,!0),!0},b.prototype.showLast=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];for(var c=this.recordings.length;c--;)if(this._show(this.recordings[c],a))return},b.prototype.showAll=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];for(var c=0;c<this.recordings.length;c++)this._show(this.recordings[c],a)},b.prototype.showLogs=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];for(var c=0;c<this.recordings.length;c++)this.recordings[c].logMethod===console.log&&this._show(this.recordings[c],a)},b.prototype.showErrors=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];for(var c=0;c<this.recordings.length;c++)this.recordings[c].logMethod===console.error&&this._show(this.recordings[c],a)},b.prototype.showWarnings=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];for(var c=0;c<this.recordings.length;c++)this.recordings[c].logMethod===console.warn&&this._show(this.recordings[c],a)},b.prototype.showTimePeriod=function(a,b,c){void 0===a&&(a=0),void 0===b&&(b=1/0),void 0===c&&(c=[]);for(var d,e=0;e<this.recordings.length;e++)d=this.recordings[e],a<d.time&&b>d.time&&this._show(d,c)},b.prototype.addFilter=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];this.tagFilters=this.tagFilters.concat(a)},b.prototype.removeFilter=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];for(var c,d=0;d<a.length;)c=this.tagFilters.indexOf(a[d]),-1!==c&&this.tagFilters.splice(c,1),d++},b}();b.Log=c}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){}return a.parseVersion=function(a){var b=a.split(".");return{majorVersion:parseInt(b[0]),minorVersion:parseInt(b[1]),patchVersion:parseInt(b[2])}},a.compareVersions=function(b,c){var d=a.parseVersion(b),e=a.parseVersion(c);return d.majorVersion>e.majorVersion?"greater":d.majorVersion<e.majorVersion?"less":d.minorVersion>e.minorVersion?"greater":d.minorVersion<e.minorVersion?"less":d.patchVersion>e.patchVersion?"greater":d.patchVersion<e.patchVersion?"less":"equal"},a.greaterOrEqual=function(b,c){var d=a.compareVersions(b,c);return"greater"==d||"equal"==d},a}();a.Version=b}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){a.Log=new a.Utils.Log,a.VERSION="1.4.0",a.RENDERER_CANVAS=0,a.RENDERER_WEBGL=1,a.RENDERER_AUTO=2,a.TARGET_BROWSER=0,a.TARGET_COCOON=1,a.DEBUG_ON=0,a.DEBUG_OFF=1,a.DEVICE=null,a.STATE=0,a.GROUP=2,a.ENTITY=3,a.CAMERA=4,a.HUD_WIDGET=5,a.TILE_LAYER=6;var b=function(){function b(){}return b.prototype.objType=function(){return"GameManager"},b.register=function(b){return a.GameManager._games.push(b)},b.total=function(){return a.GameManager._games.length},b._games=[],b}();a.GameManager=b;var c;!function(){}(c=a.Plugins||(a.Plugins={})),a.extend=function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c}}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(c,d){void 0===d&&(d={}),b.call(this,c,d),this.crossOrigin="",this.game.audio.usingAudioTag?(this.useTagLoader=!0,this._loadInParallel=!0):this.useTagLoader=!1,a.Utils.Common.isUndefined(d.crossOrigin)||(this.crossOrigin=d.crossOrigin)}return __extends(c,b),c.prototype.objType=function(){return"AudioFile"},c.prototype._load=function(){this.attemptCounter++,this.useTagLoader?this.tagLoader():this.xhrLoader("GET","arraybuffer")},c.prototype.tagLoader=function(){if(this.data=document.createElement("audio"),this.data.src=this.URL,this.data.preload="auto",this.crossOrigin&&(this.data.crossOrigin=this.crossOrigin),this.game.audio.locked)this.loadSuccess();else{var b=this,c=function(){b.data.removeEventListener("canplaythrough",c,!1),b.data.pause(),b.data.currentTime=0,b.data.volume=1,b.loadSuccess()};this.data.addEventListener("canplaythrough",c,!1),this.game.deviceTargetOption==a.TARGET_COCOON?this.data.load():(this.data.volume=0,this.data.play())}},c.prototype.processXhr=function(a){this.data={raw:a,decoded:!1,buffer:null},this._decodeAudio()},c.prototype._decodeAudio=function(){var b=this;this.game.audio.context.decodeAudioData(this.data.raw,function(a){a&&(b.data.buffer=a,b.data.decoded=!0,b.loadSuccess())},function(c){a.Log.error("Kiwi.Files.AudioFile: Error decoding audio data.","#loading","#decoding"),b.loadError(c)})},c}(a.Files.File);b.AudioFile=c}(b=a.Files||(a.Files={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(a,c){void 0===c&&(c={}),b.call(this,a,c),this.useTagLoader=!1,this._loadInParallel=!1}return __extends(c,b),c.prototype.parseParams=function(c){b.prototype.parseParams.call(this,c),this.parse=a.Utils.Common.isUndefined(c.parse)?!1:c.parse},c.prototype.objType=function(){return"DataFile"},c.prototype._load=function(){this.attemptCounter++,this.dataType===a.Files.File.BINARY_DATA?this.xhrLoader("GET","arraybuffer"):this.xhrLoader("GET","text")},c.prototype.processXhr=function(b){if(!this.parse)return this.data=b,void this.loadSuccess();switch(this.dataType){case a.Files.File.JSON:this.processJSON(b);break;case a.Files.File.XML:this.parseXML(b);break;case a.Files.File.TEXT_DATA:case a.Files.File.BINARY_DATA:default:this.data=b}},c.prototype.parseXML=function(b){if(a.Log.log("Kiwi.Files.DataFile: Data loaded is being parsed as XML.","#loading","#parsing"),window.DOMParser){var c=new DOMParser;this.data=c.parseFromString(b,"text/xml")}else this.data=new ActiveXObject("Microsoft.XMLDOM"),this.data.async="false",this.data.loadXML(b);this.data&&this.data.documentElement&&!this.data.getElementsByTagName("parsererror").length?this.loadSuccess():this.loadError("XML parse error.")},c.prototype.processJSON=function(b){a.Log.log("Kiwi.Files.DataFile: Data loaded is being parsed as JSON.","#loading","#parsing");try{this.data=JSON.parse(b)}catch(c){return void this.loadError(c)}this.loadSuccess()},c}(a.Files.File);b.DataFile=c}(b=a.Files||(a.Files={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(c,d){void 0===d&&(d={}),b.call(this,c,d),this.crossOrigin="",d.xhrLoading?(this.useTagLoader=!1,this._loadInParallel=!1):(this.useTagLoader=!0,this._loadInParallel=!0),a.Utils.Common.isUndefined(d.crossOrigin)||(this.crossOrigin=d.crossOrigin)}return __extends(c,b),c.prototype.objType=function(){return"TextureFile"},c.prototype._load=function(){this.attemptCounter++,this.useTagLoader?this.tagLoader():this.xhrLoader("GET","arraybuffer")},c.prototype.tagLoader=function(){var a=this;this.data=new Image,this.data.src=this.URL,this.crossOrigin&&(this.data.crossOrigin=this.crossOrigin),this.data.onload=function(){return a.loadSuccess()},this.data.onerror=function(b){return a.loadError(b)}},c.prototype.processXhr=function(a){this.data=document.createElement("img");var b=new Blob([a],{type:this.type}),c=this;this.data.addEventListener("load",function(){c.loadSuccess()}),window.URL?this.data.src=window.URL.createObjectURL(b):window.webkitURL&&(this.data.src=window.webkitURL.createObjectURL(b))},c.prototype.revoke=function(){window.URL?window.URL.revokeObjectURL(this.data.src):window.webkitURL&&window.webkitURL.revokeObjectURL(this.data.src)},c.prototype.destroy=function(){this.useTagLoader||this.revoke(),b.prototype.destroy.call(this)},c}(a.Files.File);b.TextureFile=c}(b=a.Files||(a.Files={}))}(Kiwi||(Kiwi={})); |