!function(e){var t;"object"==typeof exports?module.exports=e():("undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.p2=e())}(function(){return function o(s,a,n){function h(i,e){if(!a[i]){if(!s[i]){var t="function"==typeof require&&require;if(!e&&t)return t(i,!0);if(c)return c(i,!0);throw new Error("Cannot find module '"+i+"'")}var r=a[i]={exports:{}};s[i][0].call(r.exports,function(e){var t=s[i][1][e];return h(t||e)},r,r.exports,o,s,a,n)}return a[i].exports}for(var c="function"==typeof require&&require,e=0;ee.vertices.length)throw new Error("lol2");if(t<0)throw new Error("lol3");for(var r=t;rt[e][0])&&(e=i);v.left(this.at(e-1),this.at(e),this.at(e+1))||this.reverse()},z.prototype.reverse=function(){for(var e=[],t=0,i=this.vertices.length;t!==i;t++)e.push(this.vertices.pop());this.vertices=e},z.prototype.isReflex=function(e){return v.right(this.at(e-1),this.at(e),this.at(e+1))};var h=[],c=[];function C(e,t,i,r,o){o=o||0;var s=t[1]-e[1],a=e[0]-t[0],n=s*e[0]+a*e[1],h=r[1]-i[1],c=i[0]-r[0],l=h*i[0]+c*i[1],m=s*c-h*a;return u.eq(m,0,o)?[0,0]:[(c*n-a*l)/m,(s*l-h*n)/m]}z.prototype.canSee=function(e,t){var i,r,o=h,s=c;if(v.leftOn(this.at(e+1),this.at(e),this.at(t))&&v.rightOn(this.at(e-1),this.at(e),this.at(t)))return!1;r=v.sqdist(this.at(e),this.at(t));for(var a=0;a!==this.vertices.length;++a)if((a+1)%this.vertices.length!==e&&a!==e&&v.leftOn(this.at(e),this.at(t),this.at(a+1))&&v.rightOn(this.at(e),this.at(t),this.at(a))&&(o[0]=this.at(e),o[1]=this.at(t),s[0]=this.at(a),s[1]=this.at(a+1),i=n.lineInt(o,s),v.sqdist(this.at(e),i) (http://steffe.se)",keywords:["p2.js","p2","physics","engine","2d"],main:"./src/p2.js",engines:{node:"*"},repository:{type:"git",url:"https://github.com/schteppe/p2.js.git"},bugs:{url:"https://github.com/schteppe/p2.js/issues"},licenses:[{type:"MIT"}],devDependencies:{grunt:"^0.4.5","grunt-contrib-jshint":"^0.11.2","grunt-contrib-nodeunit":"^0.4.1","grunt-contrib-uglify":"~0.4.0","grunt-contrib-watch":"~0.5.0","grunt-browserify":"~2.0.1","grunt-contrib-concat":"^0.4.0"},dependencies:{"poly-decomp":"0.1.0"}}},{}],7:[function(e,t,i){var d=e("../math/vec2");e("../utils/Utils");function r(e){this.lowerBound=d.create(),e&&e.lowerBound&&d.copy(this.lowerBound,e.lowerBound),this.upperBound=d.create(),e&&e.upperBound&&d.copy(this.upperBound,e.upperBound)}t.exports=r;var p=d.create();r.prototype.setFromPoints=function(e,t,i,r){var o=this.lowerBound,s=this.upperBound;"number"!=typeof i&&(i=0),0!==i?d.rotate(o,e[0],i):d.copy(o,e[0]),d.copy(s,o);for(var a=Math.cos(i),n=Math.sin(i),h=1;hs[u]&&(s[u]=c[u]),c[u]i&&(this.lowerBound[t]=i);var r=e.upperBound[t];this.upperBound[t]Math.pow(u,2))return 0;if(h)return!0;var d=this.createContactEquation(e,o,t,s);return W(d.normalA,a,i),U.normalize(d.normalA,d.normalA),U.scale(d.contactPointA,d.normalA,c),U.scale(d.contactPointB,d.normalA,-l),X(d.contactPointA,d.contactPointA,i),W(d.contactPointA,d.contactPointA,e.position),X(d.contactPointB,d.contactPointB,a),W(d.contactPointB,d.contactPointB,o.position),this.contactEquations.push(d),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(d)),1},$.prototype[c.PLANE|c.CONVEX]=$.prototype[c.PLANE|c.BOX]=$.prototype.planeConvex=function(e,t,i,r,o,s,a,n,h){var c=j,l=Y,m=V,u=0;U.rotate(l,C,r);for(var d=0;d!==s.vertices.length;d++){var p=s.vertices[d];if(U.rotate(c,p,n),X(c,c,a),W(m,c,i),H(m,l)<=0){if(h)return!0;u++;var f=this.createContactEquation(e,o,t,s);W(m,c,i),U.copy(f.normalA,l);var y=H(m,f.normalA);U.scale(m,f.normalA,y),W(f.contactPointB,c,o.position),W(f.contactPointA,c,m),W(f.contactPointA,f.contactPointA,e.position),this.contactEquations.push(f),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(f))}}return this.enableFrictionReduction&&this.enableFriction&&u&&this.frictionEquations.push(this.createFrictionFromAverage(u)),u},$.prototype[c.PARTICLE|c.PLANE]=$.prototype.particlePlane=function(e,t,i,r,o,s,a,n,h){var c=j,l=Y;n=n||0,W(c,i,a),U.rotate(l,C,n);var m=H(c,l);if(0Math.pow(t.radius,2))return 0;if(h)return!0;var l=this.createContactEquation(e,o,t,s);return U.copy(l.normalA,c),U.normalize(l.normalA,l.normalA),U.scale(l.contactPointA,l.normalA,t.radius),X(l.contactPointA,l.contactPointA,i),W(l.contactPointA,l.contactPointA,e.position),W(l.contactPointB,a,o.position),this.contactEquations.push(l),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(l)),1};var T=new n({radius:1}),P=U.create(),A=U.create();U.create();$.prototype[c.PLANE|c.CAPSULE]=$.prototype.planeCapsule=function(e,t,i,r,o,s,a,n,h){var c,l=P,m=A,u=T;U.set(l,-s.length/2,0),U.rotate(l,l,n),X(l,l,a),U.set(m,s.length/2,0),U.rotate(m,m,n),X(m,m,a),u.radius=s.radius,this.enableFrictionReduction&&(c=this.enableFriction,this.enableFriction=!1);var d=this.circlePlane(o,u,l,0,e,t,i,r,h),p=this.circlePlane(o,u,m,0,e,t,i,r,h);if(this.enableFrictionReduction&&(this.enableFriction=c),h)return d||p;var f=d+p;return this.enableFrictionReduction&&f&&this.frictionEquations.push(this.createFrictionFromAverage(f)),f},$.prototype[c.CIRCLE|c.PLANE]=$.prototype.circlePlane=function(e,t,i,r,o,s,a,n,h){var c=e,l=t,m=i,u=o,d=a,p=n;p=p||0;var f=j,y=Y,S=V;W(f,m,d),U.rotate(y,C,p);var w=H(y,f);if(w>l.radius)return 0;if(h)return!0;var g=this.createContactEquation(u,c,s,t);return U.copy(g.normalA,y),U.scale(g.contactPointB,g.normalA,-l.radius),X(g.contactPointB,g.contactPointB,m),W(g.contactPointB,g.contactPointB,c.position),U.scale(S,g.normalA,w),W(g.contactPointA,f,S),X(g.contactPointA,g.contactPointA,d),W(g.contactPointA,g.contactPointA,u.position),this.contactEquations.push(g),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(g)),1},$.prototype[c.CONVEX]=$.prototype[c.CONVEX|c.BOX]=$.prototype[c.BOX]=$.prototype.convexConvex=function(e,t,i,r,o,s,a,n,h,c){var l=j,m=Y,u=V,d=K,p=q,f=Z,y=J,S=Q,w=0;c="number"==typeof c?c:0;if(!$.findSeparatingAxis(t,i,r,s,a,n,l))return 0;W(y,a,i),0f[0]&&(b=p,x=f,!0),h=(v=b[0]-x[1])<=0,(null===n||nf[0]&&(b=p,x=f,!0),h=(v=b[0]-x[1])<=0,(null===n||n=l.length&&(x=l.length-1);for(var b=l[g],v=l[x],z=g;zb&&(b=l[z]);if(i[1]-c>b)return!h&&0;var C=!1;for(z=g;z=S[0]&&d[0]=c.length&&(y=c.length-1);for(var S=c[f],w=c[y],g=f;gS&&(S=c[g]);if(e.aabb.lowerBound[1]>S)return!h&&0;var x=0;for(g=f;gt.boundingRadius*t.boundingRadius||(this._currentBody=o,(this._currentShape=t).raycast(e,this,r,i),this._currentBody=this._currentShape=null)},a.prototype.getAABB=function(e){var t=this.to,i=this.from;h.set(e.lowerBound,Math.min(t[0],i[0]),Math.min(t[1],i[1])),h.set(e.upperBound,Math.max(t[0],i[0]),Math.max(t[1],i[1]))};h.create();a.prototype.reportIntersection=function(e,t,i,r){this.from,this.to;var o=this._currentShape,s=this._currentBody;if(!(this.skipBackfaces&&0this.upperLimit&&(s.maxForce=0,s.minForce=-this.maxForce,this.distance=this.upperLimit,n=!0),this.lowerLimitEnabled&&this.position>1;if(t<3)return[];for(var i=[],r=[],o=0;o3*s)break}return i.push(r[0],r[1],r[2]),i},_PointInTriangle:function(e,t,i,r,o,s,a,n){var h=a-i,c=n-r,l=o-i,m=s-r,u=e-i,d=t-r,p=h*h+c*c,f=h*l+c*m,y=h*u+c*d,S=l*l+m*m,w=l*u+m*d,g=1/(p*S-f*f),x=(S*y-f*w)*g,b=(p*w-f*y)*g;return 0<=x&&0<=b&&x+b<1},_convex:function(e,t,i,r,o,s){return 0<=(t-r)*(o-i)+(i-e)*(s-r)}};t.exports=w},{}],30:[function(e,t,i){var a=t.exports={},r=e("../utils/Utils");a.crossLength=function(e,t){return e[0]*t[1]-e[1]*t[0]},a.crossVZ=function(e,t,i){return a.rotate(e,t,-Math.PI/2),a.scale(e,e,i),e},a.crossZV=function(e,t,i){return a.rotate(e,i,Math.PI/2),a.scale(e,e,t),e},a.rotate=function(e,t,i){if(0!==i){var r=Math.cos(i),o=Math.sin(i),s=t[0],a=t[1];e[0]=r*s-o*a,e[1]=o*s+r*a}else e[0]=t[0],e[1]=t[1]},a.rotate90cw=function(e,t){var i=t[0],r=t[1];e[0]=r,e[1]=-i},a.toLocalFrame=function(e,t,i,r){a.copy(e,t),a.sub(e,e,i),a.rotate(e,e,-r)},a.toGlobalFrame=function(e,t,i,r){a.copy(e,t),a.rotate(e,e,r),a.add(e,e,i)},a.vectorToLocalFrame=function(e,t,i){a.rotate(e,t,-i)},a.vectorToGlobalFrame=function(e,t,i){a.rotate(e,t,i)},a.centroid=function(e,t,i,r){return a.add(e,t,i),a.add(e,e,r),a.scale(e,e,1/3),e},a.create=function(){var e=new r.ARRAY_TYPE(2);return e[0]=0,e[1]=0,e},a.clone=function(e){var t=new r.ARRAY_TYPE(2);return t[0]=e[0],t[1]=e[1],t},a.fromValues=function(e,t){var i=new r.ARRAY_TYPE(2);return i[0]=e,i[1]=t,i},a.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},a.set=function(e,t,i){return e[0]=t,e[1]=i,e},a.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e},a.subtract=function(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e},a.sub=a.subtract,a.multiply=function(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e},a.mul=a.multiply,a.divide=function(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e},a.div=a.divide,a.scale=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e},a.distance=function(e,t){var i=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(i*i+r*r)},a.dist=a.distance,a.squaredDistance=function(e,t){var i=t[0]-e[0],r=t[1]-e[1];return i*i+r*r},a.sqrDist=a.squaredDistance,a.length=function(e){var t=e[0],i=e[1];return Math.sqrt(t*t+i*i)},a.len=a.length,a.squaredLength=function(e){var t=e[0],i=e[1];return t*t+i*i},a.sqrLen=a.squaredLength,a.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},a.normalize=function(e,t){var i=t[0],r=t[1],o=i*i+r*r;return 0this.sleepTimeLimit&&(t?this.wantsToSleep=!0:this.sleep())}},n.prototype.overlaps=function(e){return this.world.overlapKeeper.bodiesAreOverlapping(this,e)};var z=m.create(),C=m.create();n.prototype.integrate=function(e){var t=this.invMass,i=this.force,r=this.position,o=this.velocity;m.copy(this.previousPosition,this.position),this.previousAngle=this.angle,this.fixedRotation||(this.angularVelocity+=this.angularForce*this.invInertia*e),m.scale(z,i,e*t),m.multiply(z,this.massMultiplier,z),m.add(o,z,o),this.integrateToTimeOfImpact(e)||(m.scale(C,o,e),m.add(r,r,C),this.fixedRotation||(this.angle+=this.angularVelocity*e)),this.aabbNeedsUpdate=!0};var T=new r,P=new o({mode:o.ALL}),A=m.create(),_=m.create(),B=m.create(),D=m.create();n.prototype.integrateToTimeOfImpact=function(e){if(this.ccdSpeedThreshold<0||m.squaredLength(this.velocity)d&&(v.sub(n,a,h),v.normalize(n,n),t.reportIntersection(e,p,n,-1),e.shouldStop(t)))return}else{var w=Math.sqrt(p),g=1/(2*f),x=(-y-w)*g,b=(-y+w)*g;if(0<=x&&x<=1&&(v.lerp(a,o,s,x),v.squaredDistance(a,i)>d&&(v.sub(n,a,h),v.normalize(n,n),t.reportIntersection(e,x,n,-1),e.shouldStop(t))))return;if(0<=b&&b<=1&&(v.lerp(a,o,s,b),v.squaredDistance(a,i)>d&&(v.sub(n,a,h),v.normalize(n,n),t.reportIntersection(e,b,n,-1),e.shouldStop(t))))return}}}},{"../math/vec2":30,"./Shape":45}],39:[function(e,t,i){var r=e("./Shape"),S=e("../math/vec2");function o(e){"number"==typeof e&&(e={radius:e}),e=e||{},this.radius=e.radius||1,e.type=r.CIRCLE,r.call(this,e)}(((t.exports=o).prototype=new r).constructor=o).prototype.computeMomentOfInertia=function(e){var t=this.radius;return e*t*t/2},o.prototype.updateBoundingRadius=function(){this.boundingRadius=this.radius},o.prototype.updateArea=function(){this.area=Math.PI*this.radius*this.radius},o.prototype.computeAABB=function(e,t,i){var r=this.radius;S.set(e.upperBound,r,r),S.set(e.lowerBound,-r,-r),t&&(S.add(e.lowerBound,e.lowerBound,t),S.add(e.upperBound,e.upperBound,t))};var w=S.create(),g=S.create();o.prototype.raycast=function(e,t,i,r){var o=t.from,s=t.to,a=this.radius,n=Math.pow(s[0]-o[0],2)+Math.pow(s[1]-o[1],2),h=2*((s[0]-o[0])*(o[0]-i[0])+(s[1]-o[1])*(o[1]-i[1])),c=Math.pow(o[0]-i[0],2)+Math.pow(o[1]-i[1],2)-Math.pow(a,2),l=Math.pow(h,2)-4*n*c,m=w,u=g;if(!(l<0))if(0===l)S.lerp(m,o,s,l),S.sub(u,m,i),S.normalize(u,u),t.reportIntersection(e,l,u,-1);else{var d=Math.sqrt(l),p=1/(2*n),f=(-h-d)*p,y=(-h+d)*p;if(0<=f&&f<=1&&(S.lerp(m,o,s,f),S.sub(u,m,i),S.normalize(u,u),t.reportIntersection(e,f,u,-1),e.shouldStop(t)))return;0<=y&&y<=1&&(S.lerp(m,o,s,y),S.sub(u,m,i),S.normalize(u,u),t.reportIntersection(e,y,u,-1))}}},{"../math/vec2":30,"./Shape":45}],40:[function(e,t,i){var h=e("./Shape"),d=e("../math/vec2"),n=e("../math/polyk");e("poly-decomp");function u(e){Array.isArray(e)&&(e={vertices:e,axes:arguments[1]}),e=e||{},this.vertices=[];for(var t=void 0!==e.vertices?e.vertices:[],i=0;ie;)t.pop();for(;t.length=e&&r=this.children.length)throw new Error("The supplied index is out of bounds");var i=this.getChildIndex(e);this.children.splice(i,1),this.children.splice(t,0,e)},I.DisplayObjectContainer.prototype.getChildAt=function(e){if(e<0||e>=this.children.length)throw new Error("getChildAt: Supplied index "+e+" does not exist in the child list, or the supplied DisplayObject must be a child of the caller");return this.children[e]},I.DisplayObjectContainer.prototype.removeChild=function(e){var t=this.children.indexOf(e);if(-1!==t)return this.removeChildAt(t)},I.DisplayObjectContainer.prototype.removeChildAt=function(e){var t=this.getChildAt(e);return t&&(t.parent=void 0,this.children.splice(e,1)),t},I.DisplayObjectContainer.prototype.removeChildren=function(e,t){void 0===e&&(e=0),void 0===t&&(t=this.children.length);var i=t-e;if(0>16&255)/255,(e>>8&255)/255,(255&e)/255]},I.rgb2hex=function(e){return(255*e[0]<<16)+(255*e[1]<<8)+255*e[2]},I.canUseNewCanvasBlendModes=function(){if(void 0===document)return!1;var e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/",t="AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==",i=new Image;i.src=e+"AP804Oa6"+t;var r=new Image;r.src=e+"/wCKxvRF"+t;var o=I.CanvasPool.create(this,6,1).getContext("2d");if(o.globalCompositeOperation="multiply",o.drawImage(i,0,0),o.drawImage(r,2,0),!o.getImageData(2,0,1,1))return!1;var s=o.getImageData(2,0,1,1).data;return I.CanvasPool.remove(this),255===s[0]&&0===s[1]&&0===s[2]},I.getNextPowerOfTwo=function(e){if(0=this.size&&(this.flush(),this.currentBaseTexture=i.baseTexture);var o=i._uvs;if(o){var s,a,n,h,c=e.anchor.x,l=e.anchor.y;if(i.trim){var m=i.trim;s=(a=m.x-c*m.width)+i.crop.width,n=(h=m.y-l*m.height)+i.crop.height}else s=i.frame.width*(1-c),a=i.frame.width*-c,n=i.frame.height*(1-l),h=i.frame.height*-l;var u=4*this.currentBatchSize*this.vertSize,d=i.baseTexture.resolution,p=r.a/d,f=r.b/d,y=r.c/d,S=r.d/d,w=r.tx,g=r.ty,x=this.colors,b=this.positions;this.renderSession.roundPixels?(b[u]=p*a+y*h+w|0,b[u+1]=S*h+f*a+g|0,b[u+5]=p*s+y*h+w|0,b[u+6]=S*h+f*s+g|0,b[u+10]=p*s+y*n+w|0,b[u+11]=S*n+f*s+g|0,b[u+15]=p*a+y*n+w|0,b[u+16]=S*n+f*a+g|0):(b[u]=p*a+y*h+w,b[u+1]=S*h+f*a+g,b[u+5]=p*s+y*h+w,b[u+6]=S*h+f*s+g,b[u+10]=p*s+y*n+w,b[u+11]=S*n+f*s+g,b[u+15]=p*a+y*n+w,b[u+16]=S*n+f*a+g),b[u+2]=o.x0,b[u+3]=o.y0,b[u+7]=o.x1,b[u+8]=o.y1,b[u+12]=o.x2,b[u+13]=o.y2,b[u+17]=o.x3,b[u+18]=o.y3;var v=e.tint;x[u+4]=x[u+9]=x[u+14]=x[u+19]=(v>>16)+(65280&v)+((255&v)<<16)+(255*e.worldAlpha<<24),this.sprites[this.currentBatchSize++]=e}},I.WebGLSpriteBatch.prototype.renderTilingSprite=function(e){var t=e.tilingTexture;this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=t.baseTexture),e._uvs||(e._uvs=new I.TextureUvs);var i=e._uvs,r=t.baseTexture.width,o=t.baseTexture.height;e.tilePosition.x%=r*e.tileScaleOffset.x,e.tilePosition.y%=o*e.tileScaleOffset.y;var s=e.tilePosition.x/(r*e.tileScaleOffset.x),a=e.tilePosition.y/(o*e.tileScaleOffset.y),n=e.width/r/(e.tileScale.x*e.tileScaleOffset.x),h=e.height/o/(e.tileScale.y*e.tileScaleOffset.y);i.x0=0-s,i.y0=0-a,i.x1=1*n-s,i.y1=0-a,i.x2=1*n-s,i.y2=1*h-a,i.x3=0-s,i.y3=1*h-a;var c=e.tint,l=(c>>16)+(65280&c)+((255&c)<<16)+(255*e.worldAlpha<<24),m=this.positions,u=this.colors,d=e.width,p=e.height,f=e.anchor.x,y=e.anchor.y,S=d*(1-f),w=d*-f,g=p*(1-y),x=p*-y,b=4*this.currentBatchSize*this.vertSize,v=t.baseTexture.resolution,z=e.worldTransform,C=z.a/v,T=z.b/v,P=z.c/v,A=z.d/v,_=z.tx,B=z.ty;m[b++]=C*w+P*x+_,m[b++]=A*x+T*w+B,m[b++]=i.x0,m[b++]=i.y0,u[b++]=l,m[b++]=C*S+P*x+_,m[b++]=A*x+T*S+B,m[b++]=i.x1,m[b++]=i.y1,u[b++]=l,m[b++]=C*S+P*g+_,m[b++]=A*g+T*S+B,m[b++]=i.x2,m[b++]=i.y2,u[b++]=l,m[b++]=C*w+P*g+_,m[b++]=A*g+T*w+B,m[b++]=i.x3,m[b++]=i.y3,u[b++]=l,this.sprites[this.currentBatchSize++]=e},I.WebGLSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var e,t,i,r,o=this.gl;if(this.dirty){this.dirty=!1,o.activeTexture(o.TEXTURE0),o.bindBuffer(o.ARRAY_BUFFER,this.vertexBuffer),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,this.indexBuffer),e=this.defaultShader.shaders[o.id];var s=4*this.vertSize;o.vertexAttribPointer(e.aVertexPosition,2,o.FLOAT,!1,s,0),o.vertexAttribPointer(e.aTextureCoord,2,o.FLOAT,!1,s,8),o.vertexAttribPointer(e.colorAttribute,4,o.UNSIGNED_BYTE,!0,s,16)}if(this.currentBatchSize>.5*this.size)o.bufferSubData(o.ARRAY_BUFFER,0,this.vertices);else{var a=this.positions.subarray(0,4*this.currentBatchSize*this.vertSize);o.bufferSubData(o.ARRAY_BUFFER,0,a)}for(var n,h=0,c=0,l=null,m=this.renderSession.blendModeManager.currentBlendMode,u=null,d=!1,p=!1,f=0,y=this.currentBatchSize;f=this.size&&this.flush()}},I.WebGLFastSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var e=this.gl;if(this.currentBaseTexture._glTextures[e.id]||this.renderSession.renderer.updateTexture(this.currentBaseTexture,e),e.bindTexture(e.TEXTURE_2D,this.currentBaseTexture._glTextures[e.id]),this.currentBatchSize>.5*this.size)e.bufferSubData(e.ARRAY_BUFFER,0,this.vertices);else{var t=this.vertices.subarray(0,4*this.currentBatchSize*this.vertSize);e.bufferSubData(e.ARRAY_BUFFER,0,t)}e.drawElements(e.TRIANGLES,6*this.currentBatchSize,e.UNSIGNED_SHORT,0),this.currentBatchSize=0,this.renderSession.drawCount++}},I.WebGLFastSpriteBatch.prototype.stop=function(){this.flush()},I.WebGLFastSpriteBatch.prototype.start=function(){var e=this.gl;e.activeTexture(e.TEXTURE0),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var t=this.renderSession.projection;e.uniform2f(this.shader.projectionVector,t.x,t.y),e.uniformMatrix3fv(this.shader.uMatrix,!1,this.matrix);var i=4*this.vertSize;e.vertexAttribPointer(this.shader.aVertexPosition,2,e.FLOAT,!1,i,0),e.vertexAttribPointer(this.shader.aPositionCoord,2,e.FLOAT,!1,i,8),e.vertexAttribPointer(this.shader.aScale,2,e.FLOAT,!1,i,16),e.vertexAttribPointer(this.shader.aRotation,1,e.FLOAT,!1,i,24),e.vertexAttribPointer(this.shader.aTextureCoord,2,e.FLOAT,!1,i,28),e.vertexAttribPointer(this.shader.colorAttribute,1,e.FLOAT,!1,i,36)},I.WebGLFilterManager=function(){this.filterStack=[],this.offsetX=0,this.offsetY=0},I.WebGLFilterManager.prototype.constructor=I.WebGLFilterManager,I.WebGLFilterManager.prototype.setContext=function(e){this.gl=e,this.texturePool=[],this.initShaderBuffers()},I.WebGLFilterManager.prototype.begin=function(e,t){this.renderSession=e,this.defaultShader=e.shaderManager.defaultShader;var i=this.renderSession.projection;this.width=2*i.x,this.height=2*-i.y,this.buffer=t},I.WebGLFilterManager.prototype.pushFilter=function(e){var t=this.gl,i=this.renderSession.projection,r=this.renderSession.offset;e._filterArea=e.target.filterArea||e.target.getBounds(),e._previous_stencil_mgr=this.renderSession.stencilManager,this.renderSession.stencilManager=new I.WebGLStencilManager,this.renderSession.stencilManager.setContext(t),t.disable(t.STENCIL_TEST),this.filterStack.push(e);var o=e.filterPasses[0];this.offsetX+=e._filterArea.x,this.offsetY+=e._filterArea.y;var s=this.texturePool.pop();s?s.resize(this.width*this.renderSession.resolution,this.height*this.renderSession.resolution):s=new I.FilterTexture(this.gl,this.width*this.renderSession.resolution,this.height*this.renderSession.resolution),t.bindTexture(t.TEXTURE_2D,s.texture);var a=e._filterArea,n=o.padding;a.x-=n,a.y-=n,a.width+=2*n,a.height+=2*n,a.x<0&&(a.x=0),a.width>this.width&&(a.width=this.width),a.y<0&&(a.y=0),a.height>this.height&&(a.height=this.height),t.bindFramebuffer(t.FRAMEBUFFER,s.frameBuffer),t.viewport(0,0,a.width*this.renderSession.resolution,a.height*this.renderSession.resolution),i.x=a.width/2,i.y=-a.height/2,r.x=-a.x,r.y=-a.y,t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),e._glFilterTexture=s},I.WebGLFilterManager.prototype.popFilter=function(){var e=this.gl,t=this.filterStack.pop(),i=t._filterArea,r=t._glFilterTexture,o=this.renderSession.projection,s=this.renderSession.offset;if(1this.baseTexture.width||e.y+e.height>this.baseTexture.height))this.valid=e&&e.width&&e.height&&this.baseTexture.source&&this.baseTexture.hasLoaded,this.trim&&(this.width=this.trim.width,this.height=this.trim.height,this.frame.width=this.trim.width,this.frame.height=this.trim.height),this.valid&&this._updateUvs();else{if(!I.TextureSilentFail)throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);this.valid=!1}},I.Texture.prototype._updateUvs=function(){this._uvs||(this._uvs=new I.TextureUvs);var e=this.crop,t=this.baseTexture.width,i=this.baseTexture.height;this._uvs.x0=e.x/t,this._uvs.y0=e.y/i,this._uvs.x1=(e.x+e.width)/t,this._uvs.y1=e.y/i,this._uvs.x2=(e.x+e.width)/t,this._uvs.y2=(e.y+e.height)/i,this._uvs.x3=e.x/t,this._uvs.y3=(e.y+e.height)/i},I.Texture.fromCanvas=function(e,t){var i=I.BaseTexture.fromCanvas(e,t);return new I.Texture(i)},I.TextureUvs=function(){this.x0=0,this.y0=0,this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.x3=0,this.y3=0},I.RenderTexture=function(e,t,i,r,o){if(this.width=e||100,this.height=t||100,this.resolution=o||1,this.frame=new I.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution),this.crop=new I.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution),this.baseTexture=new I.BaseTexture,this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution,this.baseTexture._glTextures=[],this.baseTexture.resolution=this.resolution,this.baseTexture.scaleMode=r||I.scaleModes.DEFAULT,this.baseTexture.hasLoaded=!0,I.Texture.call(this,this.baseTexture,new I.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution)),this.renderer=i||I.defaultRenderer,this.renderer.type===I.WEBGL_RENDERER){var s=this.renderer.gl;this.baseTexture._dirty[s.id]=!1,this.textureBuffer=new I.FilterTexture(s,this.width,this.height,this.baseTexture.scaleMode),this.baseTexture._glTextures[s.id]=this.textureBuffer.texture,this.render=this.renderWebGL,this.projection=new I.Point(.5*this.width,.5*-this.height)}else this.render=this.renderCanvas,this.textureBuffer=new I.CanvasBuffer(this.width*this.resolution,this.height*this.resolution),this.baseTexture.source=this.textureBuffer.canvas;this.valid=!0,this.tempMatrix=new Phaser.Matrix,this._updateUvs()},I.RenderTexture.prototype=Object.create(I.Texture.prototype),I.RenderTexture.prototype.constructor=I.RenderTexture,I.RenderTexture.prototype.resize=function(e,t,i){e===this.width&&t===this.height||(this.valid=0>>0;if("function"!=typeof e)throw new TypeError;for(var r=2<=arguments.length?arguments[1]:void 0,o=0;o=(e=e.toString()).length)switch(r){case 1:e=new Array(t+1-e.length).join(i)+e;break;case 3:var s=Math.ceil((o=t-e.length)/2);e=new Array(o-s+1).join(i)+e+new Array(s+1).join(i);break;default:e+=new Array(t+1-e.length).join(i)}return e},isPlainObject:function(e){if("object"!=typeof e||e.nodeType||e===e.window)return!1;try{if(e.constructor&&!{}.hasOwnProperty.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(e){return!1}return!0},extend:function(){var e,t,i,r,o,s,a=arguments[0]||{},n=1,h=arguments.length,c=!1;for("boolean"==typeof a&&(c=a,a=arguments[1]||{},n=2),h===n&&(a=this,--n);nthis.x?(this._radius=0,this._diameter=0):this.radius=this.x-e}}),Object.defineProperty(W.Circle.prototype,"right",{get:function(){return this.x+this._radius},set:function(e){ethis.y?(this._radius=0,this._diameter=0):this.radius=this.y-e}}),Object.defineProperty(W.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(e){e=e.left&&t<=e.right&&i>=e.top&&i<=e.bottom&&(e.x-t)*(e.x-t)+(e.y-i)*(e.y-i)<=e.radius*e.radius},W.Circle.equals=function(e,t){return e.x===t.x&&e.y===t.y&&e.diameter===t.diameter},W.Circle.intersects=function(e,t){return W.Math.distance(e.x,e.y,t.x,t.y)<=e.radius+t.radius},W.Circle.circumferencePoint=function(e,t,i,r){return void 0===i&&(i=!1),void 0===r&&(r=new W.Point),!0===i&&(t=W.Math.degToRad(t)),r.x=e.x+e.radius*Math.cos(t),r.y=e.y+e.radius*Math.sin(t),r},W.Circle.intersectsRectangle=function(e,t){var i=Math.abs(e.x-t.x-t.halfWidth);if(t.halfWidth+e.radius=this.right?this.width=0:this.width=this.right-e,this.x=e}}),Object.defineProperty(W.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(e){e<=this.x?this.width=0:this.width=e-this.x}}),Object.defineProperty(W.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}}),Object.defineProperty(W.Rectangle.prototype,"perimeter",{get:function(){return 2*this.width+2*this.height}}),Object.defineProperty(W.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(e){this.x=e-this.halfWidth}}),Object.defineProperty(W.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(e){this.y=e-this.halfHeight}}),Object.defineProperty(W.Rectangle.prototype,"randomX",{get:function(){return this.x+Math.random()*this.width}}),Object.defineProperty(W.Rectangle.prototype,"randomY",{get:function(){return this.y+Math.random()*this.height}}),Object.defineProperty(W.Rectangle.prototype,"top",{get:function(){return this.y},set:function(e){e>=this.bottom?(this.height=0,this.y=e):this.height=this.bottom-e}}),Object.defineProperty(W.Rectangle.prototype,"topLeft",{get:function(){return new W.Point(this.x,this.y)},set:function(e){this.x=e.x,this.y=e.y}}),Object.defineProperty(W.Rectangle.prototype,"topRight",{get:function(){return new W.Point(this.x+this.width,this.y)},set:function(e){this.right=e.x,this.y=e.y}}),Object.defineProperty(W.Rectangle.prototype,"empty",{get:function(){return!this.width||!this.height},set:function(e){!0===e&&this.setTo(0,0,0,0)}}),W.Rectangle.prototype.constructor=W.Rectangle,W.Rectangle.inflate=function(e,t,i){return e.x-=t,e.width+=2*t,e.y-=i,e.height+=2*i,e},W.Rectangle.inflatePoint=function(e,t){return W.Rectangle.inflate(e,t.x,t.y)},W.Rectangle.size=function(e,t){return null==t?t=new W.Point(e.width,e.height):t.setTo(e.width,e.height),t},W.Rectangle.clone=function(e,t){return null==t?t=new W.Rectangle(e.x,e.y,e.width,e.height):t.setTo(e.x,e.y,e.width,e.height),t},W.Rectangle.contains=function(e,t,i){return!(e.width<=0||e.height<=0)&&(t>=e.x&&t=e.y&&it.volume)&&(e.x>=t.x&&e.y>=t.y&&e.rightt.right||e.y>t.bottom)},W.Rectangle.intersectsRaw=function(e,t,i,r,o,s){return void 0===s&&(s=0),!(t>e.right+s||ie.bottom+s||oi&&(i=e.x),e.xo&&(o=e.y),e.ythis.deadzone.right&&(this.view.x=this.game.math.linear(this.view.x,this._targetPosition.x-this.deadzone.right,this.lerp.x)),this._edge=this._targetPosition.y-this.view.y,this._edgethis.deadzone.bottom&&(this.view.y=this.game.math.linear(this.view.y,this._targetPosition.y-this.deadzone.bottom,this.lerp.y))):(this.view.x=this.game.math.linear(this.view.x,this._targetPosition.x-this.view.halfWidth,this.lerp.x),this.view.y=this.game.math.linear(this.view.y,this._targetPosition.y-this.view.halfHeight,this.lerp.y)),this.bounds&&this.checkBounds(),this.roundPx&&this.view.floor(),this.displayObject.position.x=-this.view.x,this.displayObject.position.y=-this.view.y},setBoundsToWorld:function(){this.bounds&&this.bounds.copyFrom(this.game.world.bounds)},checkBounds:function(){this.atLimit.x=!1,this.atLimit.y=!1;var e=this.view.x+this._shake.x,t=this.view.right+this._shake.x,i=this.view.y+this._shake.y,r=this.view.bottom+this._shake.y;e<=this.bounds.x*this.scale.x&&(this.atLimit.x=!0,this.view.x=this.bounds.x*this.scale.x,this._shake.shakeBounds||(this._shake.x=0)),t>=this.bounds.right*this.scale.x&&(this.atLimit.x=!0,this.view.x=this.bounds.right*this.scale.x-this.width,this._shake.shakeBounds||(this._shake.x=0)),i<=this.bounds.top*this.scale.y&&(this.atLimit.y=!0,this.view.y=this.bounds.top*this.scale.y,this._shake.shakeBounds||(this._shake.y=0)),r>=this.bounds.bottom*this.scale.y&&(this.atLimit.y=!0,this.view.y=this.bounds.bottom*this.scale.y-this.height,this._shake.shakeBounds||(this._shake.y=0))},setPosition:function(e,t){this.view.x=e,this.view.y=t,this.bounds&&this.checkBounds()},setSize:function(e,t){this.view.width=e,this.view.height=t},reset:function(){this.target=null,this.view.x=0,this.view.y=0,this._shake.duration=0,this.resetFX()},resetFX:function(){this.fx&&(this.fx.clear(),this.fx.alpha=0,this._fxDuration=0)}},W.Camera.prototype.constructor=W.Camera,Object.defineProperty(W.Camera.prototype,"x",{get:function(){return this.view.x},set:function(e){this.view.x=e,this.bounds&&this.checkBounds()}}),Object.defineProperty(W.Camera.prototype,"y",{get:function(){return this.view.y},set:function(e){this.view.y=e,this.bounds&&this.checkBounds()}}),Object.defineProperty(W.Camera.prototype,"position",{get:function(){return this._position.set(this.view.x,this.view.y),this._position},set:function(e){void 0!==e.x&&(this.view.x=e.x),void 0!==e.y&&(this.view.y=e.y),this.bounds&&this.checkBounds()}}),Object.defineProperty(W.Camera.prototype,"width",{get:function(){return this.view.width},set:function(e){this.view.width=e}}),Object.defineProperty(W.Camera.prototype,"height",{get:function(){return this.view.height},set:function(e){this.view.height=e}}),Object.defineProperty(W.Camera.prototype,"shakeIntensity",{get:function(){return this._shake.intensity},set:function(e){this._shake.intensity=e}}),W.State=function(){this.game=null,this.key="",this.add=null,this.make=null,this.camera=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.sound=null,this.scale=null,this.stage=null,this.state=null,this.time=null,this.tweens=null,this.world=null,this.particles=null,this.physics=null,this.rnd=null},W.State.prototype={init:function(){},preload:function(){},loadUpdate:function(){},loadRender:function(){},create:function(){},update:function(){},preRender:function(){},render:function(){},resize:function(){},paused:function(){},resumed:function(){},pauseUpdate:function(){},shutdown:function(){}},W.State.prototype.constructor=W.State,W.StateManager=function(e,t){this.game=e,this.states={},(this._pendingState=null)!=t&&(this._pendingState=t),this._clearWorld=!1,this._clearCache=!1,this._created=!1,this._args=[],this.current="",this.onStateChange=new W.Signal,this.onInitCallback=null,this.onPreloadCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onRenderCallback=null,this.onResizeCallback=null,this.onPreRenderCallback=null,this.onLoadUpdateCallback=null,this.onLoadRenderCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null,this.onShutDownCallback=null},W.StateManager.prototype={boot:function(){this.game.onPause.add(this.pause,this),this.game.onResume.add(this.resume,this),null!==this._pendingState&&"string"!=typeof this._pendingState&&this.add("default",this._pendingState,!0)},add:function(e,t,i){var r;return void 0===i&&(i=!1),t instanceof W.State?r=t:"object"==typeof t?(r=t).game=this.game:"function"==typeof t&&(r=new t(this.game)),this.states[e]=r,i&&(this.game.isBooted?this.start(e):this._pendingState=e),r},remove:function(e){this.current===e&&(this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onPreRenderCallback=null,this.onRenderCallback=null,this.onResizeCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null),delete this.states[e]},start:function(e,t,i){void 0===t&&(t=!0),void 0===i&&(i=!1),this.checkState(e)&&(this._pendingState=e,this._clearWorld=t,this._clearCache=i,3=this.children.length?-1:this.getChildAt(e)},W.Group.prototype.create=function(e,t,i,r,o,s){void 0===o&&(o=!0);var a=new this.classType(this.game,e,t,i,r);return a.exists=o,a.visible=o,a.alive=o,this.add(a,!1,s)},W.Group.prototype.createMultiple=function(r,e,t,o){void 0===t&&(t=0),void 0===o&&(o=!1),Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]);var s=this,a=[];return e.forEach(function(i){t.forEach(function(e){for(var t=0;tthis.children.length||-1===e&&-1===t)return!1;for(var a=new W.Rectangle(0,0,i,r),n=e*i,h=t*r,c=s;cthis.children.length-1&&(e=0),this.cursor)return this.cursorIndex=e,this.cursor=this.children[this.cursorIndex],this.cursor},W.Group.prototype.next=function(){if(this.cursor)return this.cursorIndex>=this.children.length-1?this.cursorIndex=0:this.cursorIndex++,this.cursor=this.children[this.cursorIndex],this.cursor},W.Group.prototype.previous=function(){if(this.cursor)return 0===this.cursorIndex?this.cursorIndex=this.children.length-1:this.cursorIndex--,this.cursor=this.children[this.cursorIndex],this.cursor},W.Group.prototype.swap=function(e,t){this.swapChildren(e,t),this.updateZ()},W.Group.prototype.bringToTop=function(e){return e.parent===this&&this.getIndex(e)this.children.length)return-1;this.getChildAt(e).x=t,this.getChildAt(e).y=i},W.Group.prototype.reverse=function(){this.children.reverse(),this.updateZ()},W.Group.prototype.getIndex=function(e){return this.children.indexOf(e)},W.Group.prototype.getByName=function(e){for(var t=0;tt[this._sortProperty]?1:e.zt[this._sortProperty]?-1:0},W.Group.prototype.iterate=function(e,t,i,r,o,s){if(0===this.children.length){if(i===W.Group.RETURN_TOTAL)return 0;if(i===W.Group.RETURN_ALL)return[]}var a=0;if(i===W.Group.RETURN_ALL)var n=[];for(var h=0;hthis.children.length)return!1;for(var o=t;e<=o;){!r&&this.children[o].events&&this.children[o].events.onRemovedFromGroup$dispatch(this.children[o],this);var s=this.removeChild(this.children[o]);this.removeFromHash(s),i&&s&&s.destroy(!0),this.cursor===this.children[o]&&(this.cursor=null),o--}this.updateZ()}},W.Group.prototype.destroy=function(e,t){null===this.game||this.ignoreDestroy||(void 0===e&&(e=!0),void 0===t&&(t=!1),this.onDestroy.dispatch(this,e,t),this.removeAll(e),this.cursor=null,this.filters=null,this.pendingDestroy=!1,t||(this.parent&&this.parent.removeChild(this),this.game=null,this.exists=!1))},Object.defineProperty(W.Group.prototype,"total",{get:function(){return this.iterate("exists",!0,W.Group.RETURN_TOTAL)}}),Object.defineProperty(W.Group.prototype,"length",{get:function(){return this.children.length}}),Object.defineProperty(W.Group.prototype,"angle",{get:function(){return W.Math.radToDeg(this.rotation)},set:function(e){this.rotation=W.Math.degToRad(e)}}),Object.defineProperty(W.Group.prototype,"centerX",{get:function(){return this.getBounds(this.parent).centerX},set:function(e){var t=this.getBounds(this.parent),i=this.x-t.x;this.x=e+i-t.halfWidth}}),Object.defineProperty(W.Group.prototype,"centerY",{get:function(){return this.getBounds(this.parent).centerY},set:function(e){var t=this.getBounds(this.parent),i=this.y-t.y;this.y=e+i-t.halfHeight}}),Object.defineProperty(W.Group.prototype,"left",{get:function(){return this.getBounds(this.parent).left},set:function(e){var t=this.getBounds(this.parent),i=this.x-t.x;this.x=e+i}}),Object.defineProperty(W.Group.prototype,"right",{get:function(){return this.getBounds(this.parent).right},set:function(e){var t=this.getBounds(this.parent),i=this.x-t.x;this.x=e+i-t.width}}),Object.defineProperty(W.Group.prototype,"top",{get:function(){return this.getBounds(this.parent).top},set:function(e){var t=this.getBounds(this.parent),i=this.y-t.y;this.y=e+i}}),Object.defineProperty(W.Group.prototype,"bottom",{get:function(){return this.getBounds(this.parent).bottom},set:function(e){var t=this.getBounds(this.parent),i=this.y-t.y;this.y=e+i-t.height}}),W.World=function(e){W.Group.call(this,e,null,"__world",!1),this.bounds=new W.Rectangle(0,0,e.width,e.height),this.camera=null,this._definedSize=!1,this._width=e.width,this._height=e.height,this.game.state.onStateChange.add(this.stateChange,this)},W.World.prototype=Object.create(W.Group.prototype),W.World.prototype.constructor=W.World,W.World.prototype.boot=function(){this.camera=new W.Camera(this.game,0,0,0,this.game.width,this.game.height),this.game.stage.addChild(this),this.camera.boot()},W.World.prototype.stateChange=function(){this.x=0,this.y=0,this.camera.reset()},W.World.prototype.setBounds=function(e,t,i,r){this._definedSize=!0,this._width=i,this._height=r,this.bounds.setTo(e,t,i,r),this.x=e,this.y=t,this.camera.bounds&&this.camera.bounds.setTo(e,t,Math.max(i,this.game.width),Math.max(r,this.game.height)),this.game.physics.setBoundsToWorld()},W.World.prototype.resize=function(e,t){this._definedSize&&(ethis.bounds.right&&(e.x=this.bounds.left)),o&&(e.y+e._currentBounds.heightthis.bounds.bottom&&(e.y=this.bounds.top))):(r&&e.x+tthis.bounds.right&&(e.x=this.bounds.left-t),o&&e.y+tthis.bounds.bottom&&(e.y=this.bounds.top-t))},Object.defineProperty(W.World.prototype,"width",{get:function(){return this.bounds.width},set:function(e){ethis._nextFpsNotification&&(this._nextFpsNotification=this.time.time+1e4,this.fpsProblemNotifier.dispatch()),this._deltaTime=0,this._spiraling=0,this.updateRender(this.time.slowMotion*this.time.desiredFps);else{var t=1e3*this.time.slowMotion/this.time.desiredFps;this._deltaTime+=Math.max(Math.min(3*t,this.time.elapsed),0);var i=0;for(this.updatesThisFrame=Math.floor(this._deltaTime/t),this.forceSingleUpdate&&(this.updatesThisFrame=Math.min(1,this.updatesThisFrame));this._deltaTime>=t&&(this._deltaTime-=t,this.currentUpdateID=i,this.updateLogic(this.time.desiredFpsMult),i++,!this.forceSingleUpdate||1!==i);)this.time.refresh();i>this._lastCount?this._spiraling++:i=W.Input.MAX_POINTERS)return null;var e=this.pointers.length+1,t=new W.Pointer(this.game,e,W.PointerMode.TOUCH);return this.pointers.push(t),this["pointer"+e]=t},update:function(){if(this.keyboard&&this.keyboard.update(),0=this.maxPointers)return null;if(!this.pointer1.active)return this.pointer1.start(e);if(!this.pointer2.active)return this.pointer2.start(e);for(var t=2;t=s&&this._localPoint.x=a&&this._localPoint.y=s&&this._localPoint.x=a&&this._localPoint.ythis.game.time.time},justReleased:function(e){return e=e||250,this.isUp&&this.timeUp+e>this.game.time.time},reset:function(){this.isDown=!1,this.isUp=!0,this.timeDown=this.game.time.time,this.repeats=0,this.altKey=!1,this.shiftKey=!1,this.ctrlKey=!1},destroy:function(){this.onDown.dispose(),this.onUp.dispose(),this.onFloat.dispose(),this.parent=null,this.game=null}},W.DeviceButton.prototype.constructor=W.DeviceButton,Object.defineProperty(W.DeviceButton.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.time-this.timeDown}}),W.Pointer=function(e,t,i){this.game=e,this.id=t,this.type=W.POINTER,this.exists=!0,this.identifier=0,this.pointerId=null,this.pointerMode=i||W.PointerMode.CURSOR|W.PointerMode.CONTACT,this.target=null,this.button=null,this.leftButton=new W.DeviceButton(this,W.Pointer.LEFT_BUTTON),this.middleButton=new W.DeviceButton(this,W.Pointer.MIDDLE_BUTTON),this.rightButton=new W.DeviceButton(this,W.Pointer.RIGHT_BUTTON),this.backButton=new W.DeviceButton(this,W.Pointer.BACK_BUTTON),this.forwardButton=new W.DeviceButton(this,W.Pointer.FORWARD_BUTTON),this.eraserButton=new W.DeviceButton(this,W.Pointer.ERASER_BUTTON),this._holdSent=!1,this._history=[],this._nextDrop=0,this._stateReset=!1,this.withinGame=!1,this.clientX=-1,this.clientY=-1,this.pageX=-1,this.pageY=-1,this.screenX=-1,this.screenY=-1,this.rawMovementX=0,this.rawMovementY=0,this.movementX=0,this.movementY=0,this.x=-1,this.y=-1,this.isMouse=0===t,this.isDown=!1,this.isUp=!0,this.timeDown=0,this.timeUp=0,this.previousTapTime=0,this.totalTouches=0,this.msSinceLastClick=Number.MAX_VALUE,this.targetObject=null,this.interactiveCandidates=[],this.active=!1,this.dirty=!1,this.position=new W.Point,this.positionDown=new W.Point,this.positionUp=new W.Point,this.circle=new W.Circle(0,0,44),this._clickTrampolines=null,this._trampolineTargetObject=null},W.Pointer.NO_BUTTON=0,W.Pointer.LEFT_BUTTON=1,W.Pointer.RIGHT_BUTTON=2,W.Pointer.MIDDLE_BUTTON=4,W.Pointer.BACK_BUTTON=8,W.Pointer.FORWARD_BUTTON=16,W.Pointer.ERASER_BUTTON=32,W.Pointer.prototype={resetButtons:function(){this.isDown=!1,this.isUp=!0,this.isMouse&&(this.leftButton.reset(),this.middleButton.reset(),this.rightButton.reset(),this.backButton.reset(),this.forwardButton.reset(),this.eraserButton.reset())},processButtonsDown:function(e,t){W.Pointer.LEFT_BUTTON&e&&this.leftButton.start(t),W.Pointer.RIGHT_BUTTON&e&&this.rightButton.start(t),W.Pointer.MIDDLE_BUTTON&e&&this.middleButton.start(t),W.Pointer.BACK_BUTTON&e&&this.backButton.start(t),W.Pointer.FORWARD_BUTTON&e&&this.forwardButton.start(t),W.Pointer.ERASER_BUTTON&e&&this.eraserButton.start(t)},processButtonsUp:function(e,t){e===W.Mouse.LEFT_BUTTON&&this.leftButton.stop(t),e===W.Mouse.RIGHT_BUTTON&&this.rightButton.stop(t),e===W.Mouse.MIDDLE_BUTTON&&this.middleButton.stop(t),e===W.Mouse.BACK_BUTTON&&this.backButton.stop(t),e===W.Mouse.FORWARD_BUTTON&&this.forwardButton.stop(t),5===e&&this.eraserButton.stop(t)},updateButtons:function(e){this.button=e.button;var t="down"===e.type.toLowerCase().substr(-4);void 0!==e.buttons?t?this.processButtonsDown(e.buttons,e):this.processButtonsUp(e.button,e):t?this.leftButton.start(e):(this.leftButton.stop(e),this.rightButton.stop(e)),1===e.buttons&&e.ctrlKey&&this.leftButton.isDown&&(this.leftButton.stop(e),this.rightButton.start(e)),this.isUp=!0,this.isDown=!1,(this.leftButton.isDown||this.rightButton.isDown||this.middleButton.isDown||this.backButton.isDown||this.forwardButton.isDown||this.eraserButton.isDown)&&(this.isUp=!1,this.isDown=!0)},start:function(e){var t=this.game.input;return e.pointerId&&(this.pointerId=e.pointerId),this.identifier=e.identifier,this.target=e.target,this.isMouse?this.updateButtons(e):(this.isDown=!0,this.isUp=!1),this.active=!0,this.withinGame=!0,this.dirty=!1,this._history=[],this._clickTrampolines=null,this._trampolineTargetObject=null,this.msSinceLastClick=this.game.time.time-this.timeDown,this.timeDown=this.game.time.time,this._holdSent=!1,this.move(e,!0),this.positionDown.setTo(this.x,this.y),(t.multiInputOverride===W.Input.MOUSE_OVERRIDES_TOUCH||t.multiInputOverride===W.Input.MOUSE_TOUCH_COMBINE||t.multiInputOverride===W.Input.TOUCH_OVERRIDES_MOUSE&&0===t.totalActivePointers)&&(t.x=this.x,t.y=this.y,t.position.setTo(this.x,this.y),t.onDown.dispatch(this,e),t.resetSpeed(this.x,this.y)),this._stateReset=!1,this.totalTouches++,null!==this.targetObject&&this.targetObject._touchedHandler(this),this},update:function(){var e=this.game.input;this.active&&(this.dirty&&(0=e.holdRate&&((e.multiInputOverride===W.Input.MOUSE_OVERRIDES_TOUCH||e.multiInputOverride===W.Input.MOUSE_TOUCH_COMBINE||e.multiInputOverride===W.Input.TOUCH_OVERRIDES_MOUSE&&0===e.totalActivePointers)&&e.onHold.dispatch(this),this._holdSent=!0),e.recordPointerHistory&&this.game.time.time>=this._nextDrop&&(this._nextDrop=this.game.time.time+e.recordRate,this._history.push({x:this.position.x,y:this.position.y}),this._history.length>e.recordLimit&&this._history.shift()))},move:function(e,t){var i=this.game.input;if(!i.pollLocked){void 0===t&&(t=!1),void 0!==e.button&&(this.button=e.button),t&&this.isMouse&&this.updateButtons(e),this.clientX=e.clientX,this.clientY=e.clientY,this.pageX=e.pageX,this.pageY=e.pageY,this.screenX=e.screenX,this.screenY=e.screenY,this.isMouse&&i.mouse.locked&&!t&&(this.rawMovementX=e.movementX||e.mozMovementX||e.webkitMovementX||0,this.rawMovementY=e.movementY||e.mozMovementY||e.webkitMovementY||0,this.movementX+=this.rawMovementX,this.movementY+=this.rawMovementY),this.x=(this.pageX-this.game.scale.offset.x)*i.scale.x,this.y=(this.pageY-this.game.scale.offset.y)*i.scale.y,this.position.setTo(this.x,this.y),this.circle.x=this.x,this.circle.y=this.y,(i.multiInputOverride===W.Input.MOUSE_OVERRIDES_TOUCH||i.multiInputOverride===W.Input.MOUSE_TOUCH_COMBINE||i.multiInputOverride===W.Input.TOUCH_OVERRIDES_MOUSE&&0===i.totalActivePointers)&&(i.activePointer=this,i.x=this.x,i.y=this.y,i.position.setTo(i.x,i.y),i.circle.x=i.x,i.circle.y=i.y),this.withinGame=this.game.scale.bounds.contains(this.pageX,this.pageY);for(var r=i.moveCallbacks.length;r--;)i.moveCallbacks[r].callback.call(i.moveCallbacks[r].context,this,this.x,this.y,t);return null!==this.targetObject&&!0===this.targetObject.isDragged?!1===this.targetObject.update(this)&&(this.targetObject=null):0this.game.time.time},justReleased:function(e){return e=e||this.game.input.justReleasedRate,this.isUp&&this.timeUp+e>this.game.time.time},addClickTrampoline:function(e,t,i,r){if(this.isDown){for(var o=this._clickTrampolines=this._clickTrampolines||[],s=0;se||this.priorityID===e&&this.sprite.renderOrderID>t))},isPixelPerfect:function(){return this.pixelPerfectClick||this.pixelPerfectOver},pointerX:function(e){return e=e||0,this._pointerData[e].x},pointerY:function(e){return e=e||0,this._pointerData[e].y},pointerDown:function(e){return e=e||0,this._pointerData[e].isDown},pointerUp:function(e){return e=e||0,this._pointerData[e].isUp},pointerTimeDown:function(e){return e=e||0,this._pointerData[e].timeDown},pointerTimeUp:function(e){return e=e||0,this._pointerData[e].timeUp},pointerOver:function(e){if(!this.enabled)return!1;if(void 0!==e)return this._pointerData[e].isOver;for(var t=0;t<10;t++)if(this._pointerData[t].isOver)return!0;return!1},pointerOut:function(e){if(!this.enabled)return!1;if(void 0!==e)return this._pointerData[e].isOut;for(var t=0;t<10;t++)if(this._pointerData[t].isOut)return!0},pointerTimeOver:function(e){return e=e||0,this._pointerData[e].timeOver},pointerTimeOut:function(e){return e=e||0,this._pointerData[e].timeOut},pointerDragged:function(e){return e=e||0,this._pointerData[e].isDragged},checkPointerDown:function(e,t){return!!(e.isDown&&this.enabled&&this.sprite&&this.sprite.parent&&this.sprite.visible&&this.sprite.parent.visible&&0!==this.sprite.worldScale.x&&0!==this.sprite.worldScale.y)&&(!!this.game.input.hitTest(this.sprite,e,this._tempPoint)&&(void 0===t&&(t=!1),!(!t&&this.pixelPerfectClick)||this.checkPixel(this._tempPoint.x,this._tempPoint.y)))},checkPointerOver:function(e,t){return!!(this.enabled&&this.sprite&&this.sprite.parent&&this.sprite.visible&&this.sprite.parent.visible&&0!==this.sprite.worldScale.x&&0!==this.sprite.worldScale.y)&&(!!this.game.input.hitTest(this.sprite,e,this._tempPoint)&&(void 0===t&&(t=!1),!(!t&&this.pixelPerfectOver)||this.checkPixel(this._tempPoint.x,this._tempPoint.y)))},checkPixel:function(e,t,i){if(this.sprite.texture.baseTexture.source){if(null===e&&null===t){this.game.input.getLocalPosition(this.sprite,i,this._tempPoint);e=this._tempPoint.x,t=this._tempPoint.y}if(0!==this.sprite.anchor.x&&(e-=-this.sprite.texture.frame.width*this.sprite.anchor.x),0!==this.sprite.anchor.y&&(t-=-this.sprite.texture.frame.height*this.sprite.anchor.y),e+=this.sprite.texture.frame.x,t+=this.sprite.texture.frame.y,this.sprite.texture.trim&&(e-=this.sprite.texture.trim.x,t-=this.sprite.texture.trim.y,ethis.sprite.texture.crop.right||tthis.sprite.texture.crop.bottom))return this._dx=e,this._dy=t,!1;if(this._dx=e,this._dy=t,this.game.input.hitContext.clearRect(0,0,1,1),this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source,e,t,1,1,0,0,1,1),this.game.input.hitContext.getImageData(0,0,1,1).data[3]>=this.pixelPerfectAlpha)return!0}return!1},update:function(e){if(null!==this.sprite&&void 0!==this.sprite.parent)return this.enabled&&this.sprite.visible&&this.sprite.parent.visible?this._pendingDrag?(this._dragDistancePass||(this._dragDistancePass=W.Math.distance(e.x,e.y,this.downPoint.x,this.downPoint.y)>=this.dragDistanceThreshold),this._dragDistancePass&&this._dragTimePass&&this.startDrag(e),!0):this.draggable&&this._draggedPointerID===e.id?this.updateDrag(e,!1):this._pointerData[e.id].isOver?this.checkPointerOver(e)?(this._pointerData[e.id].x=e.x-this.sprite.x,this._pointerData[e.id].y=e.y-this.sprite.y,!0):(this._pointerOutHandler(e),!1):void 0:(this._pointerOutHandler(e),!1)},_pointerOverHandler:function(e,t){if(null!==this.sprite){var i=this._pointerData[e.id];if(!1===i.isOver||e.dirty){var r=!1===i.isOver;i.isOver=!0,i.isOut=!1,i.timeOver=this.game.time.time,i.x=e.x-this.sprite.x,i.y=e.y-this.sprite.y,this.useHandCursor&&!1===i.isDragged&&(this.game.canvas.style.cursor="pointer",this._setHandCursor=!0),!t&&r&&this.sprite&&this.sprite.events&&this.sprite.events.onInputOver$dispatch(this.sprite,e),this.sprite.parent&&this.sprite.parent.type===W.GROUP&&this.sprite.parent.onChildInputOver.dispatch(this.sprite,e)}}},_pointerOutHandler:function(e,t){if(null!==this.sprite){var i=this._pointerData[e.id];i.isOver=!1,i.isOut=!0,i.timeOut=this.game.time.time,this.useHandCursor&&!1===i.isDragged&&(this.game.canvas.style.cursor="default",this._setHandCursor=!1),!t&&this.sprite&&this.sprite.events&&(this.sprite.events.onInputOut$dispatch(this.sprite,e),this.sprite&&this.sprite.parent&&this.sprite.parent.type===W.GROUP&&this.sprite.parent.onChildInputOut.dispatch(this.sprite,e))}},_touchedHandler:function(e){if(null!==this.sprite){var t=this._pointerData[e.id];if(!t.isDown&&t.isOver){if(this.pixelPerfectClick&&!this.checkPixel(null,null,e))return;if(t.isDown=!0,t.isUp=!1,t.timeDown=this.game.time.time,this.downPoint.set(e.x,e.y),e.dirty=!0,this.sprite&&this.sprite.events&&(this.sprite.events.onInputDown$dispatch(this.sprite,e),this.sprite&&this.sprite.parent&&this.sprite.parent.type===W.GROUP&&this.sprite.parent.onChildInputDown.dispatch(this.sprite,e),null===this.sprite))return;this.draggable&&!1===this.isDragged&&(0===this.dragTimeThreshold&&0===this.dragDistanceThreshold?this.startDrag(e):(this._pendingDrag=!0,this._dragDistancePass=0===this.dragDistanceThreshold,0this.boundsRect.right&&(this.sprite.cameraOffset.x=this.boundsRect.right-this.sprite.width),this.sprite.cameraOffset.ythis.boundsRect.bottom&&(this.sprite.cameraOffset.y=this.boundsRect.bottom-this.sprite.height)):(this.sprite.leftthis.boundsRect.right&&(this.sprite.x=this.boundsRect.right-(this.sprite.width-this.sprite.offsetX)),this.sprite.topthis.boundsRect.bottom&&(this.sprite.y=this.boundsRect.bottom-(this.sprite.height-this.sprite.offsetY)))},checkBoundsSprite:function(){this.sprite.fixedToCamera&&this.boundsSprite.fixedToCamera?(this.sprite.cameraOffset.xthis.boundsSprite.cameraOffset.x+this.boundsSprite.width&&(this.sprite.cameraOffset.x=this.boundsSprite.cameraOffset.x+this.boundsSprite.width-this.sprite.width),this.sprite.cameraOffset.ythis.boundsSprite.cameraOffset.y+this.boundsSprite.height&&(this.sprite.cameraOffset.y=this.boundsSprite.cameraOffset.y+this.boundsSprite.height-this.sprite.height)):(this.sprite.leftthis.boundsSprite.right&&(this.sprite.x=this.boundsSprite.right-(this.sprite.width-this.sprite.offsetX)),this.sprite.topthis.boundsSprite.bottom&&(this.sprite.y=this.boundsSprite.bottom-(this.sprite.height-this.sprite.offsetY)))}},W.InputHandler.prototype.constructor=W.InputHandler,W.Gamepad=function(e){this.game=e,this._gamepadIndexMap={},this._rawPads=[],this._active=!1,this.enabled=!0,this._gamepadSupportAvailable=!!navigator.webkitGetGamepads||!!navigator.webkitGamepads||-1!==navigator.userAgent.indexOf("Firefox/")||!!navigator.getGamepads,this._prevRawGamepadTypes=[],this._prevTimestamps=[],(this.callbackContext=this).onConnectCallback=null,this.onDisconnectCallback=null,this.onDownCallback=null,this.onUpCallback=null,this.onAxisCallback=null,this.onFloatCallback=null,this._ongamepadconnected=null,this._gamepaddisconnected=null,this._gamepads=[new W.SinglePad(e,this),new W.SinglePad(e,this),new W.SinglePad(e,this),new W.SinglePad(e,this)]},W.Gamepad.prototype={addCallbacks:function(e,t){void 0!==t&&(this.onConnectCallback="function"==typeof t.onConnect?t.onConnect:this.onConnectCallback,this.onDisconnectCallback="function"==typeof t.onDisconnect?t.onDisconnect:this.onDisconnectCallback,this.onDownCallback="function"==typeof t.onDown?t.onDown:this.onDownCallback,this.onUpCallback="function"==typeof t.onUp?t.onUp:this.onUpCallback,this.onAxisCallback="function"==typeof t.onAxis?t.onAxis:this.onAxisCallback,this.onFloatCallback="function"==typeof t.onFloat?t.onFloat:this.onFloatCallback,this.callbackContext=e)},start:function(){if(!this._active){this._active=!0;var t=this;this._onGamepadConnected=function(e){return t.onGamepadConnected(e)},this._onGamepadDisconnected=function(e){return t.onGamepadDisconnected(e)},window.addEventListener("gamepadconnected",this._onGamepadConnected,!1),window.addEventListener("gamepaddisconnected",this._onGamepadDisconnected,!1)}},onGamepadConnected:function(e){var t=e.gamepad;this._rawPads.push(t),this._gamepads[t.index].connect(t)},onGamepadDisconnected:function(e){var t=e.gamepad;for(var i in this._rawPads)this._rawPads[i].index===t.index&&this._rawPads.splice(i,1);this._gamepads[t.index].disconnect()},update:function(){this._pollGamepads(),this.pad1.pollStatus(),this.pad2.pollStatus(),this.pad3.pollStatus(),this.pad4.pollStatus()},_pollGamepads:function(){if(this._active){if(navigator.getGamepads)var e=navigator.getGamepads();else if(navigator.webkitGetGamepads)e=navigator.webkitGetGamepads();else if(navigator.webkitGamepads)e=navigator.webkitGamepads();if(e){for(var t=!(this._rawPads=[]),i=0;ithis.deadZone||r<0&&r<-this.deadZone?this.processAxisChange(i,r):this.processAxisChange(i,0)}this._prevTimestamp=this._rawPad.timestamp}},connect:function(e){var t=!this.connected;this.connected=!0,this.index=e.index,this._rawPad=e,this._buttons=[],this._buttonsLen=e.buttons.length,this._axes=[],this._axesLen=e.axes.length;for(var i=0;ithis.maxHealth&&(this.health=this.maxHealth),this},heal:function(e){return this.alive&&(this.health+=e,this.health>this.maxHealth&&(this.health=this.maxHealth)),this}},W.Component.InCamera=function(){},W.Component.InCamera.prototype={inCamera:{get:function(){return this.game.world.camera.view.intersects(this._bounds)}}},W.Component.InputEnabled=function(){},W.Component.InputEnabled.prototype={input:null,inputEnabled:{get:function(){return this.input&&this.input.enabled},set:function(e){e?null===this.input?(this.input=new W.InputHandler(this),this.input.start()):this.input&&!this.input.enabled&&this.input.start():this.input&&this.input.enabled&&this.input.stop()}}},W.Component.InWorld=function(){},W.Component.InWorld.preUpdate=function(){if(this.autoCull||this.checkWorldBounds){if(this._bounds.copyFrom(this.getBounds()),this._bounds.x+=this.game.camera.view.x,this._bounds.y+=this.game.camera.view.y,this.autoCull)if(this.game.world.camera.view.intersects(this._bounds))this.renderable=!0,this.game.world.camera.totalInView++;else if(this.renderable=!1,this.outOfCameraBoundsKill)return this.kill(),!1;if(this.checkWorldBounds)if(this._outOfBoundsFired&&this.game.world.bounds.intersects(this._bounds))this._outOfBoundsFired=!1,this.events.onEnterBounds$dispatch(this);else if(!this._outOfBoundsFired&&!this.game.world.bounds.intersects(this._bounds)&&(this._outOfBoundsFired=!0,this.events.onOutOfBounds$dispatch(this),this.outOfBoundsKill))return this.kill(),!1}return!0},W.Component.InWorld.prototype={checkWorldBounds:!1,outOfBoundsKill:!1,outOfCameraBoundsKill:!1,_outOfBoundsFired:!1,inWorld:{get:function(){return this.game.world.bounds.intersects(this.getBounds())}}},W.Component.LifeSpan=function(){},W.Component.LifeSpan.preUpdate=function(){return!(0this.scaleMax.x&&(e.a=this.scaleMax.x),e.d>this.scaleMax.y&&(e.d=this.scaleMax.y))},setScaleMinMax:function(e,t,i,r){void 0===t?t=i=r=e:void 0===i&&(i=r=t,t=e),null===e?this.scaleMin=null:this.scaleMin?this.scaleMin.set(e,t):this.scaleMin=new W.Point(e,t),null===i?this.scaleMax=null:this.scaleMax?this.scaleMax.set(i,r):this.scaleMax=new W.Point(i,r),null===this.scaleMin?this.transformCallback=null:(this.transformCallback=this.checkTransform,this.transformCallbackContext=this)}},W.Component.Smoothed=function(){},W.Component.Smoothed.prototype={smoothed:{get:function(){return!this.texture.baseTexture.scaleMode},set:function(e){e?this.texture&&(this.texture.baseTexture.scaleMode=0):this.texture&&(this.texture.baseTexture.scaleMode=1)}}},W.GameObjectFactory=function(e){this.game=e,this.world=this.game.world},W.GameObjectFactory.prototype={existing:function(e){return this.world.add(e)},weapon:function(e,t,i,r){var o=this.game.plugins.add(W.Weapon);return o.createBullets(e,t,i,r),o},image:function(e,t,i,r,o){return void 0===o&&(o=this.world),o.add(new W.Image(this.game,e,t,i,r))},sprite:function(e,t,i,r,o){return void 0===o&&(o=this.world),o.create(e,t,i,r)},creature:function(e,t,i,r,o){void 0===o&&(o=this.world);var s=new W.Creature(this.game,e,t,i,r);return o.add(s),s},tween:function(e){return this.game.tweens.create(e)},group:function(e,t,i,r,o){return new W.Group(this.game,e,t,i,r,o)},physicsGroup:function(e,t,i,r){return new W.Group(this.game,t,i,r,!0,e)},spriteBatch:function(e,t,i){return void 0===e&&(e=null),void 0===t&&(t="group"),void 0===i&&(i=!1),new W.SpriteBatch(this.game,e,t,i)},audio:function(e,t,i,r){return this.game.sound.add(e,t,i,r)},sound:function(e,t,i,r){return this.game.sound.add(e,t,i,r)},audioSprite:function(e){return this.game.sound.addSprite(e)},tileSprite:function(e,t,i,r,o,s,a){return void 0===a&&(a=this.world),a.add(new W.TileSprite(this.game,e,t,i,r,o,s))},rope:function(e,t,i,r,o,s){return void 0===s&&(s=this.world),s.add(new W.Rope(this.game,e,t,i,r,o))},text:function(e,t,i,r,o){return void 0===o&&(o=this.world),o.add(new W.Text(this.game,e,t,i,r))},button:function(e,t,i,r,o,s,a,n,h,c){return void 0===c&&(c=this.world),c.add(new W.Button(this.game,e,t,i,r,o,s,a,n,h))},graphics:function(e,t,i){return void 0===i&&(i=this.world),i.add(new W.Graphics(this.game,e,t))},emitter:function(e,t,i){return this.game.particles.add(new W.Particles.Arcade.Emitter(this.game,e,t,i))},retroFont:function(e,t,i,r,o,s,a,n,h){return new W.RetroFont(this.game,e,t,i,r,o,s,a,n,h)},bitmapText:function(e,t,i,r,o,s){return void 0===s&&(s=this.world),s.add(new W.BitmapText(this.game,e,t,i,r,o))},tilemap:function(e,t,i,r,o){return new W.Tilemap(this.game,e,t,i,r,o)},renderTexture:function(e,t,i,r){void 0!==i&&""!==i||(i=this.game.rnd.uuid()),void 0===r&&(r=!1);var o=new W.RenderTexture(this.game,e,t,i);return r&&this.game.cache.addRenderTexture(i,o),o},video:function(e,t){return new W.Video(this.game,e,t)},bitmapData:function(e,t,i,r){void 0===r&&(r=!1),void 0!==i&&""!==i||(i=this.game.rnd.uuid());var o=new W.BitmapData(this.game,i,e,t);return r&&this.game.cache.addBitmapData(i,o),o},filter:function(e){var t=Array.prototype.slice.call(arguments,1);return(e=new W.Filter[e](this.game)).init.apply(e,t),e},plugin:function(e){return this.game.plugins.add(e)}},W.GameObjectFactory.prototype.constructor=W.GameObjectFactory,W.GameObjectCreator=function(e){this.game=e,this.world=this.game.world},W.GameObjectCreator.prototype={image:function(e,t,i,r){return new W.Image(this.game,e,t,i,r)},sprite:function(e,t,i,r){return new W.Sprite(this.game,e,t,i,r)},tween:function(e){return new W.Tween(e,this.game,this.game.tweens)},group:function(e,t,i,r,o){return new W.Group(this.game,e,t,i,r,o)},spriteBatch:function(e,t,i){return void 0===t&&(t="group"),void 0===i&&(i=!1),new W.SpriteBatch(this.game,e,t,i)},audio:function(e,t,i,r){return this.game.sound.add(e,t,i,r)},audioSprite:function(e){return this.game.sound.addSprite(e)},sound:function(e,t,i,r){return this.game.sound.add(e,t,i,r)},tileSprite:function(e,t,i,r,o,s){return new W.TileSprite(this.game,e,t,i,r,o,s)},rope:function(e,t,i,r,o){return new W.Rope(this.game,e,t,i,r,o)},text:function(e,t,i,r){return new W.Text(this.game,e,t,i,r)},button:function(e,t,i,r,o,s,a,n,h){return new W.Button(this.game,e,t,i,r,o,s,a,n,h)},graphics:function(e,t){return new W.Graphics(this.game,e,t)},emitter:function(e,t,i){return new W.Particles.Arcade.Emitter(this.game,e,t,i)},retroFont:function(e,t,i,r,o,s,a,n,h){return new W.RetroFont(this.game,e,t,i,r,o,s,a,n,h)},bitmapText:function(e,t,i,r,o,s){return new W.BitmapText(this.game,e,t,i,r,o,s)},tilemap:function(e,t,i,r,o){return new W.Tilemap(this.game,e,t,i,r,o)},renderTexture:function(e,t,i,r){void 0!==i&&""!==i||(i=this.game.rnd.uuid()),void 0===r&&(r=!1);var o=new W.RenderTexture(this.game,e,t,i);return r&&this.game.cache.addRenderTexture(i,o),o},bitmapData:function(e,t,i,r){void 0===r&&(r=!1),void 0!==i&&""!==i||(i=this.game.rnd.uuid());var o=new W.BitmapData(this.game,i,e,t);return r&&this.game.cache.addBitmapData(i,o),o},filter:function(e){var t=Array.prototype.slice.call(arguments,1);return(e=new W.Filter[e](this.game)).init.apply(e,t),e}},W.GameObjectCreator.prototype.constructor=W.GameObjectCreator,W.Sprite=function(e,t,i,r,o){t=t||0,i=i||0,r=r||null,o=o||null,this.type=W.SPRITE,this.physicsType=W.SPRITE,PIXI.Sprite.call(this,W.Cache.DEFAULT),W.Component.Core.init.call(this,e,t,i,r,o)},W.Sprite.prototype=Object.create(PIXI.Sprite.prototype),W.Sprite.prototype.constructor=W.Sprite,W.Component.Core.install.call(W.Sprite.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Delta","Destroy","FixedToCamera","Health","InCamera","InputEnabled","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","ScaleMinMax","Smoothed"]),W.Sprite.prototype.preUpdatePhysics=W.Component.PhysicsBody.preUpdate,W.Sprite.prototype.preUpdateLifeSpan=W.Component.LifeSpan.preUpdate,W.Sprite.prototype.preUpdateInWorld=W.Component.InWorld.preUpdate,W.Sprite.prototype.preUpdateCore=W.Component.Core.preUpdate,W.Sprite.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},W.Image=function(e,t,i,r,o){t=t||0,i=i||0,r=r||null,o=o||null,this.type=W.IMAGE,PIXI.Sprite.call(this,W.Cache.DEFAULT),W.Component.Core.init.call(this,e,t,i,r,o)},W.Image.prototype=Object.create(PIXI.Sprite.prototype),W.Image.prototype.constructor=W.Image,W.Component.Core.install.call(W.Image.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Destroy","FixedToCamera","InputEnabled","LifeSpan","LoadTexture","Overlap","Reset","ScaleMinMax","Smoothed"]),W.Image.prototype.preUpdateInWorld=W.Component.InWorld.preUpdate,W.Image.prototype.preUpdateCore=W.Component.Core.preUpdate,W.Image.prototype.preUpdate=function(){return!!this.preUpdateInWorld()&&this.preUpdateCore()},W.Button=function(e,t,i,r,o,s,a,n,h,c){t=t||0,i=i||0,r=r||null,o=o||null,s=s||this,W.Image.call(this,e,t,i,r,n),this.type=W.BUTTON,this.physicsType=W.SPRITE,this._onOverFrame=null,this._onOutFrame=null,this._onDownFrame=null,this._onUpFrame=null,this.onOverSound=null,this.onOutSound=null,this.onDownSound=null,this.onUpSound=null,this.onOverSoundMarker="",this.onOutSoundMarker="",this.onDownSoundMarker="",this.onUpSoundMarker="",this.onInputOver=new W.Signal,this.onInputOut=new W.Signal,this.onInputDown=new W.Signal,this.onInputUp=new W.Signal,this.onOverMouseOnly=!0,this.justReleasedPreventsOver=W.PointerMode.TOUCH,this.freezeFrames=!1,this.forceOut=!1,this.inputEnabled=!0,this.input.start(0,!0),this.input.useHandCursor=!0,this.setFrames(a,n,h,c),null!==o&&this.onInputUp.add(o,s),this.events.onInputOver.add(this.onInputOverHandler,this),this.events.onInputOut.add(this.onInputOutHandler,this),this.events.onInputDown.add(this.onInputDownHandler,this),this.events.onInputUp.add(this.onInputUpHandler,this),this.events.onRemovedFromWorld.add(this.removedFromWorld,this)},W.Button.prototype=Object.create(W.Image.prototype),W.Button.prototype.constructor=W.Button;var h="Over",c="Out",l="Down",m="Up";W.Button.prototype.clearFrames=function(){this.setFrames(null,null,null,null)},W.Button.prototype.removedFromWorld=function(){this.inputEnabled=!1},W.Button.prototype.setStateFrame=function(e,t,i){var r="_on"+e+"Frame";null!==t?(this[r]=t,i&&this.changeStateFrame(e)):this[r]=null},W.Button.prototype.changeStateFrame=function(e){if(this.freezeFrames)return!1;var t=this["_on"+e+"Frame"];return"string"==typeof t?(this.frameName=t,!0):"number"==typeof t&&(this.frame=t,!0)},W.Button.prototype.setFrames=function(e,t,i,r){this.setStateFrame(h,e,this.input.pointerOver()),this.setStateFrame(c,t,!this.input.pointerOver()),this.setStateFrame(l,i,this.input.pointerDown()),this.setStateFrame(m,r,this.input.pointerUp())},W.Button.prototype.setStateSound=function(e,t,i){var r="on"+e+"Sound",o="on"+e+"SoundMarker";t instanceof W.Sound||t instanceof W.AudioSprite?(this[r]=t,this[o]="string"==typeof i?i:""):(this[r]=null,this[o]="")},W.Button.prototype.playStateSound=function(e){var t=this["on"+e+"Sound"];if(t){var i=this["on"+e+"SoundMarker"];return t.play(i),!0}return!1},W.Button.prototype.setSounds=function(e,t,i,r,o,s,a,n){this.setStateSound(h,e,t),this.setStateSound(c,o,s),this.setStateSound(l,i,r),this.setStateSound(m,a,n)},W.Button.prototype.setOverSound=function(e,t){this.setStateSound(h,e,t)},W.Button.prototype.setOutSound=function(e,t){this.setStateSound(c,e,t)},W.Button.prototype.setDownSound=function(e,t){this.setStateSound(l,e,t)},W.Button.prototype.setUpSound=function(e,t){this.setStateSound(m,e,t)},W.Button.prototype.onInputOverHandler=function(e,t){t.justReleased()&&(this.justReleasedPreventsOver&t.pointerMode)===t.pointerMode||(this.changeStateFrame(h),this.onOverMouseOnly&&!t.isMouse||(this.playStateSound(h),this.onInputOver&&this.onInputOver.dispatch(this,t)))},W.Button.prototype.onInputOutHandler=function(e,t){this.changeStateFrame(c),this.playStateSound(c),this.onInputOut&&this.onInputOut.dispatch(this,t)},W.Button.prototype.onInputDownHandler=function(e,t){this.changeStateFrame(l),this.playStateSound(l),this.onInputDown&&this.onInputDown.dispatch(this,t)},W.Button.prototype.onInputUpHandler=function(e,t,i){(this.playStateSound(m),this.onInputUp&&this.onInputUp.dispatch(this,t,i),this.freezeFrames)||(!0===this.forceOut||(this.forceOut&t.pointerMode)===t.pointerMode?this.changeStateFrame(c):this.changeStateFrame(m)||(i?this.changeStateFrame(h):this.changeStateFrame(c)))},W.SpriteBatch=function(e,t,i,r){null==t&&(t=e.world),PIXI.SpriteBatch.call(this),W.Group.call(this,e,t,i,r),this.type=W.SPRITEBATCH},W.SpriteBatch.prototype=W.Utils.extend(!0,W.SpriteBatch.prototype,PIXI.SpriteBatch.prototype,W.Group.prototype),W.SpriteBatch.prototype.constructor=W.SpriteBatch,W.BitmapData=function(e,t,i,r,o){void 0!==i&&0!==i||(i=256),void 0!==r&&0!==r||(r=256),void 0===o&&(o=!1),this.game=e,this.key=t,this.width=i,this.height=r,this.canvas=W.Canvas.create(this,i,r,null,o),this.context=this.canvas.getContext("2d",{alpha:!0}),this.ctx=this.context,this.smoothProperty=e.renderType===W.CANVAS?e.renderer.renderSession.smoothProperty:W.Canvas.getSmoothingPrefix(this.context),this.imageData=this.context.getImageData(0,0,i,r),this.data=null,this.imageData&&(this.data=this.imageData.data),this.pixels=null,this.data&&(this.imageData.data.buffer?(this.buffer=this.imageData.data.buffer,this.pixels=new Uint32Array(this.buffer)):window.ArrayBuffer?(this.buffer=new ArrayBuffer(this.imageData.data.length),this.pixels=new Uint32Array(this.buffer)):this.pixels=this.imageData.data),this.baseTexture=new PIXI.BaseTexture(this.canvas),this.texture=new PIXI.Texture(this.baseTexture),this.frameData=new W.FrameData,this.textureFrame=this.frameData.addFrame(new W.Frame(0,0,0,i,r,"bitmapData")),this.texture.frame=this.textureFrame,this.type=W.BITMAPDATA,this.disableTextureUpload=!1,this.dirty=!1,this.cls=this.clear,this._image=null,this._pos=new W.Point,this._size=new W.Point,this._scale=new W.Point,this._rotate=0,this._alpha={prev:1,current:1},this._anchor=new W.Point,this._tempR=0,this._tempG=0,this._tempB=0,this._circle=new W.Circle,this._swapCanvas=void 0},W.BitmapData.prototype={move:function(e,t,i){return 0!==e&&this.moveH(e,i),0!==t&&this.moveV(t,i),this},moveH:function(e,t){void 0===t&&(t=!0),void 0===this._swapCanvas&&(this._swapCanvas=PIXI.CanvasPool.create(this,this.width,this.height));var i=this._swapCanvas.getContext("2d"),r=this.height,o=this.canvas;if(i.clearRect(0,0,this.width,this.height),e<0){e=Math.abs(e);var s=this.width-e;t&&i.drawImage(o,0,0,e,r,s,0,e,r),i.drawImage(o,e,0,s,r,0,0,s,r)}else{s=this.width-e;t&&i.drawImage(o,s,0,e,r,0,0,e,r),i.drawImage(o,0,0,s,r,e,0,s,r)}return this.clear(),this.copy(this._swapCanvas)},moveV:function(e,t){void 0===t&&(t=!0),void 0===this._swapCanvas&&(this._swapCanvas=PIXI.CanvasPool.create(this,this.width,this.height));var i=this._swapCanvas.getContext("2d"),r=this.width,o=this.canvas;if(i.clearRect(0,0,this.width,this.height),e<0){e=Math.abs(e);var s=this.height-e;t&&i.drawImage(o,0,0,r,e,0,s,r,e),i.drawImage(o,0,e,r,s,0,0,r,s)}else{s=this.height-e;t&&i.drawImage(o,0,s,r,e,0,0,r,e),i.drawImage(o,0,0,r,s,0,e,r,s)}return this.clear(),this.copy(this._swapCanvas)},add:function(e){if(Array.isArray(e))for(var t=0;t=this.height||r<=0)&&(s=!0)):2!==e&&3!==e||++r===this.height&&(r=0,((i+=o)>=this.width||i<=0)&&(s=!0)),0===t.a&&!s;);return t.x=i,t.y=r,t},getBounds:function(e){return void 0===e&&(e=new W.Rectangle),e.x=this.getFirstPixel(2).x,e.x===this.width?e.setTo(0,0,0,0):(e.y=this.getFirstPixel(0).y,e.width=this.getFirstPixel(3).x-e.x+1,e.height=this.getFirstPixel(1).y-e.y+1,e)},addToWorld:function(e,t,i,r,o,s){o=o||1,s=s||1;var a=this.game.add.image(e,t,this);return a.anchor.set(i,r),a.scale.set(o,s),a},copy:function(e,t,i,r,o,s,a,n,h,c,l,m,u,d,p,f,y){if(null==e&&(e=this),(e instanceof W.RenderTexture||e instanceof PIXI.RenderTexture)&&(e=e.getCanvas()),(this._image=e)instanceof W.Sprite||e instanceof W.Image||e instanceof W.Text||e instanceof PIXI.Sprite)this._pos.set(e.texture.crop.x,e.texture.crop.y),this._size.set(e.texture.crop.width,e.texture.crop.height),this._scale.set(e.scale.x,e.scale.y),this._anchor.set(e.anchor.x,e.anchor.y),this._rotate=e.rotation,this._alpha.current=e.alpha,e.texture instanceof W.RenderTexture||e.texture instanceof PIXI.RenderTexture?this._image=e.texture.getCanvas():this._image=e.texture.baseTexture.source,null==s&&(s=e.x),null==a&&(a=e.y),e.texture.trim&&(s+=e.texture.trim.x-e.anchor.x*e.texture.trim.width,a+=e.texture.trim.y-e.anchor.y*e.texture.trim.height),16777215!==e.tint&&(e.cachedTint!==e.tint&&(e.cachedTint=e.tint,e.tintedTexture=PIXI.CanvasTinter.getTintedTexture(e,e.tint)),this._image=e.tintedTexture,this._pos.set(0));else{if(this._pos.set(0),this._scale.set(1),this._anchor.set(0),this._rotate=0,this._alpha.current=1,e instanceof W.BitmapData)this._image=e.canvas;else if("string"==typeof e){if(null===(e=this.game.cache.getImage(e)))return;this._image=e}this._size.set(this._image.width,this._image.height)}if(null==t&&(t=0),null==i&&(i=0),r&&(this._size.x=r),o&&(this._size.y=o),null==s&&(s=t),null==a&&(a=i),null==n&&(n=this._size.x),null==h&&(h=this._size.y),"number"==typeof c&&(this._rotate=c),"number"==typeof l&&(this._anchor.x=l),"number"==typeof m&&(this._anchor.y=m),"number"==typeof u&&(this._scale.x=u),"number"==typeof d&&(this._scale.y=d),"number"==typeof p&&(this._alpha.current=p),void 0===f&&(f=null),void 0===y&&(y=!1),!(this._alpha.current<=0||0===this._scale.x||0===this._scale.y||0===this._size.x||0===this._size.y)){var S=this.context;return this._alpha.prev=S.globalAlpha,S.save(),S.globalAlpha=this._alpha.current,f&&(this.op=f),y&&(s|=0,a|=0),S.translate(s,a),S.scale(this._scale.x,this._scale.y),S.rotate(this._rotate),S.drawImage(this._image,this._pos.x+t,this._pos.y+i,this._size.x,this._size.y,-n*this._anchor.x,-h*this._anchor.y,n,h),S.restore(),S.globalAlpha=this._alpha.prev,this.dirty=!0,this}},copyTransform:function(e,t,i){if(void 0===t&&(t=null),void 0===i&&(i=!1),!e.hasOwnProperty("worldTransform")||!e.worldVisible||0===e.worldAlpha)return this;var r=e.worldTransform;if(this._pos.set(e.texture.crop.x,e.texture.crop.y),this._size.set(e.texture.crop.width,e.texture.crop.height),0===r.a||0===r.d||0===this._size.x||0===this._size.y)return this;e.texture instanceof W.RenderTexture||e.texture instanceof PIXI.RenderTexture?this._image=e.texture.getCanvas():this._image=e.texture.baseTexture.source;var o=r.tx,s=r.ty;e.texture.trim&&(o+=e.texture.trim.x-e.anchor.x*e.texture.trim.width,s+=e.texture.trim.y-e.anchor.y*e.texture.trim.height),16777215!==e.tint&&(e.cachedTint!==e.tint&&(e.cachedTint=e.tint,e.tintedTexture=PIXI.CanvasTinter.getTintedTexture(e,e.tint)),this._image=e.tintedTexture,this._pos.set(0)),i&&(o|=0,s|=0);var a=this.context;return this._alpha.prev=a.globalAlpha,a.save(),a.globalAlpha=this._alpha.current,t&&(this.op=t),a[this.smoothProperty]=e.texture.baseTexture.scaleMode===PIXI.scaleModes.LINEAR,a.setTransform(r.a,r.b,r.c,r.d,o,s),a.drawImage(this._image,this._pos.x,this._pos.y,this._size.x,this._size.y,-this._size.x*e.anchor.x,-this._size.y*e.anchor.y,this._size.x,this._size.y),a.restore(),a.globalAlpha=this._alpha.prev,this.dirty=!0,this},copyRect:function(e,t,i,r,o,s,a){return this.copy(e,t.x,t.y,t.width,t.height,i,r,t.width,t.height,0,0,0,1,1,o,s,a)},draw:function(e,t,i,r,o,s,a){return this.copy(e,null,null,null,null,t,i,r,o,null,null,null,null,null,null,s,a)},drawGroup:function(e,t,i){return 0t.width&&(r=t.width);var o=this.context;return o.fillStyle=o.createPattern(t,i),this._circle=new W.Circle(e.start.x,e.start.y,t.height),this._circle.circumferencePoint(e.angle-1.5707963267948966,!1,this._pos),o.save(),o.translate(this._pos.x,this._pos.y),o.rotate(e.angle),o.fillRect(0,0,r,t.height),o.restore(),this.dirty=!0,this}},render:function(){return!this.disableTextureUpload&&this.dirty&&(this.baseTexture.dirty(),this.dirty=!1),this},destroy:function(){this.frameData.destroy(),this.texture.destroy(!0),PIXI.CanvasPool.remove(this)},blendReset:function(){return this.op="source-over",this},blendSourceOver:function(){return this.op="source-over",this},blendSourceIn:function(){return this.op="source-in",this},blendSourceOut:function(){return this.op="source-out",this},blendSourceAtop:function(){return this.op="source-atop",this},blendDestinationOver:function(){return this.op="destination-over",this},blendDestinationIn:function(){return this.op="destination-in",this},blendDestinationOut:function(){return this.op="destination-out",this},blendDestinationAtop:function(){return this.op="destination-atop",this},blendXor:function(){return this.op="xor",this},blendAdd:function(){return this.op="lighter",this},blendMultiply:function(){return this.op="multiply",this},blendScreen:function(){return this.op="screen",this},blendOverlay:function(){return this.op="overlay",this},blendDarken:function(){return this.op="darken",this},blendLighten:function(){return this.op="lighten",this},blendColorDodge:function(){return this.op="color-dodge",this},blendColorBurn:function(){return this.op="color-burn",this},blendHardLight:function(){return this.op="hard-light",this},blendSoftLight:function(){return this.op="soft-light",this},blendDifference:function(){return this.op="difference",this},blendExclusion:function(){return this.op="exclusion",this},blendHue:function(){return this.op="hue",this},blendSaturation:function(){return this.op="saturation",this},blendColor:function(){return this.op="color",this},blendLuminosity:function(){return this.op="luminosity",this}},Object.defineProperty(W.BitmapData.prototype,"smoothed",{get:function(){W.Canvas.getSmoothingEnabled(this.context)},set:function(e){W.Canvas.setSmoothingEnabled(this.context,e)}}),Object.defineProperty(W.BitmapData.prototype,"op",{get:function(){return this.context.globalCompositeOperation},set:function(e){this.context.globalCompositeOperation=e}}),W.BitmapData.getTransform=function(e,t,i,r,o,s){return"number"!=typeof e&&(e=0),"number"!=typeof t&&(t=0),"number"!=typeof i&&(i=1),"number"!=typeof r&&(r=1),"number"!=typeof o&&(o=0),"number"!=typeof s&&(s=0),{sx:i,sy:r,scaleX:i,scaleY:r,skewX:o,skewY:s,translateX:e,translateY:t,tx:e,ty:t}},W.BitmapData.prototype.constructor=W.BitmapData,PIXI.Graphics=function(){PIXI.DisplayObjectContainer.call(this),this.renderable=!0,this.fillAlpha=1,this.lineWidth=0,this.lineColor=0,this.graphicsData=[],this.tint=16777215,this.blendMode=PIXI.blendModes.NORMAL,this.currentPath=null,this._webGL=[],this.isMask=!1,this.boundsPadding=0,this._localBounds=new PIXI.Rectangle(0,0,1,1),this.dirty=!0,this._boundsDirty=!1,this.webGLDirty=!1,this.cachedSpriteDirty=!1},PIXI.Graphics.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),PIXI.Graphics.prototype.constructor=PIXI.Graphics,PIXI.Graphics.prototype.lineStyle=function(e,t,i){return this.lineWidth=e||0,this.lineColor=t||0,this.lineAlpha=void 0===i?1:i,this.currentPath&&(this.currentPath.shape.points.length?this.drawShape(new PIXI.Polygon(this.currentPath.shape.points.slice(-2))):(this.currentPath.lineWidth=this.lineWidth,this.currentPath.lineColor=this.lineColor,this.currentPath.lineAlpha=this.lineAlpha)),this},PIXI.Graphics.prototype.moveTo=function(e,t){return this.drawShape(new PIXI.Polygon([e,t])),this},PIXI.Graphics.prototype.lineTo=function(e,t){return this.currentPath||this.moveTo(0,0),this.currentPath.shape.points.push(e,t),this.dirty=!0,this._boundsDirty=!0,this},PIXI.Graphics.prototype.quadraticCurveTo=function(e,t,i,r){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);var o,s,a=this.currentPath.shape.points;0===a.length&&this.moveTo(0,0);for(var n=a[a.length-2],h=a[a.length-1],c=0,l=1;l<=20;++l)o=n+(e-n)*(c=l/20),s=h+(t-h)*c,a.push(o+(e+(i-e)*c-o)*c,s+(t+(r-t)*c-s)*c);return this.dirty=!0,this._boundsDirty=!0,this},PIXI.Graphics.prototype.bezierCurveTo=function(e,t,i,r,o,s){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);for(var a,n,h,c,l,m=this.currentPath.shape.points,u=m[m.length-2],d=m[m.length-1],p=0,f=1;f<=20;++f)h=(n=(a=1-(p=f/20))*a)*a,l=(c=p*p)*p,m.push(h*u+3*n*p*e+3*a*c*i+l*o,h*d+3*n*p*t+3*a*c*r+l*s);return this.dirty=!0,this._boundsDirty=!0,this},PIXI.Graphics.prototype.arcTo=function(e,t,i,r,o){this.currentPath?0===this.currentPath.shape.points.length&&this.currentPath.shape.points.push(e,t):this.moveTo(e,t);var s=this.currentPath.shape.points,a=s[s.length-2],n=s[s.length-1]-t,h=a-e,c=r-t,l=i-e,m=Math.abs(n*l-h*c);if(m<1e-8||0===o)s[s.length-2]===e&&s[s.length-1]===t||s.push(e,t);else{var u=n*n+h*h,d=c*c+l*l,p=n*c+h*l,f=o*Math.sqrt(u)/m,y=o*Math.sqrt(d)/m,S=f*p/u,w=y*p/d,g=f*l+y*h,x=f*c+y*n,b=h*(y+S),v=n*(y+S),z=l*(f+w),C=c*(f+w),T=Math.atan2(v-x,b-g),P=Math.atan2(C-x,z-g);this.arc(g+e,x+t,o,T,P,l*n80*i){r=s=e[0],o=a=e[1];for(var p=i;ps.x?o.x>a.x?o.x:a.x:s.x>a.x?s.x:a.x,l=o.y>s.y?o.y>a.y?o.y:a.y:s.y>a.y?s.y:a.y,m=PIXI.EarCut.zOrder(n,h,t,i,r),u=PIXI.EarCut.zOrder(c,l,t,i,r),d=e.nextZ;d&&d.z<=u;){if(d!==e.prev&&d!==e.next&&PIXI.EarCut.pointInTriangle(o.x,o.y,s.x,s.y,a.x,a.y,d.x,d.y)&&0<=PIXI.EarCut.area(d.prev,d,d.next))return!1;d=d.nextZ}for(d=e.prevZ;d&&d.z>=m;){if(d!==e.prev&&d!==e.next&&PIXI.EarCut.pointInTriangle(o.x,o.y,s.x,s.y,a.x,a.y,d.x,d.y)&&0<=PIXI.EarCut.area(d.prev,d,d.next))return!1;d=d.prevZ}return!0},PIXI.EarCut.cureLocalIntersections=function(e,t,i){var r=e;do{var o=r.prev,s=r.next.next;PIXI.EarCut.intersects(o,r,r.next,s)&&PIXI.EarCut.locallyInside(o,s)&&PIXI.EarCut.locallyInside(s,o)&&(t.push(o.i/i),t.push(r.i/i),t.push(s.i/i),PIXI.EarCut.removeNode(r),PIXI.EarCut.removeNode(r.next),r=e=s),r=r.next}while(r!==e);return r},PIXI.EarCut.splitEarcut=function(e,t,i,r,o,s){var a=e;do{for(var n=a.next.next;n!==a.prev;){if(a.i!==n.i&&PIXI.EarCut.isValidDiagonal(a,n)){var h=PIXI.EarCut.splitPolygon(a,n);return a=PIXI.EarCut.filterPoints(a,a.next),h=PIXI.EarCut.filterPoints(h,h.next),PIXI.EarCut.earcutLinked(a,t,i,r,o,s),void PIXI.EarCut.earcutLinked(h,t,i,r,o,s)}n=n.next}a=a.next}while(a!==e)},PIXI.EarCut.eliminateHoles=function(e,t,i,r){var o,s,a,n,h,c=[];for(o=0,s=t.length;o=r.next.y){var n=r.x+(s-r.y)*(r.next.x-r.x)/(r.next.y-r.y);n<=o&&a=r.x&&r.x>=i.x&&PIXI.EarCut.pointInTriangle(si.x)&&PIXI.EarCut.locallyInside(r,e)&&(i=r,l=h),r=r.next;return i},PIXI.EarCut.indexCurve=function(e,t,i,r){for(var o=e;null===o.z&&(o.z=PIXI.EarCut.zOrder(o.x,o.y,t,i,r)),o.prevZ=o.prev,o.nextZ=o.next,(o=o.next)!==e;);o.prevZ.nextZ=null,o.prevZ=null,PIXI.EarCut.sortLinked(o)},PIXI.EarCut.sortLinked=function(e){var t,i,r,o,s,a,n,h,c=1;do{for(i=e,s=e=null,a=0;i;){for(a++,r=i,t=n=0;ts!=i.next.y>s&&o<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(r=!r),(i=i.next)!==e;);return r},PIXI.EarCut.splitPolygon=function(e,t){var i=new PIXI.EarCut.Node(e.i,e.x,e.y),r=new PIXI.EarCut.Node(t.i,t.x,t.y),o=e.next,s=t.prev;return(e.next=t).prev=e,(i.next=o).prev=i,(r.next=i).prev=r,(s.next=r).prev=s,r},PIXI.EarCut.insertNode=function(e,t,i,r){var o=new PIXI.EarCut.Node(e,t,i);return r?(o.next=r.next,(o.prev=r).next.prev=o,r.next=o):(o.prev=o).next=o,o},PIXI.EarCut.removeNode=function(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)},PIXI.EarCut.Node=function(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1},PIXI.WebGLGraphics=function(){},PIXI.WebGLGraphics.stencilBufferLimit=6,PIXI.WebGLGraphics.renderGraphics=function(e,t){var i,r=t.gl,o=t.projection,s=t.offset,a=t.shaderManager.primitiveShader;e.dirty&&PIXI.WebGLGraphics.updateGraphics(e,r);for(var n=e._webGL[r.id],h=0;h=PIXI.WebGLGraphics.stencilBufferLimit)if(a.points.length<2*PIXI.WebGLGraphics.stencilBufferLimit)r=PIXI.WebGLGraphics.switchMode(o,0),PIXI.WebGLGraphics.buildPoly(a,r)||(r=PIXI.WebGLGraphics.switchMode(o,1),PIXI.WebGLGraphics.buildComplexPoly(a,r));else r=PIXI.WebGLGraphics.switchMode(o,1),PIXI.WebGLGraphics.buildComplexPoly(a,r);0>16&255)/255,i=(e.tint>>8&255)/255,r=(255&e.tint)/255,o=0;o>16&255)/255*t*255<<16)+((a>>8&255)/255*i*255<<8)+(255&a)/255*r*255,s._lineTint=((n>>16&255)/255*t*255<<16)+((n>>8&255)/255*i*255<<8)+(255&n)/255*r*255}},W.Graphics=function(e,t,i){void 0===t&&(t=0),void 0===i&&(i=0),this.type=W.GRAPHICS,this.physicsType=W.SPRITE,this.anchor=new W.Point,PIXI.Graphics.call(this),W.Component.Core.init.call(this,e,t,i,"",null)},W.Graphics.prototype=Object.create(PIXI.Graphics.prototype),W.Graphics.prototype.constructor=W.Graphics,W.Component.Core.install.call(W.Graphics.prototype,["Angle","AutoCull","Bounds","Destroy","FixedToCamera","InputEnabled","InWorld","LifeSpan","PhysicsBody","Reset"]),W.Graphics.prototype.preUpdatePhysics=W.Component.PhysicsBody.preUpdate,W.Graphics.prototype.preUpdateLifeSpan=W.Component.LifeSpan.preUpdate,W.Graphics.prototype.preUpdateInWorld=W.Component.InWorld.preUpdate,W.Graphics.prototype.preUpdateCore=W.Component.Core.preUpdate,W.Graphics.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},W.Graphics.prototype.postUpdate=function(){W.Component.PhysicsBody.postUpdate.call(this),W.Component.FixedToCamera.postUpdate.call(this),this._boundsDirty&&(this.updateLocalBounds(),this._boundsDirty=!1);for(var e=0;ef&&(S=-f),0!==S&&(y+=0i&&(this.style.wordWrapWidth=i)),this.updateTexture(),this},W.Text.prototype.updateTexture=function(){var e=this.texture.baseTexture,t=this.texture.crop,i=this.texture.frame,r=this.canvas.width,o=this.canvas.height;if(e.width=r,e.height=o,t.width=r,t.height=o,i.width=r,i.height=o,this.texture.width=r,this.texture.height=o,this._width=r,this._height=o,this.textBounds){var s=this.textBounds.x,a=this.textBounds.y;"right"===this.style.boundsAlignH?s+=this.textBounds.width-this.canvas.width/this.resolution:"center"===this.style.boundsAlignH&&(s+=this.textBounds.halfWidth-this.canvas.width/this.resolution/2),"bottom"===this.style.boundsAlignV?a+=this.textBounds.height-this.canvas.height/this.resolution:"middle"===this.style.boundsAlignV&&(a+=this.textBounds.halfHeight-this.canvas.height/this.resolution/2),this.pivot.x=-s,this.pivot.y=-a}this.renderable=0!==r&&0!==o,this.texture.requiresReTint=!0,this.texture.baseTexture.dirty()},W.Text.prototype._renderWebGL=function(e){this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype._renderWebGL.call(this,e)},W.Text.prototype._renderCanvas=function(e){this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype._renderCanvas.call(this,e)},W.Text.prototype.determineFontProperties=function(e){var t=W.Text.fontPropertiesCache[e];if(!t){t={};var i=W.Text.fontPropertiesCanvas,r=W.Text.fontPropertiesContext;r.font=e;var o=Math.ceil(r.measureText("|MÉq").width),s=Math.ceil(r.measureText("|MÉq").width),a=2*s;if(s=1.4*s|0,i.width=o,i.height=a,r.fillStyle="#f00",r.fillRect(0,0,o,a),r.font=e,r.textBaseline="alphabetic",r.fillStyle="#000",r.fillText("|MÉq",0,s),!r.getImageData(0,0,o,a))return t.ascent=s,t.descent=s+6,t.fontSize=t.ascent+t.descent,W.Text.fontPropertiesCache[e]=t;var n,h,c=r.getImageData(0,0,o,a).data,l=c.length,m=4*o,u=0,d=!1;for(n=0;nthis.textWidth&&(this.textWidth=l.width),o+=e.lineHeight*i,t=t.substr(l.text.length+1)}while(!1===l.end);this.textHeight=o;for(var s=0,a=0,n=this.textWidth*this.anchor.x,h=this.textHeight*this.anchor.y,c=0;c?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",W.RetroFont.TEXT_SET2=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ",W.RetroFont.TEXT_SET3="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",W.RetroFont.TEXT_SET4="ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",W.RetroFont.TEXT_SET5="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",W.RetroFont.TEXT_SET6="ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ",W.RetroFont.TEXT_SET7="AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39",W.RetroFont.TEXT_SET8="0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",W.RetroFont.TEXT_SET9="ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",W.RetroFont.TEXT_SET10="ABCDEFGHIJKLMNOPQRSTUVWXYZ",W.RetroFont.TEXT_SET11="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789",W.RetroFont.prototype.setFixedWidth=function(e,t){void 0===t&&(t="left"),this.fixedWidth=e,this.align=t},W.RetroFont.prototype.setText=function(e,t,i,r,o,s){this.multiLine=t||!1,this.customSpacingX=i||0,this.customSpacingY=r||0,this.align=o||"left",this.autoUpperCase=!s,0this.width))break},W.RetroFont.prototype.getLongestLine=function(){var e=0;if(0e&&(e=t[i].length);return e},W.RetroFont.prototype.removeUnsupportedCharacters=function(e){for(var t="",i=0;i=W.Math.PI2-i?e=t:(Math.abs(t-e)>Math.PI&&(te[i]&&(i=t);return e[i]},minProperty:function(e){if(2===arguments.length&&"object"==typeof arguments[1])var t=arguments[1];else t=arguments.slice(1);for(var i=1,r=0,o=t.length;it[r][e]&&(r=i);return t[r][e]},wrapAngle:function(e,t){return t?this.wrap(e,-Math.PI,Math.PI):this.wrap(e,-180,180)},linearInterpolation:function(e,t){var i=e.length-1,r=i*t,o=Math.floor(r);return t<0?this.linear(e[0],e[1],r):1>>0,r=(t*=r)>>>0,r+=4294967296*(t-=r);return 2.3283064365386963e-10*(r>>>0)},integer:function(){return 4294967296*this.rnd.apply(this)},frac:function(){return this.rnd.apply(this)+11102230246251565e-32*(2097152*this.rnd.apply(this)|0)},real:function(){return this.integer()+this.frac()},integerInRange:function(e,t){return Math.floor(this.realInRange(0,t-e+1)+e)},between:function(e,t){return this.integerInRange(e,t)},realInRange:function(e,t){return this.frac()*(t-e)+e},normal:function(){return 1-2*this.frac()},uuid:function(){var e="",t="";for(t=e="";e++<36;t+=~e%5|3*e&4?(15^e?8^this.frac()*(20^e?16:4):4).toString(16):"-");return t},pick:function(e){return e[this.integerInRange(0,e.length-1)]},sign:function(){return this.pick([-1,1])},weightedPick:function(e){return e[~~(Math.pow(this.frac(),2)*(e.length-1)+.5)]},timestamp:function(e,t){return this.realInRange(e||9466848e5,t||1577862e6)},angle:function(){return this.integerInRange(-180,180)},state:function(e){return"string"==typeof e&&e.match(/^!rnd/)&&(e=e.split(","),this.c=parseFloat(e[1]),this.s0=parseFloat(e[2]),this.s1=parseFloat(e[3]),this.s2=parseFloat(e[4])),["!rnd",this.c,this.s0,this.s1,this.s2].join(",")}},W.RandomDataGenerator.prototype.constructor=W.RandomDataGenerator,W.QuadTree=function(e,t,i,r,o,s,a){this.maxObjects=10,this.maxLevels=4,this.level=0,this.bounds={},this.objects=[],this.nodes=[],this._empty=[],this.reset(e,t,i,r,o,s,a)},W.QuadTree.prototype={reset:function(e,t,i,r,o,s,a){this.maxObjects=o||10,this.maxLevels=s||4,this.level=a||0,this.bounds={x:Math.round(e),y:Math.round(t),width:i,height:r,subWidth:Math.floor(i/2),subHeight:Math.floor(r/2),right:Math.round(e)+Math.floor(i/2),bottom:Math.round(t)+Math.floor(r/2)},this.objects.length=0,this.nodes.length=0},populate:function(e){e.forEach(this.populateHandler,this,!0)},populateHandler:function(e){e.body&&e.exists&&this.insert(e.body)},split:function(){this.nodes[0]=new W.QuadTree(this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[1]=new W.QuadTree(this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[2]=new W.QuadTree(this.bounds.x,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[3]=new W.QuadTree(this.bounds.right,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1)},insert:function(e){var t,i=0;if(null==this.nodes[0]||-1===(t=this.getIndex(e))){if(this.objects.push(e),this.objects.length>this.maxObjects&&this.levelthis.bounds.bottom&&(t=2):e.x>this.bounds.right&&(e.ythis.bounds.bottom&&(t=3)),t},retrieve:function(e){if(e instanceof W.Rectangle)var t=this.objects,i=this.getIndex(e);else{if(!e.body)return this._empty;t=this.objects,i=this.getIndex(e.body)}return this.nodes[0]&&(t=-1!==i?t.concat(this.nodes[i].retrieve(e)):(t=(t=(t=t.concat(this.nodes[0].retrieve(e))).concat(this.nodes[1].retrieve(e))).concat(this.nodes[2].retrieve(e))).concat(this.nodes[3].retrieve(e))),t},clear:function(){this.objects.length=0;for(var e=this.nodes.length;e--;)this.nodes[e].clear(),this.nodes.splice(e,1);this.nodes.length=0}},W.QuadTree.prototype.constructor=W.QuadTree,W.Net=function(e){this.game=e},W.Net.prototype={getHostName:function(){return window.location&&window.location.hostname?window.location.hostname:null},checkDomainName:function(e){return-1!==window.location.hostname.indexOf(e)},updateQueryString:function(e,t,i,r){void 0===i&&(i=!1),void 0!==r&&""!==r||(r=window.location.href);var o="",s=new RegExp("([?|&])"+e+"=.*?(&|#|$)(.*)","gi");if(s.test(r))o=null!=t?r.replace(s,"$1"+e+"="+t+"$2$3"):r.replace(s,"$1$3").replace(/(&|\?)$/,"");else if(null!=t){var a=-1!==r.indexOf("?")?"&":"?",n=r.split("#");r=n[0]+a+e+"="+t,n[1]&&(r+="#"+n[1]),o=r}else o=r;if(!i)return o;window.location.href=o},getQueryString:function(e){void 0===e&&(e="");var t={},i=location.search.substring(1).split("&");for(var r in i){var o=i[r].split("=");if(1this.timeline.length-1)&&(e=0),this.current=e,this.timeline[this.current].start(),this},stop:function(e){return void 0===e&&(e=!1),this.isRunning=!1,this._onUpdateCallback=null,this._onUpdateCallbackContext=null,e&&(this.onComplete.dispatch(this.target,this),this._hasStarted=!1,this.chainedTween&&this.chainedTween.start()),this.manager.remove(this),this},updateTweenData:function(e,t,i){if(0===this.timeline.length)return this;if(void 0===i&&(i=0),-1===i)for(var r=0;r=this.startTime))return W.TweenData.PENDING;this.isRunning=!0}var t=this.parent.frameBased?this.game.time.physicsElapsedMS:this.game.time.elapsedMS;for(var i in this.parent.reverse?(this.dt-=t*this.parent.timeScale,this.dt=Math.max(this.dt,0)):(this.dt+=t*this.parent.timeScale,this.dt=Math.min(this.dt,this.duration)),this.percent=this.dt/this.duration,this.value=this.easingFunction(this.percent),this.vEnd){var r=this.vStart[i],o=this.vEnd[i];Array.isArray(o)?this.parent.target[i]=this.interpolationFunction.call(this.interpolationContext,o,this.value):this.parent.target[i]=r+(o-r)*this.value}return!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent?this.repeat():W.TweenData.RUNNING},generateData:function(e){this.parent.reverse?this.dt=this.duration:this.dt=0;var t=[],i=!1,r=1/e*1e3;do{this.parent.reverse?(this.dt-=r,this.dt=Math.max(this.dt,0)):(this.dt+=r,this.dt=Math.min(this.dt,this.duration)),this.percent=this.dt/this.duration,this.value=this.easingFunction(this.percent);var o={};for(var s in this.vEnd){var a=this.vStart[s],n=this.vEnd[s];Array.isArray(n)?o[s]=this.interpolationFunction(n,this.value):o[s]=a+(n-a)*this.value}t.push(o),(!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent)&&(i=!0)}while(!i);if(this.yoyo){var h=t.slice();h.reverse(),t=t.concat(h)}return t},repeat:function(){if(this.yoyo){if(this.inReverse&&0===this.repeatCounter){for(var e in this.vStartCache)this.vStart[e]=this.vStartCache[e],this.vEnd[e]=this.vEndCache[e];return this.inReverse=!1,W.TweenData.COMPLETE}this.inReverse=!this.inReverse}else if(0===this.repeatCounter)return W.TweenData.COMPLETE;if(this.inReverse)for(var e in this.vStartCache)this.vStart[e]=this.vEndCache[e],this.vEnd[e]=this.vStartCache[e];else{for(var e in this.vStartCache)this.vStart[e]=this.vStartCache[e],this.vEnd[e]=this.vEndCache[e];0=2*this._desiredFps&&(this.suggestedFps=5*Math.floor(200/(this._elapsedAccumulator/this._frameCount)),this._frameCount=0,this._elapsedAccumulator=0),this.msMin=Math.min(this.msMin,this.elapsed),this.msMax=Math.max(this.msMax,this.elapsed),this.frames++,this.now>this._timeLastSecond+1e3&&(this.fps=Math.round(1e3*this.frames/(this.now-this._timeLastSecond)),this.fpsMin=Math.min(this.fpsMin,this.fps),this.fpsMax=Math.max(this.fpsMax,this.fps),this._timeLastSecond=this.now,this.frames=0)},gamePaused:function(){this._pauseStarted=Date.now(),this.events.pause();for(var e=this._timers.length;e--;)this._timers[e]._pause()},gameResumed:function(){this.time=Date.now(),this.pauseDuration=this.time-this._pauseStarted,this.events.resume();for(var e=this._timers.length;e--;)this._timers[e]._resume()},totalElapsedSeconds:function(){return.001*(this.time-this._started)},elapsedSince:function(e){return this.time-e},elapsedSecondsSince:function(e){return.001*(this.time-e)},reset:function(){this._started=this.time,this.removeAll()}},Object.defineProperty(W.Time.prototype,"desiredFps",{get:function(){return this._desiredFps},set:function(e){this._desiredFps=e,this.physicsElapsed=1/e,this.physicsElapsedMS=1e3*this.physicsElapsed,this.desiredFpsMult=1/e}}),W.Time.prototype.constructor=W.Time,W.Timer=function(e,t){void 0===t&&(t=!0),this.game=e,this.running=!1,this.autoDestroy=t,this.expired=!1,this.elapsed=0,this.events=[],this.onComplete=new W.Signal,this.nextTick=0,this.timeCap=1e3,this.paused=!1,this._codePaused=!1,this._started=0,this._pauseStarted=0,this._pauseTotal=0,this._now=Date.now(),this._len=0,this._marked=0,this._i=0,this._diff=0,this._newTick=0},W.Timer.MINUTE=6e4,W.Timer.SECOND=1e3,W.Timer.HALF=500,W.Timer.QUARTER=250,W.Timer.prototype={create:function(e,t,i,r,o,s){var a=e=Math.round(e);0===this._now?a+=this.game.time.time:a+=this._now;var n=new W.TimerEvent(this,e,a,i,t,r,o,s);return this.events.push(n),this.order(),this.expired=!1,n},add:function(e,t,i){return this.create(e,!1,0,t,i,Array.prototype.slice.call(arguments,3))},repeat:function(e,t,i,r){return this.create(e,!1,t,i,r,Array.prototype.slice.call(arguments,4))},loop:function(e,t,i){return this.create(e,!0,0,t,i,Array.prototype.slice.call(arguments,3))},start:function(e){if(!this.running){this._started=this.game.time.time+(e||0),this.running=!0;for(var t=0;tt.tick?1:0},clearPendingEvents:function(){for(this._i=this.events.length;this._i--;)this.events[this._i].pendingDelete&&this.events.splice(this._i,1);this._len=this.events.length,this._i=0},update:function(e){if(this.paused)return!0;if(this.elapsed=e-this._now,this._now=e,this.elapsed>this.timeCap&&this.adjustEvents(e-this.elapsed),this._marked=0,this.clearPendingEvents(),this.running&&this._now>=this.nextTick&&0=this.events[this._i].tick&&!this.events[this._i].pendingDelete;)this._newTick=this._now+this.events[this._i].delay-(this._now-this.events[this._i].tick),this._newTick<0&&(this._newTick=this._now+this.events[this._i].delay),!0===this.events[this._i].loop?this.events[this._i].tick=this._newTick:0this._marked?this.order():(this.expired=!0,this.onComplete.dispatch(this))}return!this.expired||!this.autoDestroy},pause:function(){this.running&&(this._codePaused=!0,this.paused||(this._pauseStarted=this.game.time.time,this.paused=!0))},_pause:function(){!this.paused&&this.running&&(this._pauseStarted=this.game.time.time,this.paused=!0)},adjustEvents:function(e){for(var t=0;tthis._now?this.nextTick-this._now:0}}),Object.defineProperty(W.Timer.prototype,"length",{get:function(){return this.events.length}}),Object.defineProperty(W.Timer.prototype,"ms",{get:function(){return this.running?this._now-this._started-this._pauseTotal:0}}),Object.defineProperty(W.Timer.prototype,"seconds",{get:function(){return this.running?.001*this.ms:0}}),W.Timer.prototype.constructor=W.Timer,W.TimerEvent=function(e,t,i,r,o,s,a,n){this.timer=e,this.delay=t,this.tick=i,this.repeatCount=r-1,this.loop=o,this.callback=s,this.callbackContext=a,this.args=n,this.pendingDelete=!1},W.TimerEvent.prototype.constructor=W.TimerEvent,W.AnimationManager=function(e){this.sprite=e,this.game=e.game,this.currentFrame=null,this.currentAnim=null,this.updateIfVisible=!0,this.isLoaded=!1,this._frameData=null,this._anims={},this._outputFrames=[]},W.AnimationManager.prototype={loadFrameData:function(e,t){if(void 0===e)return!1;if(this.isLoaded)for(var i in this._anims)this._anims[i].updateFrameData(e);return this._frameData=e,null==t?this.frame=0:"string"==typeof t?this.frameName=t:this.frame=t,this.isLoaded=!0},copyFrameData:function(e,t){if(this._frameData=e.clone(),this.isLoaded)for(var i in this._anims)this._anims[i].updateFrameData(this._frameData);return null==t?this.frame=0:"string"==typeof t?this.frameName=t:this.frame=t,this.isLoaded=!0},add:function(e,t,i,r,o){return t=t||[],i=i||60,void 0===r&&(r=!1),void 0===o&&(o=!(!t||"number"!=typeof t[0])),this._outputFrames=[],this._frameData.getFrameIndexes(t,o,this._outputFrames),this._anims[e]=new W.Animation(this.game,this.sprite,e,this._frameData,this._outputFrames,i,r),this.currentAnim=this._anims[e],this.sprite.tilingTexture&&(this.sprite.refreshTexture=!0),this._anims[e]},validateFrames:function(e,t){void 0===t&&(t=!0);for(var i=0;ithis._frameData.total)return!1}else if(!1===this._frameData.checkFrameName(e[i]))return!1;return!0},play:function(e,t,i,r){if(this._anims[e])return this.currentAnim===this._anims[e]?!1===this.currentAnim.isPlaying?(this.currentAnim.paused=!1,this.currentAnim.play(t,i,r)):this.currentAnim:(this.currentAnim&&this.currentAnim.isPlaying&&this.currentAnim.stop(),this.currentAnim=this._anims[e],this.currentAnim.paused=!1,this.currentFrame=this.currentAnim.currentFrame,this.currentAnim.play(t,i,r))},stop:function(e,t){void 0===t&&(t=!1),!this.currentAnim||"string"==typeof e&&e!==this.currentAnim.name||this.currentAnim.stop(t)},update:function(){return!(this.updateIfVisible&&!this.sprite.visible)&&(!(!this.currentAnim||!this.currentAnim.update())&&(this.currentFrame=this.currentAnim.currentFrame,!0))},next:function(e){this.currentAnim&&(this.currentAnim.next(e),this.currentFrame=this.currentAnim.currentFrame)},previous:function(e){this.currentAnim&&(this.currentAnim.previous(e),this.currentFrame=this.currentAnim.currentFrame)},getAnimation:function(e){return"string"==typeof e&&this._anims[e]?this._anims[e]:null},refreshFrame:function(){},destroy:function(){var e=null;for(var e in this._anims)this._anims.hasOwnProperty(e)&&this._anims[e].destroy();this._anims={},this._outputFrames=[],this._frameData=null,this.currentAnim=null,this.currentFrame=null,this.sprite=null,this.game=null}},W.AnimationManager.prototype.constructor=W.AnimationManager,Object.defineProperty(W.AnimationManager.prototype,"frameData",{get:function(){return this._frameData}}),Object.defineProperty(W.AnimationManager.prototype,"frameTotal",{get:function(){return this._frameData.total}}),Object.defineProperty(W.AnimationManager.prototype,"paused",{get:function(){return this.currentAnim.isPaused},set:function(e){this.currentAnim.paused=e}}),Object.defineProperty(W.AnimationManager.prototype,"name",{get:function(){if(this.currentAnim)return this.currentAnim.name}}),Object.defineProperty(W.AnimationManager.prototype,"frame",{get:function(){if(this.currentFrame)return this.currentFrame.index},set:function(e){"number"==typeof e&&this._frameData&&null!==this._frameData.getFrame(e)&&(this.currentFrame=this._frameData.getFrame(e),this.currentFrame&&this.sprite.setFrame(this.currentFrame))}}),Object.defineProperty(W.AnimationManager.prototype,"frameName",{get:function(){if(this.currentFrame)return this.currentFrame.name},set:function(e){"string"==typeof e&&this._frameData&&null!==this._frameData.getFrameByName(e)&&(this.currentFrame=this._frameData.getFrameByName(e),this.currentFrame&&(this._frameIndex=this.currentFrame.index,this.sprite.setFrame(this.currentFrame)))}}),W.Animation=function(e,t,i,r,o,s,a){void 0===a&&(a=!1),this.game=e,this._parent=t,this._frameData=r,this.name=i,this._frames=[],this._frames=this._frames.concat(o),this.delay=1e3/s,this.loop=a,this.loopCount=0,this.killOnComplete=!1,this.isFinished=!1,this.isPlaying=!1,this.isPaused=!1,this._pauseStartTime=0,this._frameIndex=0,this._frameDiff=0,this._frameSkip=1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.onStart=new W.Signal,this.onUpdate=null,this.onComplete=new W.Signal,this.onLoop=new W.Signal,this.isReversed=!1,this.game.onPause.add(this.onPause,this),this.game.onResume.add(this.onResume,this)},W.Animation.prototype={play:function(e,t,i){return"number"==typeof e&&(this.delay=1e3/e),"boolean"==typeof t&&(this.loop=t),void 0!==i&&(this.killOnComplete=i),this.isPlaying=!0,this.isFinished=!1,this.paused=!1,this.loopCount=0,this._timeLastFrame=this.game.time.time,this._timeNextFrame=this.game.time.time+this.delay,this._frameIndex=this.isReversed?this._frames.length-1:0,this.updateCurrentFrame(!1,!0),this._parent.events.onAnimationStart$dispatch(this._parent,this),this.onStart.dispatch(this._parent,this),(this._parent.animations.currentAnim=this)._parent.animations.currentFrame=this.currentFrame,this},restart:function(){this.isPlaying=!0,this.isFinished=!1,this.paused=!1,this.loopCount=0,this._timeLastFrame=this.game.time.time,this._timeNextFrame=this.game.time.time+this.delay,this._frameIndex=0,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this._parent.setFrame(this.currentFrame),(this._parent.animations.currentAnim=this)._parent.animations.currentFrame=this.currentFrame,this.onStart.dispatch(this._parent,this)},reverse:function(){return this.reversed=!this.reversed,this},reverseOnce:function(){return this.onComplete.addOnce(this.reverse,this),this.reverse()},setFrame:function(e,t){var i;if(void 0===t&&(t=!1),"string"==typeof e)for(var r=0;r=this._timeNextFrame)&&(this._frameSkip=1,this._frameDiff=this.game.time.time-this._timeNextFrame,this._timeLastFrame=this.game.time.time,this._frameDiff>this.delay&&(this._frameSkip=Math.floor(this._frameDiff/this.delay),this._frameDiff-=this._frameSkip*this.delay),this._timeNextFrame=this.game.time.time+(this.delay-this._frameDiff),this.isReversed?this._frameIndex-=this._frameSkip:this._frameIndex+=this._frameSkip,!this.isReversed&&this._frameIndex>=this._frames.length||this.isReversed&&this._frameIndex<=-1?this.loop?(this._frameIndex=Math.abs(this._frameIndex)%this._frames.length,this.isReversed&&(this._frameIndex=this._frames.length-1-this._frameIndex),this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&this._parent.setFrame(this.currentFrame),this.loopCount++,this._parent.events.onAnimationLoop$dispatch(this._parent,this),this.onLoop.dispatch(this._parent,this),!this.onUpdate||(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData)):(this.complete(),!1):this.updateCurrentFrame(!0)))},updateCurrentFrame:function(e,t){if(void 0===t&&(t=!1),!this._frameData)return!1;var i=this.currentFrame.index;return this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&(t||!t&&i!==this.currentFrame.index)&&this._parent.setFrame(this.currentFrame),!this.onUpdate||!e||(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData)},next:function(e){void 0===e&&(e=1);var t=this._frameIndex+e;t>=this._frames.length&&(this.loop?t%=this._frames.length:t=this._frames.length-1),t!==this._frameIndex&&(this._frameIndex=t,this.updateCurrentFrame(!0))},previous:function(e){void 0===e&&(e=1);var t=this._frameIndex-e;t<0&&(this.loop?t=this._frames.length+t:t++),t!==this._frameIndex&&(this._frameIndex=t,this.updateCurrentFrame(!0))},updateFrameData:function(e){this._frameData=e,this.currentFrame=this._frameData?this._frameData.getFrame(this._frames[this._frameIndex%this._frames.length]):null},destroy:function(){this._frameData&&(this.game.onPause.remove(this.onPause,this),this.game.onResume.remove(this.onResume,this),this.game=null,this._parent=null,this._frames=null,this._frameData=null,this.currentFrame=null,this.isPlaying=!1,this.onStart.dispose(),this.onLoop.dispose(),this.onComplete.dispose(),this.onUpdate&&this.onUpdate.dispose())},complete:function(){this._frameIndex=this._frames.length-1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.isPlaying=!1,this.isFinished=!0,this.paused=!1,this._parent.events.onAnimationComplete$dispatch(this._parent,this),this.onComplete.dispatch(this._parent,this),this.killOnComplete&&this._parent.kill()}},W.Animation.prototype.constructor=W.Animation,Object.defineProperty(W.Animation.prototype,"paused",{get:function(){return this.isPaused},set:function(e){(this.isPaused=e)?this._pauseStartTime=this.game.time.time:this.isPlaying&&(this._timeNextFrame=this.game.time.time+this.delay)}}),Object.defineProperty(W.Animation.prototype,"reversed",{get:function(){return this.isReversed},set:function(e){this.isReversed=e}}),Object.defineProperty(W.Animation.prototype,"frameTotal",{get:function(){return this._frames.length}}),Object.defineProperty(W.Animation.prototype,"frame",{get:function(){return null!==this.currentFrame?this.currentFrame.index:this._frameIndex},set:function(e){this.currentFrame=this._frameData.getFrame(this._frames[e]),null!==this.currentFrame&&(this._frameIndex=e,this._parent.setFrame(this.currentFrame),this.onUpdate&&this.onUpdate.dispatch(this,this.currentFrame))}}),Object.defineProperty(W.Animation.prototype,"speed",{get:function(){return 1e3/this.delay},set:function(e){0=this._frames.length&&(e=0),this._frames[e]},getFrameByName:function(e){return"number"==typeof this._frameNames[e]?this._frames[this._frameNames[e]]:null},checkFrameName:function(e){return null!=this._frameNames[e]},clone:function(){for(var e=new W.FrameData,t=0;t=i||t&&this._loadedPackCount===this._totalPackCount)break}if(this.updateProgress(),this._processingHead>=this._fileList.length)this.finishedLoading();else if(!this._flightQueue.length){var o=this;setTimeout(function(){o.finishedLoading(!0)},2e3)}}else this.finishedLoading(!0)},finishedLoading:function(e){this.hasLoaded||(this.hasLoaded=!0,this.isLoading=!1,e||this._fileLoadStarted||(this._fileLoadStarted=!0,this.onLoadStart.dispatch()),this.onLoadComplete.dispatch(),this.game.state.loadComplete(),this.reset())},asyncComplete:function(e,t){void 0===t&&(t=""),e.loaded=!0,e.error=!!t,t&&(e.errorMessage=t),this.processLoadQueue()},processPack:function(e){var t=e.data[e.key];if(t)for(var i=0;i=this.durationMS&&(this.usingWebAudio?this.loop?(this.onLoop.dispatch(this),this.isPlaying=!1,""===this.currentMarker?(this.currentTime=0,this.startTime=this.game.time.time,this.isPlaying=!0):(this.onMarkerComplete.dispatch(this.currentMarker,this),this.play(this.currentMarker,0,this.volume,!0,!0))):""!==this.currentMarker&&this.stop():this.loop?(this.onLoop.dispatch(this),""===this.currentMarker&&(this.currentTime=0,this.startTime=this.game.time.time),this.isPlaying=!1,this.play(this.currentMarker,0,this.volume,!0,!0)):this.stop()))):this.destroy()},loopFull:function(e){return this.play(null,0,e,!0)},play:function(e,t,i,r,o){if(void 0!==e&&!1!==e&&null!==e||(e=""),void 0===o&&(o=!0),this.isPlaying&&!this.allowMultiple&&!o&&!this.override)return this;if(this._sound&&this.isPlaying&&!this.allowMultiple&&(this.override||o)){if(this.usingWebAudio){if(void 0===this._sound.stop)this._sound.noteOff(0);else try{this._sound.stop(0)}catch(e){}this.externalNode?this._sound.disconnect(this.externalNode):this.gainNode&&this._sound.disconnect(this.gainNode)}else this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0);this.isPlaying=!1}var s=Object.keys(this.markers);if(""===e&&1===s.length&&(e=s[0]),""===e&&0this.width}}),Object.defineProperty(W.ScaleManager.prototype,"isGameLandscape",{get:function(){return this.width>this.height}}),W.Utils.Debug=function(e){this.game=e,this.sprite=null,this.bmd=null,this.canvas=null,this.context=null,this.font="14px Courier",this.columnWidth=100,this.lineHeight=16,this.renderShadow=!0,this.currentX=0,this.currentY=0,this.currentAlpha=1,this.dirty=!1},W.Utils.Debug.prototype={boot:function(){this.game.renderType===W.CANVAS?this.context=this.game.context:(this.bmd=new W.BitmapData(this.game,"__DEBUG",this.game.width,this.game.height,!0),this.sprite=this.game.make.image(0,0,this.bmd),this.game.stage.addChild(this.sprite),this.game.scale.onSizeChange.add(this.resize,this),this.canvas=PIXI.CanvasPool.create(this,this.game.width,this.game.height),this.context=this.canvas.getContext("2d"))},resize:function(e,t,i){this.bmd.resize(t,i),this.canvas.width=t,this.canvas.height=i},preUpdate:function(){this.dirty&&this.sprite&&(this.bmd.clear(),this.bmd.draw(this.canvas,0,0),this.context.clearRect(0,0,this.game.width,this.game.height),this.dirty=!1)},reset:function(){this.context&&this.context.clearRect(0,0,this.game.width,this.game.height),this.sprite&&this.bmd.clear()},start:function(e,t,i,r){"number"!=typeof e&&(e=0),"number"!=typeof t&&(t=0),i=i||"rgb(255,255,255)",void 0===r&&(r=0),this.currentX=e,this.currentY=t,this.currentColor=i,this.columnWidth=r,this.dirty=!0,this.context.save(),this.context.setTransform(1,0,0,1,0,0),this.context.strokeStyle=i,this.context.fillStyle=i,this.context.font=this.font,this.context.globalAlpha=this.currentAlpha},stop:function(){this.context.restore()},line:function(){for(var e=this.currentX,t=0;tt.width?r:o;if("viewport"===e)return this.visualBounds.height>this.visualBounds.width?r:o;if("window.orientation"===e&&"number"==typeof window.orientation)return 0===window.orientation||180===window.orientation?r:o;if(window.matchMedia){if(window.matchMedia("(orientation: portrait)").matches)return r;if(window.matchMedia("(orientation: landscape)").matches)return o}return this.visualBounds.height>this.visualBounds.width?r:o},visualBounds:new W.Rectangle,layoutBounds:new W.Rectangle,documentBounds:new W.Rectangle},W.Device.whenReady(function(e){var t=window&&"pageXOffset"in window?function(){return window.pageXOffset}:function(){return document.documentElement.scrollLeft},i=window&&"pageYOffset"in window?function(){return window.pageYOffset}:function(){return document.documentElement.scrollTop};if(Object.defineProperty(W.DOM,"scrollX",{get:t}),Object.defineProperty(W.DOM,"scrollY",{get:i}),Object.defineProperty(W.DOM.visualBounds,"x",{get:t}),Object.defineProperty(W.DOM.visualBounds,"y",{get:i}),Object.defineProperty(W.DOM.layoutBounds,"x",{value:0}),Object.defineProperty(W.DOM.layoutBounds,"y",{value:0}),e.desktop&&document.documentElement.clientWidth<=window.innerWidth&&document.documentElement.clientHeight<=window.innerHeight){var r=function(){return Math.max(window.innerWidth,document.documentElement.clientWidth)},o=function(){return Math.max(window.innerHeight,document.documentElement.clientHeight)};Object.defineProperty(W.DOM.visualBounds,"width",{get:r}),Object.defineProperty(W.DOM.visualBounds,"height",{get:o}),Object.defineProperty(W.DOM.layoutBounds,"width",{get:r}),Object.defineProperty(W.DOM.layoutBounds,"height",{get:o})}else Object.defineProperty(W.DOM.visualBounds,"width",{get:function(){return window.innerWidth}}),Object.defineProperty(W.DOM.visualBounds,"height",{get:function(){return window.innerHeight}}),Object.defineProperty(W.DOM.layoutBounds,"width",{get:function(){var e=document.documentElement.clientWidth,t=window.innerWidth;return e>>0:(e<<24|t<<16|i<<8|r)>>>0},unpackPixel:function(e,t,i,r){return null==t&&(t=W.Color.createColor()),null==i&&(i=!1),null==r&&(r=!1),W.Device.LITTLE_ENDIAN?(t.a=(4278190080&e)>>>24,t.b=(16711680&e)>>>16,t.g=(65280&e)>>>8,t.r=255&e):(t.r=(4278190080&e)>>>24,t.g=(16711680&e)>>>16,t.b=(65280&e)>>>8,t.a=255&e),t.color=e,t.rgba="rgba("+t.r+","+t.g+","+t.b+","+t.a/255+")",i&&W.Color.RGBtoHSL(t.r,t.g,t.b,t),r&&W.Color.RGBtoHSV(t.r,t.g,t.b,t),t},fromRGBA:function(e,t){return t||(t=W.Color.createColor()),t.r=(4278190080&e)>>>24,t.g=(16711680&e)>>>16,t.b=(65280&e)>>>8,t.a=255&e,t.rgba="rgba("+t.r+","+t.g+","+t.b+","+t.a+")",t},toRGBA:function(e,t,i,r){return e<<24|t<<16|i<<8|r},toABGR:function(e,t,i,r){return(r<<24|i<<16|t<<8|e)>>>0},RGBtoHSL:function(e,t,i,r){r||(r=W.Color.createColor(e,t,i,1)),e/=255,t/=255,i/=255;var o=Math.min(e,t,i),s=Math.max(e,t,i);if(r.h=0,r.s=0,r.l=(s+o)/2,s!==o){var a=s-o;r.s=.5>>24,red:e>>16&255,green:e>>8&255,blue:255&e,a:e>>>24,r:e>>16&255,g:e>>8&255,b:255&e}:{alpha:255,red:e>>16&255,green:e>>8&255,blue:255&e,a:255,r:e>>16&255,g:e>>8&255,b:255&e}},getWebRGB:function(e){if("object"==typeof e)return"rgba("+e.r.toString()+","+e.g.toString()+","+e.b.toString()+","+(e.a/255).toString()+")";var t=W.Color.getRGB(e);return"rgba("+t.r.toString()+","+t.g.toString()+","+t.b.toString()+","+(t.a/255).toString()+")"},getAlpha:function(e){return e>>>24},getAlphaFloat:function(e){return(e>>>24)/255},getRed:function(e){return e>>16&255},getGreen:function(e){return e>>8&255},getBlue:function(e){return 255&e},blendNormal:function(e){return e},blendLighten:function(e,t){return e>8)},blendExclusion:function(e,t){return e+t-2*e*t/255},blendOverlay:function(e,t){return t<128?2*e*t/255:255-2*(255-e)*(255-t)/255},blendSoftLight:function(e,t){return t<128?2*(64+(e>>1))*(t/255):255-2*(255-(64+(e>>1)))*(255-t)/255},blendHardLight:function(e,t){return W.Color.blendOverlay(t,e)},blendColorDodge:function(e,t){return 255===t?t:Math.min(255,(e<<8)/(255-t))},blendColorBurn:function(e,t){return 0===t?t:Math.max(0,255-(255-e<<8)/t)},blendLinearDodge:function(e,t){return W.Color.blendAdd(e,t)},blendLinearBurn:function(e,t){return W.Color.blendSubtract(e,t)},blendLinearLight:function(e,t){return t<128?W.Color.blendLinearBurn(e,2*t):W.Color.blendLinearDodge(e,2*(t-128))},blendVividLight:function(e,t){return t<128?W.Color.blendColorBurn(e,2*t):W.Color.blendColorDodge(e,2*(t-128))},blendPinLight:function(e,t){return t<128?W.Color.blendDarken(e,2*t):W.Color.blendLighten(e,2*(t-128))},blendHardMix:function(e,t){return W.Color.blendVividLight(e,t)<128?0:255},blendReflect:function(e,t){return 255===t?t:Math.min(255,e*e/(255-t))},blendGlow:function(e,t){return W.Color.blendReflect(t,e)},blendPhoenix:function(e,t){return Math.min(e,t)-Math.max(e,t)+255}},W.Physics=function(e,t){t=t||{},this.game=e,this.config=t,this.arcade=null,this.p2=null,this.ninja=null,this.box2d=null,this.chipmunk=null,this.matter=null,this.parseConfig()},W.Physics.ARCADE=0,W.Physics.P2JS=1,W.Physics.NINJA=2,W.Physics.BOX2D=3,W.Physics.CHIPMUNK=4,W.Physics.MATTERJS=5,W.Physics.prototype={parseConfig:function(){this.config.hasOwnProperty("arcade")&&!0!==this.config.arcade||!W.Physics.hasOwnProperty("Arcade")||(this.arcade=new W.Physics.Arcade(this.game)),this.config.hasOwnProperty("ninja")&&!0===this.config.ninja&&W.Physics.hasOwnProperty("Ninja")&&(this.ninja=new W.Physics.Ninja(this.game)),this.config.hasOwnProperty("p2")&&!0===this.config.p2&&W.Physics.hasOwnProperty("P2")&&(this.p2=new W.Physics.P2(this.game,this.config)),this.config.hasOwnProperty("box2d")&&!0===this.config.box2d&&W.Physics.hasOwnProperty("BOX2D")&&(this.box2d=new W.Physics.BOX2D(this.game,this.config)),this.config.hasOwnProperty("matter")&&!0===this.config.matter&&W.Physics.hasOwnProperty("Matter")&&(this.matter=new W.Physics.Matter(this.game,this.config))},startSystem:function(e){e===W.Physics.ARCADE?this.arcade=new W.Physics.Arcade(this.game):e===W.Physics.P2JS?null===this.p2?this.p2=new W.Physics.P2(this.game,this.config):this.p2.reset():e===W.Physics.NINJA?this.ninja=new W.Physics.Ninja(this.game):e===W.Physics.BOX2D?null===this.box2d?this.box2d=new W.Physics.Box2D(this.game,this.config):this.box2d.reset():e===W.Physics.MATTERJS&&(null===this.matter?this.matter=new W.Physics.Matter(this.game,this.config):this.matter.reset())},enable:function(e,t,i){void 0===t&&(t=W.Physics.ARCADE),void 0===i&&(i=!1),t===W.Physics.ARCADE?this.arcade.enable(e):t===W.Physics.P2JS&&this.p2?this.p2.enable(e,i):t===W.Physics.NINJA&&this.ninja?this.ninja.enableAABB(e):t===W.Physics.BOX2D&&this.box2d?this.box2d.enable(e):t===W.Physics.MATTERJS&&this.matter&&this.matter.enable(e)},preUpdate:function(){this.p2&&this.p2.preUpdate(),this.box2d&&this.box2d.preUpdate(),this.matter&&this.matter.preUpdate()},update:function(){this.p2&&this.p2.update(),this.box2d&&this.box2d.update(),this.matter&&this.matter.update()},setBoundsToWorld:function(){this.arcade&&this.arcade.setBoundsToWorld(),this.ninja&&this.ninja.setBoundsToWorld(),this.p2&&this.p2.setBoundsToWorld(),this.box2d&&this.box2d.setBoundsToWorld(),this.matter&&this.matter.setBoundsToWorld()},clear:function(){this.p2&&this.p2.clear(),this.box2d&&this.box2d.clear(),this.matter&&this.matter.clear()},reset:function(){this.p2&&this.p2.reset(),this.box2d&&this.box2d.reset(),this.matter&&this.matter.reset()},destroy:function(){this.p2&&this.p2.destroy(),this.box2d&&this.box2d.destroy(),this.matter&&this.matter.destroy(),this.arcade=null,this.ninja=null,this.p2=null,this.box2d=null,this.matter=null}},W.Physics.prototype.constructor=W.Physics,W.Physics.Arcade=function(e){this.game=e,this.gravity=new W.Point,this.bounds=new W.Rectangle(0,0,e.world.width,e.world.height),this.checkCollision={up:!0,down:!0,left:!0,right:!0},this.maxObjects=10,this.maxLevels=4,this.OVERLAP_BIAS=4,this.forceX=!1,this.sortDirection=W.Physics.Arcade.LEFT_RIGHT,this.skipQuadTree=!0,this.isPaused=!1,this.quadTree=new W.QuadTree(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this._total=0,this.setBoundsToWorld()},W.Physics.Arcade.prototype.constructor=W.Physics.Arcade,W.Physics.Arcade.SORT_NONE=0,W.Physics.Arcade.LEFT_RIGHT=1,W.Physics.Arcade.RIGHT_LEFT=2,W.Physics.Arcade.TOP_BOTTOM=3,W.Physics.Arcade.BOTTOM_TOP=4,W.Physics.Arcade.prototype={setBounds:function(e,t,i,r){this.bounds.setTo(e,t,i,r)},setBoundsToWorld:function(){this.bounds.copyFrom(this.game.world.bounds)},enable:function(e,t){void 0===t&&(t=!0);var i=1;if(Array.isArray(e))for(i=e.length;i--;)e[i]instanceof W.Group?this.enable(e[i].children,t):(this.enableBody(e[i]),t&&e[i].hasOwnProperty("children")&&0a.right)break;if(a.x>e.body.right)continue}else if(this.sortDirection===W.Physics.Arcade.TOP_BOTTOM){if(e.body.bottoma.bottom)break;if(a.y>e.body.bottom)continue}this.collideSpriteVsSprite(e,h,i,r,o,s)}}else{this.quadTree.clear(),this.quadTree.reset(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this.quadTree.populate(t);var c=this.quadTree.retrieve(e);for(n=0;nc.right)continue;if(c.x>a.right)break}else if(this.sortDirection===W.Physics.Arcade.TOP_BOTTOM){if(a.bottomc.bottom)continue;if(c.y>n.body.bottom)break}this.collideSpriteVsSprite(n,l,t,i,r,o)}}}}},collideGroupVsGroup:function(e,t,i,r,o,s){if(0!==e.length&&0!==t.length)for(var a=0;a=t.right)&&!(e.position.y>=t.bottom))))},circleBodyIntersects:function(e,t){var i=W.Math.clamp(e.center.x,t.left,t.right),r=W.Math.clamp(e.center.y,t.top,t.bottom);return(e.center.x-i)*(e.center.x-i)+(e.center.y-r)*(e.center.y-r)<=e.radius*e.radius},separateCircle:function(e,t,i){this.getOverlapX(e,t),this.getOverlapY(e,t);var r=t.center.x-e.center.x,o=t.center.y-e.center.y,s=Math.atan2(o,r),a=0;if(e.isCircle!==t.isCircle){var n={x:t.isCircle?e.position.x:t.position.x,y:t.isCircle?e.position.y:t.position.y,right:t.isCircle?e.right:t.right,bottom:t.isCircle?e.bottom:t.bottom},h={x:e.isCircle?e.position.x+e.radius:t.position.x+t.radius,y:e.isCircle?e.position.y+e.radius:t.position.y+t.radius,radius:e.isCircle?e.radius:t.radius};h.ye.velocity.x?e.velocity.x*=-1:t.velocity.x<0&&!t.immovable&&e.velocity.xe.velocity.y?e.velocity.y*=-1:t.velocity.y<0&&!t.immovable&&e.velocity.yMath.PI/2&&(e.velocity.x<0&&!e.immovable&&t.velocity.xt.velocity.x?t.velocity.x*=-1:e.velocity.y<0&&!e.immovable&&t.velocity.yt.velocity.y&&(t.velocity.y*=-1)),e.immovable||(e.x+=e.velocity.x*this.game.time.physicsElapsed-a*Math.cos(s),e.y+=e.velocity.y*this.game.time.physicsElapsed-a*Math.sin(s)),t.immovable||(t.x+=t.velocity.x*this.game.time.physicsElapsed+a*Math.cos(s),t.y+=t.velocity.y*this.game.time.physicsElapsed+a*Math.sin(s)),e.onCollide&&e.onCollide.dispatch(e.sprite,t.sprite),t.onCollide&&t.onCollide.dispatch(t.sprite,e.sprite),!0},getOverlapX:function(e,t,i){var r=0,o=e.deltaAbsX()+t.deltaAbsX()+this.OVERLAP_BIAS;return 0===e.deltaX()&&0===t.deltaX()?(e.embedded=!0,t.embedded=!0):e.deltaX()>t.deltaX()?o<(r=e.right-t.x)&&!i||!1===e.checkCollision.right||!1===t.checkCollision.left?r=0:(e.touching.none=!1,e.touching.right=!0,t.touching.none=!1,t.touching.left=!0):e.deltaX()t.deltaY()?o<(r=e.bottom-t.y)&&!i||!1===e.checkCollision.down||!1===t.checkCollision.up?r=0:(e.touching.none=!1,e.touching.down=!0,t.touching.none=!1,t.touching.up=!0):e.deltaY()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:0this.deltaMax.y&&(this._dy=this.deltaMax.y)),this.sprite.position.x+=this._dx,this.sprite.position.y+=this._dy,this._reset=!0),this.center.setTo(this.position.x+this.halfWidth,this.position.y+this.halfHeight),this.allowRotation&&(this.sprite.angle+=this.deltaZ()),this.prev.x=this.position.x,this.prev.y=this.position.y)},checkWorldBounds:function(){var e=this.position,t=this.game.physics.arcade.bounds,i=this.game.physics.arcade.checkCollision,r=this.worldBounce?-this.worldBounce.x:-this.bounce.x,o=this.worldBounce?-this.worldBounce.y:-this.bounce.y;if(this.isCircle){var s=this.center.x-this.radius,a=this.center.y-this.radius,n=this.center.x+this.radius,h=this.center.y+this.radius;st.right&&i.right&&(e.x=t.right-this.halfWidth-this.radius,this.velocity.x*=r,this.blocked.right=!0),at.bottom&&i.down&&(e.y=t.bottom-this.halfHeight-this.radius,this.velocity.y*=o,this.blocked.down=!0)}else e.xt.right&&i.right&&(e.x=t.right-this.width,this.velocity.x*=r,this.blocked.right=!0),e.yt.bottom&&i.down&&(e.y=t.bottom-this.height,this.velocity.y*=o,this.blocked.down=!0);return this.blocked.up||this.blocked.down||this.blocked.left||this.blocked.right},moveFrom:function(e,t,i){return void 0===t&&(t=this.speed),0!==t&&(void 0===i?(r=this.angle,i=this.game.math.radToDeg(r)):r=this.game.math.degToRad(i),this.moveTimer=0,this.moveDuration=e,0===i||180===i?this.velocity.set(Math.cos(r)*t,0):90===i||270===i?this.velocity.set(0,Math.sin(r)*t):this.velocity.set(Math.cos(r)*t,Math.sin(r)*t),this.isMoving=!0);var r},moveTo:function(e,t,i){var r,o=t/(e/1e3);return 0!==o&&(void 0===i?(r=this.angle,i=this.game.math.radToDeg(r)):r=this.game.math.degToRad(i),t=Math.abs(t),this.moveDuration=0,this.moveDistance=t,null===this.moveTarget&&(this.moveTarget=new W.Line,this.moveEnd=new W.Point),this.moveTarget.fromAngle(this.x,this.y,r,t),this.moveEnd.set(this.moveTarget.end.x,this.moveTarget.end.y),this.moveTarget.setTo(this.x,this.y,this.x,this.y),0===i||180===i?this.velocity.set(Math.cos(r)*o,0):90===i||270===i?this.velocity.set(0,Math.sin(r)*o):this.velocity.set(Math.cos(r)*o,Math.sin(r)*o),this.isMoving=!0)},setSize:function(e,t,i,r){void 0===i&&(i=this.offset.x),void 0===r&&(r=this.offset.y),this.sourceWidth=e,this.sourceHeight=t,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.setTo(i,r),this.center.setTo(this.position.x+this.halfWidth,this.position.y+this.halfHeight),this.isCircle=!1,this.radius=0},setCircle:function(e,t,i){void 0===t&&(t=this.offset.x),void 0===i&&(i=this.offset.y),0t.deltaAbsY()?c=-1:t.deltaAbsX()t.left&&(r=e.right-o-t.left)>this.TILE_BIAS&&(r=0),0!==r&&(e.customSeparateX?e.overlapX=r:this.processTileSeparationX(e,r)),r},tileCheckY:function(e,t,i){var r=0,o=i.fixedToCamera?0:i.position.y;return e.deltaY()<0&&!e.blocked.up&&t.collideDown&&e.checkCollision.up?t.faceBottom&&e.y-ot.top&&(r=e.bottom-o-t.top)>this.TILE_BIAS&&(r=0),0!==r&&(e.customSeparateY?e.overlapY=r:this.processTileSeparationY(e,r)),r},processTileSeparationX:function(e,t){t<0?e.blocked.left=!0:0=this.firstgid&&ethis.right||t>this.bottom)},intersects:function(e,t,i,r){return!(i<=this.worldX)&&(!(r<=this.worldY)&&(!(e>=this.worldX+this.width)&&!(t>=this.worldY+this.height)))},setCollisionCallback:function(e,t){this.collisionCallback=e,this.collisionCallbackContext=t},destroy:function(){this.collisionCallback=null,this.collisionCallbackContext=null,this.properties=null},setCollision:function(e,t,i,r){this.collideLeft=e,this.collideRight=t,this.collideUp=i,this.collideDown=r,this.faceLeft=e,this.faceRight=t,this.faceTop=i,this.faceBottom=r},resetCollision:function(){this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1},isInteresting:function(e,t){return e&&t?this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.faceTop||this.faceBottom||this.faceLeft||this.faceRight||this.collisionCallback:e?this.collideLeft||this.collideRight||this.collideUp||this.collideDown:!!t&&(this.faceTop||this.faceBottom||this.faceLeft||this.faceRight)},copy:function(e){this.index=e.index,this.alpha=e.alpha,this.properties=e.properties,this.collideUp=e.collideUp,this.collideDown=e.collideDown,this.collideLeft=e.collideLeft,this.collideRight=e.collideRight,this.collisionCallback=e.collisionCallback,this.collisionCallbackContext=e.collisionCallbackContext}},W.Tile.prototype.constructor=W.Tile,Object.defineProperty(W.Tile.prototype,"collides",{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown}}),Object.defineProperty(W.Tile.prototype,"canCollide",{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.collisionCallback}}),Object.defineProperty(W.Tile.prototype,"left",{get:function(){return this.worldX}}),Object.defineProperty(W.Tile.prototype,"right",{get:function(){return this.worldX+this.width}}),Object.defineProperty(W.Tile.prototype,"top",{get:function(){return this.worldY}}),Object.defineProperty(W.Tile.prototype,"bottom",{get:function(){return this.worldY+this.height}}),W.Tilemap=function(e,t,i,r,o,s){this.game=e,this.key=t;var a=W.TilemapParser.parse(this.game,t,i,r,o,s);null!==a&&(this.width=a.width,this.height=a.height,this.tileWidth=a.tileWidth,this.tileHeight=a.tileHeight,this.orientation=a.orientation,this.format=a.format,this.version=a.version,this.properties=a.properties,this.widthInPixels=a.widthInPixels,this.heightInPixels=a.heightInPixels,this.layers=a.layers,this.tilesets=a.tilesets,this.imagecollections=a.imagecollections,this.tiles=a.tiles,this.objects=a.objects,this.collideIndexes=[],this.collision=a.collision,this.images=a.images,this.enableDebug=!1,this.currentLayer=0,this.debugMap=[],this._results=[],this._tempA=0,this._tempB=0)},W.Tilemap.CSV=0,W.Tilemap.TILED_JSON=1,W.Tilemap.NORTH=0,W.Tilemap.EAST=1,W.Tilemap.SOUTH=2,W.Tilemap.WEST=3,W.Tilemap.prototype={create:function(e,t,i,r,o,s){return void 0===s&&(s=this.game.world),this.width=t,this.height=i,this.setTileSize(r,o),this.layers.length=0,this.createBlankLayer(e,t,i,r,o,s)},setTileSize:function(e,t){this.tileWidth=e,this.tileHeight=t,this.widthInPixels=this.width*e,this.heightInPixels=this.height*t},addTilesetImage:function(e,t,i,r,o,s,a){if(void 0===e)return null;void 0===i&&(i=this.tileWidth),void 0===r&&(r=this.tileHeight),void 0===o&&(o=0),void 0===s&&(s=0),void 0===a&&(a=0),0===i&&(i=32),0===r&&(r=32);var n=null;if(null==t&&(t=e),t instanceof W.BitmapData)n=t.canvas;else{if(!this.game.cache.checkImageKey(t))return null;n=this.game.cache.getImage(t)}var h=this.getTilesetIndex(e);if(null===h&&this.format===W.Tilemap.TILED_JSON)return null;if(this.tilesets[h])return this.tilesets[h].setImage(n),this.tilesets[h];var c=new W.Tileset(e,a,i,r,o,s,{});c.setImage(n),this.tilesets.push(c);for(var l=this.tilesets.length-1,m=o,u=o,d=0,p=0,f=0,y=a;ythis.layers.length)){void 0===t||t<=0?t=Math.min(this.game.width,this.layers[o].widthInPixels):t>this.game.width&&(t=this.game.width),void 0===i||i<=0?i=Math.min(this.game.height,this.layers[o].heightInPixels):i>this.game.height&&(i=this.game.height),this.enableDebug;var s=r.add(new W.TilemapLayer(this.game,this,o,t,i));return this.enableDebug,s}},createBlankLayer:function(e,t,i,r,o,s){if(void 0===s&&(s=this.game.world),null===this.getLayerIndex(e)){for(var a,n={name:e,x:0,y:0,width:t,height:i,widthInPixels:t*r,heightInPixels:i*o,alpha:1,visible:!0,properties:{},indexes:[],callbacks:[],bodies:[],data:null},h=[],c=0;cthis.game.width&&(m=this.game.width),u>this.game.height&&(u=this.game.height),(h=new W.TilemapLayer(this.game,this,this.layers.length-1,m,u)).name=e,s.add(h)}},getIndex:function(e,t){for(var i=0;ithis.layers[o].width&&(i=this.layers[o].width),r>this.layers[o].height&&(r=this.layers[o].height),this._results.length=0,this._results.push({x:e,y:t,width:i,height:r,layer:o});for(var s=t;s>>0;o.data=n,delete o.encoding}else if(o.compression)continue;var c={name:o.name,x:o.x,y:o.y,width:o.width,height:o.height,widthInPixels:o.width*e.tilewidth,heightInPixels:o.height*e.tileheight,alpha:o.opacity,visible:o.visible,properties:{},indexes:[],callbacks:[],bodies:[]};o.properties&&(c.properties=o.properties);var l,m,u,d=0,p=[],f=[],y=0;for(a=o.data.length;y=this.firstgid&&e=this._timer)if(this._timer=this.game.time.time+this.frequency*this.game.time.slowMotion,0!==this._flowTotal)if(0=this._flowTotal)){this.on=!1;break}}else this.emitParticle()&&(this._counter++,-1!==this._flowTotal&&this._counter>=this._flowTotal&&(this.on=!1));else this.emitParticle()&&(this._counter++,0=this._quantity&&(this.on=!1));for(e=this.children.length;e--;)this.children[e].exists&&this.children[e].update()},W.Particles.Arcade.Emitter.prototype.makeParticles=function(e,t,i,r,o){var s;void 0===t&&(t=0),void 0===i&&(i=this.maxParticles),void 0===r&&(r=!1),void 0===o&&(o=!1);var a=0,n=e,h=t;for(this._frames=t,i>this.maxParticles&&(this.maxParticles=i);athis.maxParticles&&(i=this.maxParticles),this._counter=0,this._flowQuantity=i,this._flowTotal=r,o?(this.start(!0,e,t,i),this._counter+=i,this.on=!0,this._timer=this.game.time.time+t*this.game.time.slowMotion):this.start(!1,e,t,i),this},W.Particles.Arcade.Emitter.prototype.start=function(e,t,i,r,o){if(void 0===e&&(e=!0),void 0===t&&(t=0),null==i&&(i=250),void 0===r&&(r=0),void 0===o&&(o=!1),r>this.maxParticles&&(r=this.maxParticles),this.revive(),this.visible=!0,this.lifespan=t,this.frequency=i,e||o)for(var s=0;s=this.bulletFrames.length&&(this.bulletFrameIndex=0)):this.bulletFrameRandom&&(c.frame=this.bulletFrames[Math.floor(Math.random()*this.bulletFrames.length)]);if(c.data.bodyDirty&&(this._data.customBody&&c.body.setSize(this._data.width,this._data.height,this._data.offsetX,this._data.offsetY),c.body.collideWorldBounds=this.bulletCollideWorldBounds,c.data.bodyDirty=!1),c.body.velocity.set(n,h),c.body.gravity.set(this.bulletGravity.x,this.bulletGravity.y),0!==this.bulletSpeedVariance){var m=this.fireRate;(m+=W.Math.between(-this.fireRateVariance,this.fireRateVariance))<0&&(m=0),this._nextFire=this.game.time.now+m}else this._nextFire=this.game.time.now+this.fireRate;this.shots++,this.onFire.dispatch(c,this,r),0W.Weapon.KILL_LIFESPAN&&(this.data.killType===W.Weapon.KILL_DISTANCE?this.game.physics.arcade.distanceToXY(this,this.data.fromX,this.data.fromY,!0)>this.data.killDistance&&this.kill():this.data.bulletManager.bulletBounds.intersects(this)||this.kill()),this.data.rotateToVelocity&&(this.rotation=Math.atan2(this.body.velocity.y,this.body.velocity.x)),this.data.bulletManager.bulletWorldWrap&&this.game.world.wrap(this,this.data.bulletManager.bulletWorldWrapPadding))},W.Video=function(e,t,i){if(void 0===t&&(t=null),void 0===i&&(i=null),this.game=e,this.key=t,this.width=0,this.height=0,this.type=W.VIDEO,this.disableTextureUpload=!1,this.touchLocked=!1,this.onPlay=new W.Signal,this.onChangeSource=new W.Signal,this.onComplete=new W.Signal,this.onAccess=new W.Signal,this.onError=new W.Signal,this.onTimeout=new W.Signal,this.timeout=15e3,this._timeOutID=null,this.video=null,this.videoStream=null,this.isStreaming=!1,this.retryLimit=20,this.retry=0,this.retryInterval=500,this._retryID=null,this._codeMuted=!1,this._muted=!1,this._codePaused=!1,this._paused=!1,this._pending=!1,this._autoplay=!1,this._endCallback=null,this._playCallback=null,t&&this.game.cache.checkVideoKey(t)){var r=this.game.cache.getVideo(t);r.isBlob?this.createVideoFromBlob(r.data):this.video=r.data,this.width=this.video.videoWidth,this.height=this.video.videoHeight}else i&&this.createVideoFromURL(i,!1);this.video&&!i?this.baseTexture=new PIXI.BaseTexture(this.video):this.baseTexture=new PIXI.BaseTexture(W.Cache.DEFAULT.baseTexture.source),this.baseTexture.forceLoaded(this.width,this.height),this.texture=new PIXI.Texture(this.baseTexture),this.textureFrame=new W.Frame(0,0,0,this.width,this.height,"video"),this.texture.setFrame(this.textureFrame),this.texture.valid=!1,null!==t&&this.video&&(this.texture.valid=this.video.canplay),this.snapshot=null,W.BitmapData&&(this.snapshot=new W.BitmapData(this.game,"",this.width,this.height)),!this.game.device.cocoonJS&&(this.game.device.iOS||this.game.device.chrome)||window.PhaserGlobal&&window.PhaserGlobal.fakeiOSTouchLock?this.setTouchLock():r&&(r.locked=!1)},W.Video.prototype={connectToMediaStream:function(e,t){return e&&t&&(this.video=e,this.videoStream=t,this.isStreaming=!0,this.baseTexture.source=this.video,this.updateTexture(null,this.video.videoWidth,this.video.videoHeight),this.onAccess.dispatch(this)),this},startMediaStream:function(e,t,i){if(void 0===e&&(e=!1),void 0===t&&(t=null),void 0===i&&(i=null),!this.game.device.getUserMedia)return this.onError.dispatch(this,"No getUserMedia"),!1;null!==this.videoStream&&(this.videoStream.active?this.videoStream.active=!1:this.videoStream.stop()),this.removeVideoElement(),this.video=document.createElement("video"),this.video.setAttribute("autoplay","autoplay"),null!==t&&(this.video.width=t),null!==i&&(this.video.height=i),this._timeOutID=window.setTimeout(this.getUserMediaTimeout.bind(this),this.timeout);try{navigator.getUserMedia({audio:e,video:!0},this.getUserMediaSuccess.bind(this),this.getUserMediaError.bind(this))}catch(e){this.getUserMediaError(e)}return this},getUserMediaTimeout:function(){clearTimeout(this._timeOutID),this.onTimeout.dispatch(this)},getUserMediaError:function(e){clearTimeout(this._timeOutID),this.onError.dispatch(this,e)},getUserMediaSuccess:function(e){clearTimeout(this._timeOutID),this.videoStream=e,void 0!==this.video.mozSrcObject?this.video.mozSrcObject=e:this.video.src=window.URL&&window.URL.createObjectURL(e)||e;var o=this;this.video.onloadeddata=function(){var r=10;!function e(){if(0=e.length-1)return!1;var i=e.lastIndexOf(".",t-1);if(i<=0||t-1<=i)return!1;var r=o[e.slice(t+1)];return!!r&&0<=r.indexOf(" "+e.slice(i+1,t)+" ")},e.is=function(e){var t=e.lastIndexOf(".");if(t<=0||t>=e.length-1)return!1;if(0<=e.lastIndexOf(".",t-1))return!1;var i=o[e.slice(t+1)];return!!i&&0<=i.indexOf(" "+e.slice(0,t)+" ")},e.get=function(e){var t=e.lastIndexOf(".");if(t<=0||t>=e.length-1)return null;var i=e.lastIndexOf(".",t-1);if(i<=0||t-1<=i)return null;var r=o[e.slice(t+1)];return r?r.indexOf(" "+e.slice(i+1,t)+" ")<0?null:e.slice(i+1):null},e}(),s=function(){function e(){}return e.setList=function(e){o=e||{}},e.getDomain=function(e){if(!o)return null;var t=e.match(/\./g);if(t&&t.length<2)return e;var i=this.getTld(e);if(!i)return null;var r=e.length-i.length-1;return r=e.lastIndexOf(".",r-1)+1,e.substring(r)||""},e.getTld=function(e){if(!o)return"";var t=e.lastIndexOf("."),i=e.substring(t+1);return o[i.toLowerCase()]&&r.get(e)||i},e.KEY="Domains",e}(),a=function(){function e(){this.cache={}}return Object.defineProperty(e,"instance",{get:function(){return void 0===e.classInstance&&(e.classInstance=new e),e.classInstance},enumerable:!0,configurable:!0}),e.prototype.load=function(t,e,i){var r=this;return this.contains(t)?Promise.reject("Already in cache."):(this.cache[t]={url:e,data:null},this.requestXhr(e,i).then(function(e){return r.loadComplete(t,e)}).catch(function(e){return r.remove(t),Promise.reject(e)}))},e.prototype.loadComplete=function(e,t){if(!this.contains(e))return Promise.reject("Item was removed from cache before loading was complete.");try{var i=JSON.parse(t);return this.cache[e].data=i,Promise.resolve(i)}catch(e){return Promise.reject("There was an error parsing JSON file.")}},e.prototype.remove=function(e){this.contains(e)&&delete this.cache[e]},e.prototype.get=function(e){return this.contains(e)?this.cache[e].data:null},e.prototype.contains=function(e){return this.cache.hasOwnProperty(e)},e.prototype.isLoading=function(e){return this.contains(e)&&null===this.cache[e].data},e.prototype.isLoaded=function(e){return this.contains(e)&&null!==this.cache[e].data},e.prototype.loadScript=function(r,e,o){return void 0===e&&(e=!0),new Promise(function(e,t){var i=document.createElement("script");i.src=r,i.async=!1,i.onload=function(){"function"==typeof o&&o(),e()},document.head.appendChild(i)})},e.prototype.requestXhr=function(i,r){var o;return void 0===r&&(r="application/json"),window.XMLHttpRequest?(o=new XMLHttpRequest,new Promise(function(e,t){o.onreadystatechange=function(){4===o.readyState&&(200===o.status?(e(o.responseText),o.onreadystatechange=null):0>>2]|=(i[o>>>2]>>>24-o%4*8&255)<<24-(r+o)%4*8;else if(65535>>2]=i[o>>>2];else t.push.apply(t,i);return this.sigBytes+=e,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=n.ceil(t/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],i=0;i>>2]>>>24-r%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(e){for(var t=e.length,i=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new h.init(i,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var i=[],r=0;r>>2]>>>24-r%4*8&255));return i.join("")},parse:function(e){for(var t=e.length,i=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new h.init(i,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},m=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new h.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t=this._data,i=t.words,r=t.sigBytes,o=this.blockSize,s=r/(4*o);if(e=(s=e?n.ceil(s):n.max((0|s)-this._minBufferSize,0))*o,r=n.min(4*e,r),e){for(var a=0;a>>7)^(u<<14|u>>>18)^u>>>3)+f[m-7]+((d<<15|d>>>17)^(d<<13|d>>>19)^d>>>10)+f[m-16]}u=l+((n<<26|n>>>6)^(n<<21|n>>>11)^(n<<7|n>>>25))+(n&h^~n&c)+p[m]+f[m],d=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&o^r&s^o&s),l=c,c=h,h=n,n=a+u|0,a=s,s=o,o=r,r=u+d|0}i[0]=i[0]+r|0,i[1]=i[1]+o|0,i[2]=i[2]+s|0,i[3]=i[3]+a|0,i[4]=i[4]+n|0,i[5]=i[5]+h|0,i[6]=i[6]+c|0,i[7]=i[7]+l|0},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=o.floor(i/4294967296),t[15+(r+64>>>9<<4)]=i,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});e.SHA256=i._createHelper(r),e.HmacSHA256=i._createHmacHelper(r)}(Math),l=(c=P).enc.Utf8,c.algo.HMAC=c.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=l.parse(t));var i=e.blockSize,r=4*i;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),s=this._iKey=t.clone(),a=o.words,n=s.words,h=0;h>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;a<4&&o+.75*a>>6*(3-a)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,i=this._map;(r=i.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],o=0,s=0;s>>6-s%4*2;r[o>>>2]|=(a|n)<<24-o%4*8,o++}return d.create(r,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},p=Le||(Le={}),(f=p.EGAErrorSeverity||(p.EGAErrorSeverity={}))[f.Undefined=0]="Undefined",f[f.Debug=1]="Debug",f[f.Info=2]="Info",f[f.Warning=3]="Warning",f[f.Error=4]="Error",f[f.Critical=5]="Critical",(y=p.EGAGender||(p.EGAGender={}))[y.Undefined=0]="Undefined",y[y.Male=1]="Male",y[y.Female=2]="Female",(S=p.EGAProgressionStatus||(p.EGAProgressionStatus={}))[S.Undefined=0]="Undefined",S[S.Start=1]="Start",S[S.Complete=2]="Complete",S[S.Fail=3]="Fail",(w=p.EGAResourceFlowType||(p.EGAResourceFlowType={}))[w.Undefined=0]="Undefined",w[w.Source=1]="Source",w[w.Sink=2]="Sink",g=p.http||(p.http={}),(x=g.EGASdkErrorType||(g.EGASdkErrorType={}))[x.Undefined=0]="Undefined",x[x.Rejected=1]="Rejected",(b=g.EGAHTTPApiResponse||(g.EGAHTTPApiResponse={}))[b.NoResponse=0]="NoResponse",b[b.BadResponse=1]="BadResponse",b[b.RequestTimeout=2]="RequestTimeout",b[b.JsonEncodeFailed=3]="JsonEncodeFailed",b[b.JsonDecodeFailed=4]="JsonDecodeFailed",b[b.InternalServerError=5]="InternalServerError",b[b.BadRequest=6]="BadRequest",b[b.Unauthorized=7]="Unauthorized",b[b.UnknownResponseCode=8]="UnknownResponseCode",b[b.Ok=9]="Ok";var A,_,B,D,k,E,M,I,L,O,R,F,N,U,W,X,H,j,Y,V,K,q,Z,J,Q,$,ee,te,ie,re,oe,se,ae,ne,he,ce,le,me,ue,de,pe,fe,ye,Se,we,ge,xe,be,ve,ze,Ce,Te,Pe,Ae,_e,Be,De,ke,Ee,Me,Ie,Le,Oe,Re,Fe,Ge,Ne,Ue,We,Xe,He,je,Ye,Ve;Le.EGAErrorSeverity,Le.EGAGender,Le.EGAProgressionStatus,Le.EGAResourceFlowType;(function(e){var r,t;(t=r||(r={}))[t.Error=0]="Error",t[t.Warning=1]="Warning",t[t.Info=2]="Info",t[t.Debug=3]="Debug";var i=function(){function i(){i.debugEnabled=!1}return i.setInfoLog=function(e){i.instance.infoLogEnabled=e},i.setVerboseLog=function(e){i.instance.infoLogVerboseEnabled=e},i.i=function(e){if(i.instance.infoLogEnabled){var t="Info/"+i.Tag+": "+e;i.instance.sendNotificationMessage(t,r.Info)}},i.w=function(e){var t="Warning/"+i.Tag+": "+e;i.instance.sendNotificationMessage(t,r.Warning)},i.e=function(e){var t="Error/"+i.Tag+": "+e;i.instance.sendNotificationMessage(t,r.Error)},i.ii=function(e){if(i.instance.infoLogVerboseEnabled){var t="Verbose/"+i.Tag+": "+e;i.instance.sendNotificationMessage(t,r.Info)}},i.d=function(e){if(i.debugEnabled){var t="Debug/"+i.Tag+": "+e;i.instance.sendNotificationMessage(t,r.Debug)}},i.prototype.sendNotificationMessage=function(e,t){switch(t){case r.Error:case r.Warning:break;case r.Debug:console.debug;break;case r.Info:}},i.instance=new i,i.Tag="GameAnalytics",i}();e.GALogger=i})((A=Le||(Le={})).logging||(A.logging={})),_=Le||(Le={}),B=_.utilities||(_.utilities={}),D=_.logging.GALogger,k=function(){function l(){}return l.getHmac=function(e,t){var i=P.HmacSHA256(t,e);return P.enc.Base64.stringify(i)},l.stringMatch=function(e,t){return!(!e||!t)&&t.test(e)},l.joinStringArray=function(e,t){for(var i="",r=0,o=e.length;r>2,o=(3&t)<<4|(i=e.charCodeAt(c++))>>4,s=(15&i)<<2|(n=e.charCodeAt(c++))>>6,h=63&n,isNaN(i)?s=h=64:isNaN(n)&&(h=64),a=a+l.keyStr.charAt(r)+l.keyStr.charAt(o)+l.keyStr.charAt(s)+l.keyStr.charAt(h),t=i=n=0,r=o=s=h=0,ce)return I.w(s+" validation failed: array cannot exceed "+e+" values. It has "+o.length+" values."),!1;for(var a=0;am.MaxNumberOfEntries},m.select=function(e,t,i,r){void 0===t&&(t=[]),void 0===i&&(i=!1),void 0===r&&(r=0);var o=m.getStore(e);if(!o)return null;for(var s=[],a=0;ar&&(s=s.slice(0,r+1)),s},m.update=function(e,t,i){void 0===i&&(i=[]);var r=m.getStore(e);if(!r)return!1;for(var o=0;o=a.MaxCount)){var o=se.getHmac(r,i),s=new XMLHttpRequest;s.onreadystatechange=function(){if(4===s.readyState){if(!s.responseText)return;if(200!=s.status)return void ae.w("sdk error failed. response code not 200. status code: "+s.status+", description: "+s.statusText+", body: "+s.responseText);a.countMap[t]=a.countMap[t]+1}},s.open("POST",e,!0),s.setRequestHeader("Content-Type","application/json"),s.setRequestHeader("Authorization",o);try{s.send(i)}catch(e){}}},a.MaxCount=10,a.countMap={},a}(),oe.SdkErrorTask=ne,he=Le||(Le={}),ce=he.http||(he.http={}),le=he.state.GAState,me=he.logging.GALogger,ue=he.utilities.GAUtilities,de=he.validators.GAValidator,pe=he.tasks.SdkErrorTask,fe=function(){function l(){this.protocol="https",this.hostName="api.gameanalytics.com",this.version="v2",this.baseUrl=this.protocol+"://"+this.hostName+"/"+this.version,this.initializeUrlPath="init",this.eventsUrlPath="events",this.useGzip=!1}return l.prototype.requestInit=function(e){var t=le.getGameKey(),i=(this.baseUrl,this.initializeUrlPath);i="json/null.json?https://rubick.gameanalytics.com/v2/command_center?game_key="+t+"&interval_seconds=1000000";var r=le.getInitAnnotations(),o=JSON.stringify(r);if(o){var s=this.createPayloadData(o,this.useGzip),a=[];a.push(o),l.sendRequest(i,s,a,this.useGzip,l.initRequestCallback,e)}else e(ce.EGAHTTPApiResponse.JsonEncodeFailed,null)},l.prototype.sendEventsInArray=function(e,t,i){if(0!=e.length){var r=le.getGameKey(),o=this.baseUrl+"/"+r+"/"+this.eventsUrlPath,s=JSON.stringify(e);if(s){var a=this.createPayloadData(s,this.useGzip),n=[];n.push(s),n.push(t),n.push(e.length.toString()),l.sendRequest(o,a,n,this.useGzip,l.sendEventInArrayRequestCallback,i)}else i(ce.EGAHTTPApiResponse.JsonEncodeFailed,null,t,e.length)}},l.prototype.sendSdkErrorEvent=function(e){if(le.isEventSubmissionEnabled()){var t=le.getGameKey(),i=le.getGameSecret();if(de.validateSdkErrorEvent(t,i,e)){var r,o=this.baseUrl+"/"+t+"/"+this.eventsUrlPath,s=le.getSdkErrorEventAnnotations(),a=l.sdkErrorTypeToString(e);s.type=a;var n=[];n.push(s),(r=JSON.stringify(n))?pe.execute(o,e,r,i):me.w("sendSdkErrorEvent: JSON encoding failed.")}}},l.sendEventInArrayRequestCallback=function(e,t,i,r){void 0===r&&(r=null),r[0],r[1];var o,s,a=r[2],n=parseInt(r[3]);o=e.responseText,s=e.status;var h=l.instance.processRequestResponse(s,e.statusText,o,"Events");if(h==ce.EGAHTTPApiResponse.Ok||h==ce.EGAHTTPApiResponse.BadRequest){var c=o?JSON.parse(o):{};null!=c?(ce.EGAHTTPApiResponse.BadRequest,i(h,c,a,n)):i(ce.EGAHTTPApiResponse.JsonDecodeFailed,null,a,n)}else i(h,null,a,n)},l.sendRequest=function(e,t,i,r,o,s){var a=new XMLHttpRequest,n=le.getGameSecret(),h=ue.getHmac(n,t),c=[];for(var l in c.push(h),i)c.push(i[l]);if(a.onreadystatechange=function(){4===a.readyState&&o(a,e,s,c)},a.open("POST",e,!0),a.setRequestHeader("Content-Type","text/plain"),a.setRequestHeader("Authorization",h),r)throw new Error("gzip not supported");try{a.send(t)}catch(e){}},l.initRequestCallback=function(e,t,i,r){var o,s;void 0===r&&(r=null),r[0],r[1],o=e.responseText,s=e.status;var a=o?JSON.parse(o):{},n=l.instance.processRequestResponse(s,e.statusText,o,"Init");if(n==ce.EGAHTTPApiResponse.Ok||n==ce.EGAHTTPApiResponse.BadRequest)if(null!=a)if(n!==ce.EGAHTTPApiResponse.BadRequest){var h=de.validateAndCleanInitRequestResponse(a);h?i(ce.EGAHTTPApiResponse.Ok,h,"",0):i(ce.EGAHTTPApiResponse.BadResponse,null,"",0)}else i(n,null,"",0);else i(ce.EGAHTTPApiResponse.JsonDecodeFailed,null,"",0);else i(n,null,"",0)},l.prototype.createPayloadData=function(e,t){if(t)throw new Error("gzip not supported");return e},l.prototype.processRequestResponse=function(e,t,i,r){return i?200===e?ce.EGAHTTPApiResponse.Ok:0===e||401===e?ce.EGAHTTPApiResponse.Unauthorized:400===e?ce.EGAHTTPApiResponse.BadRequest:500===e?ce.EGAHTTPApiResponse.InternalServerError:ce.EGAHTTPApiResponse.UnknownResponseCode:ce.EGAHTTPApiResponse.NoResponse},l.sdkErrorTypeToString=function(e){switch(e){case ce.EGASdkErrorType.Rejected:return"rejected";default:return""}},l.instance=new l,l}(),ce.GAHTTPApi=fe,ye=Le||(Le={}),Se=ye.events||(ye.events={}),we=ye.store.GAStore,ge=ye.store.EGAStore,xe=ye.store.EGAStoreArgsOperator,be=ye.state.GAState,ve=ye.logging.GALogger,ze=ye.utilities.GAUtilities,Ce=ye.http.EGAHTTPApiResponse,Te=ye.http.GAHTTPApi,Pe=ye.validators.GAValidator,Ae=ye.http.EGASdkErrorType,_e=function(){function u(){}return u.addSessionStartEvent=function(){if(be.isEventSubmissionEnabled()){var e={};e.category=u.CategorySessionStart,be.incrementSessionNum(),we.setItem(be.SessionNumKey,be.getSessionNum().toString()),u.addDimensionsToEvent(e),u.addEventToStore(e),ve.i("Add SESSION START event"),u.processEvents(u.CategorySessionStart,!1)}},u.addSessionEndEvent=function(){if(be.isEventSubmissionEnabled()){var e=be.getSessionStart(),t=be.getClientTsAdjusted()-e;t<0&&(ve.w("Session length was calculated to be less then 0. Should not be possible. Resetting to 0."),t=0);var i={};i.category=u.CategorySessionEnd,i.length=t,u.addDimensionsToEvent(i),u.addEventToStore(i),ve.i("Add SESSION END event."),u.processEvents("",!1)}},u.addBusinessEvent=function(e,t,i,r,o,s){if(void 0===o&&(o=null),be.isEventSubmissionEnabled())if(Pe.validateBusinessEvent(e,t,o,i,r)){var a={};be.incrementTransactionNum(),we.setItem(be.TransactionNumKey,be.getTransactionNum().toString()),a.event_id=i+":"+r,a.category=u.CategoryBusiness,a.currency=e,a.amount=t,a[be.TransactionNumKey]=be.getTransactionNum(),o&&(a.cart_type=o),u.addDimensionsToEvent(a),u.addFieldsToEvent(a,be.validateAndCleanCustomFields(s)),ve.i("Add BUSINESS event: {currency:"+e+", amount:"+t+", itemType:"+i+", itemId:"+r+", cartType:"+o+"}"),u.addEventToStore(a)}else Te.instance.sendSdkErrorEvent(Ae.Rejected)},u.addResourceEvent=function(e,t,i,r,o,s){if(be.isEventSubmissionEnabled())if(Pe.validateResourceEvent(e,t,i,r,o,be.getAvailableResourceCurrencies(),be.getAvailableResourceItemTypes())){e===ye.EGAResourceFlowType.Sink&&(i*=-1);var a={},n=u.resourceFlowTypeToString(e);a.event_id=n+":"+t+":"+r+":"+o,a.category=u.CategoryResource,a.amount=i,u.addDimensionsToEvent(a),u.addFieldsToEvent(a,be.validateAndCleanCustomFields(s)),ve.i("Add RESOURCE event: {currency:"+t+", amount:"+i+", itemType:"+r+", itemId:"+o+"}"),u.addEventToStore(a)}else Te.instance.sendSdkErrorEvent(Ae.Rejected)},u.addProgressionEvent=function(e,t,i,r,o,s,a){if(be.isEventSubmissionEnabled()){var n=u.progressionStatusToString(e);if(Pe.validateProgressionEvent(e,t,i,r)){var h,c={};h=i?r?t+":"+i+":"+r:t+":"+i:t,c.category=u.CategoryProgression,c.event_id=n+":"+h;var l=0;s&&e!=ye.EGAProgressionStatus.Start&&(c.score=o),e===ye.EGAProgressionStatus.Fail&&be.incrementProgressionTries(h),e===ye.EGAProgressionStatus.Complete&&(be.incrementProgressionTries(h),l=be.getProgressionTries(h),c.attempt_num=l,be.clearProgressionTries(h)),u.addDimensionsToEvent(c),u.addFieldsToEvent(c,be.validateAndCleanCustomFields(a)),ve.i("Add PROGRESSION event: {status:"+n+", progression01:"+t+", progression02:"+i+", progression03:"+r+", score:"+o+", attempt:"+l+"}"),u.addEventToStore(c)}else Te.instance.sendSdkErrorEvent(Ae.Rejected)}},u.addDesignEvent=function(e,t,i,r){if(be.isEventSubmissionEnabled())if(Pe.validateDesignEvent(e,t)){var o={};o.category=u.CategoryDesign,o.event_id=e,i&&(o.value=t),u.addDimensionsToEvent(o),u.addFieldsToEvent(o,be.validateAndCleanCustomFields(r)),ve.i("Add DESIGN event: {eventId:"+e+", value:"+t+"}"),u.addEventToStore(o)}else Te.instance.sendSdkErrorEvent(Ae.Rejected)},u.addErrorEvent=function(e,t,i){if(be.isEventSubmissionEnabled()){var r=u.errorSeverityToString(e);if(Pe.validateErrorEvent(e,t)){var o={};o.category=u.CategoryError,o.severity=r,o.message=t,u.addDimensionsToEvent(o),u.addFieldsToEvent(o,be.validateAndCleanCustomFields(i)),ve.i("Add ERROR event: {severity:"+r+", message:"+t+"}"),u.addEventToStore(o)}else Te.instance.sendSdkErrorEvent(Ae.Rejected)}},u.processEvents=function(e,t){if(be.isEventSubmissionEnabled())try{var i=ze.createGuid();t&&(u.cleanupEvents(),u.fixMissingSessionEndEvents());var r=[];r.push(["status",xe.Equal,"new"]);var o=[];o.push(["status",xe.Equal,"new"]),e&&(r.push(["category",xe.Equal,e]),o.push(["category",xe.Equal,e]));var s=[];s.push(["status",i]);var a=we.select(ge.Events,r);if(!a||0==a.length)return ve.i("Event queue: No events to send"),void u.updateSessionStore();if(a.length>u.MaxEventCount){if(!(a=we.select(ge.Events,r,!0,u.MaxEventCount)))return;var n=a[a.length-1].client_ts;if(r.push(["client_ts",xe.LessOrEqual,n]),!(a=we.select(ge.Events,r)))return;o.push(["client_ts",xe.LessOrEqual,n])}if(ve.i("Event queue: Sending "+a.length+" events."),!we.update(ge.Events,s,o))return;for(var h=[],c=0;ca[0]&&t[1]e.strokeWidth&&(t=e.trailWidth);var i=50-t/2;return o.render(this._pathTemplate,{radius:i,"2radius":2*i})},s.prototype._trailString=function(e){return this._pathString(e)},t.exports=s},{"./shape":7,"./utils":9}],3:[function(e,t,i){var r=e("./shape"),o=e("./utils"),s=function(e,t){this._pathTemplate="M 0,{center} L 100,{center}",r.apply(this,arguments)};((s.prototype=new r).constructor=s).prototype._initializeSvg=function(e,t){e.setAttribute("viewBox","0 0 100 "+t.strokeWidth),e.setAttribute("preserveAspectRatio","none")},s.prototype._pathString=function(e){return o.render(this._pathTemplate,{center:e.strokeWidth/2})},s.prototype._trailString=function(e){return this._pathString(e)},t.exports=s},{"./shape":7,"./utils":9}],4:[function(e,t,i){t.exports={Line:e("./line"),Circle:e("./circle"),SemiCircle:e("./semicircle"),Square:e("./square"),Path:e("./path"),Shape:e("./shape"),utils:e("./utils")}},{"./circle":2,"./line":3,"./path":5,"./semicircle":6,"./shape":7,"./square":8,"./utils":9}],5:[function(e,t,i){var l=e("shifty"),m=e("./utils"),r={easeIn:"easeInCubic",easeOut:"easeOutCubic",easeInOut:"easeInOutCubic"},o=function e(t,i){if(!(this instanceof e))throw new Error("Constructor was called without new keyword");var r;i=m.extend({duration:800,easing:"linear",from:{},to:{},step:function(){}},i),r=m.isString(t)?document.querySelector(t):t,this.path=r,this._opts=i,this._tweenable=null;var o=this.path.getTotalLength();this.path.style.strokeDasharray=o+" "+o,this.set(0)};o.prototype.value=function(){var e=this._getComputedDashOffset(),t=this.path.getTotalLength(),i=1-e/t;return parseFloat(i.toFixed(6),10)},o.prototype.set=function(e){this.stop(),this.path.style.strokeDashoffset=this._progressToOffset(e);var t=this._opts.step;if(m.isFunction(t)){var i=this._easing(this._opts.easing),r=this._calculateTo(e,i),o=this._opts.shape||this;t(r,o,this._opts.attachment)}},o.prototype.stop=function(){this._stopTween(),this.path.style.strokeDashoffset=this._getComputedDashOffset()},o.prototype.animate=function(e,i,t){i=i||{},m.isFunction(i)&&(t=i,i={});var r=m.extend({},i),o=m.extend({},this._opts);i=m.extend(o,i);var s=this._easing(i.easing),a=this._resolveFromAndTo(e,s,r);this.stop(),this.path.getBoundingClientRect();var n=this._getComputedDashOffset(),h=this._progressToOffset(e),c=this;this._tweenable=new l,this._tweenable.tween({from:m.extend({offset:n},a.from),to:m.extend({offset:h},a.to),duration:i.duration,easing:s,step:function(e){c.path.style.strokeDashoffset=e.offset;var t=i.shape||c;i.step(e,t,i.attachment)},finish:function(e){m.isFunction(t)&&t()}})},o.prototype._getComputedDashOffset=function(){var e=window.getComputedStyle(this.path,null);return parseFloat(e.getPropertyValue("stroke-dashoffset"),10)},o.prototype._progressToOffset=function(e){var t=this.path.getTotalLength();return t-e*t},o.prototype._resolveFromAndTo=function(e,t,i){return i.from&&i.to?{from:i.from,to:i.to}:{from:this._calculateFrom(t),to:this._calculateTo(e,t)}},o.prototype._calculateFrom=function(e){return l.interpolate(this._opts.from,this._opts.to,this.value(),e)},o.prototype._calculateTo=function(e,t){return l.interpolate(this._opts.from,this._opts.to,e,t)},o.prototype._stopTween=function(){null!==this._tweenable&&(this._tweenable.stop(),this._tweenable=null)},o.prototype._easing=function(e){return r.hasOwnProperty(e)?r[e]:e},t.exports=o},{"./utils":9,shifty:1}],6:[function(e,t,i){var r=e("./shape"),o=e("./circle"),s=e("./utils"),a=function(e,t){this._pathTemplate="M 50,50 m -{radius},0 a {radius},{radius} 0 1 1 {2radius},0",this.containerAspectRatio=2,r.apply(this,arguments)};((a.prototype=new r).constructor=a).prototype._initializeSvg=function(e,t){e.setAttribute("viewBox","0 0 100 50")},a.prototype._initializeTextContainer=function(e,t,i){e.text.style&&(i.style.top="auto",i.style.bottom="0",e.text.alignToBottom?s.setStyle(i,"transform","translate(-50%, 0)"):s.setStyle(i,"transform","translate(-50%, 50%)"))},a.prototype._pathString=o.prototype._pathString,a.prototype._trailString=o.prototype._trailString,t.exports=a},{"./circle":2,"./shape":7,"./utils":9}],7:[function(e,t,i){var a=e("./path"),n=e("./utils"),r="Object is destroyed",o=function e(t,i){if(!(this instanceof e))throw new Error("Constructor was called without new keyword");if(0!==arguments.length){this._opts=n.extend({color:"#555",strokeWidth:1,trailColor:null,trailWidth:null,fill:null,text:{style:{color:null,position:"absolute",left:"50%",top:"50%",padding:0,margin:0,transform:{prefix:!0,value:"translate(-50%, -50%)"}},autoStyleContainer:!0,alignToBottom:!0,value:null,className:"progressbar-text"},svgStyle:{display:"block",width:"100%"},warnings:!1},i,!0),n.isObject(i)&&void 0!==i.svgStyle&&(this._opts.svgStyle=i.svgStyle),n.isObject(i)&&n.isObject(i.text)&&void 0!==i.text.style&&(this._opts.text.style=i.text.style);var r,o=this._createSvgView(this._opts);if(!(r=n.isString(t)?document.querySelector(t):t))throw new Error("Container does not exist: "+t);this._container=r,this._container.appendChild(o.svg),this._opts.warnings&&this._warnContainerAspectRatio(this._container),this._opts.svgStyle&&n.setStyles(o.svg,this._opts.svgStyle),this.svg=o.svg,this.path=o.path,this.trail=o.trail,this.text=null;var s=n.extend({attachment:void 0,shape:this},this._opts);this._progressPath=new a(o.path,s),n.isObject(this._opts.text)&&null!==this._opts.text.value&&this.setText(this._opts.text.value)}};o.prototype.animate=function(e,t,i){if(null===this._progressPath)throw new Error(r);this._progressPath.animate(e,t,i)},o.prototype.stop=function(){if(null===this._progressPath)throw new Error(r);void 0!==this._progressPath&&this._progressPath.stop()},o.prototype.destroy=function(){if(null===this._progressPath)throw new Error(r);this.stop(),this.svg.parentNode.removeChild(this.svg),this.svg=null,this.path=null,this.trail=null,(this._progressPath=null)!==this.text&&(this.text.parentNode.removeChild(this.text),this.text=null)},o.prototype.set=function(e){if(null===this._progressPath)throw new Error(r);this._progressPath.set(e)},o.prototype.value=function(){if(null===this._progressPath)throw new Error(r);return void 0===this._progressPath?0:this._progressPath.value()},o.prototype.setText=function(e){if(null===this._progressPath)throw new Error(r);null===this.text&&(this.text=this._createTextContainer(this._opts,this._container),this._container.appendChild(this.text)),n.isObject(e)?(n.removeChildren(this.text),this.text.appendChild(e)):this.text.innerHTML=e},o.prototype._createSvgView=function(e){var t=document.createElementNS("http://www.w3.org/2000/svg","svg");this._initializeSvg(t,e);var i=null;(e.trailColor||e.trailWidth)&&(i=this._createTrail(e),t.appendChild(i));var r=this._createPath(e);return t.appendChild(r),{svg:t,path:r,trail:i}},o.prototype._initializeSvg=function(e,t){e.setAttribute("viewBox","0 0 100 100")},o.prototype._createPath=function(e){var t=this._pathString(e);return this._createPathElement(t,e)},o.prototype._createTrail=function(e){var t=this._trailString(e),i=n.extend({},e);return i.trailColor||(i.trailColor="#eee"),i.trailWidth||(i.trailWidth=i.strokeWidth),i.color=i.trailColor,i.strokeWidth=i.trailWidth,i.fill=null,this._createPathElement(t,i)},o.prototype._createPathElement=function(e,t){var i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttribute("d",e),i.setAttribute("stroke",t.color),i.setAttribute("stroke-width",t.strokeWidth),t.fill?i.setAttribute("fill",t.fill):i.setAttribute("fill-opacity","0"),i},o.prototype._createTextContainer=function(e,t){var i=document.createElement("div");i.className=e.text.className;var r=e.text.style;return r&&(e.text.autoStyleContainer&&(t.style.position="relative"),n.setStyles(i,r),r.color||(i.style.color=e.color)),this._initializeTextContainer(e,t,i),i},o.prototype._initializeTextContainer=function(e,t,i){},o.prototype._pathString=function(e){throw new Error("Override this function for each progress bar")},o.prototype._trailString=function(e){throw new Error("Override this function for each progress bar")},o.prototype._warnContainerAspectRatio=function(e){if(this.containerAspectRatio){var t=window.getComputedStyle(e,null),i=parseFloat(t.getPropertyValue("width"),10),r=parseFloat(t.getPropertyValue("height"),10);n.floatEquals(this.containerAspectRatio,i/r)}},t.exports=o},{"./path":5,"./utils":9}],8:[function(e,t,i){var r=e("./shape"),o=e("./utils"),s=function(e,t){this._pathTemplate="M 0,{halfOfStrokeWidth} L {width},{halfOfStrokeWidth} L {width},{width} L {halfOfStrokeWidth},{width} L {halfOfStrokeWidth},{strokeWidth}",this._trailTemplate="M {startMargin},{halfOfStrokeWidth} L {width},{halfOfStrokeWidth} L {width},{width} L {halfOfStrokeWidth},{width} L {halfOfStrokeWidth},{halfOfStrokeWidth}",r.apply(this,arguments)};((s.prototype=new r).constructor=s).prototype._pathString=function(e){var t=100-e.strokeWidth/2;return o.render(this._pathTemplate,{width:t,strokeWidth:e.strokeWidth,halfOfStrokeWidth:e.strokeWidth/2})},s.prototype._trailString=function(e){var t=100-e.strokeWidth/2;return o.render(this._trailTemplate,{width:t,strokeWidth:e.strokeWidth,halfOfStrokeWidth:e.strokeWidth/2,startMargin:e.strokeWidth/2-e.trailWidth/2})},t.exports=s},{"./shape":7,"./utils":9}],9:[function(e,t,i){var a="Webkit Moz O ms".split(" ");function r(e,t,i){for(var r=e.style,o=0;o\n \n
\n
\n
\n \n
\n \n
\n
\n
'+i+"
\n ",s=document.head||document.getElementsByTagName("head")[0],(a=document.createElement("style")).type="text/css",a.styleSheet?a.styleSheet.cssText=r:a.appendChild(document.createTextNode(r)),s.appendChild(a),(n=document.createElement("div")).innerHTML=o,n.id="h5branding-container",(h=document.body||document.getElementsByTagName("body")[0]).insertBefore(n,h.firstChild),this.circleLoader=new Qe.Circle("#h5branding-bar",{strokeWidth:3,color:this.options.barColor}),[4,Promise.all([this.loadBranding(),this.loadLibs(),T.preload()])];case 1:return e.sent(),this.loaded=!0,[2]}var t,i})})},t.prototype.loadBranding=function(){return Ze(this,void 0,void 0,function(){var t,i,r;return Je(this,function(e){switch(e.label){case 0:return[4,z.preload(Date.now().toString())];case 1:return e.sent(),(t=document.getElementById("h5branding-background"))&&(t.style.backgroundImage="url("+this.getGameLogoUrl(this.options.gameId)+")",t.style.backgroundColor=z.brandingBackgroundColor),(i=document.getElementById("h5branding-logo"))&&C.getBrandingDomain()!==h.BrandingDomain.Neutral&&((r=document.createElement("img")).src=z.brandingLogoUrl.replace("_small",""),i.appendChild(r)),[2]}})})},t.prototype.loadLibs=function(){var i=this,r=this.options.libs.map(function(e,t){return a.instance.loadScript(e,!0,function(){i.setScriptloadProgress(r.length,t+1)})});return Promise.all(r)},Object.defineProperty(t.prototype,"bannerAllowed",{get:function(){var e=document.body.clientWidth,t=document.body.clientHeight;return this.progress<100&&!(t=s.f?r():o.fonts.load((e=s.a,v(e)+" "+e.f+"00 300px "+x(e.c)),s.h).then(function(e){1<=e.length?i():setTimeout(t,25)},function(){r()})}()}),i=null,t=new Promise(function(e,t){i=setTimeout(t,s.f)});Promise.race([t,e]).then(function(){i&&(clearTimeout(i),i=null),s.g(s.a)},function(){s.j(s.a)})};var E={D:"serif",C:"sans-serif"},M=null;function I(){if(null===M){var e=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);M=!!e&&(parseInt(e[1],10)<536||536===parseInt(e[1],10)&&parseInt(e[2],10)<=11)}return M}function L(e,t,i){for(var r in E)if(E.hasOwnProperty(r)&&t===e.f[E[r]]&&i===e.f[E[r]])return!0;return!1}function O(e){var t,i=e.g.a.offsetWidth,r=e.h.a.offsetWidth;(t=i===e.f.serif&&r===e.f["sans-serif"])||(t=I()&&L(e,i,r)),t?n()-e.A>=e.w?I()&&L(e,i,r)&&(null===e.u||e.u.hasOwnProperty(e.a.c))?R(e,e.v):R(e,e.B):setTimeout(p(function(){O(this)},e),50):R(e,e.v)}function R(e,t){setTimeout(p(function(){i(this.g.a),i(this.h.a),i(this.j.a),i(this.m.a),t(this.a)},e),0)}function F(e,t,i){this.c=e,this.a=t,this.f=0,this.m=this.j=!1,this.s=i}k.prototype.start=function(){this.f.serif=this.j.a.offsetWidth,this.f["sans-serif"]=this.m.a.offsetWidth,this.A=n(),O(this)};var G=null;function N(e){0==--e.f&&e.j&&(e.m?((e=e.a).g&&f(e.f,[e.a.c("wf","active")],[e.a.c("wf","loading"),e.a.c("wf","inactive")]),T(e,"active")):C(e.a))}function e(e){this.j=e,this.a=new P,this.h=0,this.f=this.g=!0}function U(e,t){this.c=e,this.a=t}function W(e,t){this.c=e,this.a=t}function X(e,t){this.c=e||"https://fonts.googleapis.com/css",this.a=[],this.f=[],this.g=t||""}F.prototype.g=function(e){var t=this.a;t.g&&f(t.f,[t.a.c("wf",e.c,b(e).toString(),"active")],[t.a.c("wf",e.c,b(e).toString(),"loading"),t.a.c("wf",e.c,b(e).toString(),"inactive")]),T(t,"fontactive",e),this.m=!0,N(this)},F.prototype.h=function(e){var t=this.a;if(t.g){var i=s(t.f,t.a.c("wf",e.c,b(e).toString(),"active")),r=[],o=[t.a.c("wf",e.c,b(e).toString(),"loading")];i||r.push(t.a.c("wf",e.c,b(e).toString(),"inactive")),f(t.f,r,o)}T(t,"fontinactive",e),N(this)},e.prototype.load=function(e){this.c=new t(this.j,e.context||this.j),this.g=!1!==e.events,this.f=!1!==e.classes,function(o,e,t){var i=[],r=t.timeout;s=e,s.g&&f(s.f,[s.a.c("wf","loading")]),T(s,"loading");var s;var i=function(e,t,i){var r,o=[];for(r in t)if(t.hasOwnProperty(r)){var s=e.c[r];s&&o.push(s(t[r],i))}return o}(o.a,t,o.c),a=new F(o.c,e,r);for(o.h=i.length,e=0,t=i.length;ewindow.innerHeight?a.handleCorrect():a.handleIncorrect(),a.InW==Math.round(window.innerWidth)&&a.InH==Math.round(window.innerHeight)&&3=m.Prices[e-1][this.priceIndex]&&this.numItemsTotal(e)<9&&(Game.totalMoney-=m.Prices[e-1][this.priceIndex],Game.gameShopItems[e-1]++,this.shopThankYou()),this.itemDownId=-1,this.shopItemCursor.visible=!1,this.updateMoneyAndScore(),Game.saveCookies()},m.prototype.update=function(){if(l.prototype.update.call(this),0this.marker.y?(this.mdelta=2.3,this.elevatorMoveTimer.delay=(GameplayState.Instance.findElevatorOut()-this.marker.y)/70*1e3):(this.mdelta=-2.3,this.elevatorMoveTimer.delay=(this.marker.y-GameplayState.Instance.findElevatorOut())/70*1e3),this.marker.visible=!0,this.bClip.addEventListener(this.checkFrame,this),this.elevatorMoveTimer.start()},e.prototype.bobDeleayOutElevatorEnd=function(e){this.elevatorDelayOutTimer.stop(),this.bClip.visible=!0,GameplayState.Instance.elevators[this.currentElevatorNumber].getChild("bob").visible=!1,this.BobAction="goOut",this.bClip.gotoLabel(this.BobAction),this.fadeIn.start()},e.prototype.bobMoveInElevatorEnd=function(e){this.bClip.removeEventListener(this.checkFrame),GameplayState.Instance.gameScreen.contains(this.marker)&&(GameplayState.Instance.gameScreen.removeChild(this.marker),this.marker.visible=!1),SoundManager.getInstance().playSound("SElevatorArrive"),this.elevatorMoveTimer.stop(),this.bClip.y+=1400,this.bClip.y=GameplayState.Instance.findElevatorOut(),this.bClip.setTint(1,0),this.bClip.visible=!1,this.bobElevatorOut=!0,GameplayState.Instance.elevators[this.currentElevatorNumber].getChild("bob").visible=!0,this.elevatorDelayOutTimer.start()},e.prototype.stopMove=function(){this.marker.visible&&(this.bClip.removeEventListener(this.checkFrame),this.elevatorMoveTimer.stop())},e.prototype.startMove=function(){this.marker.visible&&(this.bClip.addEventListener(this.checkFrame,this),GameplayState.Instance.findElevatorOut()>this.marker.y?(this.mdelta=2.3,this.elevatorMoveTimer.delay=(GameplayState.Instance.findElevatorOut()-this.marker.y)/70*1e3):(this.mdelta=-2.3,this.elevatorMoveTimer.delay=(this.marker.y-GameplayState.Instance.findElevatorOut())/70*1e3),this.elevatorMoveTimer.start())},e.prototype.bobStrikeEnd=function(e){this.strikeTimer.stop(),GameplayState.Instance.BobOnEnemy(),GameplayState.Instance.BobOnZombie(),this.BobAction="stay"},e.prototype.bobFadeOut=function(e){this.bTint-=.1,this.bClip.setTint(0,1-this.bTint),this.bTint<=.10001&&(this.fadeOut.stop(),this.doorCoor=GameplayState.Instance.findDoorOut(),this.bClip.x=this.doorCoor.x,this.bClip.y=this.doorCoor.y,this.BobAction="goOut",this.bClip.gotoLabel(this.BobAction),this.fadeIn.start())},e.prototype.bobFadeOutElev=function(e){this.bTint-=.1,this.bClip.setTint(0,1-this.bTint),this.bTint<=.10001&&(this.fadeOutElev.stop(),GameplayState.Instance.gameScreen.addChild(this.marker),this.marker.x=this.bClip.x,this.marker.y=this.bClip.y,this.marker.visible=!1,this.bClip.y-=1400,GameplayState.Instance.elevators[this.currentElevatorNumber].getChild("bob").visible=!0,this.elevatorDelayInTimer.start())},e.prototype.checkFrame=function(e){this.marker.y+=this.mdelta},e.prototype.bobFadeIn=function(e){this.bTint+=.1,0==this.bobElevatorOut&&this.bClip.setTint(1-this.bTint,0),1.0001<=this.bTint&&(this.fadeIn.stop(),this.BobAction="stay",this.bobElevatorOut&&GameplayState.Instance.ActivateControls(),this.bobElevatorOut=!1,this.bobActive=!0)},e.prototype.reset=function(){this.fadeOut.stop(),this.fadeOutElev.stop(),this.fadeIn.stop(),this.strikeTimer.stop(),this.elevatorMoveTimer.stop(),this.elevatorDelayInTimer.stop(),this.elevatorDelayOutTimer.stop(),this.BobAction="stay",this.bTint=1,this.wallLeft=!1,this.wallRight=!1,this.bobElevatorOut=!1,this.mdelta=0,this.speedUp=!1,this.odorless=!1,this.runShadow=!1,this.marker.visible=!1,null==this.bClip.getChild("speedLight")&&(this.bClip.addChild(new MovieClip("SpeedLight",7,-1,"speedLight")),this.bClip.addChildAt(new MovieClip("BobTailPlace",0,0,"tailPlace"),0),this.addBobAnimations(this.bClip)),this.bClip.getChild("speedLight").visible=!1},e.prototype.gotoWorkRightLoop=function(){this.bClip.gotoLabel("workRightLoop")},e.prototype.gotoWorkLeftLoop=function(){this.bClip.gotoLabel("workLeftLoop")},e.prototype.gotoWorkLoop=function(){this.bClip.gotoLabel("workLoop")},e.prototype.gotoStay=function(){this.bClip.gotoLabel("stay")},e.prototype.addBobAnimations=function(e){e.registerAnimation("stay",1),e.registerAnimation("stay2",2),e.registerAnimation("goleft",3,14),e.registerAnimation("goright",15,26),e.registerAnimation("goIn",27,36,-1,!1),e.registerAnimation("goOut",37,46,-1,!1),e.registerAnimation("climb",47,56),e.registerAnimation("hideIn",57,68,-1,!1),e.registerAnimation("hideOut",69,80,-1,!1),e.registerAnimation("fightright",81,84,-1,!1,function(){e.gotoLabel("stay")},this),e.registerAnimation("fightleft",85,88,-1,!1,function(){e.gotoLabel("stay")},this),e.registerAnimation("emptyPushRight",89,96,-1,!1,function(){e.gotoLabel("stay")},this),e.registerAnimation("emptyPushLeft",97,104,-1,!1,function(){e.gotoLabel("stay")},this),e.registerAnimation("work",105,114,-1,!1),e.registerAnimation("workLoop",114,129,-1,!1,function(){e.gotoAndStop(114)},this),e.registerAnimation("workLeft",130,134,-1,!1),e.registerAnimation("workLeftLoop",134,145,-1,!1,function(){e.gotoAndStop(134)},this),e.registerAnimation("workRight",146,150,-1,!1),e.registerAnimation("workRightLoop",150,161,-1,!1,function(){e.gotoAndStop(150)},this),e.registerAnimation("busted",162),e.registerAnimation("photo",163,192,-1,!1),e.registerAnimation("drink",193,230,-1,!1),e.registerAnimation("spray",231,268,-1,!1),e.registerAnimation("fireLeft",269,283,-1,!1),e.registerAnimation("fireRight",284,298,-1,!1)},e.prototype.bClip_bWork_play=function(){114==this.bClip.currentFrame?this.bClip.gotoLabel("workLoop"):134==this.bClip.currentFrame?this.bClip.gotoLabel("workLeftLoop"):150==this.bClip.currentFrame&&this.bClip.gotoLabel("workRightLoop")},e}(),Camera=function(){function e(e){this.switchTimerIdle=new Timer(3e3,0),this.prepareWarningTimer=new Timer(1e3,0),this.searchBobTimer=new Timer(100,0),this.blindTimer=new Timer(300,0),this.countDelay=new Timer(1e3,0),this.delta=0,this.pastDelay=0,this.IdleTimer=e.params.IdleTimer,this.Direction=e.params.Direction,this.ViewZoneLeft=e.params.ViewZoneLeft,this.ViewZoneRight=e.params.ViewZoneRight,this.cameraClip=e,this.cameraClip.gotoAndStop(7),this.switchTimerIdle.delay=this.IdleTimer,this.switchTimerIdle.addEventListener(this.cameraSwitch,this),this.switchTimerIdle.start(),this.countDelay.addEventListener(this.delayCount,this),this.countDelay.start(),this.prepareWarningTimer.addEventListener(this.warningStart,this),this.blindTimer.addEventListener(this.blindTimerEnd,this),this.passed=!1,this.cameraBlind=!1,this.stopped=!1,this.cameraClip.applyLayout("CameraOverlay"),this.cameraClip.addEventListener(this.on_enter_frame,this)}return e.prototype.on_enter_frame=function(e){var t=this.cameraClip;this.passed&&(t=this.cameraClipPassed),t.curFrameCheckAndProc(1)?this.passed||(t.getChild("lightRight").visible=t.getChild("lightLeft").visible=!1):t.curFrameCheckAndProc(5)?this.passed||(t.getChild("lightLeft").visible=!0,t.getChild("lightRight").visible=!1):t.curFrameCheckAndProc(7)?(this.passed||(t.getChild("lightLeft").visible=!0,t.getChild("lightRight").visible=!1),this.stopped=!0):t.curFrameCheckAndProc(8)?this.passed||(t.getChild("lightRight").visible=t.getChild("lightLeft").visible=!1):t.curFrameCheckAndProc(12)?this.passed||(t.getChild("lightLeft").visible=!1,t.getChild("lightRight").visible=!0):t.curFrameCheckAndProc(14)&&(this.passed||(t.getChild("lightLeft").visible=!1,t.getChild("lightRight").visible=!0),this.stopped=!0),this.stopped||t.gotoAndStop(t.currentFrame%14+1)},e.prototype.blindTimerEnd=function(e){this.blindTimer.stop(),this.cameraBlind=!1},e.prototype.warningStart=function(e){this.prepareWarningTimer.stop(),this.passed||(this.cameraClip.getChild("lightLeft").gotoAndStop(3),this.cameraClip.getChild("lightRight").gotoAndStop(3)),this.cameraClip.getChild("sign").gotoAndStop(3),1=this.fireStart&&this.enemyClip.currentFrame<=this.fireEnd){var t=this.fireStart+(this.fireEnd-this.fireStart+1)/2,i=void 0,r=void 0,o=void 0;o=this.enemyClip.currentFrame=this.rightPosition)&&(this.DistancePassed=0,"left"==this.enemyLastDirrection?this.enemyLastDirrection="right":this.enemyLastDirrection="left","[object Dog]"==this.enemyType?"left"==this.enemyLastDirrection?this.enemyAction="alarm_standL":this.enemyAction="alarm_standR":this.enemyAction="stand",this.enemyClip.gotoLabel(this.enemyAction),this.stopWalkTimer.start())),"waitForWarningWalk"!=this.enemyAction||this.bobDetected||("[object Oldman]"==this.enemyType?(this.enemySign.gotoAndStop(2),this.enemyAction="alarm_walk","left"==this.enemyLastDirrection?this.enemyClip.gotoLabel("alarm_walkR"):this.enemyClip.gotoLabel("alarm_walkL")):(this.enemyClip.gotoLabel("alarm_stand"),this.enemySign.gotoAndStop(2))),"alarm_walk"==this.enemyAction&&!this.bobDetected&&"[object Oldman]"==this.enemyType){this.enemyClip.gotoLabel("alarm_stand"),this.enemySign.gotoAndStop(2);s=this.enemyClip.currentFrame-this.alarmStart+1;this.enemyLastDirrection=1<=s&&s<24?"left":"right"}"warning_walk"!=this.enemyAction||this.bobDetected||"[object Policeman]"!=this.enemyType&&"[object Ambal]"!=this.enemyType&&"[object Securityman]"!=this.enemyType||(this.enemySign.gotoAndStop(2),"left"==this.enemyLastDirrection&&(this.enemyClip.gotoLabel("alarm_walkR"),this.enemyClip.x+=1,this.DistancePassedAlarm+=1,this.DistancePassed+=1,this.enemySign.x=this.enemyClip.x),"right"==this.enemyLastDirrection&&(this.enemyClip.gotoLabel("alarm_walkL"),this.enemyClip.x-=1,this.DistancePassedAlarm-=1,this.DistancePassed-=1,this.enemySign.x=this.enemyClip.x),(Math.abs(this.DistancePassedAlarm)>=this.bobDetectedPoint||Math.abs(this.DistancePassed)>=this.enemyClip.params.Distance)&&(this.DistancePassedAlarm=0,this.enemyAction="waitForWarningWalk",this.stopWarningWalkTimer.start())),"zombieAttack"==this.enemyAction&&("left"==this.enemyLastDirrection&&(this.enemyClip.gotoLabel("alarm_walkR"),this.enemyClip.x+=3,this.DistancePassedAlarm+=3,this.DistancePassed+=3,this.enemySign.x=this.enemyClip.x),"right"==this.enemyLastDirrection&&(this.enemyClip.gotoLabel("alarm_walkL"),this.enemyClip.x-=3,this.DistancePassedAlarm-=3,this.DistancePassed-=3,this.enemySign.x=this.enemyClip.x),(Math.abs(this.DistancePassedAlarm)>=this.bobDetectedPoint||Math.abs(this.DistancePassed)>=this.enemyClip.params.Distance)&&(this.DistancePassedAlarm=0,this.enemyAction="waitForWarningWalk",this.stopWarningWalkTimer.start()))},e.prototype.catchBob=function(){GameplayState.Instance.bobBitten=!0,"[object Dog]"==this.enemyType?(this.enemyClip.removeEventListener(this.checkFrame),SoundManager.getInstance().playSound(this.soundEnemyBite),"left"==this.enemyLastDirrection?this.enemyClip.gotoLabel("biteR"):this.enemyClip.gotoLabel("biteL"),this.enemyClip.addEventListener(this.biteUpdate,this)):("left"==this.enemyLastDirrection?this.enemyClip.gotoLabel("alarmR"):this.enemyClip.gotoLabel("alarmL"),GameplayState.Instance.totalAlerts=4)},e.prototype.biteUpdate=function(e){if(this.enemyClip.currentFramethis.biteEnd)this.enemyClip.removeEventListener(this.biteUpdate);else{var t=this.biteStart+(this.biteEnd-this.biteStart+1)/2;this.enemyClip.currentFrame!=t-1&&this.enemyClip.currentFrame!=this.biteEnd||(GameplayState.Instance.totalAlerts=4,this.enemyClip.removeEventListener(this.biteUpdate))}},e.prototype.isBobDetected=function(e){if(void 0===e&&(e=!1),this.bobCoor=GameplayState.Instance.getBobCoor(),this.bobDetected=!1,GameplayState.Instance.isBobHide())return!1;if("stun"==this.enemyAction||"shock"==this.enemyAction)return!1;if(this.bobCoor.xthis.leftPosition-40&&Math.abs(this.enemyClip.y-this.bobCoor.y)<30){if("left"==this.enemyLastDirrection&&this.bobCoor.x>this.enemyClip.x)return this.bobDetected=!0,"seeAbout"==this.enemyAction&&this.wakeUpFromStunned("endSeeAbout"),this.prepareWarningWalkTimer.stop(),this.stopWarningWalkTimer.stop(),this.bobDetectedPoint=Math.abs(this.bobCoor.x-this.enemyClip.x)-20,!0;if("right"==this.enemyLastDirrection&&this.bobCoor.x=this.enterFrameListeners.length))(i=this.enterFrameListeners[e])||(this.enterFrameListeners.splice(e,1),this.enterFrameListenersContexts.splice(e,1))}}},p.prototype.addEventListener=function(e,t){if(this.enterFrameListeners)for(var i=0;i>16&255)*t,this.tintGreen=255-(e>>8&255)*t,this.tintBlue=255-(255&e)*t},Object.defineProperty(p.prototype,"tintRed",{get:function(){return this.tint>>16&255},set:function(e){this.tint=(Math.round(Math.min(255,Math.max(0,e)))<<16)+(65535&this.tint)},enumerable:!0,configurable:!0}),Object.defineProperty(p.prototype,"tintGreen",{get:function(){return this.tint>>8&255},set:function(e){this.tint=(Math.round(Math.min(255,Math.max(0,e)))<<8)+(this.tint&510<<16)},enumerable:!0,configurable:!0}),Object.defineProperty(p.prototype,"tintBlue",{get:function(){return 255&this.tint},set:function(e){this.tint=Math.round(Math.min(255,Math.max(0,e)))+(16776960&this.tint)},enumerable:!0,configurable:!0}),p.prototype.generateDefaultAnimation=function(e){void 0===e&&(e=-1);var t=Phaser.Animation.generateFrameNames(this.mc,0,this.totalFrames(),"",4);this.animations.add("_null",t,p.FrameRate(e))},p.prototype.playLoop=function(e,t){void 0===e&&(e=-1),void 0===t&&(t="_null"),this.playAnimation2(t,p.FrameRate(e),!0)},p.prototype.playOnce=function(e,t){void 0===e&&(e=-1),void 0===t&&(t="_null"),this.playAnimation2(t,p.FrameRate(e),!1)},p.prototype.playToEnd=function(e,t,i){void 0===e&&(e=-1),void 0===t&&(t=-1),void 0===i&&(i=!1),t<0&&(t=this.currentFrame);var r="_null";if(1t&&(t=c.x+c.width),c.yr&&(r=c.y+c.height)}}}var l=this.degrees*Math.PI/180,m=new PIXI.Rectangle;return p.updateRectWithPointRot(m,e,i,l,!0),p.updateRectWithPointRot(m,t,i,l),p.updateRectWithPointRot(m,t,r,l),p.updateRectWithPointRot(m,e,r,l),m.width=m.width-m.x,m.height=m.height-m.y,m},p.updateRectWithPointRot=function(e,t,i,r,o){void 0===o&&(o=!1);var s=t*Math.cos(r)-i*Math.sin(r),a=t*Math.sin(r)+i*Math.cos(r);o?(e.x=s,e.width=s,e.y=a,e.height=a):(se.width&&(e.width=s),ae.height&&(e.height=a))},p.prototype.drawOutline=function(){var e=Game.getGame().add.graphics(0,0);if(this.addChildAt(e,0),e.lineStyle(3,65280),"CameraGraphicsComp"==this.mc)e.drawCircle(0,-2,24);else{var t=this.getMcBounds();e.drawPolygon([new Phaser.Point(t.x,t.y),new Phaser.Point(t.x+t.width,t.y),new Phaser.Point(t.x+t.width,t.y+t.height),new Phaser.Point(t.x,t.y+t.height),new Phaser.Point(t.x,t.y)])}return e.endFill(),e.rotation=this.rotation,e},p.prototype.cloneMeToChildren=function(e,t,i,r,o){void 0===i&&(i=0),void 0===r&&(r=0),void 0===o&&(o=0);for(var s=0;s=e&&(this._pauseCount=0,this.nextTask())},e.prototype.removeAllTasks=function(){this._tasks=new Array},e.prototype.nextTask=function(e){void 0===e&&(e=!1),this.cycle&&!e?this._tasks.push(this._tasks.shift()):this._tasks.shift()},e.prototype.start=function(){this.isStarted||(this.isStarted=!0,this.isPaused=!1)},e.prototype.stop=function(){this.isStarted=!1},e.prototype.update=function(){var e=this._tasks[0];e?(this.result=e.func.call(e.context,e.params),e==this._tasks[0]&&(e.isInstant||this.result)&&this.nextTask(e.ignoreCycle)):stop()},Object.defineProperty(e.prototype,"pause",{get:function(){return this.isPaused},set:function(e){e&&!this.isPaused?this.isPaused=!0:this._tasks[0]&&this.isPaused&&(this.isPaused=!1)},enumerable:!0,configurable:!0}),e.prototype.tasksNum=function(){return this._tasks.length},e.ALL_TASKS_DONE="allTasksDone",e}(),Timer=function(){function s(e,t){void 0===t&&(t=0),this.delay=e,this.repeatCount=t,this.next=this.prev=null,this.containerId=-1,this.currentCount=0}return s.Init=function(){s.TimerHeads=new Array(this.MAX_TIMES),s.CurFrame=0},s.Process=function(e){for(var t=0;t=r.repeatCount?r.remove():r.add(s.CurFrame+r.delay))}},Object.defineProperty(s.prototype,"delay",{get:function(){return this._delay},set:function(e){this._delay=e,this.running&&(this.stop(),this.start())},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"running",{get:function(){return 0<=this.containerId},enumerable:!0,configurable:!0}),s.prototype.addEventListener=function(e,t){if(this.listeners)for(var i=0;i=this.rightPosition)&&(this.DistancePassed=0,"left"==this.enemyLastDirrection?this.enemyLastDirrection="right":this.enemyLastDirrection="left",this.enemyAction="stand",this.enemyClip.gotoLabel(this.enemyAction),this.stopWalkTimer.start())),"waitForWarningWalk"!=this.enemyAction||this.bobDetected||(this.enemyClip.gotoLabel("alarm_stand"),this.enemySign.gotoAndStop(2)),"zombieAttack"==this.enemyAction&&("left"==this.enemyLastDirrection&&(this.enemyClip.gotoLabel("alarm_walkR"),this.enemyClip.x+=3,this.DistancePassedAlarm+=3,this.DistancePassed+=3,this.enemySign.x=this.enemyClip.x),"right"==this.enemyLastDirrection&&(this.enemyClip.gotoLabel("alarm_walkL"),this.enemyClip.x-=3,this.DistancePassedAlarm-=3,this.DistancePassed-=3,this.enemySign.x=this.enemyClip.x),(Math.abs(this.DistancePassedAlarm)>=this.bobDetectedPoint||Math.abs(this.DistancePassed)>=this.enemyClip.params.Distance)&&(this.enemyAction="waitForWarningWalk",this.stopWarningWalkTimer.start())),!GameplayState.Instance.isBobHide()&&OzUtil.HitTest(GameplayState.Instance.theBob.bClip,GameplayState.Instance.theBob.bbody,this.enemyClip,this.bbody)&&0==GameplayState.Instance.theBob.odorless&&(GameplayState.Instance.theBob.strikeTimer.stop(),this.catchBob(),GameplayState.Instance.theBob.bobActive=!1)},e.prototype.catchBob=function(){GameplayState.Instance.bobBitten=!0,this.enemyClip.removeEventListener(this.checkFrame),SoundManager.getInstance().playSound(this.soundEnemyBite),GameplayState.Instance.theBob.bClip.x>this.enemyClip.x?this.enemyClip.gotoLabel("biteR"):this.enemyClip.gotoLabel("biteL"),this.enemyClip.addEventListener(this.biteUpdate,this)},e.prototype.biteUpdate=function(e){if(this.enemyClip.currentFramethis.biteEnd)this.enemyClip.removeEventListener(this.biteUpdate);else{var t=this.biteStart+(this.biteEnd-this.biteStart+1)/2;this.enemyClip.currentFrame!=t-1&&this.enemyClip.currentFrame!=this.biteEnd||(GameplayState.Instance.totalAlerts=4,this.enemyClip.removeEventListener(this.biteUpdate))}},e.prototype.isBobDetected=function(e){if(void 0===e&&(e=!1),this.bobCoor=GameplayState.Instance.getBobCoor(),this.bobDetected=!1,"stun"==this.enemyAction||"shock"==this.enemyAction)return!1;if(GameplayState.Instance.isBobHide())return!1;if(this.bobCoor.xthis.leftPosition-40&&Math.abs(this.enemyClip.y-this.bobCoor.y)<30){if("left"==this.enemyLastDirrection&&this.bobCoor.x>this.enemyClip.x)return this.bobDetected=!0,"seeAbout"==this.enemyAction&&this.wakeUpFromStunned("endSeeAbout"),this.prepareWarningWalkTimer.stop(),this.stopWarningWalkTimer.stop(),this.bobDetectedPoint=Math.abs(this.bobCoor.x-this.enemyClip.x)-20,!0;if("right"==this.enemyLastDirrection&&this.bobCoor.x=this.levelScore?(this.levelWinScreen.getChild("gStar"+this.levelScore).playOnce(),this.levelScore++):this.scoreCountTimer.stop()),"scoreAlarm"==this.currentSpin&&(this.currentAlerts!=4-this.totalAlerts?(this.levelScore+=20,this.currentAlerts+=1,OzUtil.MakeDigits(this.currentAlerts,this.levelWinScreen.getChild("score").getChild("trevoga").meAndMyKids(),!0,!0),this.tvUpdateTotalScore(this.tvTotalScore+20)):(this.levelScore=1,this.currentSpin="scoreStars",this.scoreCountTimer.stop(),this.scoreCountDelayTimer.start())),"scoreMoney"==this.currentSpin&&(this.levelScore>=this.moneyCollected||this.moneyCollected<=10?(this.levelScore=0,OzUtil.MakeDigits(this.moneyCollected,this.levelWinScreen.getChild("score").getChild("Money").meAndMyKids(),!0,!0),this.tvUpdateTotalScore(this.tvTimeScore+this.moneyCollected),this.currentSpin="scoreAlarm",this.currentAlerts=0,this.scoreCountTimer.stop(),this.scoreCountDelayTimer.start()):(this.levelScore+=this.moneyCollected/10,OzUtil.MakeDigits(this.levelScore,this.levelWinScreen.getChild("score").getChild("Money").meAndMyKids(),!0,!0),this.tvUpdateTotalScore(this.tvTimeScore+this.levelScore))),"scoreTime"==this.currentSpin&&(1==this.pastTime&&(this.pastTime=0),this.levelScore>=this.pastTime||this.pastTime<=10?(this.levelScore=0,this.tvUpdateTimeScore(this.pastTime),this.tvUpdateTotalScore(this.pastTime),this.currentSpin="scoreMoney",this.scoreCountTimer.stop(),this.scoreCountDelayTimer.start()):(this.levelScore+=this.pastTime/10,this.tvUpdateTimeScore(this.levelScore),this.tvUpdateTotalScore(this.levelScore)))},v.prototype.ozShowAndSaveScore=function(e){if(SoundManager.getInstance().stopSound("SAnnouncer"),this.levelWinScreen.removeEventListener(this.updateScoreCount),this.levelWinScreen.getChild("newsChannel").getChild("newsHead").gotoAndStop(75),this.levelWinScreen.getChild("stripes").visible=!1,this.levelWinScreen.getChild("newsChannel").visible=!1,this.levelWinScreen.getChild("score").visible=!0,this.levelStarsGet=this.scores.getStars(this.moneyCollected-this.scores.getTimeForStars(this.pastTime,this.currentLevelNumber)-.1*this.scores.getMoney(this.currentLevelNumber)*this.totalAlerts,this.currentLevelNumber),this.pastTime=this.scores.getTime(this.pastTime,this.currentLevelNumber),Game.levelsScore[this.currentLevelNumber-1]=v.WalkTargetX)&&(this.theBob.bClip.x=v.WalkTargetX,this.stopWalking()),this.BobOnElevator(),this.theBob.bobActive&&(this.BobOnStairs()&&!this.BobOnFloor()||"climb"==this.theBob.BobAction||"stay2"==this.theBob.BobAction||(this.leftKey&&(this.theBob.wallLeft||(this.theBob.speedUp?(this.bobTimerLeft.running||this.bobTimerLeft.start(),this.theBob.bClip.x-=5):this.theBob.bClip.x-=2.5),this.theBob.strikeTimer.running||(this.theBob.BobAction="goleft")),this.rightKey&&(this.theBob.wallRight||(this.theBob.speedUp?(this.bobTimerRight.running||this.bobTimerRight.start(),this.theBob.bClip.x+=5):this.theBob.bClip.x+=2.5),this.theBob.strikeTimer.running||(this.theBob.BobAction="goright"))),this.upKey&&!this.theBob.strikeTimer.running&&(this.BobOnStairs()&&(!this.BobOnFloor()||0==this.theBob.twoStairs&&this.theBob.currentStairYthis.theBob.bClip.y)||this.theBob.twoStairs&&0==this.leftKey?(this.theBob.BobAction="climb",this.theBob.bClip.x=this.theBob.currentStairX,SoundManager.getInstance().stopSound("SBobWalk"),SoundManager.getInstance().isPlaying("SBobClimb")||SoundManager.getInstance().playSound("SBobClimb")):(SoundManager.getInstance().stopSound("SBobClimb"),"climb"==this.theBob.BobAction&&(this.theBob.speedUp?(this.theBob.bClip.y+=4,this.bobTimerUp.running||this.bobTimerUp.start()):this.theBob.bClip.y+=2),this.leftKey?this.theBob.BobAction="goleft":this.rightKey?this.theBob.BobAction="goright":this.theBob.BobAction="stay"),"climb"==this.theBob.BobAction&&(this.theBob.speedUp?(this.theBob.bClip.y+=4,this.bobTimerUp.running||this.bobTimerUp.start()):this.theBob.bClip.y+=2))),""!=this.bonusType?"gametarget"==this.bonusType&&(this.theBob.BobAction="work"):this.messageFullScreen.visible&&(this.theBob.BobAction="work"),"emptyPushLeft"!=this.theBob.BobAction&&"emptyPushRight"!=this.theBob.BobAction&&"fightright"!=this.theBob.BobAction&&"fightleft"!=this.theBob.BobAction&&this.totalAlerts<4&&this.theBob.bobActive&&this.theBob.bClip.gotoLabel(this.theBob.BobAction),this.theBob.bProgressSkill.visible)if(this.theBob.bProgressSkill.currentFrame<=99)this.theBob.bClip_bWork_play();else{if("lockpicks"==this.bonusType&&(SoundManager.getInstance().playSound("SUnlock"),this.findDoorToOpen(),1==this.zxcType&&this.iPanel.getChild("zbutton").gotoAndStop(1),2==this.zxcType&&this.iPanel.getChild("xbutton").gotoAndStop(1),3==this.zxcType&&this.iPanel.getChild("cbutton").gotoAndStop(1),this.theBob.bobActive=!0,this.ActivateControls()),this.endProgress(),"gametarget"==this.bonusType){if(this.gameTarget.visible=!1,this.gameExit.visible=!0,4==this.getLevelNumber()&&this.captive.gotoAndStop(2),5==this.getLevelNumber()&&(this.prisonGift.visible=!0),9==this.getLevelNumber()&&this.level9Box.gotoAndStop(2),11==this.getLevelNumber()||7==this.getLevelNumber())for(var u,d,p=0;pthis.enemies[o].enemyClip.x||"fireRight"==this.theBob.BobAction&&this.theBob.bClip.xthis.sidedoors[s].x||"fireRight"==this.theBob.BobAction&&this.theBob.bClip.xthis.walls[a].x||"fireRight"==this.theBob.BobAction&&this.theBob.bClip.xthis.zombies[o].enemyClip.x||"fireRight"==this.theBob.BobAction&&this.theBob.bClip.xthis.sidedoors[s].x||"fireRight"==this.theBob.BobAction&&this.theBob.bClip.xthis.walls[a].x||"fireRight"==this.theBob.BobAction&&this.theBob.bClip.xthis.stairs[t].y?-1:1}return e},v.prototype.BobOnStairs=function(){for(var e=1,t=0;tthis.cameras[e].cameraClip.x-this.cameras[e].ViewZoneLeft)return this.numCameraDetected=e,!0;if(OzUtil.HitTest(this.theBob.bClip,this.theBob.bbody,this.cameras[e].cameraClip.getChild("viewRight"),null,this.cameras[e].cameraClip)&&"right"==this.cameras[e].Direction&&this.theBob.bClip.xthis.enemies[e].enemyClip.x||this.rightKey&&this.theBob.bClip.xthis.enemies[e].enemyClip.x||"right"==this.theBob.BobLastDirrection&&this.theBob.bClip.xthis.zombies[e].enemyClip.x||this.rightKey&&this.theBob.bClip.xthis.zombies[e].enemyClip.x||"right"==this.theBob.BobLastDirrection&&this.theBob.bClip.xt.x-10&&14==t.currentFrame&&this.theBob.bClip.y-t.y<50&&Math.abs(this.theBob.bClip.y-t.y)<35&&t.gotoLabel("fire"),this.theBob.bClip.x>t.x-10&&(22==t.currentFrame||23==t.currentFrame)&&this.theBob.bClip.y-t.y<50&&Math.abs(this.theBob.bClip.y-t.y)<35&&(this.totalAlerts=4))}},v.prototype.checkGameSituation=function(){if(this.numCameraDetected=0,this.bobCameraDetected())"silent"==this.gameStatus&&(this.cameras[this.numCameraDetected].cameraClip.getChild("lightLeft").gotoAndStop(2),this.cameras[this.numCameraDetected].cameraClip.getChild("lightRight").gotoAndStop(2),this.cameras[this.numCameraDetected].cameraClip.getChild("sign").gotoAndStop(2),this.cameras[this.numCameraDetected].prepareWarningTimer.start(),this.cameras[this.numCameraDetected].switchTimerIdle.stop(),SoundManager.getInstance().playSound("SCameraWarn"),this.gameStatus="warning"),"warning"==this.gameStatus&&(this.cameras[this.numCameraDetected].cameraClip.getChild("sign").currentFrame<3&&(this.cameras[this.numCameraDetected].cameraClip.getChild("lightLeft").gotoAndStop(2),this.cameras[this.numCameraDetected].cameraClip.getChild("lightRight").gotoAndStop(2),this.cameras[this.numCameraDetected].cameraClip.getChild("sign").gotoAndStop(2)),this.cameras[this.numCameraDetected].prepareWarningTimer.running||(this.cameras[this.numCameraDetected].prepareWarningTimer.start(),this.cameras[this.numCameraDetected].switchTimerIdle.stop())),"alert"==this.gameStatus&&(this.cameras[this.numCameraDetected].cameraClip.getChild("lightLeft").gotoAndStop(3),this.cameras[this.numCameraDetected].cameraClip.getChild("lightRight").gotoAndStop(3),this.cameras[this.numCameraDetected].switchTimerIdle.stop(),this.cameras[this.numCameraDetected].cameraClip.getChild("sign").gotoAndStop(3),this.alertBegin||(this.totalAlerts++,this.iPanel.getChild("alerts").gotoAndStop(this.totalAlerts+1),this.alertBegin=!0,4==this.totalAlerts&&this.stopTheGame(!1)),this.countDownAlertTimer.stop(),this.panicTime_gotoAndStop(3),SoundManager.getInstance().playSound("SSiren"));else{if("silent"==this.gameStatus)for(var e=0;e(this.heroBubble.visible?18:10)&&this.BobOnFloor()?this.startWalking(e,t):0!=this.heroBubble.visible||"climb"!=this.theBob.BobAction&&"stay2"!=this.theBob.BobAction||!this.keyListeners||Math.abs(e-this.theBob.bClip.x)<19&&Math.abs(t-this.theBob.bClip.y)<21&&this.changeClimbingDir()}if(!this.messageFullScreen.visible&&this.keyListeners&&this.updateListener&&this.BobOnFloor()&&!this.theBob.bClipBack.visible)if(!this.theBob.bClip.animations||0!=this.theBob.bClip.animations.currentAnim.name.indexOf("empty")&&0!=this.theBob.bClip.animations.currentAnim.name.indexOf("fight")){var i=this.OzCanHitBaddie();0this.lastCanHit)&&(this.canHitDir<0?this.theBob.BobLastDirrection="left":this.theBob.BobLastDirrection="right",Input.getInstance().setDoing(0,"space",!0)),SoundManager.getInstance().stopSound("SBobClimb"),this.lastCanHit=i}else Input.getInstance().setDoing(0,"space",!1)}Game.Touch()&&(this.mobileWalk<0?Input.getInstance().setDoing(0,"left",!0):0this.enemies[o].enemyClip.x?this.theBob.BobAction="emptyPushLeft":this.leftKey&&this.theBob.bClip.xthis.enemies[o].enemyClip.x&&(this.theBob.BobAction="emptyPushLeft"):("left"==this.theBob.BobLastDirrection&&this.theBob.bClip.x>this.enemies[o].enemyClip.x?this.theBob.BobAction="emptyPushLeft":(this.theBob.BobLastDirrection="right",this.theBob.BobAction="emptyPushRight"),"right"==this.theBob.BobLastDirrection&&this.theBob.bClip.xthis.wireLengthArray[1]?this.wireLengthArray[0]>this.wireLengthArray[2]?0:2:this.wireLengthArray[1]>this.wireLengthArray[2]?1:2},v.prototype.buildWireAgain=function(){if(this.wireCount<4||this.crossCount<4||this.wireBlocks<38)this.wires.length=0,this.setUpWires();else{this.findWire();this.signalsEnd[this.currentWireToCut].gotoAndStop(2)}},v.prototype.buildWireAgain2=function(){if(this.wireCount<4||this.crossCount<4||this.wireBlocks<38)this.wires.length=0,this.setUpWires2();else{this.findWire();this.signalsEnd[this.currentWireToCut2].gotoAndStop(2)}},v.prototype.addWireBlock=function(){var e=Math.floor(8*Math.random()+1);if(this.changeWireCount++,0==this.curPosition.y){1==this.curDirection&&(e=4),2==this.curDirection&&(e=8),3==this.curDirection&&(e=3),this.wires[this.curPosition.y][this.curPosition.x].clipGo(e),this.wiresPanel.getChild("wires").addChild(this.wires[this.curPosition.y][this.curPosition.x]);var t=new MovieClip("WireSignalEnd");this.wiresPanel.getChild("wires").addChild(t),t.x=this.wires[this.curPosition.y][this.curPosition.x].x,t.y=this.wires[this.curPosition.y][this.curPosition.x].y-18,this.signalsEnd.push(t),this.wireCount++,2==this.wireCount&&(this.circleCount=Math.floor(2*Math.random()+1),this.curDirection=2,this.curPosition=new Vector2(3,6),this.curPosition.y-=1),3==this.wireCount&&(this.circleCount=Math.floor(2*Math.random()+1),this.curDirection=2,this.curPosition=new Vector2(5,6),this.curPosition.y-=1)}this.isValidWireSegment(this.curPosition,this.prevPosition,this.curDirection,e)&&(this.wires[this.curPosition.y][this.curPosition.x].clipGo(e),this.wiresPanel.getChild("wires").addChild(this.wires[this.curPosition.y][this.curPosition.x]),this.changeWireCount=0,this.wireBlocks++,1==this.wireCount&&(this.wireLengthArray[0]+=1),2==this.wireCount&&(this.wireLengthArray[1]+=1),3==this.wireCount&&(this.wireLengthArray[2]+=1),5!=e&&6!=e||this.crossCount++,1==e&&(2==this.curDirection&&(this.curDirection=3),1==this.curDirection&&(this.curDirection=4)),2==e&&(2==this.curDirection&&(this.curDirection=1),3==this.curDirection&&(this.curDirection=4)),3==e&&(4==this.curDirection&&(this.curDirection=1),3==this.curDirection&&(this.curDirection=2)),4==e&&(4==this.curDirection&&(this.curDirection=3),1==this.curDirection&&(this.curDirection=2)),2==this.curDirection&&(this.curPosition.y-=1),4==this.curDirection&&(this.curPosition.y+=1,this.circleCount++),1==this.curDirection&&(this.curPosition.x-=1),3==this.curDirection&&(this.curPosition.x+=1))},v.prototype.addWireBlock2=function(){var e=Math.floor(8*Math.random()+1);if(this.changeWireCount++,0==this.curPosition.y){1==this.curDirection&&(e=4),2==this.curDirection&&(e=8),3==this.curDirection&&(e=3),this.wires[this.curPosition.y][this.curPosition.x].clipGo(e),this.wiresPanel2.getChild("wires").addChild(this.wires[this.curPosition.y][this.curPosition.x]);var t=new MovieClip("WireSignalEnd");this.wiresPanel2.getChild("wires").addChild(t),t.x=this.wires[this.curPosition.y][this.curPosition.x].x,t.y=this.wires[this.curPosition.y][this.curPosition.x].y-18,this.signalsEnd.push(t),this.wireCount++,2==this.wireCount&&(this.circleCount=Math.floor(2*Math.random()+1),this.curDirection=2,this.curPosition=new Vector2(3,6),this.curPosition.y-=1),3==this.wireCount&&(this.circleCount=Math.floor(2*Math.random()+1),this.curDirection=2,this.curPosition=new Vector2(5,6),this.curPosition.y-=1)}this.isValidWireSegment(this.curPosition,this.prevPosition,this.curDirection,e)&&(this.wires[this.curPosition.y][this.curPosition.x].clipGo(e),this.wiresPanel2.getChild("wires").addChild(this.wires[this.curPosition.y][this.curPosition.x]),this.changeWireCount=0,this.wireBlocks++,1==this.wireCount&&(this.wireLengthArray[0]+=1),2==this.wireCount&&(this.wireLengthArray[1]+=1),3==this.wireCount&&(this.wireLengthArray[2]+=1),5!=e&&6!=e||this.crossCount++,1==e&&(2==this.curDirection&&(this.curDirection=3),1==this.curDirection&&(this.curDirection=4)),2==e&&(2==this.curDirection&&(this.curDirection=1),3==this.curDirection&&(this.curDirection=4)),3==e&&(4==this.curDirection&&(this.curDirection=1),3==this.curDirection&&(this.curDirection=2)),4==e&&(4==this.curDirection&&(this.curDirection=3),1==this.curDirection&&(this.curDirection=2)),2==this.curDirection&&(this.curPosition.y-=1),4==this.curDirection&&(this.curPosition.y+=1,this.circleCount++),1==this.curDirection&&(this.curPosition.x-=1),3==this.curDirection&&(this.curPosition.x+=1))},v.prototype.isValidWireSegment=function(e,t,i,r){if(1==r){if(3==i||4==i)return!1;if(0