diff --git a/dist/phaser-plugin-isometric.js b/dist/phaser-plugin-isometric.js index c017cda..0822c42 100644 --- a/dist/phaser-plugin-isometric.js +++ b/dist/phaser-plugin-isometric.js @@ -845,8 +845,8 @@ Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoX", { set: function (value) { this._isoPosition.x = value; this._depthChanged = this._isoPositionChanged = this._isoBoundsChanged = true; - if (this.body.phase===1){ - this.body.preUpdate(); + if (this.body){ + this.body._reset = true; } } }); @@ -864,8 +864,8 @@ Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoY", { set: function (value) { this._isoPosition.y = value; this._depthChanged = this._isoPositionChanged = this._isoBoundsChanged = true; - if (this.body.phase===1){ - this.body.preUpdate(); + if (this.body){ + this.body._reset = true; } } }); @@ -883,8 +883,8 @@ Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoZ", { set: function (value) { this._isoPosition.z = value; this._depthChanged = this._isoPositionChanged = this._isoBoundsChanged = true; - if (this.body.phase===1){ - this.body.preUpdate(); + if (this.body){ + this.body._reset = true; } } }); @@ -2531,6 +2531,13 @@ Phaser.Plugin.Isometric.Body.prototype = { this.phase = 2; + // stops sprites flying off if isoPosition is changed during update + if (this._reset) { + this.prev.x = this.position.x; + this.prev.y = this.position.y; + this.prev.z = this.position.z; + } + if (this.deltaAbsX() >= this.deltaAbsY() && this.deltaAbsX() >= this.deltaAbsZ()){ if (this.deltaX() < 0) { this.facing = Phaser.Plugin.Isometric.BACKWARDX; @@ -2595,6 +2602,8 @@ Phaser.Plugin.Isometric.Body.prototype = { this.prev.y = this.position.y; this.prev.z = this.position.z; + this._reset = false; + }, /** @@ -4084,7 +4093,7 @@ Phaser.Plugin.Isometric.Arcade.prototype = { /** * Find the distance between two display objects (like Sprites). * - * @method Phaser.Plugin.Isometric.Arcade#distanceBetween + * @method Phaser.Plugin.Isometric.Isometric.Arcade#distanceBetween * @param {any} source - The Display Object to test from. * @param {any} target - The Display Object to test to. * @return {number} The distance between the source and target objects. @@ -4119,29 +4128,235 @@ Phaser.Plugin.Isometric.Arcade.prototype = { }, - /** * Find the distance between a display object (like a Sprite) and the given x/y/z coordinates. * The calculation is made from the display objects x/y/z coordinate. This may be the top-left if its anchor hasn't been changed. * If you need to calculate from the center of a display object instead use the method distanceBetweenCenters() * * @method Phaser.Plugin.Isometric.Arcade#distanceToXYZ - * @param {any} displayObject - The Display Object to test from. + * @param {any} displayObjectBody - The Display Object to test from. * @param {number} x - The x coordinate to test to. * @param {number} y - The y coordinate to test to. * @param {number} z - The y coordinate to test to * @return {number} The distance between the object and the x/y coordinates. */ - distanceToXYZ: function (displayObject, x, y, z) { + distanceToXYZ: function (displayObjectBody, x, y, z) { - this._dx = displayObject.x - x; - this._dy = displayObject.y - y; - this._dz = displayObject.z - z; + this._dx = displayObjectBody.x - x; + this._dy = displayObjectBody.y - y; + this._dz = displayObjectBody.z - z; return Math.sqrt(this._dx * this._dx + this._dy * this._dy + this._dz * this._dz); + }, + + /** + * Find the distance between a display object (like a Sprite) and a Pointer. If no Pointer is given the Input.activePointer is used. + * The calculation is made from the display objects x/y coordinate. This may be the top-left if its anchor hasn't been changed. + * If you need to calculate from the center of a display object instead use the method distanceBetweenCenters() + * The distance to the Pointer is returned in isometric distance. + * + * @method Phaser.Physics.Arcade#distanceToPointer + * @param {any} displayObjectBody - The Display Object to test from. + * @param {Phaser.Pointer} [pointer] - The Phaser.Pointer to test to. If none is given then Input.activePointer is used. + * @return {number} The distance between the object and the Pointer. + */ + distanceToPointer: function (displayObjectBody, pointer) { + + pointer = pointer || this.game.input.activePointer; + var isoPointer = this.game.iso.unproject(pointer.position,undefined,displayObjectBody.z); + isoPointer.z = displayObjectBody.z; + var a = this.anglesToXYZ(displayObjectBody, isoPointer.x, isoPointer.y, isoPointer.z); + + return a.r; + + }, + + /** + * Find the angles in radians between a display object (like a IsoSprite) and the given x/y/z coordinate. + * + * @method Phaser.Physics.Isometric.Isometric.Arcade#anglesToXYZ + * @param {any} displayObjectBody - The Display Object to test from. + * @param {number} x - The x coordinate to get the angle to. + * @param {number} y - The y coordinate to get the angle to. + * @param {number} z - The z coordinate to get the angle to. + * @return {number} The angle in radians between displayObjectBody.x/y to Pointer.x/y + */ + anglesToXYZ: function (displayObjectBody, x, y, z) { + + // Spherical polar coordinates + var r = this.distanceToXYZ(displayObjectBody, x, y, z); + var theta = Math.atan2(y - displayObjectBody.y, x - displayObjectBody.x); + var phi = Math.acos((z - displayObjectBody.z)/ r); + + return {r:r,theta:theta,phi:phi}; + + }, + + /** + * Find the angle in radians between a display object (like a Sprite) and a Pointer, taking their x/y and center into account. + * This is not the visual angle but the angle in the isometric co-ordinate system. + * + * @method Phaser.Physics.Isometric.Arcade#angleToPointer + * @param {any} displayObjectBody - The Display Object to test from. + * @param {Phaser.Pointer} [pointer] - The Phaser.Pointer to test to. If none is given then Input.activePointer is used. + * @return {number} The (isometric) angle in radians between displayObjectBody.x/y to Pointer.x/y. + */ + angleToPointer: function(displayObjectBody, pointer) { + + pointer = pointer || this.game.input.activePointer; + var isoPointer = this.game.iso.unproject(pointer.position,undefined,displayObjectBody.z); + isoPointer.z = displayObjectBody.z; + var a = this.anglesToXYZ(displayObjectBody, isoPointer.x, isoPointer.y, isoPointer.z); + + return a.theta; + + }, + + /** + * Given the angle (in degrees) and speed calculate the velocity and return it as a Point object, or set it to the given point object. + * One way to use this is: velocityFromAngle(angle, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object. + * + * @method Phaser.Physics.Arcade#velocityFromAngle + * @param {number} theta - The angle in radians for x,y in the isometric co-ordinate system + * @param {number} [phi=Math.PI/2] - The angle in radians for z in the isometric co-ordinate system + * @param {number} [speed=60] - The speed it will move, in pixels per second sq. + * @param {Phaser.Point|object} [point] - The Point object in which the x and y properties will be set to the calculated velocity. + * @return {Phaser.Plugin.Isometric.Point3} - A Point where point.x contains the velocity x value and so on for y and z. + */ + velocityFromAngles: function (theta, phi, speed, point) { + + if (phi === undefined) { phi = Math.sin(Math.PI/2); } + if (speed === undefined) { speed = 60; } + point = point || new Phaser.Point(); + + return new Phaser.Plugin.Isometric.Point3( + Math.cos(theta) * Math.sin(phi) * speed, + Math.sin(theta) * Math.sin(phi) * speed, + Math.cos(phi) * speed + ); + + }, + + /** + * Sets the acceleration.x/y property on the display object so it will move towards the x/y coordinates at the given speed (in pixels per second sq.) + * You must give a maximum speed value, beyond which the display object won't go any faster. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * + * @method Phaser.Physics.Isometric.Arcade#accelerateToXYZ + * @param {any} displayObject - The display object to move. + * @param {number} x - The x coordinate to accelerate towards. + * @param {number} y - The y coordinate to accelerate towards. + * @param {number} z - The z coordinate to accelerate towards. + * @param {number} [speed=60] - The speed it will accelerate in pixels per second. + * @param {number} [xSpeedMax=500] - The maximum x velocity the display object can reach. + * @param {number} [ySpeedMax=500] - The maximum y velocity the display object can reach. + * @param {number} [zSpeedMax=500] - The maximum z velocity the display object can reach. + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new trajectory. + */ + accelerateToXYZ: function(displayObject, x, y, z, speed, xSpeedMax, ySpeedMax, zSpeedMax) { + + if (speed === undefined) { speed = 60; } + if (xSpeedMax === undefined) { xSpeedMax = 500; } + if (ySpeedMax === undefined) { ySpeedMax = 500; } + if (zSpeedMax === undefined) { zSpeedMax = 500; } + + var a = this.anglesToXYZ(displayObject.body, x, y,z); + var v = this.velocityFromAngles(a.theta,a.phi,speed); + + displayObject.body.acceleration.setTo(v.x,v.y,v.z); + displayObject.body.maxVelocity.setTo(xSpeedMax, ySpeedMax, zSpeedMax); + + return a.theta; + + }, + + /** + * Move the given display object towards the x/y coordinates at a steady velocity. + * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. + * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) + * + * @method Phaser.Physics.Isometric.Arcade#moveToXYZ + * @param {any} displayObject - The display object to move, must have an isoArcade body. + * @param {number} x - The x coordinate to move towards. + * @param {number} y - The y coordinate to move towards. + * @param {number} z - The z coordinate to move towards. + * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) + * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. + */ + moveToXYZ: function(displayObject, x, y, z, speed, maxTime) { + + if (typeof speed === 'undefined') { + speed = 60; + } + if (typeof maxTime === 'undefined') { + maxTime = 0; + } + + if (maxTime > 0) { + // We know how many pixels we need to move, but how fast? + speed = this.distanceToXYZ(displayObject.body, x, y ,z) / (maxTime / 1000); + } + var a = this.anglesToXYZ(displayObject.body, x, y,z); + var v = this.velocityFromAngles(a.theta,a.phi,speed); + + console.log(displayObject.id,v); + displayObject.body.velocity.copyFrom(v); + console.log(displayObject.id,displayObject.body.velocity); + + return a.theta; + + }, + + /** + * Move the given display object towards the destination object at a steady velocity. + * If you specify a maxTime then it will adjust the speed (overwriting what you set) so it arrives at the destination in that number of seconds. + * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) + * + * @method Phaser.Physics.Isometric.Arcade#moveToObject + * @param {any} displayObject - The display object to move. + * @param {any} destination - The display object to move towards. Can be any object but must have visible x/y/z properties. + * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) + * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. + */ + moveToObject: function (displayObject, destination, speed, maxTime) { + + return this.moveToXYZ(displayObject, destination.x, destination.y, destination.z, speed, maxTime); + + }, + + /** + * For isoArcade move the given display object towards the pointer at a steady velocity. If no pointer is given it will use Phaser.Input.activePointer. + * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. + * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * + * @method Phaser.Physics.Isometric.Arcade#moveToPointer + * @param {any} displayObject - The display object to move. + * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) + * @param {Phaser.Pointer} [pointer] - The pointer to move towards. Defaults to Phaser.Input.activePointer. + * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. + */ + moveToPointer: function(displayObject, speed, pointer, maxTime) { + + pointer = pointer || this.game.input.activePointer; + var isoPointer = this.game.iso.unproject(pointer.position,undefined,displayObject.body.z); + isoPointer.z = displayObject.body.z; + return this.moveToXYZ(displayObject, isoPointer.x, isoPointer.y, isoPointer.z, speed, maxTime); } + }; Phaser.Physics.prototype.isoArcade = null; diff --git a/dist/phaser-plugin-isometric.min.js b/dist/phaser-plugin-isometric.min.js index b644b92..55cd873 100644 --- a/dist/phaser-plugin-isometric.min.js +++ b/dist/phaser-plugin-isometric.min.js @@ -1,3 +1,3 @@ /* Phaser Isometric 0.9.2 - 28-11-2015 by Lewis Lane */ -Phaser.Plugin.Isometric=function(a,b,c){c=c||Phaser.Plugin.Isometric.CLASSIC,Phaser.Plugin.call(this,a,b),this.projector=new Phaser.Plugin.Isometric.Projector(this.game,c),this.game.iso=this.game.iso||this.projector},Phaser.Plugin.Isometric.prototype=Object.create(Phaser.Plugin.prototype),Phaser.Plugin.Isometric.prototype.constructor=Phaser.Plugin.Isometric,Phaser.Plugin.Isometric.VERSION="0.9.2",Phaser.Plugin.Isometric.UP=0,Phaser.Plugin.Isometric.DOWN=1,Phaser.Plugin.Isometric.FORWARDX=2,Phaser.Plugin.Isometric.FORWARDY=3,Phaser.Plugin.Isometric.BACKWARDX=4,Phaser.Plugin.Isometric.BACKWARDY=5,Phaser.Plugin.Isometric.ISOSPRITE="isosprite",Phaser.Plugin.Isometric.ISOARCADE="isoarcade",Phaser.Plugin.Isometric.Cube=function(a,b,c,d,e,f){a=a||0,b=b||0,c=c||0,d=d||0,e=e||0,f=f||0,this.x=a,this.y=b,this.z=c,this.widthX=d,this.widthY=e,this.height=f,this._corners=[new Phaser.Plugin.Isometric.Point3(this.x,this.y,this.z),new Phaser.Plugin.Isometric.Point3(this.x,this.y,this.z+this.height),new Phaser.Plugin.Isometric.Point3(this.x,this.y+this.widthY,this.z),new Phaser.Plugin.Isometric.Point3(this.x,this.y+this.widthY,this.z+this.height),new Phaser.Plugin.Isometric.Point3(this.x+this.widthX,this.y,this.z),new Phaser.Plugin.Isometric.Point3(this.x+this.widthX,this.y,this.z+this.height),new Phaser.Plugin.Isometric.Point3(this.x+this.widthX,this.y+this.widthY,this.z),new Phaser.Plugin.Isometric.Point3(this.x+this.widthX,this.y+this.widthY,this.z+this.height)]},Phaser.Plugin.Isometric.Cube.prototype.constructor=Phaser.Plugin.Isometric.Cube,Phaser.Plugin.Isometric.Cube.prototype={setTo:function(a,b,c,d,e,f){return this.x=a,this.y=b,this.z=c,this.widthX=d,this.widthY=e,this.height=f,this},copyFrom:function(a){this.setTo(a.x,a.y,a.z,a.widthX,a.widthY,a.height)},copyTo:function(a){return a.x=this.x,a.y=this.y,a.z=this.z,a.widthX=this.widthX,a.widthY=this.widthY,a.height=this.height,a},size:function(a){return Phaser.Plugin.Isometric.Cube.size(this,a)},contains:function(a,b,c){return Phaser.Plugin.Isometric.Cube.contains(this,a,b,c)},containsXY:function(a,b){return Phaser.Plugin.Isometric.Cube.containsXY(this,a,b)},clone:function(a){return Phaser.Plugin.Isometric.Cube.clone(this,a)},intersects:function(a){return Phaser.Plugin.Isometric.Cube.intersects(this,a)},getCorners:function(){return this._corners[0].setTo(this.x,this.y,this.z),this._corners[1].setTo(this.x,this.y,this.z+this.height),this._corners[2].setTo(this.x,this.y+this.widthY,this.z),this._corners[3].setTo(this.x,this.y+this.widthY,this.z+this.height),this._corners[4].setTo(this.x+this.widthX,this.y,this.z),this._corners[5].setTo(this.x+this.widthX,this.y,this.z+this.height),this._corners[6].setTo(this.x+this.widthX,this.y+this.widthY,this.z),this._corners[7].setTo(this.x+this.widthX,this.y+this.widthY,this.z+this.height),this._corners},toString:function(){return"[{Cube (x="+this.x+" y="+this.y+" z="+this.z+" widthX="+this.widthX+" widthY="+this.widthY+" height="+this.height+" empty="+this.empty+")}]"}},Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"halfWidthX",{get:function(){return Math.round(.5*this.widthX)}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"halfWidthY",{get:function(){return Math.round(.5*this.widthY)}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"halfHeight",{get:function(){return Math.round(.5*this.height)}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"bottom",{get:function(){return this.z},set:function(a){a>=this.top?this.height=0:this.height=this.top-a,this.z=a}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"top",{get:function(){return this.z+this.height},set:function(a){a<=this.z?this.height=0:this.height=a-this.z}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"backX",{get:function(){return this.x},set:function(a){a>=this.frontX?this.widthX=0:this.widthX=this.frontX-a,this.x=a}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"backY",{get:function(){return this.y},set:function(a){a>=this.frontY?this.widthY=0:this.widthY=this.frontY-a,this.y=a}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"frontX",{get:function(){return this.x+this.widthX},set:function(a){a<=this.x?this.widthX=0:this.widthX=a-this.x}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"frontY",{get:function(){return this.y+this.widthY},set:function(a){a<=this.y?this.widthY=0:this.widthY=a-this.y}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"volume",{get:function(){return this.widthX*this.widthY*this.height}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"centerX",{get:function(){return this.x+this.halfWidthX},set:function(a){this.x=a-this.halfWidthX}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"centerY",{get:function(){return this.y+this.halfWidthY},set:function(a){this.y=a-this.halfWidthY}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"centerZ",{get:function(){return this.z+this.halfHeight},set:function(a){this.z=a-this.halfHeight}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"randomX",{get:function(){return this.x+Math.random()*this.widthX}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"randomY",{get:function(){return this.y+Math.random()*this.widthY}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"randomZ",{get:function(){return this.z+Math.random()*this.height}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"empty",{get:function(){return!this.widthX||!this.widthY||!this.height},set:function(a){a===!0&&this.setTo(0,0,0,0,0,0)}}),Phaser.Plugin.Isometric.Cube.size=function(a,b){return"undefined"==typeof b||null===b?b=new Phaser.Plugin.Isometric.Point3(a.widthX,a.widthY,a.height):b.setTo(a.widthX,a.widthY,a.height),b},Phaser.Plugin.Isometric.Cube.clone=function(a,b){return"undefined"==typeof b||null===b?b=new Phaser.Plugin.Isometric.Cube(a.x,a.y,a.z,a.widthX,a.widthY,a.height):b.setTo(a.x,a.y,a.z,a.widthX,a.widthY,a.height),b},Phaser.Plugin.Isometric.Cube.contains=function(a,b,c,d){return a.widthX<=0||a.widthY<=0||a.height<=0?!1:b>=a.x&&b<=a.frontX&&c>=a.y&&c<=a.frontY&&d>=a.z&&d<=a.top},Phaser.Plugin.Isometric.Cube.containsXY=function(a,b,c){return a.widthX<=0||a.widthY<=0?!1:b>=a.x&&b<=a.frontX&&c>=a.y&&c<=a.frontY},Phaser.Plugin.Isometric.Cube.containsPoint3=function(a,b){return Phaser.Plugin.Isometric.Cube.contains(a,b.x,b.y,b.z)},Phaser.Plugin.Isometric.Cube.containsCube=function(a,b){return a.volume>b.volume?!1:a.x>=b.x&&a.y>=b.y&&a.z>=b.z&&a.frontX<=b.frontX&&a.frontY<=b.frontY&&a.top<=b.top},Phaser.Plugin.Isometric.Cube.intersects=function(a,b){return a.widthX<=0||a.widthY<=0||a.height<=0||b.widthX<=0||b.widthY<=0||b.height<=0?!1:!(a.frontXb.frontX||a.y>b.frontY||a.z>b.top||a.top0&&(this.position.x=Phaser.Math.snapTo(this.position.x,this.snap),this.position.y=Phaser.Math.snapTo(this.position.y,this.snap)),this._depthChanged=this._isoPositionChanged=this._isoBoundsChanged=!0)},Phaser.Plugin.Isometric.IsoSprite.prototype.resetIsoBounds=function(){"undefined"==typeof this._isoBounds&&(this._isoBounds=new Phaser.Plugin.Isometric.Cube);var a=Math.abs(this.scale.x),b=Math.abs(this.scale.y);return this._isoBounds.widthX=Math.round(.5*Math.abs(this.width))*a,this._isoBounds.widthY=Math.round(.5*Math.abs(this.width))*a,this._isoBounds.height=Math.round(Math.abs(this.height)-.5*Math.abs(this.width))*b,this._isoBounds.x=this.isoX+this._isoBounds.widthX*-this.anchor.x+.5*this._isoBounds.widthX,this._isoBounds.y=this.isoY+this._isoBounds.widthY*this.anchor.x-.5*this._isoBounds.widthY,this._isoBounds.z=this.isoZ-Math.abs(this.height)*(1-this.anchor.y)+Math.abs(.5*this.width),this._isoBounds},Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype,"isoX",{get:function(){return this._isoPosition.x},set:function(a){this._isoPosition.x=a,this._depthChanged=this._isoPositionChanged=this._isoBoundsChanged=!0,1===this.body.phase&&this.body.preUpdate()}}),Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype,"isoY",{get:function(){return this._isoPosition.y},set:function(a){this._isoPosition.y=a,this._depthChanged=this._isoPositionChanged=this._isoBoundsChanged=!0,1===this.body.phase&&this.body.preUpdate()}}),Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype,"isoZ",{get:function(){return this._isoPosition.z},set:function(a){this._isoPosition.z=a,this._depthChanged=this._isoPositionChanged=this._isoBoundsChanged=!0,1===this.body.phase&&this.body.preUpdate()}}),Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype,"isoPosition",{get:function(){return this._isoPosition}}),Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype,"isoBounds",{get:function(){return(this._isoBoundsChanged||!this._isoBounds)&&(this.resetIsoBounds(),this._isoBoundsChanged=!1),this._isoBounds}}),Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype,"depth",{get:function(){return this._depthChanged===!0&&(this._depth=this._isoPosition.x+this._isoPosition.y+1.25*this._isoPosition.z,this._depthChanged=!1),this._depth}}),Phaser.GameObjectCreator.prototype.isoSprite=function(a,b,c,d,e){return new Phaser.Plugin.Isometric.IsoSprite(this.game,a,b,c,d,e)},Phaser.GameObjectFactory.prototype.isoSprite=function(a,b,c,d,e,f){return"undefined"==typeof f&&(f=this.world),f.add(new Phaser.Plugin.Isometric.IsoSprite(this.game,a,b,c,d,e))},Phaser.Plugin.Isometric.prototype.addIsoSprite=function(a,b,c,d,e,f){return Phaser.GameObjectFactory.prototype.isoSprite.call(this.game.add,a,b,c,d,e,f)},Phaser.Utils.Debug.prototype.isoSprite=function(a,b,c){if(a.isoBounds){"undefined"==typeof c&&(c=!0),b=b||"rgba(0,255,0,0.4)";var d=[],e=a.isoBounds.getCorners(),f=-a.game.camera.x,g=-a.game.camera.y;if(this.start(),c){d=[e[1],e[3],e[2],e[6],e[4],e[5],e[1]],d=d.map(function(b){var c=a.game.iso.project(b);return c.x+=f,c.y+=g,c}),this.context.beginPath(),this.context.fillStyle=b,this.context.moveTo(d[0].x,d[0].y);for(var h=1;hthis.maxObjects&&this.levelthis.bounds.top&&(b=4):a.y>this.bounds.frontY&&(a.zthis.bounds.top&&(b=6)):a.x>this.bounds.frontX&&(a.ythis.bounds.top&&(b=5):a.y>this.bounds.frontY&&(a.zthis.bounds.top&&(b=7))),b},retrieve:function(a){var b,c;if(a instanceof Phaser.Plugin.Isometric.Cube)b=this.objects,c=this.getIndex(a);else{if(!a.body)return this._empty;b=this.objects,c=this.getIndex(a.body)}return this.nodes[0]&&(-1!==c?b=b.concat(this.nodes[c].retrieve(a)):(b=b.concat(this.nodes[0].retrieve(a)),b=b.concat(this.nodes[1].retrieve(a)),b=b.concat(this.nodes[2].retrieve(a)),b=b.concat(this.nodes[3].retrieve(a)),b=b.concat(this.nodes[4].retrieve(a)),b=b.concat(this.nodes[5].retrieve(a)),b=b.concat(this.nodes[6].retrieve(a)),b=b.concat(this.nodes[7].retrieve(a)))),b},clear:function(){this.objects.length=0;for(var a=this.nodes.length;a--;)this.nodes[a].clear(),this.nodes.splice(a,1);this.nodes.length=0}},Phaser.Plugin.Isometric.Octree.prototype.constructor=Phaser.Plugin.Isometric.Octree,Phaser.Utils.Debug.prototype.octree=function(a,b){b=b||"rgba(255,0,0,0.3)",this.start();var c,d,e=a.bounds;if(0===a.nodes.length){this.context.strokeStyle=b;var f=new Phaser.Plugin.Isometric.Cube(e.x,e.y,e.z,e.widthX,e.widthY,e.height),g=f.getCorners(),h=-this.game.camera.x,i=-this.game.camera.y;for(d=g.slice(0,g.length),d=d.map(function(a){var b=this.game.iso.project(a);return b.x+=h,b.y+=i,b}),this.context.moveTo(d[0].x,d[0].y),this.context.beginPath(),this.context.strokeStyle=b,this.context.lineTo(d[1].x,d[1].y),this.context.lineTo(d[3].x,d[3].y),this.context.lineTo(d[2].x,d[2].y),this.context.lineTo(d[6].x,d[6].y),this.context.lineTo(d[4].x,d[4].y),this.context.lineTo(d[5].x,d[5].y),this.context.lineTo(d[1].x,d[1].y),this.context.lineTo(d[0].x,d[0].y),this.context.lineTo(d[4].x,d[4].y),this.context.moveTo(d[0].x,d[0].y),this.context.lineTo(d[2].x,d[2].y),this.context.moveTo(d[3].x,d[3].y),this.context.lineTo(d[7].x,d[7].y),this.context.lineTo(d[6].x,d[6].y),this.context.moveTo(d[7].x,d[7].y),this.context.lineTo(d[5].x,d[5].y),this.context.stroke(),this.context.closePath(),c=0;ce&&null!==a.isoSpritesBehind[e];e++)d(a.isoSpritesBehind[e]),a.isoSpritesBehind[e]=null;a[c]=n++}}var e,f;if(a instanceof Phaser.Group)e=a.children,f=!0;else{if(!a.length)return;e=a}c=c||"isoDepth",b="undefined"==typeof b?1.5:b;var g,h,i,j,k,l,m=e.length;for(i=0;m>i;i++){for(g=e[i],l=0,g.isoSpritesBehind||(g.isoSpritesBehind=[]),j=0;m>j;j++)i!=j&&(h=e[j],k=g.body||g.isoBounds,h._isoPosition.x+bi;i++)d(e[i]);f&&a.sort(c)}},Object.defineProperty(Phaser.Plugin.Isometric.Projector.prototype,"projectionAngle",{get:function(){return this._projectionAngle},set:function(a){a!==this._projectionAngle&&(this._projectionAngle=a,this._transform=[Math.cos(this._projectionAngle),Math.sin(this._projectionAngle)])}}),Phaser.Plugin.Isometric.Body=function(a){this.sprite=a,this.game=a.game,this.type=Phaser.Plugin.Isometric.ISOARCADE,this.enable=!0,this.offset=new Phaser.Plugin.Isometric.Point3,this.position=new Phaser.Plugin.Isometric.Point3(a.isoX,a.isoY,a.isoZ),this.prev=new Phaser.Plugin.Isometric.Point3(this.position.x,this.position.y,this.position.z),this.allowRotation=!0,this.rotation=a.rotation,this.preRotation=a.rotation,this.sourceWidthX=a.texture.frame.width,this.sourceWidthY=a.texture.frame.width,this.sourceHeight=a.texture.frame.height,this.widthX=Math.ceil(.5*a.width),this.widthY=Math.ceil(.5*a.width),this.height=a.height-Math.ceil(.5*a.width),this.halfWidthX=Math.abs(.5*this.widthX),this.halfWidthY=Math.abs(.5*this.widthY),this.halfHeight=Math.abs(.5*this.height),this.center=new Phaser.Plugin.Isometric.Point3(a.isoX+this.halfWidthX,a.isoY+this.halfWidthY,a.isoZ+this.halfHeight),this.velocity=new Phaser.Plugin.Isometric.Point3,this.newVelocity=new Phaser.Plugin.Isometric.Point3,this.deltaMax=new Phaser.Plugin.Isometric.Point3,this.acceleration=new Phaser.Plugin.Isometric.Point3,this.drag=new Phaser.Plugin.Isometric.Point3,this.allowGravity=!0,this.gravity=new Phaser.Plugin.Isometric.Point3,this.bounce=new Phaser.Plugin.Isometric.Point3,this.maxVelocity=new Phaser.Plugin.Isometric.Point3(1e4,1e4,1e4),this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e3,this.mass=1,this.angle=0,this.speed=0,this.facing=Phaser.NONE,this.immovable=!1,this.moves=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.customSeparateZ=!1,this.overlapX=0,this.overlapY=0,this.overlapZ=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,any:!0,up:!0,down:!0,frontX:!0,frontY:!0,backX:!0,backY:!0},this.touching={none:!0,up:!1,down:!1,frontX:!1,frontY:!1,backX:!1,backY:!1},this.wasTouching={none:!0,up:!1,down:!1,frontX:!1,frontY:!1,backX:!1,backY:!1},this.blocked={up:!1,down:!1,frontX:!1,frontY:!1,backX:!1,backY:!1},this.phase=0,this.skipTree=!1,this._reset=!0,this._sx=a.scale.x,this._sy=a.scale.y,this._dx=0,this._dy=0,this._dz=0,this._corners=[new Phaser.Plugin.Isometric.Point3(this.x,this.y,this.z),new Phaser.Plugin.Isometric.Point3(this.x,this.y,this.z+this.height),new Phaser.Plugin.Isometric.Point3(this.x,this.y+this.widthY,this.z),new Phaser.Plugin.Isometric.Point3(this.x,this.y+this.widthY,this.z+this.height),new Phaser.Plugin.Isometric.Point3(this.x+this.widthX,this.y,this.z),new Phaser.Plugin.Isometric.Point3(this.x+this.widthX,this.y,this.z+this.height),new Phaser.Plugin.Isometric.Point3(this.x+this.widthX,this.y+this.widthY,this.z),new Phaser.Plugin.Isometric.Point3(this.x+this.widthX,this.y+this.widthY,this.z+this.height)]},Phaser.Plugin.Isometric.Body.prototype={updateBounds:function(){var a=Math.abs(this.sprite.scale.x),b=Math.abs(this.sprite.scale.y);(a!==this._sx||b!==this._sy)&&(this.widthX=Math.ceil(.5*this.sprite.width),this.widthY=Math.ceil(.5*this.sprite.width),this.height=Math.ceil(this.sprite.height-.5*this.sprite.width),this.halfWidthX=Math.floor(2*this.widthX),this.halfWidthY=Math.floor(2*this.widthY),this.halfHeight=Math.floor(2*this.height),this._sx=a,this._sy=b,this.center.setTo(this.position.x+this.halfWidthX,this.position.y+this.halfWidthY,this.position.z+this.halfHeight),this._reset=!0)},preUpdate:function(){this.enable&&(this.phase=1,this.wasTouching.none=this.touching.none,this.wasTouching.up=this.touching.up,this.wasTouching.down=this.touching.down,this.wasTouching.backX=this.touching.backX,this.wasTouching.backY=this.touching.backY,this.wasTouching.frontX=this.touching.frontX,this.wasTouching.frontY=this.touching.frontY,this.touching.none=!0,this.touching.up=!1,this.touching.down=!1,this.touching.backX=!1,this.touching.backY=!1,this.touching.frontX=!1,this.touching.frontY=!1,this.blocked.up=!1,this.blocked.down=!1,this.blocked.backX=!1,this.blocked.frontX=!1,this.blocked.backY=!1,this.blocked.backX=!1,this.embedded=!1,this.updateBounds(),this.position.x=this.sprite.isoX+(this.widthX*-this.sprite.anchor.x+.5*this.widthX)+this.offset.x,this.position.y=this.sprite.isoY+(this.widthY*this.sprite.anchor.x-.5*this.widthY)+this.offset.y,this.position.z=this.sprite.isoZ-Math.abs(this.sprite.height)*(1-this.sprite.anchor.y)+Math.abs(.5*this.sprite.width)+this.offset.z,this.rotation=this.sprite.angle,this.preRotation=this.rotation,(this._reset||this.sprite.fresh===!0)&&(this.prev.x=this.position.x,this.prev.y=this.position.y,this.prev.z=this.position.z),this.moves&&(this.game.physics.isoArcade.updateMotion(this),this.newVelocity.set(this.velocity.x*this.game.time.physicsElapsed,this.velocity.y*this.game.time.physicsElapsed,this.velocity.z*this.game.time.physicsElapsed),this.position.x+=this.newVelocity.x,this.position.y+=this.newVelocity.y,this.position.z+=this.newVelocity.z,(this.position.x!==this.prev.x||this.position.y!==this.prev.y||this.position.z!==this.prev.z)&&(this.speed=Math.sqrt(this.velocity.x*this.velocity.x+this.velocity.y*this.velocity.y+this.velocity.z*this.velocity.z),this.angle=Math.atan2(this.velocity.y,this.velocity.x)),this.collideWorldBounds&&this.checkWorldBounds(),this.sprite.outOfBoundsKill&&!this.game.physics.isoArcade.bounds.intersects(this.sprite.isoBounds)&&this.sprite.kill()),this._dx=this.deltaX(),this._dy=this.deltaY(),this._dz=this.deltaZ(),this._reset=!1)},postUpdate:function(){this.enable&&2!==this.phase&&(this.phase=2,this.deltaAbsX()>=this.deltaAbsY()&&this.deltaAbsX()>=this.deltaAbsZ()?this.deltaX()<0?this.facing=Phaser.Plugin.Isometric.BACKWARDX:this.deltaX()>0&&(this.facing=Phaser.Plugin.Isometric.FORWARDX):this.deltaAbsY()>=this.deltaAbsX()&&this.deltaAbsY()>=this.deltaAbsZ()?this.deltaY()<0?this.facing=Phaser.Plugin.Isometric.BACKWARDY:this.deltaY()>0&&(this.facing=Phaser.Plugin.Isometric.FORWARDY):this.deltaZ()<0?this.facing=Phaser.Plugin.Isometric.DOWN:this.deltaZ()>0&&(this.facing=Phaser.Plugin.Isometric.UP),this.moves&&(this._dx=this.deltaX(),this._dy=this.deltaY(),this._dz=this.deltaZ(),0!==this.deltaMax.x&&0!==this._dx&&(this._dx<0&&this._dx<-this.deltaMax.x?this._dx=-this.deltaMax.x:this._dx>0&&this._dx>this.deltaMax.x&&(this._dx=this.deltaMax.x)),0!==this.deltaMax.y&&0!==this._dy&&(this._dy<0&&this._dy<-this.deltaMax.y?this._dy=-this.deltaMax.y:this._dy>0&&this._dy>this.deltaMax.y&&(this._dy=this.deltaMax.y)),0!==this.deltaMax.z&&0!==this._dz&&(this._dz<0&&this._dz<-this.deltaMax.z?this._dz=-this.deltaMax.z:this._dz>0&&this._dz>this.deltaMax.z&&(this._dz=this.deltaMax.z)),this.sprite.isoX+=this._dx,this.sprite.isoY+=this._dy,this.sprite.isoZ+=this._dz),this.center.setTo(this.position.x+this.halfWidthX,this.position.y+this.halfWidthY,this.position.z+this.halfHeight),this.allowRotation&&(this.sprite.angle+=this.deltaR()),this.prev.x=this.position.x,this.prev.y=this.position.y,this.prev.z=this.position.z)},destroy:function(){this.sprite=null},checkWorldBounds:function(){this.position.xthis.game.physics.isoArcade.bounds.frontX&&this.game.physics.isoArcade.checkCollision.frontX&&(this.position.x=this.game.physics.isoArcade.bounds.frontX-this.widthX,this.velocity.x*=-this.bounce.x,this.blocked.frontX=!0),this.position.ythis.game.physics.isoArcade.bounds.frontY&&this.game.physics.isoArcade.checkCollision.frontY&&(this.position.y=this.game.physics.isoArcade.bounds.frontY-this.widthY,this.velocity.y*=-this.bounce.y,this.blocked.frontY=!0),this.position.zthis.game.physics.isoArcade.bounds.top&&this.game.physics.isoArcade.checkCollision.up&&(this.position.z=this.game.physics.isoArcade.bounds.top-this.height,this.velocity.z*=-this.bounce.z,this.blocked.up=!0)},setSize:function(a,b,c,d,e,f){"undefined"==typeof d&&(d=this.offset.x),"undefined"==typeof e&&(e=this.offset.y),"undefined"==typeof f&&(f=this.offset.z),this.sourceWidthX=a,this.sourceWidthY=b,this.sourceHeight=c,this.widthX=this.sourceWidthX*this._sx,this.widthY=this.sourceWidthY*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidthX=Math.floor(.5*this.widthX),this.halfWidthY=Math.floor(.5*this.widthY),this.halfHeight=Math.floor(.5*this.height),this.offset.setTo(d,e,f),this.center.setTo(this.position.x+this.halfWidthX,this.position.y+this.halfWidthY,this.position.z+this.halfHeight)},reset:function(a,b,c){this.velocity.set(0),this.acceleration.set(0),this.angularVelocity=0,this.angularAcceleration=0,this.position.x=a+(this.widthX*-this.sprite.anchor.x+.5*this.widthX)+this.offset.x,this.position.y=b+(this.widthY*this.sprite.anchor.x-.5*this.widthY)+this.offset.y,this.position.z=c-Math.abs(this.sprite.height)*(1-this.sprite.anchor.y)+Math.abs(.5*this.sprite.width)+this.offset.z,this.prev.x=this.position.x,this.prev.y=this.position.y,this.prev.z=this.position.z,this.rotation=this.sprite.angle,this.preRotation=this.rotation,this._sx=this.sprite.scale.x,this._sy=this.sprite.scale.y,this.center.setTo(this.position.x+this.halfWidthX,this.position.y+this.halfWidthY,this.position.z+this.halfHeight),this.sprite._isoPositionChanged=!0},hitTest:function(a,b,c){return Phaser.Plugin.Isometric.Cube.contains(this,a,b,c)},onFloor:function(){return this.blocked.down},onWall:function(){return this.blocked.frontX||this.blocked.frontY||this.blocked.backX||this.blocked.backY},deltaAbsX:function(){return this.deltaX()>0?this.deltaX():-this.deltaX()},deltaAbsY:function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},deltaAbsZ:function(){return this.deltaZ()>0?this.deltaZ():-this.deltaZ()},deltaX:function(){return this.position.x-this.prev.x},deltaY:function(){return this.position.y-this.prev.y},deltaZ:function(){return this.position.z-this.prev.z},deltaR:function(){return this.rotation-this.preRotation},getCorners:function(){return this._corners[0].setTo(this.x,this.y,this.z),this._corners[1].setTo(this.x,this.y,this.z+this.height),this._corners[2].setTo(this.x,this.y+this.widthY,this.z),this._corners[3].setTo(this.x,this.y+this.widthY,this.z+this.height),this._corners[4].setTo(this.x+this.widthX,this.y,this.z),this._corners[5].setTo(this.x+this.widthX,this.y,this.z+this.height),this._corners[6].setTo(this.x+this.widthX,this.y+this.widthY,this.z),this._corners[7].setTo(this.x+this.widthX,this.y+this.widthY,this.z+this.height),this._corners}},Object.defineProperty(Phaser.Plugin.Isometric.Body.prototype,"top",{get:function(){return this.position.z+this.height}}),Object.defineProperty(Phaser.Plugin.Isometric.Body.prototype,"frontX",{get:function(){return this.position.x+this.widthX}}),Object.defineProperty(Phaser.Plugin.Isometric.Body.prototype,"right",{get:function(){return this.position.x+this.widthX}}),Object.defineProperty(Phaser.Plugin.Isometric.Body.prototype,"frontY",{ -get:function(){return this.position.y+this.widthY}}),Object.defineProperty(Phaser.Plugin.Isometric.Body.prototype,"bottom",{get:function(){return this.position.y+this.widthY}}),Object.defineProperty(Phaser.Plugin.Isometric.Body.prototype,"x",{get:function(){return this.position.x},set:function(a){this.position.x=a}}),Object.defineProperty(Phaser.Plugin.Isometric.Body.prototype,"y",{get:function(){return this.position.y},set:function(a){this.position.y=a}}),Object.defineProperty(Phaser.Plugin.Isometric.Body.prototype,"z",{get:function(){return this.position.z},set:function(a){this.position.z=a}}),Phaser.Plugin.Isometric.Body.render=function(a,b,c,d){"undefined"==typeof d&&(d=!0),c=c||"rgba(0,255,0,0.4)";var e=[],f=b.getCorners(),g=-b.sprite.game.camera.x,h=-b.sprite.game.camera.y;if(d){e=[f[1],f[3],f[2],f[6],f[4],f[5],f[1]],e=e.map(function(a){var c=b.sprite.game.iso.project(a);return c.x+=g,c.y+=h,c}),a.beginPath(),a.fillStyle=c,a.moveTo(e[0].x,e[0].y);for(var i=1;i0&&this.enable(a[c],!0));else a instanceof Phaser.Group?this.enable(a.children,b):(this.enableBody(a),b&&a.hasOwnProperty("children")&&a.children.length>0&&this.enable(a.children,!0))},enableBody:function(a){a.hasOwnProperty("body")&&null===a.body&&(a.body=new Phaser.Plugin.Isometric.Body(a))},updateMotion:function(a){this._velocityDelta=this.computeVelocity(0,a,a.angularVelocity,a.angularAcceleration,a.angularDrag,a.maxAngular)-a.angularVelocity,a.angularVelocity+=this._velocityDelta,a.rotation+=a.angularVelocity*this.game.time.physicsElapsed,a.velocity.x=this.computeVelocity(1,a,a.velocity.x,a.acceleration.x,a.drag.x,a.maxVelocity.x),a.velocity.y=this.computeVelocity(2,a,a.velocity.y,a.acceleration.y,a.drag.y,a.maxVelocity.y),a.velocity.z=this.computeVelocity(3,a,a.velocity.z,a.acceleration.z,a.drag.z,a.maxVelocity.z)},computeVelocity:function(a,b,c,d,e,f){return f=f||1e4,1===a&&b.allowGravity?c+=(this.gravity.x+b.gravity.x)*this.game.time.physicsElapsed:2===a&&b.allowGravity?c+=(this.gravity.y+b.gravity.y)*this.game.time.physicsElapsed:3===a&&b.allowGravity&&(c+=(this.gravity.z+b.gravity.z)*this.game.time.physicsElapsed),d?c+=d*this.game.time.physicsElapsed:e&&(this._drag=e*this.game.time.physicsElapsed,c-this._drag>0?c-=this._drag:c+this._drag<0?c+=this._drag:c=0),c>f?c=f:-f>c&&(c=-f),c},overlap:function(a,b,c,d,e){if(c=c||null,d=d||null,e=e||c,this._result=!1,this._total=0,Array.isArray(b))for(var f=0,g=b.length;g>f;f++)this.collideHandler(a,b[f],c,d,e,!0);else this.collideHandler(a,b,c,d,e,!0);return this._total>0},collide:function(a,b,c,d,e){if(c=c||null,d=d||null,e=e||c,this._result=!1,this._total=0,Array.isArray(b))for(var f=0,g=b.length;g>f;f++)this.collideHandler(a,b[f],c,d,e,!1);else this.collideHandler(a,b,c,d,e,!1);return this._total>0},collideHandler:function(a,b,c,d,e,f){return b||a.type!==Phaser.GROUP?void(a&&b&&a.exists&&b.exists&&(a.type===Phaser.Plugin.Isometric.ISOSPRITE?b.type===Phaser.Plugin.Isometric.ISOSPRITE?this.collideSpriteVsSprite(a,b,c,d,e,f):b.type===Phaser.GROUP&&this.collideSpriteVsGroup(a,b,c,d,e,f):a.type===Phaser.GROUP&&(b.type===Phaser.Plugin.Isometric.ISOSPRITE?this.collideSpriteVsGroup(b,a,c,d,e,f):b.type===Phaser.GROUP&&this.collideGroupVsGroup(a,b,c,d,e,f)))):void this.collideGroupVsSelf(a,c,d,e,f)},collideSpriteVsSprite:function(a,b,c,d,e,f){return a.body&&b.body?(this.separate(a.body,b.body,d,e,f)&&(c&&c.call(e,a,b),this._total++),!0):!1},collideSpriteVsGroup:function(a,b,c,d,e,f){var g,h;if(0!==b.length&&a.body)if(a.body.skipTree||this.skipTree)for(g=0,h=b.children.length;h>g;g++)b.children[g]&&b.children[g].exists&&this.collideSpriteVsSprite(a,b.children[g],c,d,e,f);else for(this.useQuadTree?(this.quadTree.clear(),this.quadTree.reset(this.bounds.x,this.bounds.y,this.bounds.widthX,this.bounds.widthY,this.maxObjects,this.maxLevels),this.quadTree.populate(b),this._potentials=this.quadTree.retrieve(a)):(this.octree.clear(),this.octree.reset(this.bounds.x,this.bounds.y,this.bounds.z,this.bounds.widthX,this.bounds.widthY,this.bounds.height,this.maxObjects,this.maxLevels),this.octree.populate(b),this._potentials=this.octree.retrieve(a)),g=0,h=this._potentials.length;h>g;g++)this.separate(a.body,this._potentials[g],d,e,f)&&(c&&c.call(e,a,this._potentials[g].sprite),this._total++)},collideGroupVsSelf:function(a,b,c,d,e){if(0!==a.length)for(var f=a.children.length,g=0;f>g;g++)for(var h=g+1;f>=h;h++)a.children[g]&&a.children[h]&&a.children[g].exists&&a.children[h].exists&&this.collideSpriteVsSprite(a.children[g],a.children[h],b,c,d,e)},collideGroupVsGroup:function(a,b,c,d,e,f){if(0!==a.length&&0!==b.length)for(var g=0,h=a.children.length;h>g;g++)a.children[g].exists&&this.collideSpriteVsGroup(a.children[g],b,c,d,e,f)},separate:function(a,b,c,d,e){return a.enable&&b.enable&&this.intersects(a,b)?c&&c.call(d,a.sprite,b.sprite)===!1?!1:e?!0:(this.forceXY||Math.abs(this.gravity.z+a.gravity.z)=b.frontX?!1:a.y>=b.frontY?!1:a.top<=b.z?!1:a.z>=b.top?!1:!0},separateX:function(a,b,c){return a.immovable&&b.immovable?!1:(this._overlap=0,this.intersects(a,b)&&(this._maxOverlap=a.deltaAbsX()+b.deltaAbsX()+this.OVERLAP_BIAS,0===a.deltaX()&&0===b.deltaX()?(a.embedded=!0,b.embedded=!0):a.deltaX()>b.deltaX()?(this._overlap=a.frontX-b.x,this._overlap>this._maxOverlap||a.checkCollision.frontX===!1||b.checkCollision.backX===!1?this._overlap=0:(a.touching.none=!1,a.touching.frontX=!0,b.touching.none=!1,b.touching.backX=!0)):a.deltaX()this._maxOverlap||a.checkCollision.backX===!1||b.checkCollision.frontX===!1?this._overlap=0:(a.touching.none=!1,a.touching.backX=!0,b.touching.none=!1,b.touching.frontX=!0)),0!==this._overlap)?(a.overlapX=this._overlap,b.overlapX=this._overlap,c||a.customSeparateX||b.customSeparateX?!0:(this._velocity1=a.velocity.x,this._velocity2=b.velocity.x,a.immovable||b.immovable?a.immovable?b.immovable||(b.x+=this._overlap,b.velocity.x=this._velocity1-this._velocity2*b.bounce.x):(a.x=a.x-this._overlap,a.velocity.x=this._velocity2-this._velocity1*a.bounce.x):(this._overlap*=.5,a.x=a.x-this._overlap,b.x+=this._overlap,this._newVelocity1=Math.sqrt(this._velocity2*this._velocity2*b.mass/a.mass)*(this._velocity2>0?1:-1),this._newVelocity2=Math.sqrt(this._velocity1*this._velocity1*a.mass/b.mass)*(this._velocity1>0?1:-1),this._average=.5*(this._newVelocity1+this._newVelocity2),this._newVelocity1-=this._average,this._newVelocity2-=this._average,a.velocity.x=this._average+this._newVelocity1*a.bounce.x,b.velocity.x=this._average+this._newVelocity2*b.bounce.x),!0)):!1)},separateY:function(a,b,c){return a.immovable&&b.immovable?!1:(this._overlap=0,this.intersects(a,b)&&(this._maxOverlap=a.deltaAbsY()+b.deltaAbsY()+this.OVERLAP_BIAS,0===a.deltaY()&&0===b.deltaY()?(a.embedded=!0,b.embedded=!0):a.deltaY()>b.deltaY()?(this._overlap=a.frontY-b.y,this._overlap>this._maxOverlap||a.checkCollision.frontY===!1||b.checkCollision.backY===!1?this._overlap=0:(a.touching.none=!1,a.touching.frontY=!0,b.touching.none=!1,b.touching.backY=!0)):a.deltaY()this._maxOverlap||a.checkCollision.backY===!1||b.checkCollision.frontY===!1?this._overlap=0:(a.touching.none=!1,a.touching.backY=!0,b.touching.none=!1,b.touching.frontY=!0)),0!==this._overlap)?(a.overlapY=this._overlap,b.overlapY=this._overlap,c||a.customSeparateY||b.customSeparateY?!0:(this._velocity1=a.velocity.y,this._velocity2=b.velocity.y,a.immovable||b.immovable?a.immovable?b.immovable||(b.y+=this._overlap,b.velocity.y=this._velocity1-this._velocity2*b.bounce.y):(a.y=a.y-this._overlap,a.velocity.y=this._velocity2-this._velocity1*a.bounce.y):(this._overlap*=.5,a.y=a.y-this._overlap,b.y+=this._overlap,this._newVelocity1=Math.sqrt(this._velocity2*this._velocity2*b.mass/a.mass)*(this._velocity2>0?1:-1),this._newVelocity2=Math.sqrt(this._velocity1*this._velocity1*a.mass/b.mass)*(this._velocity1>0?1:-1),this._average=.5*(this._newVelocity1+this._newVelocity2),this._newVelocity1-=this._average,this._newVelocity2-=this._average,a.velocity.y=this._average+this._newVelocity1*a.bounce.y,b.velocity.y=this._average+this._newVelocity2*b.bounce.y),!0)):!1)},separateZ:function(a,b,c){return a.immovable&&b.immovable?!1:(this._overlap=0,this.intersects(a,b)&&(this._maxOverlap=a.deltaAbsZ()+b.deltaAbsZ()+this.OVERLAP_BIAS,0===a.deltaZ()&&0===b.deltaZ()?(a.embedded=!0,b.embedded=!0):a.deltaZ()>b.deltaZ()?(this._overlap=a.top-b.z,this._overlap>this._maxOverlap||a.checkCollision.down===!1||b.checkCollision.up===!1?this._overlap=0:(a.touching.none=!1,a.touching.down=!0,b.touching.none=!1,b.touching.up=!0)):a.deltaZ()this._maxOverlap||a.checkCollision.up===!1||b.checkCollision.down===!1?this._overlap=0:(a.touching.none=!1,a.touching.up=!0,b.touching.none=!1,b.touching.down=!0)),0!==this._overlap)?(a.overlapZ=this._overlap,b.overlapZ=this._overlap,c||a.customSeparateY||b.customSeparateZ?!0:(this._velocity1=a.velocity.z,this._velocity2=b.velocity.z,a.immovable||b.immovable?a.immovable?b.immovable||(b.z+=this._overlap,b.velocity.z=this._velocity1-this._velocity2*b.bounce.z,a.moves&&(b.x+=a.x-a.prev.x,a.y+=b.y-b.prev.y)):(a.z=a.z-this._overlap,a.velocity.z=this._velocity2-this._velocity1*a.bounce.z,b.moves&&(a.x+=b.x-b.prev.x,a.y+=b.y-b.prev.y)):(this._overlap*=.5,a.z=a.z-this._overlap,b.z+=this._overlap,this._newVelocity1=Math.sqrt(this._velocity2*this._velocity2*b.mass/a.mass)*(this._velocity2>0?1:-1),this._newVelocity2=Math.sqrt(this._velocity1*this._velocity1*a.mass/b.mass)*(this._velocity1>0?1:-1),this._average=.5*(this._newVelocity1+this._newVelocity2),this._newVelocity1-=this._average,this._newVelocity2-=this._average,a.velocity.z=this._average+this._newVelocity1*a.bounce.z,b.velocity.z=this._average+this._newVelocity2*b.bounce.z),!0)):!1)},distanceBetween:function(a,b){return this._dx=a.x-b.x,this._dy=a.y-b.y,this._dz=a.z-b.z,Math.sqrt(this._dx*this._dx+this._dy*this._dy+this._dz*this._dz)},distanceToXY:function(a,b,c){return this._dx=a.x-b,this._dy=a.y-c,Math.sqrt(this._dx*this._dx+this._dy*this._dy)},distanceToXYZ:function(a,b,c,d){return this._dx=a.x-b,this._dy=a.y-c,this._dz=a.z-d,Math.sqrt(this._dx*this._dx+this._dy*this._dy+this._dz*this._dz)}},Phaser.Physics.prototype.isoArcade=null,Phaser.Physics.prototype.parseConfig=function(a){return function(){return this.config.hasOwnProperty("isoArcade")&&this.config.isoArcade===!0&&Phaser.Plugin.Isometric.hasOwnProperty("IsoArcade")&&(this.isoArcade=new Phaser.Plugin.Isometric(this.game,this.config)),a.call(this)}}(Phaser.Physics.prototype.parseConfig),Phaser.Physics.prototype.startSystem=function(a){return function(b){return b===Phaser.Plugin.Isometric.ISOARCADE&&null===this.isoArcade&&(this.isoArcade=new Phaser.Plugin.Isometric.Arcade(this.game),this.setBoundsToWorld()),a.call(this,b)}}(Phaser.Physics.prototype.startSystem),Phaser.Physics.prototype.enable=function(a){return function(b,c){return c===Phaser.Plugin.Isometric.ISOARCADE&&this.isoArcade&&this.isoArcade.enable(b),a.call(this,b,c)}}(Phaser.Physics.prototype.enable),Phaser.Physics.prototype.setBoundsToWorld=function(a){return function(){return this.isoArcade&&this.isoArcade.setBoundsToWorld(),a.call(this)}}(Phaser.Physics.prototype.setBoundsToWorld),Phaser.Physics.prototype.destroy=function(a){return function(){return this.isoArcade=null,a.call(this)}}(Phaser.Physics.prototype.destroy); \ No newline at end of file +Phaser.Plugin.Isometric=function(a,b,c){c=c||Phaser.Plugin.Isometric.CLASSIC,Phaser.Plugin.call(this,a,b),this.projector=new Phaser.Plugin.Isometric.Projector(this.game,c),this.game.iso=this.game.iso||this.projector},Phaser.Plugin.Isometric.prototype=Object.create(Phaser.Plugin.prototype),Phaser.Plugin.Isometric.prototype.constructor=Phaser.Plugin.Isometric,Phaser.Plugin.Isometric.VERSION="0.9.2",Phaser.Plugin.Isometric.UP=0,Phaser.Plugin.Isometric.DOWN=1,Phaser.Plugin.Isometric.FORWARDX=2,Phaser.Plugin.Isometric.FORWARDY=3,Phaser.Plugin.Isometric.BACKWARDX=4,Phaser.Plugin.Isometric.BACKWARDY=5,Phaser.Plugin.Isometric.ISOSPRITE="isosprite",Phaser.Plugin.Isometric.ISOARCADE="isoarcade",Phaser.Plugin.Isometric.Cube=function(a,b,c,d,e,f){a=a||0,b=b||0,c=c||0,d=d||0,e=e||0,f=f||0,this.x=a,this.y=b,this.z=c,this.widthX=d,this.widthY=e,this.height=f,this._corners=[new Phaser.Plugin.Isometric.Point3(this.x,this.y,this.z),new Phaser.Plugin.Isometric.Point3(this.x,this.y,this.z+this.height),new Phaser.Plugin.Isometric.Point3(this.x,this.y+this.widthY,this.z),new Phaser.Plugin.Isometric.Point3(this.x,this.y+this.widthY,this.z+this.height),new Phaser.Plugin.Isometric.Point3(this.x+this.widthX,this.y,this.z),new Phaser.Plugin.Isometric.Point3(this.x+this.widthX,this.y,this.z+this.height),new Phaser.Plugin.Isometric.Point3(this.x+this.widthX,this.y+this.widthY,this.z),new Phaser.Plugin.Isometric.Point3(this.x+this.widthX,this.y+this.widthY,this.z+this.height)]},Phaser.Plugin.Isometric.Cube.prototype.constructor=Phaser.Plugin.Isometric.Cube,Phaser.Plugin.Isometric.Cube.prototype={setTo:function(a,b,c,d,e,f){return this.x=a,this.y=b,this.z=c,this.widthX=d,this.widthY=e,this.height=f,this},copyFrom:function(a){this.setTo(a.x,a.y,a.z,a.widthX,a.widthY,a.height)},copyTo:function(a){return a.x=this.x,a.y=this.y,a.z=this.z,a.widthX=this.widthX,a.widthY=this.widthY,a.height=this.height,a},size:function(a){return Phaser.Plugin.Isometric.Cube.size(this,a)},contains:function(a,b,c){return Phaser.Plugin.Isometric.Cube.contains(this,a,b,c)},containsXY:function(a,b){return Phaser.Plugin.Isometric.Cube.containsXY(this,a,b)},clone:function(a){return Phaser.Plugin.Isometric.Cube.clone(this,a)},intersects:function(a){return Phaser.Plugin.Isometric.Cube.intersects(this,a)},getCorners:function(){return this._corners[0].setTo(this.x,this.y,this.z),this._corners[1].setTo(this.x,this.y,this.z+this.height),this._corners[2].setTo(this.x,this.y+this.widthY,this.z),this._corners[3].setTo(this.x,this.y+this.widthY,this.z+this.height),this._corners[4].setTo(this.x+this.widthX,this.y,this.z),this._corners[5].setTo(this.x+this.widthX,this.y,this.z+this.height),this._corners[6].setTo(this.x+this.widthX,this.y+this.widthY,this.z),this._corners[7].setTo(this.x+this.widthX,this.y+this.widthY,this.z+this.height),this._corners},toString:function(){return"[{Cube (x="+this.x+" y="+this.y+" z="+this.z+" widthX="+this.widthX+" widthY="+this.widthY+" height="+this.height+" empty="+this.empty+")}]"}},Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"halfWidthX",{get:function(){return Math.round(.5*this.widthX)}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"halfWidthY",{get:function(){return Math.round(.5*this.widthY)}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"halfHeight",{get:function(){return Math.round(.5*this.height)}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"bottom",{get:function(){return this.z},set:function(a){a>=this.top?this.height=0:this.height=this.top-a,this.z=a}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"top",{get:function(){return this.z+this.height},set:function(a){a<=this.z?this.height=0:this.height=a-this.z}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"backX",{get:function(){return this.x},set:function(a){a>=this.frontX?this.widthX=0:this.widthX=this.frontX-a,this.x=a}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"backY",{get:function(){return this.y},set:function(a){a>=this.frontY?this.widthY=0:this.widthY=this.frontY-a,this.y=a}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"frontX",{get:function(){return this.x+this.widthX},set:function(a){a<=this.x?this.widthX=0:this.widthX=a-this.x}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"frontY",{get:function(){return this.y+this.widthY},set:function(a){a<=this.y?this.widthY=0:this.widthY=a-this.y}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"volume",{get:function(){return this.widthX*this.widthY*this.height}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"centerX",{get:function(){return this.x+this.halfWidthX},set:function(a){this.x=a-this.halfWidthX}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"centerY",{get:function(){return this.y+this.halfWidthY},set:function(a){this.y=a-this.halfWidthY}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"centerZ",{get:function(){return this.z+this.halfHeight},set:function(a){this.z=a-this.halfHeight}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"randomX",{get:function(){return this.x+Math.random()*this.widthX}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"randomY",{get:function(){return this.y+Math.random()*this.widthY}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"randomZ",{get:function(){return this.z+Math.random()*this.height}}),Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"empty",{get:function(){return!this.widthX||!this.widthY||!this.height},set:function(a){a===!0&&this.setTo(0,0,0,0,0,0)}}),Phaser.Plugin.Isometric.Cube.size=function(a,b){return"undefined"==typeof b||null===b?b=new Phaser.Plugin.Isometric.Point3(a.widthX,a.widthY,a.height):b.setTo(a.widthX,a.widthY,a.height),b},Phaser.Plugin.Isometric.Cube.clone=function(a,b){return"undefined"==typeof b||null===b?b=new Phaser.Plugin.Isometric.Cube(a.x,a.y,a.z,a.widthX,a.widthY,a.height):b.setTo(a.x,a.y,a.z,a.widthX,a.widthY,a.height),b},Phaser.Plugin.Isometric.Cube.contains=function(a,b,c,d){return a.widthX<=0||a.widthY<=0||a.height<=0?!1:b>=a.x&&b<=a.frontX&&c>=a.y&&c<=a.frontY&&d>=a.z&&d<=a.top},Phaser.Plugin.Isometric.Cube.containsXY=function(a,b,c){return a.widthX<=0||a.widthY<=0?!1:b>=a.x&&b<=a.frontX&&c>=a.y&&c<=a.frontY},Phaser.Plugin.Isometric.Cube.containsPoint3=function(a,b){return Phaser.Plugin.Isometric.Cube.contains(a,b.x,b.y,b.z)},Phaser.Plugin.Isometric.Cube.containsCube=function(a,b){return a.volume>b.volume?!1:a.x>=b.x&&a.y>=b.y&&a.z>=b.z&&a.frontX<=b.frontX&&a.frontY<=b.frontY&&a.top<=b.top},Phaser.Plugin.Isometric.Cube.intersects=function(a,b){return a.widthX<=0||a.widthY<=0||a.height<=0||b.widthX<=0||b.widthY<=0||b.height<=0?!1:!(a.frontXb.frontX||a.y>b.frontY||a.z>b.top||a.top0&&(this.position.x=Phaser.Math.snapTo(this.position.x,this.snap),this.position.y=Phaser.Math.snapTo(this.position.y,this.snap)),this._depthChanged=this._isoPositionChanged=this._isoBoundsChanged=!0)},Phaser.Plugin.Isometric.IsoSprite.prototype.resetIsoBounds=function(){"undefined"==typeof this._isoBounds&&(this._isoBounds=new Phaser.Plugin.Isometric.Cube);var a=Math.abs(this.scale.x),b=Math.abs(this.scale.y);return this._isoBounds.widthX=Math.round(.5*Math.abs(this.width))*a,this._isoBounds.widthY=Math.round(.5*Math.abs(this.width))*a,this._isoBounds.height=Math.round(Math.abs(this.height)-.5*Math.abs(this.width))*b,this._isoBounds.x=this.isoX+this._isoBounds.widthX*-this.anchor.x+.5*this._isoBounds.widthX,this._isoBounds.y=this.isoY+this._isoBounds.widthY*this.anchor.x-.5*this._isoBounds.widthY,this._isoBounds.z=this.isoZ-Math.abs(this.height)*(1-this.anchor.y)+Math.abs(.5*this.width),this._isoBounds},Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype,"isoX",{get:function(){return this._isoPosition.x},set:function(a){this._isoPosition.x=a,this._depthChanged=this._isoPositionChanged=this._isoBoundsChanged=!0,this.body&&(this.body._reset=!0)}}),Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype,"isoY",{get:function(){return this._isoPosition.y},set:function(a){this._isoPosition.y=a,this._depthChanged=this._isoPositionChanged=this._isoBoundsChanged=!0,this.body&&(this.body._reset=!0)}}),Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype,"isoZ",{get:function(){return this._isoPosition.z},set:function(a){this._isoPosition.z=a,this._depthChanged=this._isoPositionChanged=this._isoBoundsChanged=!0,this.body&&(this.body._reset=!0)}}),Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype,"isoPosition",{get:function(){return this._isoPosition}}),Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype,"isoBounds",{get:function(){return(this._isoBoundsChanged||!this._isoBounds)&&(this.resetIsoBounds(),this._isoBoundsChanged=!1),this._isoBounds}}),Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype,"depth",{get:function(){return this._depthChanged===!0&&(this._depth=this._isoPosition.x+this._isoPosition.y+1.25*this._isoPosition.z,this._depthChanged=!1),this._depth}}),Phaser.GameObjectCreator.prototype.isoSprite=function(a,b,c,d,e){return new Phaser.Plugin.Isometric.IsoSprite(this.game,a,b,c,d,e)},Phaser.GameObjectFactory.prototype.isoSprite=function(a,b,c,d,e,f){return"undefined"==typeof f&&(f=this.world),f.add(new Phaser.Plugin.Isometric.IsoSprite(this.game,a,b,c,d,e))},Phaser.Plugin.Isometric.prototype.addIsoSprite=function(a,b,c,d,e,f){return Phaser.GameObjectFactory.prototype.isoSprite.call(this.game.add,a,b,c,d,e,f)},Phaser.Utils.Debug.prototype.isoSprite=function(a,b,c){if(a.isoBounds){"undefined"==typeof c&&(c=!0),b=b||"rgba(0,255,0,0.4)";var d=[],e=a.isoBounds.getCorners(),f=-a.game.camera.x,g=-a.game.camera.y;if(this.start(),c){d=[e[1],e[3],e[2],e[6],e[4],e[5],e[1]],d=d.map(function(b){var c=a.game.iso.project(b);return c.x+=f,c.y+=g,c}),this.context.beginPath(),this.context.fillStyle=b,this.context.moveTo(d[0].x,d[0].y);for(var h=1;hthis.maxObjects&&this.levelthis.bounds.top&&(b=4):a.y>this.bounds.frontY&&(a.zthis.bounds.top&&(b=6)):a.x>this.bounds.frontX&&(a.ythis.bounds.top&&(b=5):a.y>this.bounds.frontY&&(a.zthis.bounds.top&&(b=7))),b},retrieve:function(a){var b,c;if(a instanceof Phaser.Plugin.Isometric.Cube)b=this.objects,c=this.getIndex(a);else{if(!a.body)return this._empty;b=this.objects,c=this.getIndex(a.body)}return this.nodes[0]&&(-1!==c?b=b.concat(this.nodes[c].retrieve(a)):(b=b.concat(this.nodes[0].retrieve(a)),b=b.concat(this.nodes[1].retrieve(a)),b=b.concat(this.nodes[2].retrieve(a)),b=b.concat(this.nodes[3].retrieve(a)),b=b.concat(this.nodes[4].retrieve(a)),b=b.concat(this.nodes[5].retrieve(a)),b=b.concat(this.nodes[6].retrieve(a)),b=b.concat(this.nodes[7].retrieve(a)))),b},clear:function(){this.objects.length=0;for(var a=this.nodes.length;a--;)this.nodes[a].clear(),this.nodes.splice(a,1);this.nodes.length=0}},Phaser.Plugin.Isometric.Octree.prototype.constructor=Phaser.Plugin.Isometric.Octree,Phaser.Utils.Debug.prototype.octree=function(a,b){b=b||"rgba(255,0,0,0.3)",this.start();var c,d,e=a.bounds;if(0===a.nodes.length){this.context.strokeStyle=b;var f=new Phaser.Plugin.Isometric.Cube(e.x,e.y,e.z,e.widthX,e.widthY,e.height),g=f.getCorners(),h=-this.game.camera.x,i=-this.game.camera.y;for(d=g.slice(0,g.length),d=d.map(function(a){var b=this.game.iso.project(a);return b.x+=h,b.y+=i,b}),this.context.moveTo(d[0].x,d[0].y),this.context.beginPath(),this.context.strokeStyle=b,this.context.lineTo(d[1].x,d[1].y),this.context.lineTo(d[3].x,d[3].y),this.context.lineTo(d[2].x,d[2].y),this.context.lineTo(d[6].x,d[6].y),this.context.lineTo(d[4].x,d[4].y),this.context.lineTo(d[5].x,d[5].y),this.context.lineTo(d[1].x,d[1].y),this.context.lineTo(d[0].x,d[0].y),this.context.lineTo(d[4].x,d[4].y),this.context.moveTo(d[0].x,d[0].y),this.context.lineTo(d[2].x,d[2].y),this.context.moveTo(d[3].x,d[3].y),this.context.lineTo(d[7].x,d[7].y),this.context.lineTo(d[6].x,d[6].y),this.context.moveTo(d[7].x,d[7].y),this.context.lineTo(d[5].x,d[5].y),this.context.stroke(),this.context.closePath(),c=0;ce&&null!==a.isoSpritesBehind[e];e++)d(a.isoSpritesBehind[e]),a.isoSpritesBehind[e]=null;a[c]=n++}}var e,f;if(a instanceof Phaser.Group)e=a.children,f=!0;else{if(!a.length)return;e=a}c=c||"isoDepth",b="undefined"==typeof b?1.5:b;var g,h,i,j,k,l,m=e.length;for(i=0;m>i;i++){for(g=e[i],l=0,g.isoSpritesBehind||(g.isoSpritesBehind=[]),j=0;m>j;j++)i!=j&&(h=e[j],k=g.body||g.isoBounds,h._isoPosition.x+bi;i++)d(e[i]);f&&a.sort(c)}},Object.defineProperty(Phaser.Plugin.Isometric.Projector.prototype,"projectionAngle",{get:function(){return this._projectionAngle},set:function(a){a!==this._projectionAngle&&(this._projectionAngle=a,this._transform=[Math.cos(this._projectionAngle),Math.sin(this._projectionAngle)])}}),Phaser.Plugin.Isometric.Body=function(a){this.sprite=a,this.game=a.game,this.type=Phaser.Plugin.Isometric.ISOARCADE,this.enable=!0,this.offset=new Phaser.Plugin.Isometric.Point3,this.position=new Phaser.Plugin.Isometric.Point3(a.isoX,a.isoY,a.isoZ),this.prev=new Phaser.Plugin.Isometric.Point3(this.position.x,this.position.y,this.position.z),this.allowRotation=!0,this.rotation=a.rotation,this.preRotation=a.rotation,this.sourceWidthX=a.texture.frame.width,this.sourceWidthY=a.texture.frame.width,this.sourceHeight=a.texture.frame.height,this.widthX=Math.ceil(.5*a.width),this.widthY=Math.ceil(.5*a.width),this.height=a.height-Math.ceil(.5*a.width),this.halfWidthX=Math.abs(.5*this.widthX),this.halfWidthY=Math.abs(.5*this.widthY),this.halfHeight=Math.abs(.5*this.height),this.center=new Phaser.Plugin.Isometric.Point3(a.isoX+this.halfWidthX,a.isoY+this.halfWidthY,a.isoZ+this.halfHeight),this.velocity=new Phaser.Plugin.Isometric.Point3,this.newVelocity=new Phaser.Plugin.Isometric.Point3,this.deltaMax=new Phaser.Plugin.Isometric.Point3,this.acceleration=new Phaser.Plugin.Isometric.Point3,this.drag=new Phaser.Plugin.Isometric.Point3,this.allowGravity=!0,this.gravity=new Phaser.Plugin.Isometric.Point3,this.bounce=new Phaser.Plugin.Isometric.Point3,this.maxVelocity=new Phaser.Plugin.Isometric.Point3(1e4,1e4,1e4),this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e3,this.mass=1,this.angle=0,this.speed=0,this.facing=Phaser.NONE,this.immovable=!1,this.moves=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.customSeparateZ=!1,this.overlapX=0,this.overlapY=0,this.overlapZ=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,any:!0,up:!0,down:!0,frontX:!0,frontY:!0,backX:!0,backY:!0},this.touching={none:!0,up:!1,down:!1,frontX:!1,frontY:!1,backX:!1,backY:!1},this.wasTouching={none:!0,up:!1,down:!1,frontX:!1,frontY:!1,backX:!1,backY:!1},this.blocked={up:!1,down:!1,frontX:!1,frontY:!1,backX:!1,backY:!1},this.phase=0,this.skipTree=!1,this._reset=!0,this._sx=a.scale.x,this._sy=a.scale.y,this._dx=0,this._dy=0,this._dz=0,this._corners=[new Phaser.Plugin.Isometric.Point3(this.x,this.y,this.z),new Phaser.Plugin.Isometric.Point3(this.x,this.y,this.z+this.height),new Phaser.Plugin.Isometric.Point3(this.x,this.y+this.widthY,this.z),new Phaser.Plugin.Isometric.Point3(this.x,this.y+this.widthY,this.z+this.height),new Phaser.Plugin.Isometric.Point3(this.x+this.widthX,this.y,this.z),new Phaser.Plugin.Isometric.Point3(this.x+this.widthX,this.y,this.z+this.height),new Phaser.Plugin.Isometric.Point3(this.x+this.widthX,this.y+this.widthY,this.z),new Phaser.Plugin.Isometric.Point3(this.x+this.widthX,this.y+this.widthY,this.z+this.height)]},Phaser.Plugin.Isometric.Body.prototype={updateBounds:function(){var a=Math.abs(this.sprite.scale.x),b=Math.abs(this.sprite.scale.y);(a!==this._sx||b!==this._sy)&&(this.widthX=Math.ceil(.5*this.sprite.width),this.widthY=Math.ceil(.5*this.sprite.width),this.height=Math.ceil(this.sprite.height-.5*this.sprite.width),this.halfWidthX=Math.floor(2*this.widthX),this.halfWidthY=Math.floor(2*this.widthY),this.halfHeight=Math.floor(2*this.height),this._sx=a,this._sy=b,this.center.setTo(this.position.x+this.halfWidthX,this.position.y+this.halfWidthY,this.position.z+this.halfHeight),this._reset=!0)},preUpdate:function(){this.enable&&(this.phase=1,this.wasTouching.none=this.touching.none,this.wasTouching.up=this.touching.up,this.wasTouching.down=this.touching.down,this.wasTouching.backX=this.touching.backX,this.wasTouching.backY=this.touching.backY,this.wasTouching.frontX=this.touching.frontX,this.wasTouching.frontY=this.touching.frontY,this.touching.none=!0,this.touching.up=!1,this.touching.down=!1,this.touching.backX=!1,this.touching.backY=!1,this.touching.frontX=!1,this.touching.frontY=!1,this.blocked.up=!1,this.blocked.down=!1,this.blocked.backX=!1,this.blocked.frontX=!1,this.blocked.backY=!1,this.blocked.backX=!1,this.embedded=!1,this.updateBounds(),this.position.x=this.sprite.isoX+(this.widthX*-this.sprite.anchor.x+.5*this.widthX)+this.offset.x,this.position.y=this.sprite.isoY+(this.widthY*this.sprite.anchor.x-.5*this.widthY)+this.offset.y,this.position.z=this.sprite.isoZ-Math.abs(this.sprite.height)*(1-this.sprite.anchor.y)+Math.abs(.5*this.sprite.width)+this.offset.z,this.rotation=this.sprite.angle,this.preRotation=this.rotation,(this._reset||this.sprite.fresh===!0)&&(this.prev.x=this.position.x,this.prev.y=this.position.y,this.prev.z=this.position.z),this.moves&&(this.game.physics.isoArcade.updateMotion(this),this.newVelocity.set(this.velocity.x*this.game.time.physicsElapsed,this.velocity.y*this.game.time.physicsElapsed,this.velocity.z*this.game.time.physicsElapsed),this.position.x+=this.newVelocity.x,this.position.y+=this.newVelocity.y,this.position.z+=this.newVelocity.z,(this.position.x!==this.prev.x||this.position.y!==this.prev.y||this.position.z!==this.prev.z)&&(this.speed=Math.sqrt(this.velocity.x*this.velocity.x+this.velocity.y*this.velocity.y+this.velocity.z*this.velocity.z),this.angle=Math.atan2(this.velocity.y,this.velocity.x)),this.collideWorldBounds&&this.checkWorldBounds(),this.sprite.outOfBoundsKill&&!this.game.physics.isoArcade.bounds.intersects(this.sprite.isoBounds)&&this.sprite.kill()),this._dx=this.deltaX(),this._dy=this.deltaY(),this._dz=this.deltaZ(),this._reset=!1)},postUpdate:function(){this.enable&&2!==this.phase&&(this.phase=2,this._reset&&(this.prev.x=this.position.x,this.prev.y=this.position.y,this.prev.z=this.position.z),this.deltaAbsX()>=this.deltaAbsY()&&this.deltaAbsX()>=this.deltaAbsZ()?this.deltaX()<0?this.facing=Phaser.Plugin.Isometric.BACKWARDX:this.deltaX()>0&&(this.facing=Phaser.Plugin.Isometric.FORWARDX):this.deltaAbsY()>=this.deltaAbsX()&&this.deltaAbsY()>=this.deltaAbsZ()?this.deltaY()<0?this.facing=Phaser.Plugin.Isometric.BACKWARDY:this.deltaY()>0&&(this.facing=Phaser.Plugin.Isometric.FORWARDY):this.deltaZ()<0?this.facing=Phaser.Plugin.Isometric.DOWN:this.deltaZ()>0&&(this.facing=Phaser.Plugin.Isometric.UP),this.moves&&(this._dx=this.deltaX(),this._dy=this.deltaY(),this._dz=this.deltaZ(),0!==this.deltaMax.x&&0!==this._dx&&(this._dx<0&&this._dx<-this.deltaMax.x?this._dx=-this.deltaMax.x:this._dx>0&&this._dx>this.deltaMax.x&&(this._dx=this.deltaMax.x)),0!==this.deltaMax.y&&0!==this._dy&&(this._dy<0&&this._dy<-this.deltaMax.y?this._dy=-this.deltaMax.y:this._dy>0&&this._dy>this.deltaMax.y&&(this._dy=this.deltaMax.y)),0!==this.deltaMax.z&&0!==this._dz&&(this._dz<0&&this._dz<-this.deltaMax.z?this._dz=-this.deltaMax.z:this._dz>0&&this._dz>this.deltaMax.z&&(this._dz=this.deltaMax.z)),this.sprite.isoX+=this._dx,this.sprite.isoY+=this._dy,this.sprite.isoZ+=this._dz),this.center.setTo(this.position.x+this.halfWidthX,this.position.y+this.halfWidthY,this.position.z+this.halfHeight),this.allowRotation&&(this.sprite.angle+=this.deltaR()),this.prev.x=this.position.x,this.prev.y=this.position.y,this.prev.z=this.position.z,this._reset=!1)},destroy:function(){this.sprite=null},checkWorldBounds:function(){this.position.xthis.game.physics.isoArcade.bounds.frontX&&this.game.physics.isoArcade.checkCollision.frontX&&(this.position.x=this.game.physics.isoArcade.bounds.frontX-this.widthX,this.velocity.x*=-this.bounce.x,this.blocked.frontX=!0),this.position.ythis.game.physics.isoArcade.bounds.frontY&&this.game.physics.isoArcade.checkCollision.frontY&&(this.position.y=this.game.physics.isoArcade.bounds.frontY-this.widthY,this.velocity.y*=-this.bounce.y,this.blocked.frontY=!0),this.position.zthis.game.physics.isoArcade.bounds.top&&this.game.physics.isoArcade.checkCollision.up&&(this.position.z=this.game.physics.isoArcade.bounds.top-this.height,this.velocity.z*=-this.bounce.z,this.blocked.up=!0)},setSize:function(a,b,c,d,e,f){"undefined"==typeof d&&(d=this.offset.x),"undefined"==typeof e&&(e=this.offset.y),"undefined"==typeof f&&(f=this.offset.z),this.sourceWidthX=a,this.sourceWidthY=b,this.sourceHeight=c,this.widthX=this.sourceWidthX*this._sx,this.widthY=this.sourceWidthY*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidthX=Math.floor(.5*this.widthX),this.halfWidthY=Math.floor(.5*this.widthY),this.halfHeight=Math.floor(.5*this.height),this.offset.setTo(d,e,f),this.center.setTo(this.position.x+this.halfWidthX,this.position.y+this.halfWidthY,this.position.z+this.halfHeight)},reset:function(a,b,c){this.velocity.set(0),this.acceleration.set(0),this.angularVelocity=0,this.angularAcceleration=0,this.position.x=a+(this.widthX*-this.sprite.anchor.x+.5*this.widthX)+this.offset.x,this.position.y=b+(this.widthY*this.sprite.anchor.x-.5*this.widthY)+this.offset.y,this.position.z=c-Math.abs(this.sprite.height)*(1-this.sprite.anchor.y)+Math.abs(.5*this.sprite.width)+this.offset.z,this.prev.x=this.position.x,this.prev.y=this.position.y,this.prev.z=this.position.z,this.rotation=this.sprite.angle,this.preRotation=this.rotation,this._sx=this.sprite.scale.x,this._sy=this.sprite.scale.y,this.center.setTo(this.position.x+this.halfWidthX,this.position.y+this.halfWidthY,this.position.z+this.halfHeight),this.sprite._isoPositionChanged=!0},hitTest:function(a,b,c){return Phaser.Plugin.Isometric.Cube.contains(this,a,b,c)},onFloor:function(){return this.blocked.down},onWall:function(){return this.blocked.frontX||this.blocked.frontY||this.blocked.backX||this.blocked.backY},deltaAbsX:function(){return this.deltaX()>0?this.deltaX():-this.deltaX()},deltaAbsY:function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},deltaAbsZ:function(){return this.deltaZ()>0?this.deltaZ():-this.deltaZ()},deltaX:function(){return this.position.x-this.prev.x},deltaY:function(){return this.position.y-this.prev.y},deltaZ:function(){return this.position.z-this.prev.z},deltaR:function(){return this.rotation-this.preRotation},getCorners:function(){return this._corners[0].setTo(this.x,this.y,this.z),this._corners[1].setTo(this.x,this.y,this.z+this.height),this._corners[2].setTo(this.x,this.y+this.widthY,this.z),this._corners[3].setTo(this.x,this.y+this.widthY,this.z+this.height),this._corners[4].setTo(this.x+this.widthX,this.y,this.z),this._corners[5].setTo(this.x+this.widthX,this.y,this.z+this.height),this._corners[6].setTo(this.x+this.widthX,this.y+this.widthY,this.z),this._corners[7].setTo(this.x+this.widthX,this.y+this.widthY,this.z+this.height),this._corners}},Object.defineProperty(Phaser.Plugin.Isometric.Body.prototype,"top",{get:function(){return this.position.z+this.height}}),Object.defineProperty(Phaser.Plugin.Isometric.Body.prototype,"frontX",{get:function(){return this.position.x+this.widthX}}),Object.defineProperty(Phaser.Plugin.Isometric.Body.prototype,"right",{ +get:function(){return this.position.x+this.widthX}}),Object.defineProperty(Phaser.Plugin.Isometric.Body.prototype,"frontY",{get:function(){return this.position.y+this.widthY}}),Object.defineProperty(Phaser.Plugin.Isometric.Body.prototype,"bottom",{get:function(){return this.position.y+this.widthY}}),Object.defineProperty(Phaser.Plugin.Isometric.Body.prototype,"x",{get:function(){return this.position.x},set:function(a){this.position.x=a}}),Object.defineProperty(Phaser.Plugin.Isometric.Body.prototype,"y",{get:function(){return this.position.y},set:function(a){this.position.y=a}}),Object.defineProperty(Phaser.Plugin.Isometric.Body.prototype,"z",{get:function(){return this.position.z},set:function(a){this.position.z=a}}),Phaser.Plugin.Isometric.Body.render=function(a,b,c,d){"undefined"==typeof d&&(d=!0),c=c||"rgba(0,255,0,0.4)";var e=[],f=b.getCorners(),g=-b.sprite.game.camera.x,h=-b.sprite.game.camera.y;if(d){e=[f[1],f[3],f[2],f[6],f[4],f[5],f[1]],e=e.map(function(a){var c=b.sprite.game.iso.project(a);return c.x+=g,c.y+=h,c}),a.beginPath(),a.fillStyle=c,a.moveTo(e[0].x,e[0].y);for(var i=1;i0&&this.enable(a[c],!0));else a instanceof Phaser.Group?this.enable(a.children,b):(this.enableBody(a),b&&a.hasOwnProperty("children")&&a.children.length>0&&this.enable(a.children,!0))},enableBody:function(a){a.hasOwnProperty("body")&&null===a.body&&(a.body=new Phaser.Plugin.Isometric.Body(a))},updateMotion:function(a){this._velocityDelta=this.computeVelocity(0,a,a.angularVelocity,a.angularAcceleration,a.angularDrag,a.maxAngular)-a.angularVelocity,a.angularVelocity+=this._velocityDelta,a.rotation+=a.angularVelocity*this.game.time.physicsElapsed,a.velocity.x=this.computeVelocity(1,a,a.velocity.x,a.acceleration.x,a.drag.x,a.maxVelocity.x),a.velocity.y=this.computeVelocity(2,a,a.velocity.y,a.acceleration.y,a.drag.y,a.maxVelocity.y),a.velocity.z=this.computeVelocity(3,a,a.velocity.z,a.acceleration.z,a.drag.z,a.maxVelocity.z)},computeVelocity:function(a,b,c,d,e,f){return f=f||1e4,1===a&&b.allowGravity?c+=(this.gravity.x+b.gravity.x)*this.game.time.physicsElapsed:2===a&&b.allowGravity?c+=(this.gravity.y+b.gravity.y)*this.game.time.physicsElapsed:3===a&&b.allowGravity&&(c+=(this.gravity.z+b.gravity.z)*this.game.time.physicsElapsed),d?c+=d*this.game.time.physicsElapsed:e&&(this._drag=e*this.game.time.physicsElapsed,c-this._drag>0?c-=this._drag:c+this._drag<0?c+=this._drag:c=0),c>f?c=f:-f>c&&(c=-f),c},overlap:function(a,b,c,d,e){if(c=c||null,d=d||null,e=e||c,this._result=!1,this._total=0,Array.isArray(b))for(var f=0,g=b.length;g>f;f++)this.collideHandler(a,b[f],c,d,e,!0);else this.collideHandler(a,b,c,d,e,!0);return this._total>0},collide:function(a,b,c,d,e){if(c=c||null,d=d||null,e=e||c,this._result=!1,this._total=0,Array.isArray(b))for(var f=0,g=b.length;g>f;f++)this.collideHandler(a,b[f],c,d,e,!1);else this.collideHandler(a,b,c,d,e,!1);return this._total>0},collideHandler:function(a,b,c,d,e,f){return b||a.type!==Phaser.GROUP?void(a&&b&&a.exists&&b.exists&&(a.type===Phaser.Plugin.Isometric.ISOSPRITE?b.type===Phaser.Plugin.Isometric.ISOSPRITE?this.collideSpriteVsSprite(a,b,c,d,e,f):b.type===Phaser.GROUP&&this.collideSpriteVsGroup(a,b,c,d,e,f):a.type===Phaser.GROUP&&(b.type===Phaser.Plugin.Isometric.ISOSPRITE?this.collideSpriteVsGroup(b,a,c,d,e,f):b.type===Phaser.GROUP&&this.collideGroupVsGroup(a,b,c,d,e,f)))):void this.collideGroupVsSelf(a,c,d,e,f)},collideSpriteVsSprite:function(a,b,c,d,e,f){return a.body&&b.body?(this.separate(a.body,b.body,d,e,f)&&(c&&c.call(e,a,b),this._total++),!0):!1},collideSpriteVsGroup:function(a,b,c,d,e,f){var g,h;if(0!==b.length&&a.body)if(a.body.skipTree||this.skipTree)for(g=0,h=b.children.length;h>g;g++)b.children[g]&&b.children[g].exists&&this.collideSpriteVsSprite(a,b.children[g],c,d,e,f);else for(this.useQuadTree?(this.quadTree.clear(),this.quadTree.reset(this.bounds.x,this.bounds.y,this.bounds.widthX,this.bounds.widthY,this.maxObjects,this.maxLevels),this.quadTree.populate(b),this._potentials=this.quadTree.retrieve(a)):(this.octree.clear(),this.octree.reset(this.bounds.x,this.bounds.y,this.bounds.z,this.bounds.widthX,this.bounds.widthY,this.bounds.height,this.maxObjects,this.maxLevels),this.octree.populate(b),this._potentials=this.octree.retrieve(a)),g=0,h=this._potentials.length;h>g;g++)this.separate(a.body,this._potentials[g],d,e,f)&&(c&&c.call(e,a,this._potentials[g].sprite),this._total++)},collideGroupVsSelf:function(a,b,c,d,e){if(0!==a.length)for(var f=a.children.length,g=0;f>g;g++)for(var h=g+1;f>=h;h++)a.children[g]&&a.children[h]&&a.children[g].exists&&a.children[h].exists&&this.collideSpriteVsSprite(a.children[g],a.children[h],b,c,d,e)},collideGroupVsGroup:function(a,b,c,d,e,f){if(0!==a.length&&0!==b.length)for(var g=0,h=a.children.length;h>g;g++)a.children[g].exists&&this.collideSpriteVsGroup(a.children[g],b,c,d,e,f)},separate:function(a,b,c,d,e){return a.enable&&b.enable&&this.intersects(a,b)?c&&c.call(d,a.sprite,b.sprite)===!1?!1:e?!0:(this.forceXY||Math.abs(this.gravity.z+a.gravity.z)=b.frontX?!1:a.y>=b.frontY?!1:a.top<=b.z?!1:a.z>=b.top?!1:!0},separateX:function(a,b,c){return a.immovable&&b.immovable?!1:(this._overlap=0,this.intersects(a,b)&&(this._maxOverlap=a.deltaAbsX()+b.deltaAbsX()+this.OVERLAP_BIAS,0===a.deltaX()&&0===b.deltaX()?(a.embedded=!0,b.embedded=!0):a.deltaX()>b.deltaX()?(this._overlap=a.frontX-b.x,this._overlap>this._maxOverlap||a.checkCollision.frontX===!1||b.checkCollision.backX===!1?this._overlap=0:(a.touching.none=!1,a.touching.frontX=!0,b.touching.none=!1,b.touching.backX=!0)):a.deltaX()this._maxOverlap||a.checkCollision.backX===!1||b.checkCollision.frontX===!1?this._overlap=0:(a.touching.none=!1,a.touching.backX=!0,b.touching.none=!1,b.touching.frontX=!0)),0!==this._overlap)?(a.overlapX=this._overlap,b.overlapX=this._overlap,c||a.customSeparateX||b.customSeparateX?!0:(this._velocity1=a.velocity.x,this._velocity2=b.velocity.x,a.immovable||b.immovable?a.immovable?b.immovable||(b.x+=this._overlap,b.velocity.x=this._velocity1-this._velocity2*b.bounce.x):(a.x=a.x-this._overlap,a.velocity.x=this._velocity2-this._velocity1*a.bounce.x):(this._overlap*=.5,a.x=a.x-this._overlap,b.x+=this._overlap,this._newVelocity1=Math.sqrt(this._velocity2*this._velocity2*b.mass/a.mass)*(this._velocity2>0?1:-1),this._newVelocity2=Math.sqrt(this._velocity1*this._velocity1*a.mass/b.mass)*(this._velocity1>0?1:-1),this._average=.5*(this._newVelocity1+this._newVelocity2),this._newVelocity1-=this._average,this._newVelocity2-=this._average,a.velocity.x=this._average+this._newVelocity1*a.bounce.x,b.velocity.x=this._average+this._newVelocity2*b.bounce.x),!0)):!1)},separateY:function(a,b,c){return a.immovable&&b.immovable?!1:(this._overlap=0,this.intersects(a,b)&&(this._maxOverlap=a.deltaAbsY()+b.deltaAbsY()+this.OVERLAP_BIAS,0===a.deltaY()&&0===b.deltaY()?(a.embedded=!0,b.embedded=!0):a.deltaY()>b.deltaY()?(this._overlap=a.frontY-b.y,this._overlap>this._maxOverlap||a.checkCollision.frontY===!1||b.checkCollision.backY===!1?this._overlap=0:(a.touching.none=!1,a.touching.frontY=!0,b.touching.none=!1,b.touching.backY=!0)):a.deltaY()this._maxOverlap||a.checkCollision.backY===!1||b.checkCollision.frontY===!1?this._overlap=0:(a.touching.none=!1,a.touching.backY=!0,b.touching.none=!1,b.touching.frontY=!0)),0!==this._overlap)?(a.overlapY=this._overlap,b.overlapY=this._overlap,c||a.customSeparateY||b.customSeparateY?!0:(this._velocity1=a.velocity.y,this._velocity2=b.velocity.y,a.immovable||b.immovable?a.immovable?b.immovable||(b.y+=this._overlap,b.velocity.y=this._velocity1-this._velocity2*b.bounce.y):(a.y=a.y-this._overlap,a.velocity.y=this._velocity2-this._velocity1*a.bounce.y):(this._overlap*=.5,a.y=a.y-this._overlap,b.y+=this._overlap,this._newVelocity1=Math.sqrt(this._velocity2*this._velocity2*b.mass/a.mass)*(this._velocity2>0?1:-1),this._newVelocity2=Math.sqrt(this._velocity1*this._velocity1*a.mass/b.mass)*(this._velocity1>0?1:-1),this._average=.5*(this._newVelocity1+this._newVelocity2),this._newVelocity1-=this._average,this._newVelocity2-=this._average,a.velocity.y=this._average+this._newVelocity1*a.bounce.y,b.velocity.y=this._average+this._newVelocity2*b.bounce.y),!0)):!1)},separateZ:function(a,b,c){return a.immovable&&b.immovable?!1:(this._overlap=0,this.intersects(a,b)&&(this._maxOverlap=a.deltaAbsZ()+b.deltaAbsZ()+this.OVERLAP_BIAS,0===a.deltaZ()&&0===b.deltaZ()?(a.embedded=!0,b.embedded=!0):a.deltaZ()>b.deltaZ()?(this._overlap=a.top-b.z,this._overlap>this._maxOverlap||a.checkCollision.down===!1||b.checkCollision.up===!1?this._overlap=0:(a.touching.none=!1,a.touching.down=!0,b.touching.none=!1,b.touching.up=!0)):a.deltaZ()this._maxOverlap||a.checkCollision.up===!1||b.checkCollision.down===!1?this._overlap=0:(a.touching.none=!1,a.touching.up=!0,b.touching.none=!1,b.touching.down=!0)),0!==this._overlap)?(a.overlapZ=this._overlap,b.overlapZ=this._overlap,c||a.customSeparateY||b.customSeparateZ?!0:(this._velocity1=a.velocity.z,this._velocity2=b.velocity.z,a.immovable||b.immovable?a.immovable?b.immovable||(b.z+=this._overlap,b.velocity.z=this._velocity1-this._velocity2*b.bounce.z,a.moves&&(b.x+=a.x-a.prev.x,a.y+=b.y-b.prev.y)):(a.z=a.z-this._overlap,a.velocity.z=this._velocity2-this._velocity1*a.bounce.z,b.moves&&(a.x+=b.x-b.prev.x,a.y+=b.y-b.prev.y)):(this._overlap*=.5,a.z=a.z-this._overlap,b.z+=this._overlap,this._newVelocity1=Math.sqrt(this._velocity2*this._velocity2*b.mass/a.mass)*(this._velocity2>0?1:-1),this._newVelocity2=Math.sqrt(this._velocity1*this._velocity1*a.mass/b.mass)*(this._velocity1>0?1:-1),this._average=.5*(this._newVelocity1+this._newVelocity2),this._newVelocity1-=this._average,this._newVelocity2-=this._average,a.velocity.z=this._average+this._newVelocity1*a.bounce.z,b.velocity.z=this._average+this._newVelocity2*b.bounce.z),!0)):!1)},distanceBetween:function(a,b){return this._dx=a.x-b.x,this._dy=a.y-b.y,this._dz=a.z-b.z,Math.sqrt(this._dx*this._dx+this._dy*this._dy+this._dz*this._dz)},distanceToXY:function(a,b,c){return this._dx=a.x-b,this._dy=a.y-c,Math.sqrt(this._dx*this._dx+this._dy*this._dy)},distanceToXYZ:function(a,b,c,d){return this._dx=a.x-b,this._dy=a.y-c,this._dz=a.z-d,Math.sqrt(this._dx*this._dx+this._dy*this._dy+this._dz*this._dz)},distanceToPointer:function(a,b){b=b||this.game.input.activePointer;var c=this.game.iso.unproject(b.position,void 0,a.z);c.z=a.z;var d=this.anglesToXYZ(a,c.x,c.y,c.z);return d.r},anglesToXYZ:function(a,b,c,d){var e=this.distanceToXYZ(a,b,c,d),f=Math.atan2(c-a.y,b-a.x),g=Math.acos((d-a.z)/e);return{r:e,theta:f,phi:g}},angleToPointer:function(a,b){b=b||this.game.input.activePointer;var c=this.game.iso.unproject(b.position,void 0,a.z);c.z=a.z;var d=this.anglesToXYZ(a,c.x,c.y,c.z);return d.theta},velocityFromAngles:function(a,b,c,d){return void 0===b&&(b=Math.sin(Math.PI/2)),void 0===c&&(c=60),d=d||new Phaser.Point,new Phaser.Plugin.Isometric.Point3(Math.cos(a)*Math.sin(b)*c,Math.sin(a)*Math.sin(b)*c,Math.cos(b)*c)},accelerateToXYZ:function(a,b,c,d,e,f,g,h){void 0===e&&(e=60),void 0===f&&(f=500),void 0===g&&(g=500),void 0===h&&(h=500);var i=this.anglesToXYZ(a.body,b,c,d),j=this.velocityFromAngles(i.theta,i.phi,e);return a.body.acceleration.setTo(j.x,j.y,j.z),a.body.maxVelocity.setTo(f,g,h),i.theta},moveToXYZ:function(a,b,c,d,e,f){"undefined"==typeof e&&(e=60),"undefined"==typeof f&&(f=0),f>0&&(e=this.distanceToXYZ(a.body,b,c,d)/(f/1e3));var g=this.anglesToXYZ(a.body,b,c,d),h=this.velocityFromAngles(g.theta,g.phi,e);return console.log(a.id,h),a.body.velocity.copyFrom(h),console.log(a.id,a.body.velocity),g.theta},moveToObject:function(a,b,c,d){return this.moveToXYZ(a,b.x,b.y,b.z,c,d)},moveToPointer:function(a,b,c,d){c=c||this.game.input.activePointer;var e=this.game.iso.unproject(c.position,void 0,a.body.z);return e.z=a.body.z,this.moveToXYZ(a,e.x,e.y,e.z,b,d)}},Phaser.Physics.prototype.isoArcade=null,Phaser.Physics.prototype.parseConfig=function(a){return function(){return this.config.hasOwnProperty("isoArcade")&&this.config.isoArcade===!0&&Phaser.Plugin.Isometric.hasOwnProperty("IsoArcade")&&(this.isoArcade=new Phaser.Plugin.Isometric(this.game,this.config)),a.call(this)}}(Phaser.Physics.prototype.parseConfig),Phaser.Physics.prototype.startSystem=function(a){return function(b){return b===Phaser.Plugin.Isometric.ISOARCADE&&null===this.isoArcade&&(this.isoArcade=new Phaser.Plugin.Isometric.Arcade(this.game),this.setBoundsToWorld()),a.call(this,b)}}(Phaser.Physics.prototype.startSystem),Phaser.Physics.prototype.enable=function(a){return function(b,c){return c===Phaser.Plugin.Isometric.ISOARCADE&&this.isoArcade&&this.isoArcade.enable(b),a.call(this,b,c)}}(Phaser.Physics.prototype.enable),Phaser.Physics.prototype.setBoundsToWorld=function(a){return function(){return this.isoArcade&&this.isoArcade.setBoundsToWorld(),a.call(this)}}(Phaser.Physics.prototype.setBoundsToWorld),Phaser.Physics.prototype.destroy=function(a){return function(){return this.isoArcade=null,a.call(this)}}(Phaser.Physics.prototype.destroy); \ No newline at end of file