Much-Assembly-Required-Fron.../mar/phaser-plugin-isometric.min.js

113 lines
49 KiB
JavaScript

/*
2015 Lewis Lane (Rotates.org)
@license {@link http://opensource.org/licenses/MIT|MIT License}
*/
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(a,b,c,d){if(b){c=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var e=a[d];e in c||(c[e]={});c=c[e]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:b})}};$jscomp.polyfill("Array.prototype.fill",function(a){return a?a:function(a,c,d){var b=this.length||0;0>c&&(c=Math.max(0,b+c));if(null==d||d>b)d=b;d=Number(d);0>d&&(d=Math.max(0,b+d));for(c=Number(c||0);c<d;c++)this[c]=a;return this}},"es6","es3");
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.3";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){this.x=a||0;this.y=b||0;this.z=c||0;this.widthX=d||0;this.widthY=e||0;this.height=f||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.Cube.prototype.constructor=Phaser.Plugin.Isometric.Cube;
Phaser.Plugin.Isometric.Cube.prototype={setTo:function(a,b,c,d,e,f){this.x=a;this.y=b;this.z=c;this.widthX=d;this.widthY=e;this.height=f;return this},copyFrom:function(a){this.setTo(a.x,a.y,a.z,a.widthX,a.widthY,a.height)},copyTo:function(a){a.x=this.x;a.y=this.y;a.z=this.z;a.widthX=this.widthX;a.widthY=this.widthY;a.height=this.height;return 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(){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);return 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){this.height=a>=this.top?0:this.top-a;this.z=a}});Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"top",{get:function(){return this.z+this.height},set:function(a){this.height=a<=this.z?0:a-this.z}});Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"backX",{get:function(){return this.x},set:function(a){this.widthX=a>=this.frontX?0:this.frontX-a;this.x=a}});
Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"backY",{get:function(){return this.y},set:function(a){this.widthY=a>=this.frontY?0:this.frontY-a;this.y=a}});Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"frontX",{get:function(){return this.x+this.widthX},set:function(a){this.widthX=a<=this.x?0:a-this.x}});Object.defineProperty(Phaser.Plugin.Isometric.Cube.prototype,"frontY",{get:function(){return this.y+this.widthY},set:function(a){this.widthY=a<=this.y?0: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){!0===a&&this.setTo(0,0,0,0,0,0)}});Phaser.Plugin.Isometric.Cube.size=function(a,b){"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);return b};
Phaser.Plugin.Isometric.Cube.clone=function(a,b){"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);return b};Phaser.Plugin.Isometric.Cube.contains=function(a,b,c,d){return 0>=a.widthX||0>=a.widthY||0>=a.height?!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 0>=a.widthX||0>=a.widthY?!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 0>=a.widthX||0>=a.widthY||0>=a.height||0>=b.widthX||0>=b.widthY||0>=b.height?!1:!(a.frontX<b.x||a.frontY<b.y||a.x>b.frontX||a.y>b.frontY||a.z>b.top||a.top<b.z)};
Phaser.Plugin.Isometric.IsoSprite=function(a,b,c,d,e,f){Phaser.Sprite.call(this,a,b,c,e,f);this.type=Phaser.Plugin.Isometric.ISOSPRITE;this._isoPosition=new Phaser.Plugin.Isometric.Point3(b,c,d);this._depth=this.snap=0;this._isoBoundsChanged=this._isoPositionChanged=this._depthChanged=!0;this._project();this._isoBounds=this.resetIsoBounds()};Phaser.Plugin.Isometric.IsoSprite.prototype=Object.create(Phaser.Sprite.prototype);Phaser.Plugin.Isometric.IsoSprite.prototype.constructor=Phaser.Plugin.Isometric.IsoSprite;
Phaser.Plugin.Isometric.IsoSprite.prototype.postUpdate=function(){Phaser.Sprite.prototype.postUpdate.call(this);this._project()};Phaser.Plugin.Isometric.IsoSprite.prototype._project=function(){this._isoPositionChanged&&(this.game.iso.project(this._isoPosition,this.position),0<this.snap&&(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);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);return 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(){if(this._isoBoundsChanged||!this._isoBounds)this.resetIsoBounds(),this._isoBoundsChanged=!1;return this._isoBounds}});Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype,"depth",{get:function(){!0===this._depthChanged&&(this._depth=this._isoPosition.x+this._isoPosition.y+1.25*this._isoPosition.z,this._depthChanged=!1);return 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){"undefined"===typeof f&&(f=this.world);return 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=[];d=a.isoBounds.getCorners();var e=-a.game.camera.x,f=-a.game.camera.y;this.start();if(c){d=[d[1],d[3],d[2],d[6],d[4],d[5],d[1]];d=d.map(function(b){b=a.game.iso.project(b);b.x+=e;b.y+=f;return b});this.context.beginPath();this.context.fillStyle=b;this.context.moveTo(d[0].x,d[0].y);for(b=1;b<d.length;b++)this.context.lineTo(d[b].x,d[b].y);this.context.fill()}else d=
d.slice(0,d.length),d=d.map(function(b){b=a.game.iso.project(b);b.x+=e;b.y+=f;return 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();this.stop()}};Phaser.Plugin.Isometric.Octree=function(a,b,c,d,e,f,g,h,k){this.maxObjects=10;this.maxLevels=4;this.level=0;this.bounds={};this.objects=[];this.nodes=[];this._empty=[];this.reset(a,b,c,d,e,f,g,h,k)};
Phaser.Plugin.Isometric.Octree.prototype={reset:function(a,b,c,d,e,f,g,h,k){this.maxObjects=g||10;this.maxLevels=h||4;this.level=k||0;this.bounds={x:Math.round(a),y:Math.round(b),z:Math.round(c),widthX:d,widthY:e,height:f,subWidthX:Math.floor(.5*d),subWidthY:Math.floor(.5*e),subHeight:Math.floor(.5*f),frontX:Math.round(a)+Math.floor(.5*d),frontY:Math.round(b)+Math.floor(.5*e),top:Math.round(c)+Math.floor(.5*f)};this.objects.length=0;this.nodes.length=0},populate:function(a){a.forEach(this.populateHandler,
this,!0)},populateHandler:function(a){a.body&&a.exists&&this.insert(a.body)},split:function(){this.nodes[0]=new Phaser.Plugin.Isometric.Octree(this.bounds.x,this.bounds.y,this.bounds.z,this.bounds.subWidthX,this.bounds.subWidthY,this.bounds.subHeight,this.maxLevels,this.level+1);this.nodes[1]=new Phaser.Plugin.Isometric.Octree(this.bounds.frontX,this.bounds.y,this.bounds.z,this.bounds.subWidthX,this.bounds.subWidthY,this.bounds.subHeight,this.maxLevels,this.level+1);this.nodes[2]=new Phaser.Plugin.Isometric.Octree(this.bounds.x,
this.bounds.frontY,this.bounds.z,this.bounds.subWidthX,this.bounds.subWidthY,this.bounds.subHeight,this.maxLevels,this.level+1);this.nodes[3]=new Phaser.Plugin.Isometric.Octree(this.bounds.frontX,this.bounds.frontY,this.bounds.z,this.bounds.subWidthX,this.bounds.subWidthY,this.bounds.subHeight,this.maxLevels,this.level+1);this.nodes[4]=new Phaser.Plugin.Isometric.Octree(this.bounds.x,this.bounds.y,this.bounds.top,this.bounds.subWidthX,this.bounds.subWidthY,this.bounds.subHeight,this.maxLevels,this.level+
1);this.nodes[5]=new Phaser.Plugin.Isometric.Octree(this.bounds.frontX,this.bounds.y,this.bounds.top,this.bounds.subWidthX,this.bounds.subWidthY,this.bounds.subHeight,this.maxLevels,this.level+1);this.nodes[6]=new Phaser.Plugin.Isometric.Octree(this.bounds.x,this.bounds.frontY,this.bounds.top,this.bounds.subWidthX,this.bounds.subWidthY,this.bounds.subHeight,this.maxLevels,this.level+1);this.nodes[7]=new Phaser.Plugin.Isometric.Octree(this.bounds.frontX,this.bounds.frontY,this.bounds.top,this.bounds.subWidthX,
this.bounds.subWidthY,this.bounds.subHeight,this.maxLevels,this.level+1)},insert:function(a){var b=0;if(null!=this.nodes[0]){var c=this.getIndex(a);if(-1!=c){this.nodes[c].insert(a);return}}this.objects.push(a);if(this.objects.length>this.maxObjects&&this.level<this.maxLevels)for(null==this.nodes[0]&&this.split();b<this.objects.length;)c=this.getIndex(this.objects[b]),-1!=c?this.nodes[c].insert(this.objects.splice(b,1)[0]):b++},getIndex:function(a){var b=-1;a.x<this.bounds.frontX&&a.frontX<this.bounds.frontX?
a.y<this.bounds.frontY&&a.frontY<this.bounds.frontY?a.z<this.bounds.top&&a.top<this.bounds.top?b=0:a.z>this.bounds.top&&(b=4):a.y>this.bounds.frontY&&(a.z<this.bounds.top&&a.top<this.bounds.top?b=2:a.z>this.bounds.top&&(b=6)):a.x>this.bounds.frontX&&(a.y<this.bounds.frontY&&a.frontY<this.bounds.frontY?a.z<this.bounds.top&&a.top<this.bounds.top?b=1:a.z>this.bounds.top&&(b=5):a.y>this.bounds.frontY&&(a.z<this.bounds.top&&a.top<this.bounds.top?b=3:a.z>this.bounds.top&&(b=7)));return b},retrieve:function(a){if(a instanceof
Phaser.Plugin.Isometric.Cube){var b=this.objects;var c=this.getIndex(a)}else{if(!a.body)return this._empty;b=this.objects;c=this.getIndex(a.body)}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))));
return 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=a.bounds;if(0===a.nodes.length){this.context.strokeStyle=b;c=(new Phaser.Plugin.Isometric.Cube(c.x,c.y,c.z,c.widthX,c.widthY,c.height)).getCorners();var d=-this.game.camera.x,e=-this.game.camera.y;c=c.slice(0,c.length);c=c.map(function(a){a=this.game.iso.project(a);a.x+=d;a.y+=e;return a});this.context.moveTo(c[0].x,c[0].y);this.context.beginPath();this.context.strokeStyle=b;this.context.lineTo(c[1].x,c[1].y);
this.context.lineTo(c[3].x,c[3].y);this.context.lineTo(c[2].x,c[2].y);this.context.lineTo(c[6].x,c[6].y);this.context.lineTo(c[4].x,c[4].y);this.context.lineTo(c[5].x,c[5].y);this.context.lineTo(c[1].x,c[1].y);this.context.lineTo(c[0].x,c[0].y);this.context.lineTo(c[4].x,c[4].y);this.context.moveTo(c[0].x,c[0].y);this.context.lineTo(c[2].x,c[2].y);this.context.moveTo(c[3].x,c[3].y);this.context.lineTo(c[7].x,c[7].y);this.context.lineTo(c[6].x,c[6].y);this.context.moveTo(c[7].x,c[7].y);this.context.lineTo(c[5].x,
c[5].y);this.context.stroke();this.context.closePath();for(b=0;b<a.objects.length;b++)this.body(a.objects[b].sprite,"rgb(0,255,0)",!1)}else for(b=0;b<a.nodes.length;b++)this.octree(a.nodes[b]);this.stop()};Phaser.Plugin.Isometric.Point3=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0};
Phaser.Plugin.Isometric.Point3.prototype={copyFrom:function(a){return this.setTo(a.x,a.y,a.z)},copyTo:function(a){a.x=this.x;a.y=this.y;a.z=this.z;return a},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},set:function(a,b,c){this.x=a||0;this.y=b||(0!==b?this.x:0);this.z=c||("undefined"===typeof b?this.x:0);return this},setTo:function(a,b,c){return this.set(a,b,c)},add:function(a,b){this.x+=a||0;this.y+=b||0;return this},subtract:function(a,b,c){this.x-=a||0;this.y-=b||0;this.z-=
c||0;return this},multiply:function(a,b,c){this.x*=a||1;this.y*=b||1;this.z*=c||1;return this},divide:function(a,b,c){this.x/=a||1;this.y/=b||1;this.z/=c||1;return this}};Phaser.Plugin.Isometric.Point3.prototype.constructor=Phaser.Plugin.Isometric.Point3;Phaser.Plugin.Isometric.Point3.add=function(a,b,c){"undefined"===typeof c&&(c=new Phaser.Plugin.Isometric.Point3);c.x=a.x+b.x;c.y=a.y+b.y;c.z=a.z+b.z;return c};
Phaser.Plugin.Isometric.Point3.subtract=function(a,b,c){"undefined"===typeof c&&(c=new Phaser.Plugin.Isometric.Point3);c.x=a.x-b.x;c.y=a.y-b.y;c.z=a.z-b.z;return c};Phaser.Plugin.Isometric.Point3.multiply=function(a,b,c){"undefined"===typeof c&&(c=new Phaser.Plugin.Isometric.Point3);c.x=a.x*b.x;c.y=a.y*b.y;c.z=a.z*b.z;return c};Phaser.Plugin.Isometric.Point3.divide=function(a,b,c){"undefined"===typeof c&&(c=new Phaser.Plugin.Isometric.Point3);c.x=a.x/b.x;c.y=a.y/b.y;c.z=a.z/b.z;return c};
Phaser.Plugin.Isometric.Point3.equals=function(a,b){return a.x===b.x&&a.y===b.y&&a.z===b.z};Phaser.Plugin.Isometric.Projector=function(a,b){this.game=a;this._transform=null;this._projectionAngle=0;this.projectionAngle=b||Phaser.Plugin.Isometric.CLASSIC;this.anchor=new Phaser.Point(.5,0)};Phaser.Plugin.Isometric.CLASSIC=Math.atan(.5);Phaser.Plugin.Isometric.ISOMETRIC=Math.PI/6;Phaser.Plugin.Isometric.MILITARY=Math.PI/4;
Phaser.Plugin.Isometric.Projector.prototype={project:function(a,b){"undefined"===typeof b&&(b=new Phaser.Point);b.x=(a.x-a.y)*this._transform[0];b.y=(a.x+a.y)*this._transform[1]-a.z;b.x+=this.game.world.width*this.anchor.x;b.y+=this.game.world.height*this.anchor.y;return b},projectXY:function(a,b){"undefined"===typeof b&&(b=new Phaser.Point);b.x=(a.x-a.y)*this._transform[0];b.y=(a.x+a.y)*this._transform[1];b.x+=this.game.world.width*this.anchor.x;b.y+=this.game.world.height*this.anchor.y;return b},
unproject:function(a,b,c){"undefined"===typeof b&&(b=new Phaser.Plugin.Isometric.Point3);c=c||0;var d=a.x-this.game.world.x-this.game.world.width*this.anchor.x;a=a.y-this.game.world.y-this.game.world.height*this.anchor.y+c;b.x=d/(2*this._transform[0])+a/(2*this._transform[1]);b.y=-(d/(2*this._transform[0]))+a/(2*this._transform[1]);b.z=c;return b},simpleSort:function(a){a.sort("depth")},topologicalSort:function(a,b,c){function d(a){if(!1===a.isoVisitedFlag){a.isoVisitedFlag=!0;for(var b=a.isoSpritesBehind.length,
e=0;e<b&&null!==a.isoSpritesBehind[e];e++)d(a.isoSpritesBehind[e]),a.isoSpritesBehind[e]=null;a[c]=p++}}if(a instanceof Phaser.Group){var e=a.children;var f=!0}else if(a.length)e=a;else return;c=c||"isoDepth";"undefined"===typeof b&&(b=1.5);var g,h,k=e.length;for(g=0;g<k;g++){var l=e[g];var q=0;l.isoSpritesBehind||(l.isoSpritesBehind=[]);for(h=0;h<k;h++)if(g!=h){var m=e[h];var n=l.body||l.isoBounds;m._isoPosition.x+b<n.frontX-b&&m._isoPosition.y+b<n.frontY-b&&m._isoPosition.z+b<n.top-b&&(l.isoSpritesBehind[q++]=
m)}l.isoVisitedFlag=!1}var p=0;for(g=0;g<k;g++)d(e[g]);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.preRotation=this.rotation=a.rotation;this.sourceWidthY=this.sourceWidthX=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.angularDrag=this.angularAcceleration=this.angularVelocity=0;this.maxAngular=1E3;this.mass=1;this.speed=this.angle=0;this.facing=Phaser.NONE;this.immovable=!1;this.moves=!0;this.customSeparateZ=this.customSeparateY=this.customSeparateX=
!1;this.overlapZ=this.overlapY=this.overlapX=0;this.collideWorldBounds=this.embedded=!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._dz=this._dy=this._dx=
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);if(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(){if(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.embedded=this.blocked.backX=!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.preRotation=this.rotation=this.sprite.angle;if(this._reset||!0===this.sprite.fresh)this.prev.x=this.position.x,this.prev.y=this.position.y,this.prev.z=this.position.z;if(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;if(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()?0>this.deltaX()?this.facing=Phaser.Plugin.Isometric.BACKWARDX:0<this.deltaX()&&(this.facing=Phaser.Plugin.Isometric.FORWARDX):this.deltaAbsY()>=this.deltaAbsX()&&this.deltaAbsY()>=this.deltaAbsZ()?0>this.deltaY()?
this.facing=Phaser.Plugin.Isometric.BACKWARDY:0<this.deltaY()&&(this.facing=Phaser.Plugin.Isometric.FORWARDY):0>this.deltaZ()?this.facing=Phaser.Plugin.Isometric.DOWN:0<this.deltaZ()&&(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&&(0>this._dx&&this._dx<-this.deltaMax.x?this._dx=-this.deltaMax.x:0<this._dx&&this._dx>this.deltaMax.x&&(this._dx=this.deltaMax.x)),0!==this.deltaMax.y&&0!==this._dy&&
(0>this._dy&&this._dy<-this.deltaMax.y?this._dy=-this.deltaMax.y:0<this._dy&&this._dy>this.deltaMax.y&&(this._dy=this.deltaMax.y)),0!==this.deltaMax.z&&0!==this._dz&&(0>this._dz&&this._dz<-this.deltaMax.z?this._dz=-this.deltaMax.z:0<this._dz&&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.x<this.game.physics.isoArcade.bounds.x&&this.game.physics.isoArcade.checkCollision.backX?(this.position.x=this.game.physics.isoArcade.bounds.x,this.velocity.x*=-this.bounce.x,this.blocked.backX=!0):this.frontX>this.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.y<this.game.physics.isoArcade.bounds.y&&this.game.physics.isoArcade.checkCollision.backY?(this.position.y=this.game.physics.isoArcade.bounds.y,this.velocity.y*=-this.bounce.y,this.blocked.backY=!0):this.frontY>this.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.z<this.game.physics.isoArcade.bounds.z&&this.game.physics.isoArcade.checkCollision.down?(this.position.z=this.game.physics.isoArcade.bounds.z,this.velocity.z*=-this.bounce.z,this.blocked.down=!0):this.top>this.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.angularAcceleration=this.angularVelocity=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.preRotation=this.rotation=this.sprite.angle;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 0<this.deltaX()?this.deltaX():-this.deltaX()},deltaAbsY:function(){return 0<this.deltaY()?this.deltaY():-this.deltaY()},deltaAbsZ:function(){return 0<this.deltaZ()?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(){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);return 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=[];e=b.getCorners();var f=-b.sprite.game.camera.x,g=-b.sprite.game.camera.y;if(d){e=[e[1],e[3],e[2],e[6],e[4],e[5],e[1]];e=e.map(function(a){a=b.sprite.game.iso.project(a);a.x+=f;a.y+=g;return a});a.beginPath();a.fillStyle=c;a.moveTo(e[0].x,e[0].y);for(c=1;c<e.length;c++)a.lineTo(e[c].x,e[c].y);a.fill()}else e=e.slice(0,e.length),e=e.map(function(a){a=b.sprite.game.iso.project(a);a.x+=
f;a.y+=g;return a}),a.moveTo(e[0].x,e[0].y),a.beginPath(),a.strokeStyle=c,a.lineTo(e[1].x,e[1].y),a.lineTo(e[3].x,e[3].y),a.lineTo(e[2].x,e[2].y),a.lineTo(e[6].x,e[6].y),a.lineTo(e[4].x,e[4].y),a.lineTo(e[5].x,e[5].y),a.lineTo(e[1].x,e[1].y),a.lineTo(e[0].x,e[0].y),a.lineTo(e[4].x,e[4].y),a.moveTo(e[0].x,e[0].y),a.lineTo(e[2].x,e[2].y),a.moveTo(e[3].x,e[3].y),a.lineTo(e[7].x,e[7].y),a.lineTo(e[6].x,e[6].y),a.moveTo(e[7].x,e[7].y),a.lineTo(e[5].x,e[5].y),a.stroke(),a.closePath()};
Phaser.Plugin.Isometric.Body.renderBodyInfo=function(a,b){a.line("x: "+b.x.toFixed(2),"y: "+b.y.toFixed(2),"z: "+b.z.toFixed(2),"widthX: "+b.widthX,"widthY: "+b.widthY,"height: "+b.height);a.line("velocity x: "+b.velocity.x.toFixed(2),"y: "+b.velocity.y.toFixed(2),"z: "+b.velocity.z.toFixed(2),"deltaX: "+b._dx.toFixed(2),"deltaY: "+b._dy.toFixed(2),"deltaZ: "+b._dz.toFixed(2));a.line("acceleration x: "+b.acceleration.x.toFixed(2),"y: "+b.acceleration.y.toFixed(2),"z: "+b.acceleration.z.toFixed(2),
"speed: "+b.speed.toFixed(2),"angle: "+b.angle.toFixed(2));a.line("gravity x: "+b.gravity.x,"y: "+b.gravity.y,"z: "+b.gravity.z);a.line("bounce x: "+b.bounce.x.toFixed(2),"y: "+b.bounce.y.toFixed(2),"z: "+b.bounce.z.toFixed(2));a.line("touching: ","frontX: "+(b.touching.frontX?1:0)+" frontY: "+(b.touching.frontY?1:0)+" backX: "+(b.touching.backX?1:0)+" backY: "+(b.touching.backY?1:0)+" up: "+(b.touching.up?1:0)+" down: "+(b.touching.down?1:0));a.line("blocked: ","frontX: "+(b.blocked.frontX?1:0)+
" frontY: "+(b.blocked.frontY?1:0)+" backX: "+(b.blocked.backX?1:0)+" backY: "+(b.blocked.backY?1:0)+" up: "+(b.blocked.up?1:0)+" down: "+(b.blocked.down?1:0))};Phaser.Plugin.Isometric.Body.prototype.constructor=Phaser.Plugin.Isometric.Body;
Phaser.Utils.Debug.prototype.body=function(a){return function(b,c,d,e){b.body&&b.body.type===Phaser.Plugin.Isometric.ISOARCADE&&(this.start(),Phaser.Plugin.Isometric.Body.render(this.context,b.body,c,d),e&&this.text(b.depth.toFixed(2),b.x,b.y,c,"12px Courier"),this.stop());return a.call(this,b,c,d)}}(Phaser.Utils.Debug.prototype.body);
Phaser.Utils.Debug.prototype.bodyInfo=function(a){return function(b,c,d,e){b.body&&b.body.type===Phaser.Plugin.Isometric.ISOARCADE&&(this.start(c,d,e,210),Phaser.Plugin.Isometric.Body.renderBodyInfo(this,b.body),this.stop());return a.call(this,b,c,d,e)}}(Phaser.Utils.Debug.prototype.bodyInfo);
Phaser.Plugin.Isometric.Arcade=function(a){this.game=a;this.gravity=new Phaser.Plugin.Isometric.Point3;this.bounds=new Phaser.Plugin.Isometric.Cube(0,0,0,.5*a.world.width,.5*a.world.width,a.world.height);this.checkCollision={up:!0,down:!0,frontX:!0,frontY:!0,backX:!0,backY:!0};this.maxObjects=10;this.OVERLAP_BIAS=this.maxLevels=4;this.useQuadTree=this.skipTree=this.forceXY=!1;this.quadTree=new Phaser.QuadTree(this.bounds.x,this.bounds.y,this.bounds.widthX,this.bounds.widthY,this.maxObjects,this.maxLevels);
this.octree=new Phaser.Plugin.Isometric.Octree(this.bounds.x,this.bounds.y,this.bounds.z,this.bounds.widthX,this.bounds.widthY,this.bounds.height,this.maxObjects,this.maxLevels);this._average=this._newVelocity2=this._newVelocity1=this._velocity2=this._velocity1=this._maxOverlap=this._overlap=0;this._mapData=[];this._result=!1;this._dz=this._dy=this._dx=this._angle=this._total=0};Phaser.Plugin.Isometric.Arcade.prototype.constructor=Phaser.Plugin.Isometric.Arcade;
Phaser.Plugin.Isometric.Arcade.prototype={setBounds:function(a,b,c,d,e,f){this.bounds.setTo(a,b,c,d,e,f)},setBoundsToWorld:function(){this.bounds.setTo(0,0,0,.5*this.game.world.width,.5*this.game.world.width,this.game.world.height)},enable:function(a,b){"undefined"===typeof b&&(b=!0);var c;if(Array.isArray(a))for(c=a.length;c--;)a[c]instanceof Phaser.Group?this.enable(a[c].children,b):(this.enableBody(a[c]),b&&a[c].hasOwnProperty("children")&&0<a[c].children.length&&this.enable(a[c],!0));else a instanceof
Phaser.Group?this.enable(a.children,b):(this.enableBody(a),b&&a.hasOwnProperty("children")&&0<a.children.length&&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){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=0<c-this._drag?c-this._drag:0>c+this._drag?c+this._drag:0);c>f?c=f:c<-f&&(c=-f);return c},overlap:function(a,b,c,d,e){c=c||null;d=d||null;e=e||c;this._result=!1;this._total=0;if(Array.isArray(b))for(var f=0,g=b.length;f<g;f++)this.collideHandler(a,b[f],c,d,e,!0);else this.collideHandler(a,b,c,d,e,!0);return 0<this._total},collide:function(a,
b,c,d,e){c=c||null;d=d||null;e=e||c;this._result=!1;this._total=0;if(Array.isArray(b))for(var f=0,g=b.length;f<g;f++)this.collideHandler(a,b[f],c,d,e,!1);else this.collideHandler(a,b,c,d,e,!1);return 0<this._total},collideHandler:function(a,b,c,d,e,f){b||a.type!==Phaser.GROUP?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))):this.collideGroupVsSelf(a,c,d,e,f)},collideSpriteVsSprite:function(a,b,c,d,e,f){if(!a.body||!b.body)return!1;this.separate(a.body,b.body,d,e,f)&&(c&&c.call(e,a,b),this._total++);return!0},collideSpriteVsGroup:function(a,b,c,d,e,f){var g;if(0!==b.length&&a.body)if(a.body.skipTree||this.skipTree){var h=0;for(g=b.children.length;h<g;h++)b.children[h]&&
b.children[h].exists&&this.collideSpriteVsSprite(a,b.children[h],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)),h=0,g=this._potentials.length;h<g;h++)this.separate(a.body,this._potentials[h],d,e,f)&&(c&&c.call(e,a,this._potentials[h].sprite),this._total++)},collideGroupVsSelf:function(a,b,c,d,e){if(0!==a.length)for(var f=a.children.length,g=0;g<f;g++)for(var h=g+1;h<=f;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;g<h;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&&!1===c.call(d,a.sprite,b.sprite)?!1:e?!0:this._result=this.forceXY||Math.abs(this.gravity.z+a.gravity.z)<Math.abs(this.gravity.x+a.gravity.x)||Math.abs(this.gravity.z+a.gravity.z)<Math.abs(this.gravity.y+a.gravity.y)?this.separateX(a,b,e)||this.separateY(a,b,e)||this.separateZ(a,b,e):this.separateZ(a,
b,e)||this.separateX(a,b,e)||this.separateY(a,b,e)},intersects:function(a,b){return a.frontX<=b.x||a.frontY<=b.y||a.x>=b.frontX||a.y>=b.frontY||a.top<=b.z||a.z>=b.top?!1:!0},separateX:function(a,b,c){if(a.immovable&&b.immovable)return!1;this._overlap=0;if(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||!1===a.checkCollision.frontX||
!1===b.checkCollision.backX?this._overlap=0:(a.touching.none=!1,a.touching.frontX=!0,b.touching.none=!1,b.touching.backX=!0)):a.deltaX()<b.deltaX()&&(this._overlap=a.x-b.widthX-b.x,-this._overlap>this._maxOverlap||!1===a.checkCollision.backX||!1===b.checkCollision.frontX?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;if(c||a.customSeparateX||b.customSeparateX)return!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-=this._overlap,a.velocity.x=this._velocity2-this._velocity1*a.bounce.x):(this._overlap*=.5,a.x-=this._overlap,b.x+=this._overlap,this._newVelocity1=Math.sqrt(this._velocity2*this._velocity2*b.mass/a.mass)*(0<this._velocity2?1:-1),this._newVelocity2=Math.sqrt(this._velocity1*this._velocity1*a.mass/b.mass)*(0<this._velocity1?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);return!0}return!1},separateY:function(a,b,c){if(a.immovable&&b.immovable)return!1;this._overlap=0;if(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||!1===a.checkCollision.frontY||!1===b.checkCollision.backY?this._overlap=0:(a.touching.none=!1,a.touching.frontY=!0,b.touching.none=!1,b.touching.backY=!0)):a.deltaY()<b.deltaY()&&(this._overlap=a.y-b.widthY-b.y,-this._overlap>this._maxOverlap||!1===a.checkCollision.backY||!1===b.checkCollision.frontY?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;if(c||a.customSeparateY||b.customSeparateY)return!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-=this._overlap,a.velocity.y=this._velocity2-this._velocity1*a.bounce.y):(this._overlap*=.5,a.y-=this._overlap,b.y+=this._overlap,this._newVelocity1=Math.sqrt(this._velocity2*this._velocity2*b.mass/a.mass)*(0<this._velocity2?
1:-1),this._newVelocity2=Math.sqrt(this._velocity1*this._velocity1*a.mass/b.mass)*(0<this._velocity1?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);return!0}return!1},separateZ:function(a,b,c){if(a.immovable&&b.immovable)return!1;this._overlap=0;if(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||!1===a.checkCollision.down||!1===b.checkCollision.up?this._overlap=0:(a.touching.none=!1,a.touching.down=!0,b.touching.none=!1,b.touching.up=!0)):a.deltaZ()<b.deltaZ()&&(this._overlap=a.z-b.top,-this._overlap>this._maxOverlap||!1===a.checkCollision.up||!1===b.checkCollision.down?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;if(c||a.customSeparateY||b.customSeparateZ)return!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,b.y+=a.y-a.prev.y)):(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-=this._overlap,b.z+=this._overlap,this._newVelocity1=Math.sqrt(this._velocity2*this._velocity2*b.mass/a.mass)*(0<this._velocity2?1:-1),this._newVelocity2=Math.sqrt(this._velocity1*this._velocity1*a.mass/b.mass)*(0<this._velocity1?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);return!0}return!1},distanceBetween:function(a,b){this._dx=a.x-b.x;this._dy=a.y-b.y;this._dz=a.z-b.z;return Math.sqrt(this._dx*this._dx+this._dy*this._dy+this._dz*this._dz)},distanceToXY:function(a,b,c){this._dx=a.x-b;this._dy=a.y-c;return Math.sqrt(this._dx*this._dx+this._dy*this._dy)},distanceToXYZ:function(a,b,c,d){this._dx=a.x-b;this._dy=a.y-c;this._dz=a.z-d;return Math.sqrt(this._dx*this._dx+this._dy*this._dy+this._dz*this._dz)},distanceToPointer:function(a,b){b=b||this.game.input.activePointer;
b=this.game.iso.unproject(b.position,void 0,a.z);b.z=a.z;return this.anglesToXYZ(a,b.x,b.y,b.z).r},anglesToXYZ:function(a,b,c,d){var e=this.distanceToXYZ(a,b,c,d);return{r:e,theta:Math.atan2(c-a.y,b-a.x),phi:Math.acos((d-a.z)/e)}},angleToPointer:function(a,b){b=b||this.game.input.activePointer;b=this.game.iso.unproject(b.position,void 0,a.z);b.z=a.z;return this.anglesToXYZ(a,b.x,b.y,b.z).theta},velocityFromAngles:function(a,b,c,d){void 0===b&&(b=Math.sin(Math.PI/2));void 0===c&&(c=60);d||new Phaser.Point;
return 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);b=this.anglesToXYZ(a.body,b,c,d);e=this.velocityFromAngles(b.theta,b.phi,e);a.body.acceleration.setTo(e.x,e.y,e.z);a.body.maxVelocity.setTo(f,g,h);return b.theta},moveToXYZ:function(a,b,c,d,e,f){"undefined"===typeof e&&(e=60);"undefined"===typeof f&&(f=0);0<f&&(e=this.distanceToXYZ(a.body,
b,c,d)/(f/1E3));b=this.anglesToXYZ(a.body,b,c,d);e=this.velocityFromAngles(b.theta,b.phi,e);a.body.velocity.copyFrom(e);return b.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;c=this.game.iso.unproject(c.position,void 0,a.body.z);c.z=a.body.z;"undefined"===typeof b&&(b=60);"undefined"===typeof d&&(d=0);0<d&&(b=this.distanceToXYZ(a.body,c.x,c.y,c.z)/(d/1E3));d=this.anglesToXYZ(a.body,c.x,c.y,c.z);b=
this.velocityFromAngles(d.theta,d.phi,b);a.body.velocity.x=b.x;a.body.velocity.y=b.y;return d.theta}};Phaser.Physics.prototype.isoArcade=null;Phaser.Physics.prototype.parseConfig=function(a){return function(){this.config.hasOwnProperty("isoArcade")&&!0===this.config.isoArcade&&Phaser.Plugin.Isometric.hasOwnProperty("IsoArcade")&&(this.isoArcade=new Phaser.Plugin.Isometric(this.game,this.config));return a.call(this)}}(Phaser.Physics.prototype.parseConfig);
Phaser.Physics.prototype.startSystem=function(a){return function(b){b===Phaser.Plugin.Isometric.ISOARCADE&&null===this.isoArcade&&(this.isoArcade=new Phaser.Plugin.Isometric.Arcade(this.game),this.setBoundsToWorld());return a.call(this,b)}}(Phaser.Physics.prototype.startSystem);Phaser.Physics.prototype.enable=function(a){return function(b,c){c===Phaser.Plugin.Isometric.ISOARCADE&&this.isoArcade&&this.isoArcade.enable(b);return a.call(this,b,c)}}(Phaser.Physics.prototype.enable);
Phaser.Physics.prototype.setBoundsToWorld=function(a){return function(){this.isoArcade&&this.isoArcade.setBoundsToWorld();return a.call(this)}}(Phaser.Physics.prototype.setBoundsToWorld);Phaser.Physics.prototype.destroy=function(a){return function(){this.isoArcade=null;return a.call(this)}}(Phaser.Physics.prototype.destroy);