diff --git a/bower.json b/bower.json index 478ce83f..cfb57975 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "Platypus", - "version": "0.6.4", + "version": "0.6.5", "homepage": "https://github.com/PBS-KIDS/Platypus", "authors": [ "probityrules", diff --git a/build/README.md b/build/README.md index edffea72..2f3b08ba 100644 --- a/build/README.md +++ b/build/README.md @@ -14,7 +14,7 @@ This command will: **NEXT version** -The same process as above, but uses "NEXT" as the version. This is used to generate minified builds with the latest source between release versions. +The same process as above, but uses "NEXT" as the version and doesn't generate documentation. This is used to generate minified builds with the latest source between release versions. grunt next diff --git a/build/package.json b/build/package.json index 40202115..ac4deee3 100644 --- a/build/package.json +++ b/build/package.json @@ -1,6 +1,6 @@ { "name": "Platypus", - "version": "0.6.4", + "version": "0.6.5", "description": "Platypus Docs", "url": "https://github.com/PBS-KIDS/Platypus", "logo": "assets/platypus-title.png", diff --git a/docs/Platypus_docs-0.6.4.zip b/docs/Platypus_docs-0.6.4.zip deleted file mode 100644 index cc56e0ba..00000000 Binary files a/docs/Platypus_docs-0.6.4.zip and /dev/null differ diff --git a/docs/Platypus_docs-0.6.5.zip b/docs/Platypus_docs-0.6.5.zip new file mode 100644 index 00000000..19910a8d Binary files /dev/null and b/docs/Platypus_docs-0.6.5.zip differ diff --git a/lib/platypus.combined.js b/lib/platypus.combined.js index 4dddfecf..e1488548 100644 --- a/lib/platypus.combined.js +++ b/lib/platypus.combined.js @@ -19,7 +19,7 @@ this.platypus = this.platypus || {}; * @type String * @static **/ - platypus.version = /*=version*/"NEXT"; // injected by build process + platypus.version = /*=version*/"0.6.5"; // injected by build process /** * The build date for this release in UTC format. @@ -27,7 +27,7 @@ this.platypus = this.platypus || {}; * @type String * @static **/ - platypus.buildDate = /*=date*/"Tue, 20 Oct 2015 18:50:23 GMT"; // injected by build process + platypus.buildDate = /*=date*/"Tue, 20 Oct 2015 19:41:33 GMT"; // injected by build process })(); @@ -14407,7 +14407,6 @@ Replicates logic for a wind-up toy: listens for a wind-up message over a series * @class Mover * @uses Component */ -// Requires: ["Motion", "../Vector.js"] /*global platypus */ /*jslint plusplus:true */ (function () { @@ -14909,58 +14908,12 @@ This component causes an entity to be a position on a [[NodeMap]]. This componen //############################################################################## /** -# COMPONENT **NodeMap** -This component sets up a NodeMap to be used by the [[NodeResident]] component on this entity's child entities. - -## Dependencies -- [[EntityContainer]] - This component expects the entity to have an `EntityContainer` component so it knows when `NodeResident` children are added. - -## Messages - -### Listens for: -- **add-node** - Expects a node definition to create a node in the NodeMap. - - @param definition.nodeId (string or array) - This value becomes the id of the Node. Arrays are joined using "|" to create the id string. - - @param definition.type (string) - This determines the type of the node. - - @param definition.x (number) - Sets the x axis position of the node. - - @param definition.y (number) - Sets the y axis position of the node. - - @param definition.z (number) - Sets the z axis position of the node. - - @param definition.neighbors (object) - A list of key/value pairs where the keys are directions from the node and values are node ids. For example: {"west": "node12"}. -- **child-entity-added** - Checks the child entity for a nodeId and if found adds the child to the corresponding node. - - @param entity (Entity) - The entity that may be placed on a node. - -## JSON Definition - { - "type": "NodeMap" - - "map": [ - // Optional. An array of node definitions to create the NodeMap. - - { - "NodeId": "Node1", - // A string or array that becomes the id of the Node. Arrays are joined using "|" to create the id string. - - "type": "path", - // A string that determines the type of the node. - - "x": 0, - // Sets the x axis position of the node. - - "y": 0, - // Sets the y axis position of the node. - - "z": 0, - // Sets the z axis position of the node. - - "neighbors": { - // A list of key/value pairs where the keys are directions from the node and values are node ids. - - "west": "node0", - "east": "node2" - } - } - ] - } -*/ + * This component sets up a NodeMap to be used by the [[NodeResident]] component on this entity's child entities. + * + * @namespace platypus.components + * @class NodeMap + * @uses Component + */ /*global platypus */ /*jslint plusplus:true */ (function () { @@ -15052,6 +15005,37 @@ This component sets up a NodeMap to be used by the [[NodeResident]] component on this.residentsAwaitingNode = []; + /** + * An array of node definitions to create the NodeMap. A node definition can take the following form: + * + * { + * "NodeId": "Node1", + * // A string or array that becomes the id of the Node. Arrays are joined using "|" to create the id string. + * + * "type": "path", + * // A string that determines the type of the node. + * + * "x": 0, + * // Sets the x axis position of the node. + * + * "y": 0, + * // Sets the y axis position of the node. + * + * "z": 0, + * // Sets the z axis position of the node. + * + * "neighbors": { + * // A list of key/value pairs where the keys are directions from the node and values are node ids. + * + * "west": "node0", + * "east": "node2" + * } + * } + * + * @property map + * @type Array + * @default [] + */ if (definition.map) { for (i = 0; i < definition.map.length; i++) { this.addNode(new Node(definition.map[i], this)); @@ -15060,6 +15044,18 @@ This component sets up a NodeMap to be used by the [[NodeResident]] component on }, events: { + /** + * Expects a node definition to create a node in the NodeMap. + * + * @method 'add-node' + * @param definition {Object} Key/value pairs. + * @param definition.nodeId {String|Array} This value becomes the id of the Node. Arrays are joined using "|" to create the id string. + * @param definition.type {String} This determines the type of the node. + * @param definition.x {String} Sets the x axis position of the node. + * @param definition.y {String} Sets the y axis position of the node. + * @param definition.z {String} Sets the z axis position of the node. + * @param definition.neighbors {Object} A list of key/value pairs where the keys are directions from the node and values are node ids. For example: {"west": "node12"}. + */ "add-node": function (nodeDefinition) { var i = 0, entity = null, @@ -15083,6 +15079,13 @@ This component sets up a NodeMap to be used by the [[NodeResident]] component on } } }, + + /** + * Checks the child entity for a nodeId and if found adds the child to the corresponding node. + * + * @method 'child-entity-added' + * @param entity {Entity} The entity that may be placed on a node, or if the entity is a node it is added to the map of nodes. + */ "child-entity-added": function (entity) { if(entity.isNode){ // a node this.owner.triggerEvent('add-node', entity); diff --git a/lib/platypus.min.js b/lib/platypus.min.js index f8c054c7..bab19476 100644 --- a/lib/platypus.min.js +++ b/lib/platypus.min.js @@ -6,7 +6,7 @@ * * This notice shall be included in all copies or substantial portions of the Software. */ -this.platypus=this.platypus||{},function(){"use strict";platypus.version="NEXT",platypus.buildDate="Tue, 20 Oct 2015 18:50:23 GMT"}(),platypus.Game=function(){"use strict";var a=null,b=null,c={},d=function(a,b){b["fade-to-black"]=function(b,c,d){var e=b.stage,f=springroll.Application.instance.display.canvas,g=new PIXI.Graphics;g.beginFill("#000").drawRect(0,0,f.width,f.height),g.alpha=0,e.addChild(g),a.get(g).to({alpha:1},500).wait(250).call(function(b){c(),d(),e.removeChild(g),e.addChild(g),setTimeout(function(){a.get(g).to({alpha:0},500).call(function(a){e.removeChild(g)})},250)})}},e=function(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0),c.responseType="text",c.onload=function(){var d=null;if(200===c.status)try{d=JSON.parse(c.responseText)}catch(e){console.warn('Error parsing "'+a+'": '+e.message)}else console.warn('Error opening "'+a+'": '+c.description);b(d)},c.send()},f=function(a,b){var c=0,d="",g=0,h=function(c){g-=1,g||b(a)},i=function(a,b,c){f(a[b],function(d){a[b]=d,c(d)})};if(a){if(Array.isArray(a)){if(g=a.length)for(c=0;c5&&".json"===a.src.substring(a.src.length-5).toLowerCase())f(a.src,function(c){a.src!==c&&(a=c),b(a)});else{for(d in a)a.hasOwnProperty(d)&&(g+=1);if(g)for(d in a)a.hasOwnProperty(d)&&i(a,d,h);else b(a)}return}if("string"==typeof a&&a.length>5&&".json"===a.substring(a.length-5).toLowerCase())return void e(a,function(a){"object"==typeof a?f(a,b):b(a)})}b(a)},g=function(c,d,e){var g=this,h=function(f){var h=null;if(c=f,console.log("Game config loaded.",c),platypus.game=g,g.currentScene=null,g.loaded=null,g.settings=c,d)g.stage=d;else if(b){try{h=document.getElementById(c.global.canvas)}catch(i){console.warn('Stage not provided and canvas ID "'+c.global.canvas+'" not found in HTML wrapper.')}g.stage=new b(h)}else console.warn("Platypus requires a CreateJS Stage for rendering.");g.loadScene(c.global.initialScene),e&&e(g),a&&c.global.tickerOn!==!1&&(g.tickHandler=function(a){g.tick(a)},a.timingMode="raf",a.setFPS(c.global.fps||60),a.addEventListener("tick",g.tickHandler)),window&&(window.getEntityById=function(a){return g.getEntityById(a)},window.getEntitiesByType=function(a){return g.getEntitiesByType(a)},window.getVisibleSprites=function(a,b){if(b=b||[],a=a||d,!a.texture&&a.visible){for(var c=0;c1?"s":"")+".",b):console.warn('Entity "'+this.type+'": Event "'+a+'" has no subscribers.',b),d=0;d5)throw"Endless loop detected for '"+a+"'.";console.warn("Event '"+a+"' is nested inside another '"+a+"' event.")}d=0}if(this.loopCheck.push(a),this.messages[a]&&this.messages[a].length)for(g=this.messages[a].slice(),h=g.length,d=0;h>d;d++)g[d].callback.call(g[d].scope||this,b,c);if(this.loopCheck.length=this.loopCheck.length-1,!this.loopCheck.length&&this.unbindLater.length){for(e=0;ef;f++)this.matrix[f]=d[f];return this},b.copyValues=function(a){return this.set(a)},b.magnitude=function(a){var b=0,c=0;for(a=a||this.matrix.length,c=0;a>c;c++)b+=Math.pow(this.matrix[c],2);return Math.sqrt(b)},b.getAngle=function(){var a=this.magnitude(2),b=0;return 0!==a&&(b=Math.acos(this.x/a),this.y<0&&(b=2*Math.PI-b)),b},b.getUnit=function(){return new platypus.Vector(this).normalize()},b.getInverse=function(){return new platypus.Vector(this).multiply(-1)},b.normalize=function(){var a=this.magnitude();return 0===a?this.multiply(0):this.multiply(1/a)},b.cross=function(){var a=function(a,b,c,d){return a*d-b*c};return function(b){var c=a(this.y,this.z,b.y,b.z),d=-a(this.x,this.z,b.x,b.z),e=a(this.x,this.y,b.x,b.y);return this.x=c,this.y=d,this.z=e,this}}(),b.getCrossProduct=function(a){return new platypus.Vector(this).cross(a)},b.rotate=function(b,c){var d=c,e=Math.cos(b),f=Math.sin(b),g=1-e,h=0,i=0,j=0;return d?"x"===d?d=new a(1,0,0):"y"===d?d=new a(0,1,0):"z"===d&&(d=new a(0,0,1)):d=new a(0,0,1),h=d.x,i=d.y,j=d.z,this.multiply([[e+h*h*g,h*i*g-j*f,h*j*g+i*f],[i*h*g+j*f,e+i*i*g,i*j*g-h*f],[j*h*g-i*f,j*i*g+h*f,e+j*j*g]])},b.multiply=function(a,b){var c=0,d=0,e=null,f=0;if(Array.isArray(a))for(e=this.matrix.slice(),f=b||a.length,c=0;f>c;c++)for(this.matrix[c]=0,d=0;f>d;d++)this.matrix[c]+=e[d]*a[c][d];else for(f=b||this.matrix.length,c=0;f>c;c++)this.matrix[c]*=a;return this},b.add=function(b,c,d){var e=b,f=0,g=0;for(Array.isArray(e)?f=c||this.matrix.length:e instanceof a?(e=e.matrix,f=c||this.matrix.length):(e=[b||0,c||0,d||0],f=this.matrix.length),g=0;f>g;g++)this.matrix[g]+=e[g];return this},b.addVector=function(a,b){return this.add(a,b)},b.subtractVector=function(a,b){return this.add(a.getInverse(),b)},b.scale=function(a,b){return this.multiply(a,b)},b.dot=function(a,b){var c=0,d=0;for(b=b||this.matrix.length,d=0;b>d;d++)c+=this.matrix[d]*(a.matrix[d]||0);return c},b.angleTo=function(a){var b=this.getUnit(),c=a.getUnit();return Math.acos(b.dot(c))},b.signedAngleTo=function(a,b){var c=this.getUnit(),d=a.getUnit();return c.getCrossProduct(d).dot(b)<0?-Math.acos(c.dot(d)):Math.acos(c.dot(d))},b.scalarProjection=function(a){var b=0;return b="number"==typeof a?a:this.angleTo(a),this.magnitude(2)*Math.cos(b)},b.copy=function(){return new platypus.Vector(this)},a.assign=function(){var a=function(a,b,c,d){var e=null,f=!1;"string"==typeof a&&"undefined"!=typeof b[a]&&(e=b[a],delete b[a],f=!0),Object.defineProperty(b,a,{get:function(){return c.matrix[d]},set:function(a){c.matrix[d]=a},enumerable:!0}),f&&(b[a]=e)};return function(b,c){var d=0;if(b&&c){if(!b[c]){for(b[c]=new platypus.Vector,d=2;da.left&&(this.left=a.left),this.righta.top&&(this.top=a.top),this.bottomthis.bottom||a.leftthis.right)},b.containsVector=function(a){return!(a.ythis.bottom||a.xthis.right)},b.intersects=function(a){return!(a.bottomthis.bottom||a.rightthis.right)},a}(),function(){"use strict";var a=navigator.userAgent.toLowerCase(),b={touch:"undefined"!==window.ontouchstart,iPod:a.search("ipod")>-1,iPhone:a.search("iphone")>-1,iPad:a.search("ipad")>-1,safari:a.search("safari")>-1,ie:a.search("msie")>-1||a.search("trident")>-1,firefox:a.search("firefox")>-1,android:a.search("android")>-1,chrome:a.search("chrome")>-1,silk:a.search("silk")>-1,iPhone4:!1,iPad2:!1,iOS:!1,mobile:!1,desktop:!1};b.iPhone4=b.iPhone&&480===window.screen.height,b.iPad2=b.iPad&&(!window.devicePixelRatio||1===window.devicePixelRatio),b.iOS=b.iPod||b.iPhone||b.iPad,b.mobile=b.iOS||b.android||b.silk,b.desktop=!b.mobile,platypus.supports=b}(),platypus.CollisionData=function(){"use strict";var a=function(a,b,c,d,e,f,g,h,i){this.occurred=a||!1,this.direction=b||null,this.position=c||null,this.deltaMovement=d||null,this.aABB=e||null,this.thisShape=f||null,this.thatShape=g||null,this.vector=h||null,this.stuck=i||0},b=a.prototype;return b.copy=function(a){this.occurred=a.occurred,this.direction=a.direction,this.position=a.position,this.deltaMovement=a.deltaMovement,this.aABB=a.aABB,this.thisShape=a.thisShape,this.thatShape=a.thatShape,this.vector=a.vector,this.stuck=a.stuck},b.clear=function(){this.occurred=!1,this.direction=null,this.position=null,this.deltaMovement=null,this.aABB=null,this.thisShape=null,this.thatShape=null,this.vector=null,this.stuck=0},a}(),platypus.CollisionDataContainer=function(){"use strict";var a=function(){this.xData=[new platypus.CollisionData,new platypus.CollisionData],this.yData=[new platypus.CollisionData,new platypus.CollisionData],this.xCount=0,this.yCount=0,this.xDeltaMovement=1/0,this.yDeltaMovement=1/0},b=a.prototype;return b.getXEntry=function(a){return this.xData[a]},b.getYEntry=function(a){return this.yData[a]},b.tryToAddX=function(a){return a.deltaMovementa;a++)this.xData[a]=new platypus.CollisionData},b.ensureRoomY=function(){var a=0,b=2*this.yData.length;if(this.yData.length<=this.yCount)for(a=this.yData.length;b>a;a++)this.yData[a]=new platypus.CollisionData},b.reset=function(){this.xCount=0,this.yCount=0,this.xDeltaMovement=1/0,this.yDeltaMovement=1/0},a}(),platypus.CollisionShape=function(){"use strict";var a=function(a,b,c){var d=b.regX,e=b.regY,f=0,g=0;switch(this.owner=a,this.collisionType=c,this.width=b.width||2*b.radius||0,this.height=b.height||2*b.radius||0,this.radius=b.radius||0,"number"!=typeof d&&(d=this.width/2),"number"!=typeof e&&(e=this.height/2),platypus.Vector.assign(this,"offset","offsetX","offsetY"),this.offsetX=b.offsetX||this.width/2-d,this.offsetY=b.offsetY||this.height/2-e,platypus.Vector.assign(this,"position","x","y"),a?(this.x=a.x+this.offsetX,this.y=a.y+this.offsetY):(this.x=b.x+this.offsetX,this.y=b.y+this.offsetY),this.type=b.type||"rectangle",this.subType="",this.aABB=void 0,this.type){case"circle":f=g=2*this.radius;break;case"rectangle":f=this.width,g=this.height}platypus.Vector.assign(this,"size","width","height"),this.width=f,this.height=g,this.aABB=new platypus.AABB(this.x,this.y,f,g)},b=a.prototype;return b.update=function(a,b){this.x=a+this.offsetX,this.y=b+this.offsetY,this.aABB.move(this.x,this.y)},b.moveX=function(a){this.x=a,this.aABB.moveX(this.x)},b.moveY=function(a){this.y=a,this.aABB.moveY(this.y)},b.getAABB=function(){return this.aABB},b.setXWithEntityX=function(a){this.x=a+this.offsetX,this.aABB.moveX(this.x)},b.setYWithEntityY=function(a){this.y=a+this.offsetY,this.aABB.moveY(this.y)},b.destroy=function(){this.aABB=void 0},b.multiply=function(a){this.position.subtractVector(this.owner.position),this.position.multiply(a),this.offset.multiply(a),this.size.multiply(a),this.position.addVector(this.owner.position),this.width=Math.abs(this.width),this.height=Math.abs(this.height),this.aABB.setAll(this.x,this.y,this.width,this.height)},a}(),platypus.Entity=function(){"use strict";var a={},b=function(b,c){var d=this,e=0,f=null,g=b||{},h=g.components||[],i=g.properties||{},j=c||{},k=j.properties||{};for(platypus.Messenger.call(d),d.components=[],d.type=g.id||"none",d.id=j.id||k.id,d.id||(a[d.type]||(a[d.type]=0),d.id=d.type+"-"+a[d.type],a[d.type]+=1),this.setProperty(i),this.setProperty(k),this.bind("set-property",function(a){d.setProperty(a)}),d.state||(d.state={}),d.lastState={},this.destroyed=!1,e=0;e=k;k+=e)for(j=0;h>=j;j+=d)l.push([j,k,d,e,c,f,g]);return l},d=function(b){var c=0,d=[],e=null,f=a.instance.assetManager.cache;for(c=0;cd&&(d=0),d=this._animation.frames.length&&(c=this._animation.id,this.gotoAndPlay(this._animation.next),this.onComplete&&this.onComplete(c))},i.destroy=function(){this.stop(),PIXI.Sprite.prototype.destroy.call(this)}}(),function(){"use strict";var a=function(a){return function(){return platypus.game.settings.debug&&console.log('"'+a+'" is not an available PIXI.Graphics method.'),this}},b=PIXI.Graphics.prototype;b.a=b.arc,b.at=b.arcTo,b.bt=b.bezierCurveTo,b.c=b.clear,b.dc=b.drawCircle,b.de=b.drawEllipse,b.dr=b.drawRect,b.ef=b.endFill,b.f=b.beginFill,b.lt=b.lineTo,b.mt=b.moveTo,b.qt=b.quadraticCurveTo,b.r=b.drawRect,b.rr=b.drawRoundedRect,b.cp=a("cp"),b.lf=a("lf"),b.rf=a("rf"),b.bf=a("bf"),b.ss=a("ss"),b.sd=a("sd"),b.s=a("s"),b.ls=a("ls"),b.rs=a("rs"),b.bs=a("bs"),b.es=a("es"),b.rc=a("rc"),b.dp=a("dp"),b.p=a("p")}(),function(){"use strict";var a=PIXI.Container.prototype;a.updateTransform=function(){var a=0,b=0;if(this.visible)for(this.transformMatrix?(this.transformMatrix.copy(this.worldTransform).prepend(this.parent.worldTransform),this.worldAlpha=this.alpha*this.parent.worldAlpha,this._currentBounds=null):this.displayObjectUpdateTransform(),a=0,b=this.children.length;b>a;++a)this.children[a].updateTransform()},a.containerUpdateTransform=a.updateTransform}(),function(){"use strict";var a=include("springroll.ApplicationPlugin"),b=null,c=new a,d=null;c.preload=function(a){var c=this.config.platypus,e=null,f={delta:0};c?(this.options.debug&&(c.debug=!0),e=this.platypus=new platypus.Game(c,this.display.stage),b=function(a){f.delta=a,e.tick(f)},this.on("update",b,320),d=function(a){e.currentScene.trigger("resize",a)},this.on("resize",d)):console.warn("PlatypusPlugin: Platypus requires a game configuration."),a()},c.teardown=function(){this.platypus&&(this.off("update",b),this.off("resize",d),this.platypus.destroy(),delete this.platypus)}}(),function(){"use strict";var a=new platypus.Vector;return platypus.createComponentClass({id:"AIChaser",properties:{accelerate:!1,chasing:!0},publicProperties:{speed:.3},constructor:function(a){this.target=this.owner.target||null,this.offset=new platypus.Vector(0,0)},events:{load:function(){return this.owner.addMover?void(this.direction=this.owner.addMover({vector:[this.speed,0,0],event:"chase",accelerator:this.accelerate}).vector):void console.warn('The "AIChaser" component requires a "Mover" component to function correctly.')},"handle-ai":function(){var b=a,c=0,d=!1;this.target&&this.chasing&&(b.set(this.offset).add(this.target.position).subtractVector(this.owner.position),c=b.magnitude(2),c&&(d=!0,this.direction.set(b).normalize().multiply(this.speed))),d!==this.owner.state.chasing&&(this.owner.state.chasing=d,this.owner.triggerEvent("chase",d))},"set-target":function(a){this.target=a,this.offset.x=0,this.offset.y=0},"set-target-offset":function(a){this.offset.x=a.x,this.offset.y=a.y},"start-chasing":function(a){a&&(this.target=a),this.chasing=!0},"stop-chasing":function(){this.chasing=!1}},methods:{destroy:function(){this.target=null}}})}(),function(){"use strict";return platypus.createComponentClass({id:"AIPacer",properties:{movement:"both",direction:null},constructor:function(a){this.lastDirection="",this.currentDirection=this.direction||("horizontal"===this.movement?"left":"up")},events:{"handle-ai":function(){this.currentDirection!==this.lastDirection&&(this.lastDirection=this.currentDirection,this.owner.triggerEvent("stop"),this.owner.triggerEvent("go-"+this.currentDirection))},"turn-around":function(a){("both"===this.movement||"horizontal"===this.movement)&&(a.x>0?this.currentDirection="left":a.x<0&&(this.currentDirection="right")),("both"===this.movement||"vertical"===this.movement)&&(a.y>0?this.currentDirection="up":a.y<0&&(this.currentDirection="down"))}}})}(),function(){"use strict";var a=include("springroll.Application"),b=function(a){var b=a.split("/");return b=b[b.length-1].split("."),b[0]},c=function(a,c){var d=0,e=!1;for(a.id||(a.id=b(a.src)),d=0;d=0;b--)e.exists(d[b].id)&&(e.preload(d[b].id,a),d.splice(b,1));d.length&&this.app.load(d,{taskDone:a})}}})}(),function(){"use strict";var a=include("springroll.Application"),b={interrupt:createjs.Sound.INTERRUPT_ANY,delay:0,offset:0,loop:0,volume:1,pan:0,mute:!1,paused:!1,next:!1,events:!1},c=function(a,b){return a.time-b.time},d=function(){var b=a.instance.voPlayer;this.play=function(a,c){var d=c.complete;return b.play(a,function(){d(!1)},function(){d(!0)}),this},this.stop=this.pause=function(){b.stop()},this.unpause=function(){},Object.defineProperty(this,"position",{get:function(){return b.playing?b.getElapsed():0}})},e=function(){var b=a.instance.sound;this.play=function(a,c){return b.play(a,c)}},f=function(a){var d=0,e="",f="",g=null; +this.platypus=this.platypus||{},function(){"use strict";platypus.version="0.6.5",platypus.buildDate="Tue, 20 Oct 2015 19:41:33 GMT"}(),platypus.Game=function(){"use strict";var a=null,b=null,c={},d=function(a,b){b["fade-to-black"]=function(b,c,d){var e=b.stage,f=springroll.Application.instance.display.canvas,g=new PIXI.Graphics;g.beginFill("#000").drawRect(0,0,f.width,f.height),g.alpha=0,e.addChild(g),a.get(g).to({alpha:1},500).wait(250).call(function(b){c(),d(),e.removeChild(g),e.addChild(g),setTimeout(function(){a.get(g).to({alpha:0},500).call(function(a){e.removeChild(g)})},250)})}},e=function(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0),c.responseType="text",c.onload=function(){var d=null;if(200===c.status)try{d=JSON.parse(c.responseText)}catch(e){console.warn('Error parsing "'+a+'": '+e.message)}else console.warn('Error opening "'+a+'": '+c.description);b(d)},c.send()},f=function(a,b){var c=0,d="",g=0,h=function(c){g-=1,g||b(a)},i=function(a,b,c){f(a[b],function(d){a[b]=d,c(d)})};if(a){if(Array.isArray(a)){if(g=a.length)for(c=0;c5&&".json"===a.src.substring(a.src.length-5).toLowerCase())f(a.src,function(c){a.src!==c&&(a=c),b(a)});else{for(d in a)a.hasOwnProperty(d)&&(g+=1);if(g)for(d in a)a.hasOwnProperty(d)&&i(a,d,h);else b(a)}return}if("string"==typeof a&&a.length>5&&".json"===a.substring(a.length-5).toLowerCase())return void e(a,function(a){"object"==typeof a?f(a,b):b(a)})}b(a)},g=function(c,d,e){var g=this,h=function(f){var h=null;if(c=f,console.log("Game config loaded.",c),platypus.game=g,g.currentScene=null,g.loaded=null,g.settings=c,d)g.stage=d;else if(b){try{h=document.getElementById(c.global.canvas)}catch(i){console.warn('Stage not provided and canvas ID "'+c.global.canvas+'" not found in HTML wrapper.')}g.stage=new b(h)}else console.warn("Platypus requires a CreateJS Stage for rendering.");g.loadScene(c.global.initialScene),e&&e(g),a&&c.global.tickerOn!==!1&&(g.tickHandler=function(a){g.tick(a)},a.timingMode="raf",a.setFPS(c.global.fps||60),a.addEventListener("tick",g.tickHandler)),window&&(window.getEntityById=function(a){return g.getEntityById(a)},window.getEntitiesByType=function(a){return g.getEntitiesByType(a)},window.getVisibleSprites=function(a,b){if(b=b||[],a=a||d,!a.texture&&a.visible){for(var c=0;c1?"s":"")+".",b):console.warn('Entity "'+this.type+'": Event "'+a+'" has no subscribers.',b),d=0;d5)throw"Endless loop detected for '"+a+"'.";console.warn("Event '"+a+"' is nested inside another '"+a+"' event.")}d=0}if(this.loopCheck.push(a),this.messages[a]&&this.messages[a].length)for(g=this.messages[a].slice(),h=g.length,d=0;h>d;d++)g[d].callback.call(g[d].scope||this,b,c);if(this.loopCheck.length=this.loopCheck.length-1,!this.loopCheck.length&&this.unbindLater.length){for(e=0;ef;f++)this.matrix[f]=d[f];return this},b.copyValues=function(a){return this.set(a)},b.magnitude=function(a){var b=0,c=0;for(a=a||this.matrix.length,c=0;a>c;c++)b+=Math.pow(this.matrix[c],2);return Math.sqrt(b)},b.getAngle=function(){var a=this.magnitude(2),b=0;return 0!==a&&(b=Math.acos(this.x/a),this.y<0&&(b=2*Math.PI-b)),b},b.getUnit=function(){return new platypus.Vector(this).normalize()},b.getInverse=function(){return new platypus.Vector(this).multiply(-1)},b.normalize=function(){var a=this.magnitude();return 0===a?this.multiply(0):this.multiply(1/a)},b.cross=function(){var a=function(a,b,c,d){return a*d-b*c};return function(b){var c=a(this.y,this.z,b.y,b.z),d=-a(this.x,this.z,b.x,b.z),e=a(this.x,this.y,b.x,b.y);return this.x=c,this.y=d,this.z=e,this}}(),b.getCrossProduct=function(a){return new platypus.Vector(this).cross(a)},b.rotate=function(b,c){var d=c,e=Math.cos(b),f=Math.sin(b),g=1-e,h=0,i=0,j=0;return d?"x"===d?d=new a(1,0,0):"y"===d?d=new a(0,1,0):"z"===d&&(d=new a(0,0,1)):d=new a(0,0,1),h=d.x,i=d.y,j=d.z,this.multiply([[e+h*h*g,h*i*g-j*f,h*j*g+i*f],[i*h*g+j*f,e+i*i*g,i*j*g-h*f],[j*h*g-i*f,j*i*g+h*f,e+j*j*g]])},b.multiply=function(a,b){var c=0,d=0,e=null,f=0;if(Array.isArray(a))for(e=this.matrix.slice(),f=b||a.length,c=0;f>c;c++)for(this.matrix[c]=0,d=0;f>d;d++)this.matrix[c]+=e[d]*a[c][d];else for(f=b||this.matrix.length,c=0;f>c;c++)this.matrix[c]*=a;return this},b.add=function(b,c,d){var e=b,f=0,g=0;for(Array.isArray(e)?f=c||this.matrix.length:e instanceof a?(e=e.matrix,f=c||this.matrix.length):(e=[b||0,c||0,d||0],f=this.matrix.length),g=0;f>g;g++)this.matrix[g]+=e[g];return this},b.addVector=function(a,b){return this.add(a,b)},b.subtractVector=function(a,b){return this.add(a.getInverse(),b)},b.scale=function(a,b){return this.multiply(a,b)},b.dot=function(a,b){var c=0,d=0;for(b=b||this.matrix.length,d=0;b>d;d++)c+=this.matrix[d]*(a.matrix[d]||0);return c},b.angleTo=function(a){var b=this.getUnit(),c=a.getUnit();return Math.acos(b.dot(c))},b.signedAngleTo=function(a,b){var c=this.getUnit(),d=a.getUnit();return c.getCrossProduct(d).dot(b)<0?-Math.acos(c.dot(d)):Math.acos(c.dot(d))},b.scalarProjection=function(a){var b=0;return b="number"==typeof a?a:this.angleTo(a),this.magnitude(2)*Math.cos(b)},b.copy=function(){return new platypus.Vector(this)},a.assign=function(){var a=function(a,b,c,d){var e=null,f=!1;"string"==typeof a&&"undefined"!=typeof b[a]&&(e=b[a],delete b[a],f=!0),Object.defineProperty(b,a,{get:function(){return c.matrix[d]},set:function(a){c.matrix[d]=a},enumerable:!0}),f&&(b[a]=e)};return function(b,c){var d=0;if(b&&c){if(!b[c]){for(b[c]=new platypus.Vector,d=2;da.left&&(this.left=a.left),this.righta.top&&(this.top=a.top),this.bottomthis.bottom||a.leftthis.right)},b.containsVector=function(a){return!(a.ythis.bottom||a.xthis.right)},b.intersects=function(a){return!(a.bottomthis.bottom||a.rightthis.right)},a}(),function(){"use strict";var a=navigator.userAgent.toLowerCase(),b={touch:"undefined"!==window.ontouchstart,iPod:a.search("ipod")>-1,iPhone:a.search("iphone")>-1,iPad:a.search("ipad")>-1,safari:a.search("safari")>-1,ie:a.search("msie")>-1||a.search("trident")>-1,firefox:a.search("firefox")>-1,android:a.search("android")>-1,chrome:a.search("chrome")>-1,silk:a.search("silk")>-1,iPhone4:!1,iPad2:!1,iOS:!1,mobile:!1,desktop:!1};b.iPhone4=b.iPhone&&480===window.screen.height,b.iPad2=b.iPad&&(!window.devicePixelRatio||1===window.devicePixelRatio),b.iOS=b.iPod||b.iPhone||b.iPad,b.mobile=b.iOS||b.android||b.silk,b.desktop=!b.mobile,platypus.supports=b}(),platypus.CollisionData=function(){"use strict";var a=function(a,b,c,d,e,f,g,h,i){this.occurred=a||!1,this.direction=b||null,this.position=c||null,this.deltaMovement=d||null,this.aABB=e||null,this.thisShape=f||null,this.thatShape=g||null,this.vector=h||null,this.stuck=i||0},b=a.prototype;return b.copy=function(a){this.occurred=a.occurred,this.direction=a.direction,this.position=a.position,this.deltaMovement=a.deltaMovement,this.aABB=a.aABB,this.thisShape=a.thisShape,this.thatShape=a.thatShape,this.vector=a.vector,this.stuck=a.stuck},b.clear=function(){this.occurred=!1,this.direction=null,this.position=null,this.deltaMovement=null,this.aABB=null,this.thisShape=null,this.thatShape=null,this.vector=null,this.stuck=0},a}(),platypus.CollisionDataContainer=function(){"use strict";var a=function(){this.xData=[new platypus.CollisionData,new platypus.CollisionData],this.yData=[new platypus.CollisionData,new platypus.CollisionData],this.xCount=0,this.yCount=0,this.xDeltaMovement=1/0,this.yDeltaMovement=1/0},b=a.prototype;return b.getXEntry=function(a){return this.xData[a]},b.getYEntry=function(a){return this.yData[a]},b.tryToAddX=function(a){return a.deltaMovementa;a++)this.xData[a]=new platypus.CollisionData},b.ensureRoomY=function(){var a=0,b=2*this.yData.length;if(this.yData.length<=this.yCount)for(a=this.yData.length;b>a;a++)this.yData[a]=new platypus.CollisionData},b.reset=function(){this.xCount=0,this.yCount=0,this.xDeltaMovement=1/0,this.yDeltaMovement=1/0},a}(),platypus.CollisionShape=function(){"use strict";var a=function(a,b,c){var d=b.regX,e=b.regY,f=0,g=0;switch(this.owner=a,this.collisionType=c,this.width=b.width||2*b.radius||0,this.height=b.height||2*b.radius||0,this.radius=b.radius||0,"number"!=typeof d&&(d=this.width/2),"number"!=typeof e&&(e=this.height/2),platypus.Vector.assign(this,"offset","offsetX","offsetY"),this.offsetX=b.offsetX||this.width/2-d,this.offsetY=b.offsetY||this.height/2-e,platypus.Vector.assign(this,"position","x","y"),a?(this.x=a.x+this.offsetX,this.y=a.y+this.offsetY):(this.x=b.x+this.offsetX,this.y=b.y+this.offsetY),this.type=b.type||"rectangle",this.subType="",this.aABB=void 0,this.type){case"circle":f=g=2*this.radius;break;case"rectangle":f=this.width,g=this.height}platypus.Vector.assign(this,"size","width","height"),this.width=f,this.height=g,this.aABB=new platypus.AABB(this.x,this.y,f,g)},b=a.prototype;return b.update=function(a,b){this.x=a+this.offsetX,this.y=b+this.offsetY,this.aABB.move(this.x,this.y)},b.moveX=function(a){this.x=a,this.aABB.moveX(this.x)},b.moveY=function(a){this.y=a,this.aABB.moveY(this.y)},b.getAABB=function(){return this.aABB},b.setXWithEntityX=function(a){this.x=a+this.offsetX,this.aABB.moveX(this.x)},b.setYWithEntityY=function(a){this.y=a+this.offsetY,this.aABB.moveY(this.y)},b.destroy=function(){this.aABB=void 0},b.multiply=function(a){this.position.subtractVector(this.owner.position),this.position.multiply(a),this.offset.multiply(a),this.size.multiply(a),this.position.addVector(this.owner.position),this.width=Math.abs(this.width),this.height=Math.abs(this.height),this.aABB.setAll(this.x,this.y,this.width,this.height)},a}(),platypus.Entity=function(){"use strict";var a={},b=function(b,c){var d=this,e=0,f=null,g=b||{},h=g.components||[],i=g.properties||{},j=c||{},k=j.properties||{};for(platypus.Messenger.call(d),d.components=[],d.type=g.id||"none",d.id=j.id||k.id,d.id||(a[d.type]||(a[d.type]=0),d.id=d.type+"-"+a[d.type],a[d.type]+=1),this.setProperty(i),this.setProperty(k),this.bind("set-property",function(a){d.setProperty(a)}),d.state||(d.state={}),d.lastState={},this.destroyed=!1,e=0;e=k;k+=e)for(j=0;h>=j;j+=d)l.push([j,k,d,e,c,f,g]);return l},d=function(b){var c=0,d=[],e=null,f=a.instance.assetManager.cache;for(c=0;cd&&(d=0),d=this._animation.frames.length&&(c=this._animation.id,this.gotoAndPlay(this._animation.next),this.onComplete&&this.onComplete(c))},i.destroy=function(){this.stop(),PIXI.Sprite.prototype.destroy.call(this)}}(),function(){"use strict";var a=function(a){return function(){return platypus.game.settings.debug&&console.log('"'+a+'" is not an available PIXI.Graphics method.'),this}},b=PIXI.Graphics.prototype;b.a=b.arc,b.at=b.arcTo,b.bt=b.bezierCurveTo,b.c=b.clear,b.dc=b.drawCircle,b.de=b.drawEllipse,b.dr=b.drawRect,b.ef=b.endFill,b.f=b.beginFill,b.lt=b.lineTo,b.mt=b.moveTo,b.qt=b.quadraticCurveTo,b.r=b.drawRect,b.rr=b.drawRoundedRect,b.cp=a("cp"),b.lf=a("lf"),b.rf=a("rf"),b.bf=a("bf"),b.ss=a("ss"),b.sd=a("sd"),b.s=a("s"),b.ls=a("ls"),b.rs=a("rs"),b.bs=a("bs"),b.es=a("es"),b.rc=a("rc"),b.dp=a("dp"),b.p=a("p")}(),function(){"use strict";var a=PIXI.Container.prototype;a.updateTransform=function(){var a=0,b=0;if(this.visible)for(this.transformMatrix?(this.transformMatrix.copy(this.worldTransform).prepend(this.parent.worldTransform),this.worldAlpha=this.alpha*this.parent.worldAlpha,this._currentBounds=null):this.displayObjectUpdateTransform(),a=0,b=this.children.length;b>a;++a)this.children[a].updateTransform()},a.containerUpdateTransform=a.updateTransform}(),function(){"use strict";var a=include("springroll.ApplicationPlugin"),b=null,c=new a,d=null;c.preload=function(a){var c=this.config.platypus,e=null,f={delta:0};c?(this.options.debug&&(c.debug=!0),e=this.platypus=new platypus.Game(c,this.display.stage),b=function(a){f.delta=a,e.tick(f)},this.on("update",b,320),d=function(a){e.currentScene.trigger("resize",a)},this.on("resize",d)):console.warn("PlatypusPlugin: Platypus requires a game configuration."),a()},c.teardown=function(){this.platypus&&(this.off("update",b),this.off("resize",d),this.platypus.destroy(),delete this.platypus)}}(),function(){"use strict";var a=new platypus.Vector;return platypus.createComponentClass({id:"AIChaser",properties:{accelerate:!1,chasing:!0},publicProperties:{speed:.3},constructor:function(a){this.target=this.owner.target||null,this.offset=new platypus.Vector(0,0)},events:{load:function(){return this.owner.addMover?void(this.direction=this.owner.addMover({vector:[this.speed,0,0],event:"chase",accelerator:this.accelerate}).vector):void console.warn('The "AIChaser" component requires a "Mover" component to function correctly.')},"handle-ai":function(){var b=a,c=0,d=!1;this.target&&this.chasing&&(b.set(this.offset).add(this.target.position).subtractVector(this.owner.position),c=b.magnitude(2),c&&(d=!0,this.direction.set(b).normalize().multiply(this.speed))),d!==this.owner.state.chasing&&(this.owner.state.chasing=d,this.owner.triggerEvent("chase",d))},"set-target":function(a){this.target=a,this.offset.x=0,this.offset.y=0},"set-target-offset":function(a){this.offset.x=a.x,this.offset.y=a.y},"start-chasing":function(a){a&&(this.target=a),this.chasing=!0},"stop-chasing":function(){this.chasing=!1}},methods:{destroy:function(){this.target=null}}})}(),function(){"use strict";return platypus.createComponentClass({id:"AIPacer",properties:{movement:"both",direction:null},constructor:function(a){this.lastDirection="",this.currentDirection=this.direction||("horizontal"===this.movement?"left":"up")},events:{"handle-ai":function(){this.currentDirection!==this.lastDirection&&(this.lastDirection=this.currentDirection,this.owner.triggerEvent("stop"),this.owner.triggerEvent("go-"+this.currentDirection))},"turn-around":function(a){("both"===this.movement||"horizontal"===this.movement)&&(a.x>0?this.currentDirection="left":a.x<0&&(this.currentDirection="right")),("both"===this.movement||"vertical"===this.movement)&&(a.y>0?this.currentDirection="up":a.y<0&&(this.currentDirection="down"))}}})}(),function(){"use strict";var a=include("springroll.Application"),b=function(a){var b=a.split("/");return b=b[b.length-1].split("."),b[0]},c=function(a,c){var d=0,e=!1;for(a.id||(a.id=b(a.src)),d=0;d=0;b--)e.exists(d[b].id)&&(e.preload(d[b].id,a),d.splice(b,1));d.length&&this.app.load(d,{taskDone:a})}}})}(),function(){"use strict";var a=include("springroll.Application"),b={interrupt:createjs.Sound.INTERRUPT_ANY,delay:0,offset:0,loop:0,volume:1,pan:0,mute:!1,paused:!1,next:!1,events:!1},c=function(a,b){return a.time-b.time},d=function(){var b=a.instance.voPlayer;this.play=function(a,c){var d=c.complete;return b.play(a,function(){d(!1)},function(){d(!0)}),this},this.stop=this.pause=function(){b.stop()},this.unpause=function(){},Object.defineProperty(this,"position",{get:function(){return b.playing?b.getElapsed():0}})},e=function(){var b=a.instance.sound;this.play=function(a,c){return b.play(a,c)}},f=function(a){var d=0,e="",f="",g=null; if("string"==typeof a)e=a,g={};else if(Array.isArray(a)){if("string"==typeof a[0])e=a[0],g={next:[]};else{e=a[0].sound,g={};for(f in a[0])a[0].hasOwnProperty(f)&&(g[f]=a[0][f]);g.next?g.next=g.next.slice():g.next=[]}for(d=1;d=0;c--)d[c].soundId===a&&(b?d[c].addEventListener("loop",f):(d[c].stop(),d.splice(c,1)));else if(b)for(c=0;c=0;b--)c[b]===a&&(c[b].stop(),c.splice(b,1))},checkTimeEvents:function(a,b){var c=a.sequenceEvents,d=0;if(c&&c.length)for(d=a.position;c.length&&(b||c[0].time<=d);)this.owner.trigger(c[0].event,c[0].message),c.splice(0,1)},onComplete:function(a,b){if(this.removeClip(a),this.checkTimeEvents(a,!0),this.owner.triggerEvent("clip-complete"),b&&b.length)if("string"==typeof b)f(b).call(this);else{var c=b.slice();c.splice(0,1),c.length>0?f(b[0]).call(this,{next:c}):f(b[0]).call(this)}else this.owner.triggerEvent("sequence-complete")},removeClip:function(a){var b=0;for(b=0;b=0;c--)d[c].soundId===a&&(b?d[c].addEventListener("loop",f):(d[c].stop(),d.splice(c,1)));else if(b)for(c=0;c=0;b--)c[b]===a&&(c[b].stop(),c.splice(b,1))},onComplete:function(a){this.removeClip(a),this.owner.triggerEvent("clip-complete")},removeClip:function(a){var b=0;for(b=0;bthis.threshold?(this.worldWidth&&0!==this.worldWidth&&this.worldWidththis.worldWidth?b.moveX(this.worldWidth-b.halfWidth):this.worldWidth&&0!==this.worldWidth&&athis.threshold?(this.worldHeight&&0!==this.worldHeight&&this.worldHeightthis.worldHeight?b.moveY(this.worldHeight-b.halfHeight):this.worldHeight&&0!==this.worldHeight&&a1e-4?(this.worldCamera.orientation=a,!0):!1},lockedFollow:function(){var a=Math.min,b=function(a,b,c){return c*b+(1-c)*a},c=function(b,c){return b?a(c/b,1):1};return function(a,d,e){var f=b(this.worldCamera.viewport.x,a.x,c(this.transitionX,d)),g=b(this.worldCamera.viewport.y,a.y,c(this.transitionY,d));return this.rotate?this.move(f,g,b(this.worldCamera.orientation,-(a.orientation||0),c(this.transitionAngle,d))):this.move(f,g,0)}}(),forwardFollow:function(a,b){var c=this.forwardFollower,d=15/b,e=!1,f=a.x+this.offsetX,g=a.y+this.offsetY,h=(a.orientation||0)+this.offsetAngle;return this.followFocused&&this.lastX===f&&this.lastY===g?this.lockedFollow(c,b):(this.averageOffsetX*=.9,this.averageOffsetY*=.9,this.averageOffsetX+=.1*(f-this.lastX)*d,this.averageOffsetY+=.1*(g-this.lastY)*d,Math.abs(this.averageOffsetX)>this.worldCamera.viewport.width/(2*this.forwardX)&&(this.averageOffsetX=0),Math.abs(this.averageOffsetY)>this.worldCamera.viewport.height/(2*this.forwardY)&&(this.averageOffsetY=0),this.rotate&&(this.averageOffsetAngle*=.9,this.averageOffsetAngle+=.1*(h-this.lastOrientation)*d,Math.abs(this.averageOffsetAngle)>this.worldCamera.orientation/(2*this.forwardAngle)&&(this.averageOffsetAngle=0)),c.x=this.averageOffsetX*this.forwardX+f,c.y=this.averageOffsetY*this.forwardY+g,c.orientation=this.averageOffsetAngle*this.forwardAngle+h,this.lastX=f,this.lastY=g,this.lastOrientation=h,e=this.lockedFollow(c,b),this.followFocused||e||(this.followFocused=!0),e)},boundingFollow:function(a,b){var c=0,d=0,e=this.transitionX?Math.min(b/this.transitionX,1):1,f=1-e,g=this.transitionY?Math.min(b/this.transitionY,1):1,h=1-g;return this.boundingBox.move(this.worldCamera.viewport.x,this.worldCamera.viewport.y),a.x>this.boundingBox.right?c=a.x-this.boundingBox.halfWidth:a.xthis.boundingBox.bottom?d=a.y-this.boundingBox.halfHeight:a.ya?this.overflow?this.worldCamera.viewport.resize(this.height*b,this.height):this.viewport.resize(this.viewport.height*a,this.viewport.height):this.overflow?this.worldCamera.viewport.resize(this.width,this.width/b):this.viewport.resize(this.viewport.width,this.viewport.width/a)),this.worldPerWindowUnitWidth=this.worldCamera.viewport.width/this.viewport.width,this.worldPerWindowUnitHeight=this.worldCamera.viewport.height/this.viewport.height,this.windowPerWorldUnitWidth=this.viewport.width/this.worldCamera.viewport.width,this.windowPerWorldUnitHeight=this.viewport.height/this.worldCamera.viewport.height,this.matrix.tx=this.viewport.x-this.viewport.halfWidth,this.matrix.ty=this.viewport.y-this.viewport.halfHeight,this.viewportUpdate=!0},windowToWorld:function(a){var b=[];return b[0]=Math.round((a[0]-this.viewport.x)*this.worldPerWindowUnitWidth),b[1]=Math.round((a[1]-this.viewport.y)*this.worldPerWindowUnitHeight),b},worldToWindow:function(a){var b=[];return b[0]=Math.round(a[0]*this.windowPerWorldUnitWidth+this.viewport.x),b[1]=Math.round(a[1]*this.windowPerWorldUnitHeight+this.viewport.y),b},destroy:function(){this.parentContainer.removeChild(this.container),this.parentContainer=null,this.container=null}}})}(),function(){"use strict";return platypus.createComponentClass({id:"CameraFollowMe",properties:{camera:{},mode:"forward",pause:!1},constructor:function(a){this.pauseGame=a.pause?{time:a.time}:null,this.camera={entity:this.owner,mode:this.camera.mode||this.mode,top:this.camera.top,left:this.camera.left,offsetX:this.camera.offsetX,offsetY:this.camera.offsetY,width:this.camera.width,height:this.camera.height,time:this.camera.time}},events:{"follow-me":function(a){var b=this.camera;a&&(b={entity:this.owner,mode:a.mode||this.camera.mode,top:a.top||this.camera.top,left:a.left||this.camera.left,offsetX:a.offsetX||this.camera.offsetX,offsetY:a.offsetY||this.camera.offsetY,width:a.width||this.camera.width,height:a.height||this.camera.height,time:a.time||this.camera.time}),this.pauseGame&&(this.owner.parent.trigger("pause-logic",this.pauseGame),this.owner.parent.trigger("pause-render",this.pauseGame)),this.owner.parent.trigger("follow",b)}}})}(),function(){"use strict";var a=function(a,b,c){var d=0,e=b.stuck;e&&(d=a.magnitude(),b.thatShape.owner&&Math.abs(e)>1&&(e*=.05),(!d||d>Math.abs(e))&&(b.vector.x&&(a.x=e,a.y=0),b.vector.y&&(a.x=0,a.y=e),c.stuckWith=new platypus.Vector(b.thatShape.x,b.thatShape.y)))},b=function(a,b,c){return"string"==typeof a?function(d){d.myType===c&&d.hitType===b&&this.owner.triggerEvent(a,d)}:Array.isArray(a)?function(d){var e=0;if(d.myType===c&&d.hitType===b)for(e=0;e0&&a.bottom&&this.owner.trigger(a.bottom,d),0>f&&a.top&&this.owner.trigger(a.top,d),e>0&&a.right&&this.owner.trigger(a.right,d),0>e&&a.left&&this.owner.trigger(a.left,d),a.all&&this.owner.trigger(a.all,d))}},c=function(b,c){c.collisionFunctions||(c.collisionFunctions={},c.getAABB=function(a){var b=null,d="";if(a)return c.collisionFunctions[a]?c.collisionFunctions[a].getAABB():null;b=c.aabb=c.aabb||new platypus.AABB,b.reset();for(d in c.collisionFunctions)c.collisionFunctions.hasOwnProperty(d)&&b.include(c.collisionFunctions[d].getAABB());return b},c.getPreviousAABB=function(a){return c.collisionFunctions[a]?c.collisionFunctions[a].getPreviousAABB():null},c.getShapes=function(a){return c.collisionFunctions[a]?c.collisionFunctions[a].getShapes():null},c.getPrevShapes=function(a){return c.collisionFunctions[a]?c.collisionFunctions[a].getPrevShapes():null},c.prepareCollision=function(a,b){var d="";for(d in c.collisionFunctions)c.collisionFunctions.hasOwnProperty(d)&&c.collisionFunctions[d].prepareCollision(a,b)},c.relocateEntity=function(b,d){var e=null;d.xCount&&(e=new platypus.Vector(0,0,0),a(e,d.getXEntry(0),c)),d.yCount&&(e=e||new platypus.Vector(0,0,0),a(e,d.getYEntry(0),c)),c.triggerEvent("relocate-entity",{position:b,unstick:e})},c.movePreviousX=function(a){var b="";for(b in c.collisionFunctions)c.collisionFunctions.hasOwnProperty(b)&&c.collisionFunctions[b].movePreviousX(a)},c.getCollisionTypes=function(){return c.collisionTypes},c.getSolidCollisions=function(){return c.solidCollisions}),c.collisionFunctions[b.collisionType]={getAABB:function(){return b.getAABB()},getPreviousAABB:function(){return b.getPreviousAABB()},getShapes:function(){return b.getShapes()},getPrevShapes:function(){return b.getPrevShapes()},prepareCollision:function(a,c){b.prepareCollision(a,c)},movePreviousX:function(a){b.movePreviousX(a)}}};return platypus.createComponentClass({id:"CollisionBasic",properties:{collisionType:"none",shapeType:"rectangle",ignoreOrientation:!1,regX:null,regY:null,width:0,height:0,radius:0,margin:0,shapes:null},publicProperties:{immobile:!1,bullet:!1,jumpThrough:!1},constructor:function(a){var d=0,e="",f=null,g=this.regX,h=this.regY,i=this.width,j=this.height,k=this.radius,l=this.margin.left||this.margin,m=this.margin.right||this.margin,n=this.margin.top||this.margin,o=this.margin.bottom||this.margin;for(null===g&&(g=this.regX=i/2),null===h&&(h=this.regY=j/2),platypus.Vector.assign(this.owner,"position","x","y","z"),platypus.Vector.assign(this.owner,"previousPosition","previousX","previousY","previousZ"),this.owner.previousX=this.owner.previousX||this.owner.x,this.owner.previousY=this.owner.previousY||this.owner.y,this.aabb=new platypus.AABB,this.prevAABB=new platypus.AABB,this.shapes?f=this.shapes:"circle"===this.shapeType?(k=k||((i||0)+(j||0))/4,f=[{regX:(isNaN(g)?k:g)-(m-l)/2,regY:(isNaN(h)?k:h)-(o-n)/2,radius:k,type:this.shapeType}]):f=[{regX:(isNaN(g)?(i||0)/2:g)-(m-l)/2,regY:(isNaN(h)?(j||0)/2:h)-(o-n)/2,points:a.points,width:(i||0)+l+m,height:(j||0)+n+o,type:this.shapeType}],this.owner.collisionTypes=this.owner.collisionTypes||[],this.owner.collisionTypes.push(this.collisionType),this.shapes=[],this.prevShapes=[],this.entities=void 0,d=0;d0?this.owner.position.add(b):this.stuck=!1),this.aabb.reset(),d=0;d0&&(this.stuck||(this.stuck=!0),this.move=this.owner.stuckWith.copy().add(-this.owner.x,-this.owner.y).normalize())},"handle-logic":function(){this.move&&this.owner.position.add(this.move),this.owner.checkCollision=!0},"orientation-updated":function(a){var b=0;if(!this.ignoreOrientation)for(b=0;b0&&(this.owner.collides=!0),this.owner.softCollisions[this.collisionType]&&(this.owner.softCollisions[this.collisionType].length=0,delete this.owner.softCollisions[this.collisionType]),delete this.owner.collisionFunctions[this.collisionType],this.shapes.length=0,this.prevShapes.length=0,delete this.entities,this.owner.collisionTypes.length&&this.owner.parent.trigger("add-collision-entity",this.owner)}}})}(),function(){"use strict";var a=function(a,b,c){return function(d){a.state[b]&&a.trigger(c,d)}},b=function(a,b,c){return function(d){a.state[b]||a.trigger(c,d)}};return platypus.createComponentClass({id:"CollisionFilter",properties:{collisions:{},state:""},constructor:function(c){var d="",e=this.collisions,f=this.state;if(e)if("!"===f[0]){f=f.substring(1);for(d in e)e.hasOwnProperty(d)&&this.addEventListener(d,b(this.owner,f,e[d]))}else for(d in e)e.hasOwnProperty(d)&&this.addEventListener(d,a(this.owner,f,e[d]))}})}(),function(){"use strict";var a=function(a,b){var c=0,d=0,e=a.length,f=!1;for(c=0;cd;d++)if(b[c]===a[d]){f=!0;break}f||a.push(b[c])}return a};return platypus.createComponentClass({id:"CollisionGroup",constructor:function(a){var b=this;this.solidEntities=[],this.terrain=void 0,this.aabb=new platypus.AABB(this.owner.x,this.owner.y),this.prevAABB=new platypus.AABB(this.owner.x,this.owner.y),platypus.Vector.assign(this.owner,"position","x","y","z"),platypus.Vector.assign(this.owner,"previousPosition","previousX","previousY","previousZ"),this.owner.previousX=this.owner.previousX||this.owner.x,this.owner.previousY=this.owner.previousY||this.owner.y,this.collisionGroup=this.owner.collisionGroup={getAllEntities:function(){var a=0,c=0,d=null;for(a=0;aa?(a=Math.abs(a)-2,b[a]):a},e=function(a,b,c,d,e){var f=0,g=0,h=[];for(g=0;e>g;g++)for(h[g]=[],f=0;d>f;f++)h[g][f]=a[b+f][c+g];return h},f=function(a,b,c,d,e){var f=0,g=0,h=[];for(g=0;e>g;g++)for(h[g]=[],f=0;d>f;f++)h[g][f]=a[b+f][c+g],a[b+f][c+g]=-1;return h},g=function(a,b,c,d,e,f){var g=0,h=0;for(h=0;f>h;h++)for(g=0;e>g;g++)a[c+g][d+h]=b[h][g];return a},h={diagonal:function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=[-5,-4,-3,-2];for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+i][c+j]=d(h[i][j],k);return a},"diagonal-inverse":function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=[-3,-2,-5,-4];for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+f-i-1][c+g-j-1]=d(h[i][j],k);return a},horizontal:function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=[-2,-5,-4,-3];for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+f-i-1][c+j]=d(h[j][i],k);return a},vertical:function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=[-4,-3,-2,-5];for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+i][c+g-j-1]=d(h[j][i],k);return a},"rotate-90":function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=[-3,-4,-5,-2];for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+g-j-1][c+i]=d(h[j][i],k);return a},"rotate-180":function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=[-4,-5,-2,-3];for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+f-i-1][c+g-j-1]=d(h[j][i],k);return a},"rotate-270":function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=[-5,-2,-3,-4];for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+j][c+f-i-1]=d(h[j][i],k);return a},translate:function(a,b,c,d,e,g,h){var i=f(a,b,c,d,e),j=0,k=0;for(k=0;e>k;k++)for(j=0;d>j;j++)a[b+j+g][c+k+h]=i[k][j];return a}};return platypus.createComponentClass({id:"CollisionTiles",publicProperties:{collisionMap:[],tileWidth:10,tileHeight:10},constructor:function(a){this.tileHalfWidth=this.tileWidth/2,this.tileHalfHeight=this.tileHeight/2},events:{transform:function(a){this.transform(a)},translate:function(a){this.translate(a)}},methods:{getShape:function(c,d,e){var f=null;return b-1)a.push(this.getShape(b,c,d));else if(this.collisionMap[c][d]<-1)switch(this.collisionMap[c][d]){case-2:b.bottom<=d*this.tileHeight&&a.push(this.getShape(b,c,d));break;case-3:b.left>=(c+1)*this.tileWidth&&a.push(this.getShape(b,c,d));break;case-4:b.top>=(d+1)*this.tileHeight&&a.push(this.getShape(b,c,d));break;case-5:b.right<=c*this.tileWidth&&a.push(this.getShape(b,c,d))}return a}},publicMethods:{getAABB:function(){return{left:0,top:0,right:this.tileWidth*this.collisionMap.length,bottom:this.tileHeight*this.collisionMap.length[0]}},isTile:function(a,b){return!(0>a||0>b||a>=this.collisionMap.length||b>=this.collisionMap[0].length||-1===this.collisionMap[a][b])},getTileShapes:function(a,d){var e=Math.max(Math.floor(a.left/this.tileWidth),0),f=Math.max(Math.floor(a.top/this.tileHeight),0),g=Math.min(Math.ceil(a.right/this.tileWidth),this.collisionMap.length),h=Math.min(Math.ceil(a.bottom/this.tileHeight),this.collisionMap[0].length),i=0,j=0,k=c;for(c.length=0,b=0,i=e;g>i;i++)for(j=f;h>j;j++)this.addShape(k,d,i,j);return k},transform:function(a){var b=a||{},c=b.left||0,d=b.top||0,e=b.width||this.collisionMap[0].length,f=b.height||this.collisionMap.length,g=b.type||"horizontal";return h[g]?h[g](this.collisionMap,c,d,e,f):null},translate:function(a){var b=a||{},c=b.left||0,d=b.top||0,e=b.width||this.collisionMap[0].length,f=b.height||this.collisionMap.length,g=b.dx||0,i=b.dy||0;return h.translate(this.collisionMap,c,d,e,f,g,i)},getCollisionMatrix:function(a,b,c,d){return e(this.collisionMap,a,b,c,d)},setCollisionMatrix:function(a,b,c,d,e){return g(this.collisionMap,a,b,c,d,e)}}})}(),function(){"use strict";var a=function(a,b){return function(){setTimeout(function(){var c=0,d=0;if(a.remove)if("string"==typeof a.remove)for(c=b.components.length-1;c>-1;c--)b.components[c].type===a.remove&&b.removeComponent(b.components[c]);else for(c=0;c-1;d--)b.components[d].type===a.remove[c]&&b.removeComponent(b.components[d]);if(a.add)if(Array.isArray(a.add))for(c=0;ce&&(f=g-f),f):f},c=[null,null,null,null,["east","south","west","north"],null,null,null,["east","southeast","south","southwest","west","northwest","north","northeast"],null,null,null,null,null,null,null,["east","east-southeast","southeast","south-southeast","south","south-southwest","southwest","west-southwest","west","west-northwest","northwest","north-northwest","north","north-northeast","northeast","east-northeast"]],d=["left-button","middle-button","right-button"],e=function(a,b){this.event=a,this.trigger=b,this.filters=!1,this.current=!1,this.last=!1,this.state=!1,this.stateSummary={pressed:!1,released:!1,triggered:!1,over:!1}},f=function(a){var b=0;return Array.isArray(a)?function(c){for(b=0;bthis.joystick.outerRadius||f=b.right||a.right<=b.left||a.top>=b.bottom||a.bottom<=b.top?!1:!0},d=function(a,b){var c=0,d=0,e=null,f=null,g=0,h=0,i=null,j=0;if("rectangle"===a.type&&"rectangle"===b.type)return!0;if("circle"===a.type&&"circle"===b.type){if(c=Math.pow(a.x-b.x,2)+Math.pow(a.y-b.y,2),d=Math.pow(a.radius+b.radius,2),d>=c)return!0}else if("circle"===a.type&&"rectangle"===b.type||"rectangle"===a.type&&"circle"===b.type){if("circle"===a.type?(e=a,f=b):(e=b,f=a),i=f.getAABB(),g=Math.abs(e.x-f.x),h=Math.abs(e.y-f.y),g>=i.halfWidth+e.radius)return!1;if(h>=i.halfHeight+e.radius)return!1;if(ge;e++)if(s=this.allEntities[e],s.alwaysOn||s.checkCollision||t(s.getAABB(),u)){if(s.checkCollision=!1,i[i.length]=s,w=s.collisionTypes,s!==this.owner)for(f=0;ff;f++)s=r[f],(s.alwaysOn||t(s.getAABB(),v))&&(h[h.length]=s)}}}(),prepareCollisions:function(a){var b=0,c=null;for(this.nonColliders.length=0,b=this.allEntitiesLive.length-1;b>-1;b--)c=this.allEntitiesLive[b],c.triggerEvent("prepare-for-collision",a),c.collides||this.nonColliders.push(c)},resolveNonCollisions:function(){var a=0,b=null,c={position:new platypus.Vector,relative:!1};for(a=this.nonColliders.length-1;a>-1;a--)b=this.nonColliders[a],c.position.set(b.position),b.trigger("relocate-entity",c)},checkGroupCollisions:function(){var c=function(b,c,d,e,f,g,h,i){a.entity=c,a.myType=d,a.type=e,a.x=f,a.y=g,a.direction=i,a.hitType=h,b.triggerEvent("hit-by-"+e,a),c&&(a.entity=b,a.type=d,a.myType=e,a.x=-f,a.y=-g,a.direction=i.getInverse(),a.hitType=h,c.triggerEvent("hit-by-"+d,a))};return function(){var a=0,d=0,e=this.groupsLive,f=new platypus.Vector,g=null;for(a=e.length-1;a>-1;a--)if(e[a].collisionGroup.getSize()>1){for(b.reset(),f.set(0,0,0),f=this.checkSolidEntityCollision(e[a],e[a].collisionGroup,b,f),d=0;d-1;a--){for(b.reset(),g.set(0,0,0),g=this.checkSolidEntityCollision(f[a],f[a],b,g),d=0;df;f++){if(b.prepareCollision(a.previousX+l,a.previousY+m),h.set(a.position),h=this.processCollisionStep(a,b,q,c,h,l,m,p),h.x===a.previousX&&h.y===a.previousY){b.relocateEntity(h,c);break}b.relocateEntity(h,c)}}return h},processCollisionStep:function(){var a=new platypus.AABB,b=function(a,b,c,d,e){var f=0,g=c.getAABB(d);if(c===a)return!1;if(c.jumpThrough&&b.bottom>g.top)return!1;if(a.jumpThrough&&g.bottom>b.top)return!1;if(e)for(f=0;f0?(a.copy(f.getXEntry(0)),d.x=b.previousX+a.deltaMovement*a.direction):d.x=b.x,c.movePreviousX(d.x),0!==i)for(j=0;j0?(a.copy(f.getYEntry(0)),d.y=b.previousY+a.deltaMovement*a.direction):d.y=b.y,d}}(),findMinAxisMovement:function(){var a=new platypus.CollisionData;return function(b,c,d,e,f,g){var h=0,i=c.getShapes(d),j=c.getPrevShapes(d);for(h=0;h=f.aABB.top&&e.y<=f.aABB.bottom?f.aABB.halfWidth+e.radius:(a.y=d(e.y,f.y,f.aABB.halfHeight),i=f.aABB.halfWidth+c(a.y,e.radius),g===e?(a.x=-d(e.x-h*i,f.x,f.aABB.halfWidth)/2,a.y=-a.y):a.x=d(e.x,f.x-h*i,f.aABB.halfWidth)/2,a.normalize(),i):"y"===b?e.x>=f.aABB.left&&e.x<=f.aABB.right?f.aABB.halfHeight+e.radius:(a.x=d(e.x,f.x,f.aABB.halfWidth),i=f.aABB.halfHeight+c(a.x,e.radius),g===e?(a.x=-a.x,a.y=-d(e.y-h*i,f.y,f.aABB.halfWidth)/2):a.y=d(e.y,f.y-h*i,f.aABB.halfWidth)/2,a.normalize(),i):void 0},g=function(a,b,d){return"x"===a?c(b.y-d.y,b.radius+d.radius):"y"===a?c(b.x-d.x,b.radius+d.radius):void 0};return function(c,d,h,i){if("rectangle"===h.type){if("rectangle"===i.type)return b.position=i[c]-d*e(c,h.getAABB(),i.getAABB()),a.x=0,a.y=0,a[c]=d,b;if("circle"===i.type)return a.x=0,a.y=0,a[c]=d,b.position=i[c]-d*f(c,i,h,h,d),b}else if("circle"===h.type){if("rectangle"===i.type)return a.x=0,a.y=0,a[c]=d,b.position=i[c]-d*f(c,h,i,h,d),b;if("circle"===i.type)return b.position=i[c]-d*g(c,h,i),a.x=i.x-h.x,a.y=i.y-h.y,a[c]=i[c]-b.position,a.normalize(),b}}}();return function(e,f,g,h,i){var j=0,k=e[g],l=f[g],m=e,n=l>k?1:-1,o=l,p=null,q=l;if(k!==l)for("x"===g?m.moveX(l):"y"===g&&m.moveY(l),j=0;j0?q>o&&(k>o&&(o=k),q=o,a(i,n,q,k,f,h[j],p.contactVector)):o>q&&(o>k&&(o=k),q=o,a(i,n,q,k,f,h[j],p.contactVector)));return i}}(),checkSoftCollisions:function(a){var b=0,c=function(a){return function(b){a.trigger("hit-by-"+b.type,b)}};for(b=0;b-1;b--)if(this.entities[b]===a){this.entities.splice(b,1);break}},"pause-logic":function(a){a&&a.time?this.paused=a.time:this.paused=-1},"unpause-logic":function(){this.paused=0},"camera-update":function(a){this.camera.left=a.viewport.left,this.camera.top=a.viewport.top,this.camera.width=a.viewport.width,this.camera.height=a.viewport.height,-1===this.camera.buffer&&(this.camera.buffer=this.camera.width/10),this.camera.active=!0,this.updateNeeded=!0},tick:function(b){var c=0,d=0,e=0,f=null;if(this.leftoverTime+=b.delta,e=Math.floor(this.leftoverTime/this.stepLength)||1,this.message.delta=this.stepLength,this.leftoverTime=Math.max(this.leftoverTime-e*this.stepLength,0),this.paused>0&&(this.paused-=b.delta,this.paused<0&&(this.paused=0)),!this.paused){for(this.message.tick=b,this.activeEntities===this.entities&&(this.message.movers=this.activeEntities=[]),this.activeEntities.length=0,d=this.entities.length-1;d>-1;d--)f=this.entities[d],(f.alwaysOn||"undefined"==typeof f.x||f.x>=this.camera.left-this.camera.buffer&&f.x<=this.camera.left+this.camera.width+this.camera.buffer&&f.y>=this.camera.top-this.camera.buffer&&f.y<=this.camera.top+this.camera.height+this.camera.buffer)&&this.activeEntities.push(f);for(e=Math.min(e,this.maxStepsPerTick),c=0;e>c;c++){for(this.owner.triggerEventOnChildren&&this.owner.triggerEventOnChildren("handle-ai",this.message),d=this.activeEntities.length-1;d>-1;d--)this.activeEntities[d].triggerEvent("handle-logic",this.message);if(this.owner.triggerEvent("check-collision-group",this.message))for(d=this.activeEntities.length-1;d>-1;d--)f=this.activeEntities[d],f.triggerEvent("handle-post-collision-logic",this.message),a(f)&&f.triggerEvent("state-changed",f.state);else for(d=this.activeEntities.length-1;d>-1;d--)f=this.activeEntities[d],a(f)&&f.triggerEvent("state-changed",f.state)}}}}})}(),function(){"use strict";return platypus.createComponentClass({id:"HandlerRender",properties:{acceptInput:null},publicProperties:{},constructor:function(a){this.container=new PIXI.Container,this.camera={x:0,y:0},this.acceptInput&&(this.click=this.acceptInput.click,this.cameraMovementMovesMouse=this.acceptInput.camera,this.hover=this.acceptInput.hover,(this.click||this.hover)&&(this.addInputs(),this.addEventListener())),this.renderMessage={delta:0,container:this.container}},events:{load:function(){this.owner.triggerEvent("render-world",{world:this.container})},"child-entity-added":function(a){a.triggerEvent("handle-render-load",this.renderMessage)},"pause-render":function(a){a&&a.time?this.paused=a.time:this.paused=-1},"unpause-render":function(){this.paused=0},tick:function(){var a=function(a,b){return a.z-b.z};return function(b){var c=0,d=null,e=this.renderMessage;if(e.delta=b.delta,this.paused>0&&(this.paused-=b.delta,this.paused<0&&(this.paused=0)),this.owner.triggerEventOnChildren&&this.owner.triggerEventOnChildren("handle-render",e),this.container){for(c=this.container.children.length-1;c>-1;c--)d=this.container.children[c],d.visible&&(d.paused&&!this.paused?d.paused=!1:this.paused&&(d.paused=!0));this.container.reorder&&(this.container.reorder=!1,this.container.children.sort(a))}}}(),"camera-update":function(a){this.camera.x=a.viewport.left,this.camera.y=a.viewport.top,this.moveMouse&&this.moveMouse()}},methods:{addInputs:function(){var a=function(a,b){return function(c){var d=c.data.global.x,e=c.data.global.y,f=c.data.originalEvent,g=0,h=0;a.container&&(g=d/a.container.transformMatrix.a+a.camera.x,h=e/a.container.transformMatrix.d+a.camera.y,c.target.mouseTarget=!0,a.owner.trigger(b,{event:f,cjsEvent:c,x:g,y:h,entity:a.owner}),a.cameraMovementMovesMouse&&("pressup"===b?(c.target.mouseTarget=!1,a.moveMouse=null,c.target.removeDisplayObject&&c.target.removeDisplayObject()):a.moveMouse=function(){a.owner.trigger("pressmove",{event:f,x:d/a.container.transformMatrix.a+a.camera.x,y:e/a.container.transformMatrix.d+a.camera.y,entity:a.owner})}))}};return function(){var b=this.container,c=null,d=null,e=null,f=null,g=null,h=null,i=null,j=null,k=null,l=!1;this.click&&(b.interactive=!0,k=a(this,"mousedown"),c=function(a){k(a),l=!0}.bind(this),i=a(this,"pressmove"),f=function(a){l&&i(a)}.bind(this),j=a(this,"pressup"),g=function(a){j(a),l=!1}.bind(this),h=a(this,"click"),b.addListener("mousedown",c),b.addListener("touchstart",c),b.addListener("mouseup",g),b.addListener("touchend",g),b.addListener("mouseupoutside",g),b.addListener("touchendoutside",g),b.addListener("mousemove",f),b.addListener("touchmove",f),b.addListener("click",h),b.addListener("tap",h)),this.hover&&(b.interactive=!0,d=a(this,"mouseover"),e=a(this,"mouseout"),b.addListener("mouseover",d),b.addListener("mouseout",e)),this.removeInputListeners=function(){this.click&&(b.removeListener("mousedown",c),b.removeListener("touchstart",c),b.removeListener("mouseup",g),b.removeListener("touchend",g),b.removeListener("mouseupoutside",g),b.removeListener("touchendoutside",g),b.removeListener("mousemove",f),b.removeListener("touchmove",f),b.removeListener("click",h),b.removeListener("tap",h)),this.hover&&(b.removeListener("mouseover",d),b.removeListener("mouseout",e)),this.removeInputListeners=null}}}(),destroy:function(){var a=this;this.container.mouseTarget?(this.container.visible=!1,this.container.removeDisplayObject=function(){a.container=null}):this.container=null}},publicMethods:{}})}(),function(){"use strict";var a=function(a,b,c,d,e,f){var g=0,h=0,i=0,j=a.slice();if("horizontal"===f){for(h=e-1;h>=0;h--)for(g=h*d,i=0;(h+1)*d>g;g++,i++)j.splice((h+1)*b+i,0,c[g]);return j}return"vertical"===f?a.concat(c):void 0},b=function(a,b,c,d){var e=0,f=0,g=a.slice(),h=null;for(e=0;e0?this.piOverTwo:this.v[1]<0?-this.piOverTwo:this.angle:(c=Math.atan(this.v[1]/this.v[0]),this.v[0]<0&&(c=Math.PI+c)),this.v[0]>=0?this.v[0]=Math.min(this.v[0],this.maxVelocity*Math.cos(c)):this.v[0]=Math.max(this.v[0],this.maxVelocity*Math.cos(c)),this.v[1]>=0?this.v[1]=Math.min(this.v[1],this.maxVelocity*Math.sin(c)):this.v[1]=Math.max(this.v[1],this.maxVelocity*Math.sin(c)),this.owner.x+=this.v[0],this.owner.y+=this.v[1],this.owner.rotation=c*(180/Math.PI)+this.visualOffset)},"set-angle":function(a){this.angle=a},move:function(){this.moving=!0},stop:function(){this.moving=!1,this.v[0]=0,this.v[1]=0},"set-max-velocity":function(a){this.maxVelocity=a}}})}(),function(){"use strict";var a=0;return platypus.createComponentClass({id:"LogicAttachment",properties:{attachState:"attached",attachment:"",offsetX:0,offsetY:0,offsetZ:.01},publicProperties:{},constructor:function(b){this.state=this.owner.state,this.owner.linkId||(this.owner.linkId="attachment-link-"+a,a+=1),this.state[this.attachState]=!1,this.attachmentPosition={x:0,y:0,z:0,dx:0,dy:0,linkId:this.owner.linkId},this.attachmentProperties={type:this.attachment,properties:this.attachmentPosition},this.attachment=null,this.isAttached=!1},events:{"handle-logic":function(a){var b=0,c=this.state;this.isAttached?(this.attachment||(this.attachmentPosition.x=this.owner.x,this.attachmentPosition.y=this.owner.y,this.attachmentPosition.z=this.owner.z,this.attachment=this.owner.parent.addEntity(this.attachmentProperties)),this.attachment.destroyed?(this.owner.parent.removeEntity(this.attachment),this.attachment=null,this.isAttached=!1):(this.attachment.x=this.owner.x,b=this.offsetX,c.left?(b*=-1,this.attachment.rotation=180):c.right&&(this.attachment.rotation=0),this.attachment.x+=b,this.attachment.y=this.owner.y,b=this.offsetY,c.top?(b*=-1,this.attachment.rotation=90):c.bottom&&(this.attachment.rotation=-90),this.attachment.y+=b,this.attachment.z=this.owner.z,this.attachment.z+=this.offsetZ)):this.attachment&&(this.owner.parent.removeEntity(this.attachment),this.attachment=null),c[this.attachState]!==this.isAttached&&(c[this.attachState]=this.isAttached)},attach:function(a){this.isAttached=!a||a.pressed!==!1},detach:function(){this.isAttached=!1}},methods:{destroy:function(){this.state[this.attachState]=!1,this.attachment&&(this.owner.parent.removeEntity(this.attachment),this.attachment=null),this.isAttached=!1}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicButton",constructor:function(a){this.state=this.owner.state,this.state.released=!0,this.state.pressed=!1,this.toggle=!!a.toggle,"pressed"===a.state&&(this.state.released=!1,this.state.pressed=!0)},events:{mousedown:function(){this.toggle||this.updateState("pressed")},pressup:function(){this.toggle?this.state.pressed?this.updateState("released"):this.updateState("pressed"):this.updateState("released")},"handle-logic":function(){}},methods:{updateState:function(a){this.state.released&&"pressed"===a?(this.state.pressed=!0,this.state.released=!1,this.owner.triggerEvent(a,this.state)):this.state.pressed&&"released"===a&&(this.state.pressed=!1,this.state.released=!0,this.owner.triggerEvent(a,this.state))}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicCanvasButton",properties:{onPress:"",onRelease:"",onCancel:"",useOnce:!1,disabled:!1},publicProperties:{},constructor:function(a){this.owner.state.disabled=this.disabled,this.owner.state.down=!1,this.owner.buttonMode=!this.disabled,this.cancelled=!1,this.used=!1,this.last=null},events:{"handle-logic":function(a){this.last!==(this.disabled===this.owner.state.disabled)&&(this.last=this.disabled===this.owner.state.disabled)},mousedown:function(a){this.owner.state.down=!0,this.owner.state.disabled||this.useOnce&&this.used||this.onPress&&(this.owner.trigger(this.onPress),this.used=!0)},pressup:function(a){this.owner.state.disabled||this.useOnce&&this.used||(this.cancelled?this.onCancel&&(this.owner.trigger(this.onCancel),this.used=!0):this.onRelease&&(this.owner.trigger(this.onRelease),this.used=!0)),this.owner.state.down=!1,this.cancelled=!1},mouseover:function(){this.owner.state.down&&(this.cancelled=!1)},mouseout:function(){this.owner.state.down&&(this.cancelled=!0)},disable:function(){this.owner.state.disabled=!0,this.owner.buttonMode=!1},enable:function(){this.owner.state.disabled=!1,this.owner.buttonMode=!0},"toggle-disabled":function(){this.owner.buttonMode=this.owner.state.disabled,this.owner.state.disabled=!this.owner.state.disabled}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicCarrier",constructor:function(a){},events:{load:function(a){this.owner.trigger("add-collision-entity",this.owner)||(this.owner.addComponent(new platypus.components.CollisionGroup(this.owner,{})),this.owner.trigger("add-collision-entity",this.owner))},"carry-me":function(a){this.owner.trigger("add-collision-entity",a.entity)},"release-me":function(a){this.owner.trigger("remove-collision-entity",a.entity)}}})}(),function(){"use strict";var a=function(a){var b=function(a,b){return b&&!a.message?{event:a.event,message:b,delay:a.delay,repeat:a.repeat}:a};return a.singleInstance?function(c){var d=0,e=!0;for(d=0;d-1;b--)this.queue[b]===a&&(this.queueTimes.splice(b,1),this.queue.splice(b,1))}};return platypus.createComponentClass({id:"LogicDelayMessage",constructor:function(c){var d="";if(this.queueTimes=[],this.queue=[],c.events)for(d in c.events)c.events.hasOwnProperty(d)&&(this.addEventListener(d,a(c.events[d])),c.events[d].cancelEvent&&this.addEventListener(c.events[d].cancelEvent,b(c.events[d])))},events:{"handle-logic":function(a){var b=0;for(b=this.queue.length-1;b>-1;b--)this.queueTimes[b]-=a.delta,this.queueTimes[b]<=0&&(this.owner.trigger(this.queue[b].event,this.queue[b].message),this.queue[b]&&(this.queue[b].repeat?this.queueTimes[b]+=this.queue[b].delay:(this.queueTimes.splice(b,1),this.queue.splice(b,1))))}},methods:{destroy:function(){this.queueTimes.length=0,this.queue.length=0}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicDestroyMe",properties:{delay:0},publicProperties:{destroyed:!1},events:{"handle-logic":function(a){var b=a.delta;this.destroyed&&!this.owner.state.paused&&(this.delay-=b,this.delay<=0&&this.owner.parent.removeEntity(this.owner))},"destroy-me":function(){this.destroyed=!0}}})}(),function(){"use strict";var a=function(a){return function(b){this[a]="undefined"==typeof b||b&&b.pressed!==!1}},b=function(){},c={x:function(a,b){a!==b&&(a>180&&180>=b||180>=a&&b>180)&&this.owner.triggerEvent("transform","vertical")},y:function(a,b){a!==b&&(a>90&&270>=a&&(90>=b||b>270)||(90>=a||a>270)&&b>90&&270>=b)&&this.owner.triggerEvent("transform","horizontal")},z:function(a,b){a!==b&&this.owner.triggerEvent("replace-transform","rotate-"+a)}};return platypus.createComponentClass({id:"LogicDirectionalMovement",properties:{axis:"y",heading:0,speed:.3},constructor:function(a){var d=this;isNaN(this.speed)||(this.speed=[this.speed,0,0]),this.initialVector=new platypus.Vector(this.speed),this.reorient=c[this.axis],this.reorient||(this.reorient=b),this.owner.state.paused=!1,a.pause&&("string"==typeof a.pause?this.pausers=[a.pause]:this.pausers=a.pause,this.addEventListener("state-changed",function(b){var c=0,e=!1;if(a.pause){for(c=0;c0?this.mX=1:0>b&&(this.mX=this.flipX),this.owner.dy=0,c>0?this.mY=1:0>c&&(this.mY=this.flipY)),!0},"hit-solid":function(a){return this.stunned&&a.y>0&&(this.stunned=!1,this.owner.dx=0,this.owner.dy=0),!0}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicPacingPlatform",constructor:function(a){this.ang=this.owner.angle||a.angle||0,this.dist=this.owner.distance||a.distance||128,this.period=this.owner.period||a.period||4e3,this.time=0,this.startPos=this.owner.startPos||a.startPos||0,this.offset=0,this.originX=this.owner.x,this.originY=this.owner.y},events:{"handle-logic":function(a){var b=a.delta;this.time+=b,this.time>this.period&&(this.time=this.time%this.period),this.offset=this.time/this.period*2*Math.PI,this.owner.x=this.originX+Math.sin(this.offset+this.startPos)*this.dist*Math.cos(this.ang),this.owner.y=this.originY+Math.sin(this.offset+this.startPos)*this.dist*Math.sin(this.ang)}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicPortable",constructor:function(a){this.portableDirections=a.portableDirections||{down:!0},this.carrier=this.lastCarrier=void 0,this.message={entity:this.owner}},events:{"handle-logic":function(a){this.carrierConnected?(this.carrier!==this.lastCarrier&&(this.lastCarrier&&this.lastCarrier.trigger("release-me",this.message),this.carrier.trigger("carry-me",this.message)),this.carrierConnected=!1):this.carrier&&(this.carrier.trigger("release-me",this.message),this.carrier=void 0),this.lastCarrier=this.carrier},"hit-solid":function(a){a.y>0?this.updateCarrier(a.entity,"down"):a.y<0?this.updateCarrier(a.entity,"up"):a.x<0?this.updateCarrier(a.entity,"left"):a.x>0&&this.updateCarrier(a.entity,"right")}},methods:{updateCarrier:function(a,b){this.portableDirections[b]&&a&&(a!==this.carrier&&(this.carrier=a),this.carrierConnected=!0)}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicPortal",constructor:function(a){var b=0,c=a.entrants||a.entrant;if(this.destination=this.owner.destination||a.destination,this.used=!1,this.ready=!1,this.wasReady=!1,c)if(this.entrants={},Array.isArray(c))for(b=0;b0&&this.vY>0||a.y<0&&this.vY<0?this.vY=0:(a.x<0&&this.vX<0||a.x>0&&this.vX>0)&&(this.vX=0),!0}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicRebounder",constructor:function(a){platypus.Vector.assign(this.owner,"velocity","dx","dy","dz"),this.owner.mass=this.owner.mass||a.mass||1,this.elasticity=a.elasticity||.8,this.v=new platypus.Vector(0,0,0),this.incidentVector=new platypus.Vector(0,0,0),this.staticCollisionOccurred=!1,this.nonStaticCollisionOccurred=!1,this.hitThisTick=[],this.otherV=new platypus.Vector(0,0,0),this.otherVelocityData=[]},events:{"handle-logic":function(a){this.hitThisTick=[],this.otherVelocityData.length=0},"hit-static":function(a){var b=0,c=a.entity,d=0;for(d=0;db;b++)for(c=0;e>c;c++)h=Math.min(f,this.owner.width-b*f),i=Math.min(g,this.owner.height-c*g),this.regions.push({x:b*f,y:c*g,width:h, diff --git a/src/components/Mover.js b/src/components/Mover.js index 0ed155c5..3cf640e5 100644 --- a/src/components/Mover.js +++ b/src/components/Mover.js @@ -5,7 +5,6 @@ * @class Mover * @uses Component */ -// Requires: ["Motion", "../Vector.js"] /*global platypus */ /*jslint plusplus:true */ (function () { diff --git a/src/components/NodeMap.js b/src/components/NodeMap.js index 850bad55..0048910d 100644 --- a/src/components/NodeMap.js +++ b/src/components/NodeMap.js @@ -1,56 +1,10 @@ /** -# COMPONENT **NodeMap** -This component sets up a NodeMap to be used by the [[NodeResident]] component on this entity's child entities. - -## Dependencies -- [[EntityContainer]] - This component expects the entity to have an `EntityContainer` component so it knows when `NodeResident` children are added. - -## Messages - -### Listens for: -- **add-node** - Expects a node definition to create a node in the NodeMap. - - @param definition.nodeId (string or array) - This value becomes the id of the Node. Arrays are joined using "|" to create the id string. - - @param definition.type (string) - This determines the type of the node. - - @param definition.x (number) - Sets the x axis position of the node. - - @param definition.y (number) - Sets the y axis position of the node. - - @param definition.z (number) - Sets the z axis position of the node. - - @param definition.neighbors (object) - A list of key/value pairs where the keys are directions from the node and values are node ids. For example: {"west": "node12"}. -- **child-entity-added** - Checks the child entity for a nodeId and if found adds the child to the corresponding node. - - @param entity (Entity) - The entity that may be placed on a node. - -## JSON Definition - { - "type": "NodeMap" - - "map": [ - // Optional. An array of node definitions to create the NodeMap. - - { - "NodeId": "Node1", - // A string or array that becomes the id of the Node. Arrays are joined using "|" to create the id string. - - "type": "path", - // A string that determines the type of the node. - - "x": 0, - // Sets the x axis position of the node. - - "y": 0, - // Sets the y axis position of the node. - - "z": 0, - // Sets the z axis position of the node. - - "neighbors": { - // A list of key/value pairs where the keys are directions from the node and values are node ids. - - "west": "node0", - "east": "node2" - } - } - ] - } -*/ + * This component sets up a NodeMap to be used by the [[NodeResident]] component on this entity's child entities. + * + * @namespace platypus.components + * @class NodeMap + * @uses Component + */ /*global platypus */ /*jslint plusplus:true */ (function () { @@ -142,6 +96,37 @@ This component sets up a NodeMap to be used by the [[NodeResident]] component on this.residentsAwaitingNode = []; + /** + * An array of node definitions to create the NodeMap. A node definition can take the following form: + * + * { + * "NodeId": "Node1", + * // A string or array that becomes the id of the Node. Arrays are joined using "|" to create the id string. + * + * "type": "path", + * // A string that determines the type of the node. + * + * "x": 0, + * // Sets the x axis position of the node. + * + * "y": 0, + * // Sets the y axis position of the node. + * + * "z": 0, + * // Sets the z axis position of the node. + * + * "neighbors": { + * // A list of key/value pairs where the keys are directions from the node and values are node ids. + * + * "west": "node0", + * "east": "node2" + * } + * } + * + * @property map + * @type Array + * @default [] + */ if (definition.map) { for (i = 0; i < definition.map.length; i++) { this.addNode(new Node(definition.map[i], this)); @@ -150,6 +135,18 @@ This component sets up a NodeMap to be used by the [[NodeResident]] component on }, events: { + /** + * Expects a node definition to create a node in the NodeMap. + * + * @method 'add-node' + * @param definition {Object} Key/value pairs. + * @param definition.nodeId {String|Array} This value becomes the id of the Node. Arrays are joined using "|" to create the id string. + * @param definition.type {String} This determines the type of the node. + * @param definition.x {String} Sets the x axis position of the node. + * @param definition.y {String} Sets the y axis position of the node. + * @param definition.z {String} Sets the z axis position of the node. + * @param definition.neighbors {Object} A list of key/value pairs where the keys are directions from the node and values are node ids. For example: {"west": "node12"}. + */ "add-node": function (nodeDefinition) { var i = 0, entity = null, @@ -173,6 +170,13 @@ This component sets up a NodeMap to be used by the [[NodeResident]] component on } } }, + + /** + * Checks the child entity for a nodeId and if found adds the child to the corresponding node. + * + * @method 'child-entity-added' + * @param entity {Entity} The entity that may be placed on a node, or if the entity is a node it is added to the map of nodes. + */ "child-entity-added": function (entity) { if(entity.isNode){ // a node this.owner.triggerEvent('add-node', entity);