/* 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;dc&&(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=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.frontXb.frontX||a.y>b.frontY||a.z>b.top||a.topthis.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)));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=this.deltaAbsY()&&this.deltaAbsX()>=this.deltaAbsZ()?0>this.deltaX()?this.facing=Phaser.Plugin.Isometric.BACKWARDX:0=this.deltaAbsX()&&this.deltaAbsY()>=this.deltaAbsZ()?0>this.deltaY()? this.facing=Phaser.Plugin.Isometric.BACKWARDY:0this.deltaZ()?this.facing=Phaser.Plugin.Isometric.DOWN:0this._dx&&this._dx<-this.deltaMax.x?this._dx=-this.deltaMax.x:0this.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:0this.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:0this.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.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 0c+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=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()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 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()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)*(0b.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()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