initial commit

This commit is contained in:
Juraj Michalek committed 2015-12-25 17:51:53 +01:00
commit f349981c4e
8 files changed
+35422

No files matched your search

File diff suppressed because it is too large. Load diff
+11
View File
@@ -0,0 +1,11 @@
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.Line truncated
},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._activeLine truncated
}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&&(thiLine truncated
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[Line truncated
},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[Line truncated
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._curreLine truncated
}();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._onMouseLine truncated
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.setLine truncated
},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,configLine truncated
},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._isRunLine truncated
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("GLine truncated