function Terrain(e){function t(e){return Math.floor(e)-model.distance}function n(e){var t=a.dist();return Math.floor(e)-t}function i(e){return Math.floor(e)}function o(e,t,n,i,o,a,r){return{x:e+r*(2*(1-r)*(n-e)+r*(o-e)),y:t+r*(2*(1-r)*(i-t)+r*(a-t))}}var a=this;this.groundpoints=[],this.floorphys=[],this.terrainRightMost=0,this.heroCP,this.DIV=e||2,this.BGYOFFSET=BASE_HEIGHT-0,this.GROUND_TXT_WIDTH=150,this.SURFACE_THICKNESS=20,this.SURFACE_PHYSICS_THICKNESS=100,this.dist=function(){var e=a.getaddx();return model.distance-e},this.getaddx=function(){return Math.floor(model.distance/this.getWorldTotalDistance())*this.getWorldTotalDistance()},this.getViewablePoints=function(e){var t=[],n=a.dist();for(var i in e)e[i].x>n&&e[i].x0){var i=Math.abs(e-this.groundpoints[n].x);ithis.groundpoints.length&&(a-=this.groundpoints.length),this.groundpoints[a]){var r=Math.abs(e-this.groundpoints[a].x);if(rn&&e-7000&&t4&&this.enemyarr.push({type:1,x:2,y:12,dir:"R",dist:5}),{leveldata:this.leveldata,enemyarr:this.enemyarr,startpos:{x:11,y:2}}}function getLevel2(){return this.leveldata=[],this.leveldata.push([0,0,0,0,0,0,0,0,0,0,0,0,0]),this.leveldata.push([0,0,1,1,1,0,0,0,1,1,1,0,0]),this.leveldata.push([0,0,0,0,0,0,0,0,0,0,0,0,0]),this.leveldata.push([0,0,0,0,0,2,2,2,0,0,0,0,0]),this.leveldata.push([0,0,0,0,0,0,0,0,0,0,0,0,0]),this.leveldata.push([0,0,2,2,2,0,0,0,2,2,2,0,0]),this.leveldata.push([0,0,1,1,1,0,0,0,1,1,1,0,0]),this.leveldata.push([1,0,2,2,2,0,0,0,2,2,2,0,1]),this.leveldata.push([0,0,0,0,0,0,0,0,0,0,0,0,0]),this.leveldata.push([1,0,0,0,1,2,2,2,1,0,0,0,1]),this.leveldata.push([1,0,0,0,1,0,0,0,1,0,0,0,1]),this.leveldata.push([1,0,0,0,1,0,0,0,1,0,0,0,1]),this.leveldata.push([2,2,2,2,2,2,2,2,2,2,2,2,2]),this.enemyarr=[],game.level>4&&this.enemyarr.push({type:1,x:3,y:5,dir:"R",dist:3}),this.enemyarr.push({type:1,x:6,y:9,dir:"R",dist:3}),this.enemyarr.push({type:1,x:2,y:12,dir:"R",dist:10}),game.level>4&&this.enemyarr.push({type:1,x:8,y:12,dir:"R",dist:4}),{leveldata:this.leveldata,enemyarr:this.enemyarr,startpos:{x:7,y:3}}}function getLevel3(){return this.leveldata=[],this.leveldata.push([0,0,0,0,0,0,0,0,0,0,0,0,0]),this.leveldata.push([1,0,1,0,1,0,0,0,1,0,1,0,1]),this.leveldata.push([0,0,0,0,0,0,0,0,0,0,0,0,0]),this.leveldata.push([1,0,0,0,0,0,0,0,0,0,0,0,1]),this.leveldata.push([0,0,0,0,0,0,0,0,0,0,0,0,0]),this.leveldata.push([0,0,2,2,2,2,2,2,2,2,2,0,0]),this.leveldata.push([0,0,1,1,1,0,0,0,1,1,1,0,0]),this.leveldata.push([2,2,0,0,0,0,0,0,0,0,0,2,2]),this.leveldata.push([0,1,0,0,0,0,0,0,0,0,0,1,0]),this.leveldata.push([0,1,0,0,1,2,2,2,1,0,0,1,0]),this.leveldata.push([0,1,0,0,1,0,0,0,1,0,0,1,0]),this.leveldata.push([0,1,0,0,0,0,0,0,0,0,0,1,0]),this.leveldata.push([2,2,2,2,2,2,2,2,2,2,2,2,2]),this.enemyarr=[],game.level>4&&this.enemyarr.push({type:1,x:4,y:5,dir:"R",dist:8}),this.enemyarr.push({type:1,x:8,y:5,dir:"R",dist:2}),this.enemyarr.push({type:1,x:7,y:9,dir:"R",dist:2}),this.enemyarr.push({type:2,x:2,y:12,dir:"R",dist:5}),{leveldata:this.leveldata,enemyarr:this.enemyarr,startpos:{x:2,y:7}}}function getLevel4(){return this.leveldata=[],this.leveldata.push([0,0,0,0,0,1,1,1,0,0,0,0,0]),this.leveldata.push([1,1,1,0,0,0,0,0,0,0,1,1,1]),this.leveldata.push([0,0,0,0,0,0,0,0,0,0,0,0,0]),this.leveldata.push([0,0,0,0,0,0,0,0,0,0,0,0,0]),this.leveldata.push([2,2,2,0,0,1,1,1,0,0,2,2,2]),this.leveldata.push([0,0,0,0,0,0,0,0,0,0,0,0,0]),this.leveldata.push([1,0,1,0,1,0,0,0,1,0,1,0,1]),this.leveldata.push([0,2,2,2,0,0,0,0,0,2,2,2,0]),this.leveldata.push([0,0,0,0,0,0,0,0,0,0,0,0,0]),this.leveldata.push([0,0,1,1,1,0,0,0,1,1,1,0,0]),this.leveldata.push([0,0,2,2,2,0,0,0,2,2,2,0,0]),this.leveldata.push([0,0,0,0,0,0,0,0,0,0,0,0,0]),this.leveldata.push([2,2,2,2,2,2,2,2,2,2,2,2,2]),this.enemyarr=[],this.enemyarr.push({type:2,x:2,y:4,dir:"R",dist:8}),game.level>4&&this.enemyarr.push({type:1,x:4,y:7,dir:"R",dist:7}),this.enemyarr.push({type:1,x:8,y:9,dir:"R",dist:3}),this.enemyarr.push({type:2,x:2,y:12,dir:"R",dist:5}),{leveldata:this.leveldata,enemyarr:this.enemyarr,startpos:{x:14,y:4}}}function Loader(){function e(e){e.target.id;e.target.sprn&&E.push(e.target);var n="Loading : "+Math.floor(l/c*100)+"%";console.log(n);var i=document.getElementById("DIAG");$(i).html(n),++l,t()}function t(){if(l==c){for(var e in E){var t=E[e].id,n=E[e].sprn,i=E[e].frm;if(n){void 0==imagessource[n]&&(imagessource[n]=[]),PRERENDER&&halfFrame(i)&&(imagessource[n][i]=renderToCanvas(canvasWidth/3,canvasHeight/3,function(n){n.drawImage(imagessource[t],0,0,canvasWidth/3,canvasHeight/3),console.log("prerendered: "+u+"/"+c),u++,Math.ceil(e/200)==e/200&&o()}))}}r(),clearInterval(s)}}function n(){i()}function i(){}function o(){}function a(){for(var e=[],t=[{ext:".ogg",mime:"audio/ogg; codecs=vorbis"},{ext:".mp3",mime:"audio/mpeg"}],n=new Audio,i=0,o=t.length;i0)for(var n in e[t])iterateAssetData({asset:e[t][n]});else iterateAssetData(e[t])}else"asset"!=t&&"grid_square"!=t&&"buttonasset"!=t&&"logo"!=t&&"icon"!=t&&"sprite"!=t&&"assetsLevels"!=t&&"bulletasset"!=t&&"splashasset"!=t&&"mobile_button_left"!=t&&"mobile_button_rotate_left"!=t&&"mobile_button_right"!=t&&"mobile_button_rotate_right"!=t&&"mobile_button_up"!=t&&"mobile_button_down"!=t&&"mobile_button_forwards"!=t&&"mobile_button_fire"!=t||assets[e[t]]&&(fassets[e[t]]=assets[e[t]])}function setBaseSize(){CONFIG.FULLSCREEN&&(getScreenSize(),BD.screenWidth>BD.screenHeight?(BD.SCALE=BASE_HEIGHT/BD.screenHeight,BASE_WIDTH=BASE_HEIGHT*(BD.screenWidth/BD.screenHeight)):BASE_HEIGHT=BASE_WIDTH*(BD.screenHeight/BD.screenWidth))}function init_main2(){TESTING&&initFPS(),renderer=new PIXI.Application(BASE_WIDTH,BASE_HEIGHT,{backgroundColor:10066329}),document.getElementById("game").appendChild(renderer.view),stage=renderer.stage,renderer.view.style.border="solid 1px #666666";for(var e=1;e<5;e++)window["stage"+e]=new PIXI.Container(!0),stage.addChild(window["stage"+e]);stage=window.stage1,doResize(),renderer.ticker.add(function(e){tick()}),initLoader()}function initLoader(){fassets={},iterateAssetData(CONFIG),PIXI.loadingtxt=new PIXI.Text("Loading ",{font:"28px Bungee",fill:"#FFFFFF",align:"left"}),PIXI.loadingtxt.position.x=BASE_WIDTH/2-90,PIXI.loadingtxt.position.y=BASE_HEIGHT-120,stage.addChild(PIXI.loadingtxt);var e=PIXI.loader;for(var t in fassets)if(!this[t])try{e.add(t,fassets[t]),this[t]=PIXI.Texture.fromImage(fassets[t]),assetsToLoadLength++}catch(e){}0==assetsToLoadLength?onAssetsLoaded():(e.on("progress",onAssetsProgress),e.once("complete",onAssetsLoaded),e.load())}function onAssetsProgress(e){var t=100-Math.floor(e.progress/assetsToLoadLength*100);PIXI.loadingtxt&&(PIXI.loadingtxt.text="Loading "+t)}function onAssetsLoaded(){stage.removeChild(PIXI.loadingtxt),PIXI.loadingtxt=null,init_main3()}function createAnim1(){removeAll(),(new BD.Anim1).execute({callback:createSplash})}function init_main3(){TESTING?createGame():setTimeout(function(){createSplash()},1e3)}function removeAll(){if(stage.removeAll)stage&&stage.removeAll();else for(;stage.children[0];)stage.removeChild(stage.children[0]);document.onkeypress=null}this.BD=this.BD||{},function(){"use strict";BD.Anim1=function(){function e(){c.destroy(),s.destroy(),stage.removeChild(i),stage.removeChild(o),stage.removeChild(a),stage.removeChild(r),stage.removeChild(l)}function t(){i.rotation+=5e-4,o.rotation-=.025}var n,i,o,a,r,s,l,c;this.execute=function(u){function h(e){stage.removeChild(f),c.setSpeedInstant(1),i.position.x=i.position.x-1e3,o.position={x:BASE_WIDTH/2+300,y:BASE_HEIGHT/2},o.scale=new PIXI.Point(2,2),c.setRotation(Math.PI-.1),TweenLite.to(o.position,3,{x:o.position.x-400,y:o.position.y+50,ease:Power0.Linear,onComplete:e})}function d(e){c.setSpeed(0),i.position.x=BASE_WIDTH/2,i.scale=new PIXI.Point(1,1),o.position={x:BASE_WIDTH/2+400,y:BASE_HEIGHT/2+200},o.scale=new PIXI.Point(2,2),TweenLite.to(o.position,6,{x:BASE_WIDTH/2+240,y:BASE_HEIGHT/2+100,ease:Power0.easeOut}),TweenLite.to(o.scale,6,{x:o.scale.x/1.8,y:o.scale.y/1.8,ease:Power0.easeOut,onComplete:e}),setTimeout(function(){a.position.x=BASE_WIDTH/2},3e3)}function p(t){r=new PIXI.Sprite(root.control_centre),stage.addChild(r),setTimeout(function(){(l=new PIXI.Text("ALERT ALERT ALERT !!! \n\nMeteor heading direct\nfor Planet XXXXX\n\nCollision Imminent!!!",{font:"28px "+CONFIG.FONT,fill:"#baff00",wordWrap:!0,wordWrapWidth:700,align:"left",stroke:"#77a202",strokeThickness:1})).position={x:600,y:100},stage.addChild(l);var t=1;s=new BD.Button({text:"BEGIN TASK #1",position:{x:BASE_WIDTH/2,y:520},scale:1.2,onclick:function(){1==t?(r.texture=root.control_centre_map,l.text="",t=2):2==t?(r.texture=root.control_centre_chooser,l.text="",t=3):(Object.keys(CONFIG).forEach(function(e){delete CONFIG[e]}),Object.getOwnPropertyNames(CONFIG).forEach(function(e){delete CONFIG[e]}),e(),CONFIG={},gameid=71,setConfig(),initLoader())}})},1e3),setTimeout(function(){l.text="** DEFENSE PHASE 1 of 3 **\n\nTASK #1 :\nFirst missile at Meteor\n\nOBJECTIVE :\nBreak Meteor into parts"},4e3)}n=cloneObject(u),(c=new BD.BackgroundSpeed).execute({config:CONFIG.BACKGROUND}),c.setSpeed(0),(i=new PIXI.Sprite(root.planet)).anchor=new PIXI.Point(.5,.5),i.position={x:BASE_WIDTH/2,y:BASE_HEIGHT/2},i.scale=new PIXI.Point(.5,.5),stage.addChild(i),(o=new PIXI.Sprite(root.asteroid_rock)).anchor=new PIXI.Point(.5,.5),o.position={x:2e3,y:BASE_HEIGHT/2},o.scale=new PIXI.Point(2,2),stage.addChild(o),(a=new PIXI.Sprite(root.warning_red_alert)).anchor=new PIXI.Point(.5,.5),a.position={x:1500,y:BASE_HEIGHT/2},a.scale=new PIXI.Point(1.5,1.5),stage.addChild(a);var f=new PIXI.Sprite(root[CONFIG.BRANDING.logo]);f.anchor=new PIXI.Point(.5,.5),f.position={x:150,y:150},stage.addChild(f),f.scale={x:.2,y:.2},TweenLite.to(f.scale,.4,{x:.7,y:.7,ease:Bounce.easeOut}),function(e){c.setSpeed(0),i.position.x=BASE_WIDTH/2,o.position={x:BASE_WIDTH/2+1e3,y:BASE_HEIGHT/2+500},o.scale=new PIXI.Point(4,4),TweenLite.to(o.position,3,{x:BASE_WIDTH/2+500,y:BASE_HEIGHT/2+300,ease:Power0.easeOut}),TweenLite.to(o.scale,3,{x:o.scale.x/1.5,y:o.scale.y/1.5,ease:Power0.easeOut,onComplete:e})}(function(){h(function(){d(function(){p()})})}),EventDispatcher.on("update",t)},this.destroy=e}}(),this.BD=this.BD||{},function(){"use strict";BD.AnimatedSprite=function(){function e(){if("number"==typeof a.frames)l=0,c=a.frames;else{l=0;for(var e=0;e=c&&(a.loop?(d=l,e=l):i());var t=Math.floor(e/a.columns),n=Math.floor(e-t*a.columns);try{var s=new PIXI.Texture(r,new PIXI.Rectangle(n*a.w,t*a.h,a.w,a.h));o.texture=s}catch(e){log("[CAUGHT ERROR] animatedSprite L "+e)}}function n(e){p&&(o.position.x+=e.x,o.position.y+=e.y)}function i(){a.dest.removeChild(o),EventDispatcher.off("update",t),EventDispatcher.off("movebackground",n)}var o,a,r,s,l,c,u,h=stage3,d=0;this.execute=function(i,l,c,u){EventDispatcher.on("update",t),EventDispatcher.on("movebackground",n),a=Object.assign({},c),s=2,a.dest=a.dest||h,r=window[a.asset],(o=new PIXI.Sprite(r)).position={x:i,y:l};var d=new PIXI.Texture(r,new PIXI.Rectangle(0,0,1,1));return o.texture=d,a.offset&&(o.position.x+=a.offset.x,o.position.y+=a.offset.y),o.anchor={x:.5,y:.5},o.scale={x:a.scale.x,y:a.scale.y},a.dest.addChild(o),e(),this};var p=!0;CONFIG.HERO.sprite&&(p=!CONFIG.HERO.sprite.isHero),this.getAnim=function(){return s},this.getMc=function(){return o},this.setAnim=function(t,n){s=t,e()},this.setFPS=function(e){a.fps=e},this.destroy=i}}(),this.BD=this.BD||{},function(){"use strict";BD.AwardManager=function(){function e(e){l=CONFIG.LEVELUP_AWARDS[e-1]||[]}function t(e){var t=l[e].id,n=l[e].target;return h[t]&&h[t][n]?"icon_tick":"icon_cross"}function n(){var e=[];return l.forEach(function(n,i){e.push({text:l[i].title,icon:t(i)})}),e}function i(e,t){l.length>0&&n().forEach(function(e,t){var n=150+200*t,i=BASE_HEIGHT-150,o=new PIXI.Sprite(root.icon_shell);o.scale={x:2,y:2},o.anchor={x:.5,y:.5},o.position={x:n,y:i},stage4.addChild(o);var a=new PIXI.Text(e.text,{font:"bold 40px "+CONFIG.FONT,align:"center",fill:CONFIG.FONT_COLOUR_UI,wordWrapWidth:200});a.anchor={x:.5,y:.5},a.position={x:n,y:i+50},stage4.addChild(a)})}function o(e){Global.score+=Math.floor(e),window.localStorage.setItem("score",Global.score),BD.gui.refresh("score",Global.score)}function a(){var e=0;return l.forEach(function(t,n){var i=t.id,o=t.target;if(h[i]||(h[i]={}),h[i][o]){l.splice(n,1);var a=CONFIG.LEVELUP_ROLLINGOVER_AWARDS.pop();l.push(a)}h[t.id]&&h[t.id][t.target]&&e++}),e==l.length}var r,s,l,c="AWARDSX31",u=stage4,h=window.localStorage.getItem(c)?JSON.parse(window.localStorage.getItem(c)):{};Global.level=parseInt(window.localStorage.getItem("level")||1),BD.gui.refresh("level",Global.level),Global.score=parseInt(window.localStorage.getItem("score")||0),BD.gui.refresh("score",Global.score),this.execute=function(t){return r=t,u=t.container||u,EventDispatcher.on("showTaskList",i),e(Global.level),a(),i(),this},this.check=function(t){!s&&l&&l.forEach(function(n,r){var l=n.id,u=t[n.STATUS],d=n.target,p=n.award;if(h[l]||(h[l]={}),u==d&&!s){s=!0,(new BD.Message).execute({text:n.title+" "+Math.abs(u),text2:"+"+p+" shells",duration:2e3,bgasset:"panel_award",callback:function(){h[l][d]?(s=!1,o(p)):(h[l][d]=!0,window.localStorage.setItem(c,JSON.stringify(h)),i(2500,function(){s=!1,o(p),a()&&(new BD.Message).execute({bgasset:"panel_award",text:[{text:"Yee Har!!!"},{text:"Level "+Global.level+" complete"}],duration:2e3,callback:function(){Global.level++,window.localStorage.setItem("level",Global.level),BD.gui.refresh("level",Global.level),e(Global.level),i()}})}))}});var f=0,E=setInterval(function(){var e=new PIXI.Sprite(root.icon_shell);e.scale={x:1.5,y:1.5},e.position={x:BASE_WIDTH/2-150,y:BASE_HEIGHT/2+50},stage4.addChild(e);var t=BD.gui.getMcByKey("score");e.anchor=t.anchor,TweenLite.to(e.position,1,{x:t.position.x,y:t.position.y,ease:Linear.none}),TweenLite.to(e.scale,1,{x:t.scale.x,y:t.scale.y,ease:Linear.none}),f++>5&&clearInterval(E)},200)}})},this.destroy=function(){}}}(),this.BD=this.BD||{},function(){"use strict";BD.Background=function(){function e(e){if(Global.oktomoveBG){for(var i in s)e.x&&(s[i].position.x+=e.x*(a.config.xmulti||1)),e.y&&(s[i].position.y+=e.y*(a.config.ymulti||1)),a.config.fadeout&&(s[i].alpha-=e.y/1e4);t(e),a.config.cloud&&n()}}function t(e){for(var t in s)e.x>0&&s[t].position.x>i*(l-1)&&(s[t].position.x-=i*l),e.x<0&&s[t].position.x<-i&&(s[t].position.x+=i*l),a.config.repeatHorizontalOnly||(e.y>0&&s[t].position.y>o*(c-1)&&(s[t].position.y-=o*c,s[t].indy--),e.y<0&&s[t].position.y<-o&&(s[t].position.y+=o*c,s[t].indy++))}function n(){for(var e in s)s[e].indy>-1?s[e].alpha=0:s[e].alpha=1}var i,o,a,r,s=[],l=3,c=3;EventDispatcher.on("movebackground",e),this.execute=function(e){if(a=e,r=window[a.config.stage]||window.stage1,i=BASE_WIDTH*(a.config.scale?a.config.scale.x:1),o=BASE_HEIGHT*(a.config.scale?a.config.scale.y:1),u=window[e.asset||a.config.asset])for(var t=0;t=1&&a.config.assetBottomRow&&(u=window[a.config.assetBottomRow]);var h=new PIXI.Sprite(u);r.addChild(h),h.width=i+1,h.height=o+1,h.position={x:i*n,y:o*t},h.indy=t,s.push(h)}return this},this.destroy=function(){for(var t in s)r.removeChild(s[t]);EventDispatcher.off("movebackground",e)},this.reset=function(){for(var e in s)r.removeChild(s[e])}}}(),this.BD=this.BD||{},function(){"use strict";BD.BackgroundSpeed=function(){function e(){var e=window[t.config.asset],s=BASE_WIDTH-a*BASE_WIDTH;s<10&&(s=10),n.texture=new PIXI.Texture(e,new PIXI.Rectangle(parseInt(i),0,s,BASE_HEIGHT)),i+=a,ae.width-s&&(i=0)}var t,n;this.execute=function(i){t=i,n=new PIXI.Sprite,stage.addChild(n),n.width=1.2*BASE_WIDTH,n.height=1.2*BASE_HEIGHT,n.x=BASE_WIDTH/2,n.y=BASE_HEIGHT/2,n.anchor={x:.5,y:.5},BD.bg=n,EventDispatcher.on("update",e)},this.setSpeed=function(e){o=e/30,r=e,i=0,a=0},this.setSpeedInstant=function(e){r=e,a=e},this.setRotation=function(e){n.rotation=e},this.destroy=function(){EventDispatcher.off("update",e),stage.removeChild(n)};var i=0,o=.01,a=0,r=0}}(),this.BD=this.BD||{},function(){"use strict";BD.BackgroundTerrain=function(e){function t(){s=!0,a=new PIXI.Container,d.addChild(a),r=new Terrain(c.div);for(var e=c.offsetY+(Global.level-1)*(c.offsetYPerLevel||0),t=c.amplitude+(Global.level-1)*(c.amplitudePerLevel||0),n=[],i=(c.distance,Math.floor(10*Math.random()),0);i<(c.distance||10);i++)n.push({x:i*(c.stepsize||100),y:220+(e||0)+Math.random()*(t||300)});var o=r.buildTerrainDefineGroundpoints(n);for(l=0,l="object"==typeof c.offsetX?c.offsetX[0]:c.offsetX,i=2;i3&&c.randomX&&(f+=Math.random()*c.randomX);var E;if(c.asset instanceof Array)if(c.randomAssets){var g=Math.floor(Math.random()*c.asset.length);E=c.asset[g]}else{var v=Global.level-1;v>=c.asset.length&&(v=c.asset.length-1),E=c.asset[v]}else E=c.asset;var y=p.create(f,o[i].y,0,0,1,E);u.push(y),y.anchor=new PIXI.Point(.5,c.anchorY||.5),y.scale=c.scale?{x:c.scale.x,y:c.scale.y}:{x:1,y:1},h.push(p)}}function n(){s&&o()}function i(e){for(var t in u)u[t].position.x+=1.2*e.x,u[t].position.y+=e.y}function o(){p&&u[u.length-1].position.x1&&c.offsetX.shift(),EventDispatcher.trigger("levelCleared",{detail:c}),p=!1)}var a,r,s,l,c=cloneObject(e),u=[],h=[],d=stage1,p=!0;if(c.stagelevel)switch(c.stagelevel){case 1:d=stage1;break;case 2:d=stage2;break;case 3:d=stage3;break;case 4:d=stage4}EventDispatcher.on("update",n),EventDispatcher.on("movebackground",i),this.checkWaveCleared=o,this.startCreate=function(){t()},this.getEnemies=function(){return h},this.getBullets=function(){return[]},this.getConfig=function(){return c},this.destroy=function(){EventDispatcher.off("update",n),EventDispatcher.off("movebackground",i);for(var e in h)h[e].destroy();d.removeChild(a)}}}(),this.BD=this.BD||{},function(){"use strict";var e,t,n,i,o,a,r=[];BD.BackgroundTiles=function(s){function l(){c=new PIXI.extras.TilingSprite(texture,renderer.width,renderer.height),stage.addChild(c)}EventDispatcher.on("update",function(){c.tilePosition.x+=1.2*CONFIG.BACKGROUND.xspeed,c.tilePosition.y+=CONFIG.BACKGROUND.yspeed}),e=s.gridX||15,t=s.gridY||5,n=s.blockSize||100,i=s.blockPadding||8,o=s.gridOffsetX||300,a=s.gridOffsetY||40;var c;this.startCreate=function(){l()},this.getEnemies=function(){return r},this.getBullets=function(){return[]},this.getConfig=function(){return s}}}();var BrowserDetect={init:function(){this.browser=this.searchString(this.dataBrowser)||"An unknown browser",this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version",this.OS=this.searchString(this.dataOS)||"an unknown OS"},searchString:function(e){for(var t=0;t>",position:{x:getGameCentre().x+150,y:getGameCentre().y+150},width:50,onclick:function(){EventDispatcher.trigger("builderPanRight")}});t.push(u)}}}(),this.BD=this.BD||{},function(){"use strict";BD.Bullet=function(){function e(){t&&(t.position.x+=n.speed.x,t.position.y+=n.speed.y),(t.position.xCONFIG.BOUNDS.limitRightPerc*BASE_WIDTH||t.position.yCONFIG.BOUNDS.limitBottomPerc*BASE_HEIGHT)&&n.onDestroy&&n.onDestroy()}var t,n,i,o=stage2;this.destroy=function(){o.removeChild(t),EventDispatcher.off("update",e)},this.execute=function(i){n=Object.assign({},i),(t=new PIXI.Sprite(root[CONFIG.HERO.bulletasset])).position.x=n.position.x,t.position.y=n.position.y,t.scale=CONFIG.BULLET.scale,t.anchor={x:.5,y:.5},o.addChild(t),EventDispatcher.on("update",e)},this.update=e,this.getPos=function(){return t?t.position:{x:0,y:0}},this.getMc=function(){return t},this.getHitSize=function(){var e=t.rotation+45,n=t.width||i.texture.width,o=t.height||i.texture.height;return e>=0&&e<=90||e>180&&e<270?{width:n,height:o}:{width:o,height:n}}}}(),this.BD=this.BD||{},function(){"use strict";BD.BulletMananger=function(){function e(){CONFIG.BULLET&&CONFIG.BULLET.autoFire&&(o=setInterval(n,1e3*CONFIG.BULLET.autoFire))}function t(){CONFIG.BULLET&&CONFIG.BULLET.autoFire&&clearInterval(o)}function n(e){if(a.length>CONFIG.BULLET.maxCount-1)return!1;e||(e={startmc:BD.player.getMc()});var t=e.startmc,n=t.rotation+(CONFIG.BULLET.startRotation/360*(2*Math.PI)||0)-Math.PI/2,o={x:Math.cos(n)*CONFIG.BULLET.speed,y:Math.sin(n)*CONFIG.BULLET.speed},r=e.type?e.type:"bullet";if("ring"===r)(s=new BD.BulletRing).execute({position:t.position,speed:o,radius:e.radius,onComplete:function(){a.splice(a.indexOf(s),1)}});else{var s=new BD.Bullet,l=t.position;s.execute({rotation:n,position:l,speed:o,onDestroy:function(){i(s)}})}s.type=r,s.outcome=e.outcome,a.push(s)}function i(e){"ring"!==e.type&&(e.destroy(),a.splice(a.indexOf(e),1))}var o,a=[];this.execute=function(){CONFIG.BULLET&&e(),EventDispatcher.on("fire",n)},this.destroy=function(){EventDispatcher.off("fire",n),a.forEach(function(e){e.destroy()}),a=[],t()},this.getBullets=function(){return a},this.destroyBullet=i}}(),this.BD=this.BD||{},function(){"use strict";BD.BulletRing=function(){function e(){n&&(n.scale.x+=.005,n.scale.y+=.005),n.scale.x>a&&t()}function t(){EventDispatcher.off("update",e),r.removeChild(n),i.onComplete&&i.onComplete()}var n,i,o,a,r=stage2;this.destroy=t,this.execute=function(t){i=Object.assign({},t),n=new PIXI.Container,r.addChild(n),n.position.x=i.position.x,n.position.y=i.position.y,n.rotation=i.rotation+Math.PI/2,n.scale={x:0,y:0},o=new PIXI.Sprite(root.bullet_ring),n.addChild(o),o.anchor={x:.5,y:.5},a=i.radius?i.radius/10:.3,EventDispatcher.on("update",e)},this.update=e,this.getPos=function(){return n?n.position:{x:0,y:0}},this.getMc=function(){return n},this.getHitSize=function(){var e=(n.width||o.texture.width)*n.scale.x;return{width:(n.height||o.texture.height)*n.scale.x,height:e}}}}(),this.BD=this.BD||{},function(){"use strict";BD.Button=function(e){function t(e){o=e,a=e.container||stage4;var t=o.scale||1;(i=new PIXI.Container).position.x=o.position.x,i.position.y=o.position.y,i.scale={x:1*t,y:1*t},void 0!==o.alpha&&(i.alpha=o.alpha),i.interactive=!0,i.buttonMode=!0,i.mousedown=i.touchstart=function(e){o.onclick(e)},i.mouseup=i.mouseupoutside=i.touchend=i.touchendoutside=function(e){o.onrelease&&o.onrelease(e)},o.keypress&&(document.onkeypress=n),a.addChild(i);var s;if(o.icon)s=new PIXI.Sprite(root[o.icon]);else{var l=window[o.asset]||window[CONFIG.UI.buttonasset];(r=new PIXI.Sprite(l)).anchor=new PIXI.Point(.5,.5),r.mouseover=function(e){TweenLite.to(r.scale,.1,{x:1*t*1.05,y:1*t*1.05,ease:Circ.easeOut})},r.mouseout=function(e){TweenLite.to(r.scale,.3,{x:1*t,y:1*t,ease:Circ.easeOut})},i.addChild(r),o.text&&(s=new PIXI.Text(o.text,{font:CONFIG.UI.buttonfontsize+"px "+CONFIG.FONT,fill:CONFIG.FONT_COLOUR_BTN,stroke:CONFIG.FONT_COLOUR_STROKE,strokeThickness:5,align:"center",wrap:o.wrap}))}return s&&(s.anchor=new PIXI.Point(.5,.6),s.position.y=4,o.textOffset&&(s.position.x+=o.textOffset.x,s.position.y+=o.textOffset.y),i.addChild(s)),i}function n(e){13!==e.keyCode&&0!==e.keyCode||(document.onkeypress=null,o.onclick(e.target))}var i,o,a,r;t(e),this.destroy=function(){document.onkeypress=null,a.removeChild(i)},this.execute=t}}(),this.BD=this.BD||{},function(){"use strict";BD.CountDown=function(){function e(){t--,n.text=t,0==t&&(clearInterval(i),a.removeChild(n),o.callback())}var t,n,i,o,a=stage3;this.execute=function(r){t=TESTING?1:CONFIG.COUNTDOWN||3,o=Object.assign({},r),(n=new PIXI.Text(t,{font:"240px "+CONFIG.FONT,fill:CONFIG.FONT_COLOUR,align:"center"})).anchor={x:1,y:.5};var s=(1-CONFIG.UI.widthPerc)*BASE_WIDTH;n.position.x=BASE_WIDTH/2-s,n.position.y=BASE_HEIGHT/2+50,a.addChild(n),i=setInterval(e,1e3)}}}(),this.BD=this.BD||{},function(){"use strict";BD.Enemy=function(){var e,t,n,i;this.create=function(n,o,a,r,s,l,c){i=c||stage2,Math.random();var u=s||1;return e=new PIXI.Container,t=new PIXI.Sprite(window[l]),t.anchor={x:.5,y:.5},e.addChild(t),e.type=!0,e.assetname=l,e.interactive=!0,e.buttonMode=!0,e.position={x:n,y:o},e.inst=this,e.spr=t,e.anchor={x:.5,y:.5},CONFIG.ENEMIES&&CONFIG.ENEMIES.scale&&(e.scale={x:CONFIG.ENEMIES.scale.x*u,y:CONFIG.ENEMIES.scale.y*u}),e.xsp=a||0,e.ysp=r||0,i.addChild(e),e},this.destroy=function(){i.removeChild(e)},this.getPos=function(){return e?e.position:{x:0,y:0}},this.getScale=function(){return e?e.scale:1},this.getMc=function(){return e},this.getHitSize=function(){var t=e.rotation+45,n=(e.texture?e.texture.width:0)*e.scale.x,i=(e.texture?e.texture.height:0)*e.scale.y;return t>=0&&t<=90||t>180&&t<270?{width:n,height:i}:{width:i,height:n}},this.getNumber=function(){return n}}}(),this.BD=this.BD||{},function(){"use strict";BD.XXXXXEnemyClass=function(){function e(t,n){C.invincible=t,r.alpha=C.invincible?.5:1,n&&setTimeout(function(){e(!1,0)},n)}function t(e){switch(e.keyCode){case CONFIG.HERO.controls.right:f=!0;break;case CONFIG.HERO.controls.left:E=!0;break;case CONFIG.HERO.controls.up:g=!0;break;case CONFIG.HERO.controls.forwards:v=!0;break;case CONFIG.HERO.controls.down:y=!0;break;case CONFIG.HERO.controls.rotate_left:I=!0;break;case CONFIG.HERO.controls.rotate_right:m=!0;break;case CONFIG.HERO.controls.fire:o()}}function n(e){switch(e.keyCode){case CONFIG.HERO.controls.right:f=!1;break;case CONFIG.HERO.controls.left:E=!1;break;case CONFIG.HERO.controls.up:g=!1;break;case CONFIG.HERO.controls.forwards:v=!1;break;case CONFIG.HERO.controls.down:y=!1;break;case CONFIG.HERO.controls.rotate_left:I=!1;break;case CONFIG.HERO.controls.rotate_right:m=!1}}function i(){if(r){if(d&&(r.position.x+=(d-r.position.x)/CONFIG.HERO.speed),p&&(r.position.y+=(p-r.position.y)/CONFIG.HERO.speed),f&&(r.position.x<(CONFIG.HERO.limitRightPerc||1)*BASE_WIDTH?s<=CONFIG.HERO.speed&&(s+=CONFIG.HERO.accel):s=0,d=0),r.position.x>(CONFIG.HERO.wrapRightPerc||999)*BASE_WIDTH&&(r.position.x=CONFIG.HERO.limitLeftPerc*BASE_WIDTH,r.position.y+=CONFIG.HERO.wrapRightStepDownPixels||0),E&&(r.position.x>(CONFIG.HERO.limitLeftPerc||0)*BASE_WIDTH?s>=-CONFIG.HERO.speed&&(s-=CONFIG.HERO.accel):s=0,d=0),r.position.x<(CONFIG.HERO.wrapLeftPerc||-999)*BASE_WIDTH&&(r.position.x=CONFIG.HERO.limitRightPerc*BASE_WIDTH),g&&(r.position.y>(CONFIG.HERO.limitTopPerc||0)*BASE_HEIGHT?l>=-CONFIG.HERO.speed&&(l-=CONFIG.HERO.accel):l=0,p=0),r.position.y<(CONFIG.HERO.wrapTopPerc||-999)*BASE_HEIGHT&&(r.position.y=CONFIG.HERO.limitBottomPerc*BASE_HEIGHT),y&&(r.position.y<(CONFIG.HERO.limitBottomPerc||1)*BASE_HEIGHT?l<=CONFIG.HERO.speed&&(l+=CONFIG.HERO.accel):l=0,p=0),r.position.y>(CONFIG.HERO.wrapBottomPerc||999)*BASE_HEIGHT&&(r.position.y=CONFIG.HERO.limitTopPerc*BASE_HEIGHT),f||E||(s*=1-CONFIG.HERO.deceleration),g||y||(l*=1-CONFIG.HERO.deceleration),v){var e=r.rotation-Math.PI/2;c=Math.cos(e)*CONFIG.HERO.speed,u=Math.sin(e)*CONFIG.HERO.speed,BCONFIG.HERO.limitRightPerc*BASE_WIDTH&&(r.position.x=CONFIG.HERO.limitRightPerc*BASE_WIDTH),void 0!==CONFIG.HERO.limitLeftPerc&&r.position.xCONFIG.HERO.limitBottomPerc*BASE_HEIGHT&&(r.position.y=CONFIG.HERO.limitBottomPerc*BASE_HEIGHT),I&&h-CONFIG.HERO.rotatespeed/40&&(h-=CONFIG.HERO.rotateaccel/40),I||m||(h*=1-CONFIG.HERO.rotatedeceleration/5),r.rotation+=h||0,CONFIG.BACKGROUND.scroll?(CONFIG.BACKGROUND.xspeed=-s,CONFIG.BACKGROUND.yspeed=-l,CONFIG.BACKGROUND.xspeed=-c*B,CONFIG.BACKGROUND.yspeed=-u*B):(r.position.x+=s*x,r.position.y+=l*O,r.position.x+=c*B,r.position.y+=u*B)}}function o(){if(G.length>CONFIG.BULLET.maxCount-1)return!1;var e=r.rotation+(CONFIG.BULLET.startRotation/360*(2*Math.PI)||0)-Math.PI/2,t={x:Math.cos(e)*CONFIG.BULLET.speed,y:Math.sin(e)*CONFIG.BULLET.speed},n=new BD.Bullet;n.execute({arr:G,self:n,rotation:e,position:r.position,speed:t}),G.push(n)}function a(){return r}function a(){return r}C=this;var r,s,l,c,u,h,d,p,f,E,g,v,y,I,m,C=this,x=1,O=1,B=0,G=[];this.create=function(){r=new PIXI.Container,stage.addChild(r),createGameMask(r),r.position.x=CONFIG.HERO.startPosPerc.x*BASE_WIDTH,r.position.y=CONFIG.HERO.startPosPerc.y*BASE_HEIGHT,r.rotation=CONFIG.HERO.startRotation/(180/Math.PI)||0,r.scale=CONFIG.HERO.scale;var o=new PIXI.Sprite(root[CONFIG.HERO.asset]);r.addChild(o),o.anchor={x:.5,y:.5},s=0,l=0,c=0,u=0,h=0,d=0,p=0,f=!1,E=!1,g=!1,y=!1,e(!0,3e3),window.addEventListener("keydown",t,!1),window.addEventListener("keyup",n,!1),CONFIG.HERO.controls.left==CONFIG_DRAG&&(stage.mousemove=function(e){var t=Math.floor(renderer.view.style.left.split("p")[0]),n=Math.floor(renderer.view.style.top.split("p")[0]),i=Math.floor(renderer.view.style.width.split("p")[0]),o=(Math.floor(renderer.view.style.height.split("p")[0]),BASE_WIDTH/i);d=(e.data.originalEvent.clientX-t)*o,p=(e.data.originalEvent.clientY-n)*o},document.addEventListener("touchmove",function(e){var t=Math.floor(renderer.view.style.left.split("p")[0]),n=Math.floor(renderer.view.style.top.split("p")[0]),i=Math.floor(renderer.view.style.width.split("p")[0]),o=(Math.floor(renderer.view.style.height.split("p")[0]),BASE_WIDTH/i),a=e.changedTouches[0];d=(a.clientX-t)*o,p=(a.clientY-n)*o})),document.addEventListener("tick",i,!1)},this.destroy=function(){stage.removeChild(r),window.removeEventListener("keydown",t),window.removeEventListener("keyup",n),document.removeEventListener("tick",i,!1)},this.getPos=function(){return r?r.position:{x:0,y:0}},this.getMc=a,this.getHitSize=function(){var e=r.rotation*(180/Math.PI);return(e-=45)<0&&(e+=360),console.log(e),e>=90&&e<=180||e>270&&e<360?{width:r.width,height:r.height}:{width:r.height,height:r.width}},this.getSpeed=function(){return{x:s||c,y:l||u}},this.setXSpeed=function(e){x=e,B=e,c=0},this.setYSpeed=function(e){O=e,B=e,u=0},this.getBullets=function(){return G}}}(),this.BD=this.BD||{},function(){"use strict";BD.EnemyInvader=function(){function e(e,t,o,a,r){n=new PIXI.Container;var s;if("object"==typeof t){var l=Global.level-1;l>=t.length&&(l=t.length-1),s=t[l]}else s=t;var c=new PIXI.Sprite(window[s]);return c.anchor=new PIXI.Point(.5,.5),r?n.scale={x:r,y:r}:CONFIG.ENEMIES.scale?n.scale={x:CONFIG.ENEMIES.scale.x,y:CONFIG.ENEMIES.scale.y}:n.scale={x:1,y:1},n.position.x=o,n.position.y=a,n.type=e,n.innermc=c,n.addChild(c),i.addChild(n),n}function t(e,t,o,a,r,s){n=new PIXI.Container,t.dest=n;var l=(new BD.AnimatedSprite).execute(0,0,t,s);return r?n.scale={x:r,y:r}:CONFIG.ENEMIES.scale?n.scale=CONFIG.ENEMIES.scale:n.scale={x:1,y:1},n.position.x=o,n.position.y=a,n.type=e,n.innermc=l.getMc(),i.addChild(n),n}var n,i=window.stage2;this.create=function(n,o,a,r){if(n.stagelevel)switch(n.stagelevel){case 1:i=stage1;break;case 2:i=stage2;break;case 3:i=stage3;break;case 4:i=stage4}var s=0;return n.sprite?((s+=2)>n.sprite.frames&&(s=0),t(0,n.sprite,o,a,1*r,s)):e(0,n.asset,o,a,1*r)},this.destroy=function(){i.removeChild(n)},this.getPos=function(){return n?{x:n.position.x+n.innermc.x*n.scale.x,y:n.position.y+n.innermc.y*n.scale.y}:{x:0,y:0}},this.getScale=function(){return n?n.scale:1},this.getMc=function(e){return e?n.innermc:n},this.setOffset=function(e,t){e&&(n.innermc.x=e),t&&(n.innermc.y=t)},this.getHitSize=function(){var e=n.rotation+45;return e>=0&&e<=90||e>180&&e<270?{width:n.width*n.scale.x,height:n.height*n.scale.y}:{width:n.height*n.scale.y,height:n.width*n.scale.x}}}}(),this.BD=this.BD||{},function(){"use strict";function e(e){this.enemies=[],this.bullets=[],this.init()}e.prototype={startCreate:function(){},initCreate:function(){},initFire:function(){},fire:function(){},createSingle:function(e,t,n){},checkWaveCleared:function(){0==this.enemies.length&&EventDispatcher.trigger("levelCleared")},getBullets:function(){return this.bullets},getEnemies:function(){return this.enemies},getConfig:function(){return config},update:function(){console.log("xxxxx")},fallmove:function(){console.log("xxxxx")},destroy:function(){clearTimeout(TO1),document.removeEventListener("tick",this.update,!1)},init:function(){document.addEventListener("tick",this.update)}},BD.EnemyWaveClass=e}(),this.BD=this.BD||{},function(){"use strict";BD.Game=function(){function e(){BD.LEVELUP_ENHANCE=Object.assign({},CONFIG.LEVELUP_ENHANCE,JSON.parse(window.localStorage.getItem(Global.STORAGE_ID)||"{}")),(M=new BD.BulletMananger).execute(),createTransition(),r(),n(),CONFIG.LEVELUP_AWARDS.active&&(BD.awardManager=new BD.AwardManager),EventDispatcher.on("levelCleared",l),EventDispatcher.on("die",d),EventDispatcher.on("createWave",h),EventDispatcher.on("destroyWave",a),EventDispatcher.on("quitGame",S),EventDispatcher.on("showInGameMenu",G),EventDispatcher.on("showUpgradeMenu",D),EventDispatcher.on("pauseGame",w),EventDispatcher.on("unPauseGame",N),EventDispatcher.on("restartLevel",_),EventDispatcher.on("startBuildMode",b),EventDispatcher.on("adjustUIval",x),EventDispatcher.on("movebackground",y),EventDispatcher.on("restartTimer",v),EventDispatcher.on("update",I),CONFIG.COUNTDOWN?(new BD.CountDown).execute({callback:t}):CONFIG.INTROTEXT?((new BD.IntroText).execute({callback:null}),t()):t()}function t(){Global.gameactive=!0,Global.documentFocused=!0,CONFIG.GAMETIMER&&f(),(CONFIG.LEVELUP_AWARDS.active||BD.awardManager)&&BD.awardManager.execute({}),CONFIG.GESTURES&&(R=new BD.GestureManager).execute({})}function n(){CONFIG.ENEMIES&&i(CONFIG.ENEMIES),CONFIG.ENEMIES2&&i(CONFIG.ENEMIES2),CONFIG.TERRAIN&&i(CONFIG.TERRAIN),CONFIG.TERRAIN2&&i(CONFIG.TERRAIN2),CONFIG.COLLECTABLEWAVE&&i(CONFIG.COLLECTABLEWAVE),CONFIG.COLLECTABLEWAVE2&&i(CONFIG.COLLECTABLEWAVE2)}function i(e){var t;switch(e.wave){case CONFIG_ENEMYWAVE_INVADERS:t=new BD.EnemyWaveInvaders(e);break;case CONFIG_ENEMYWAVE_ASTEROIDS:t=new BD.EnemyWaveAsteroids(e);break;case CONFIG_ENEMYWAVE_ASTEROIDS_MATHS:t=new BD.EnemyWaveAsteroidsMaths(e);break;case CONFIG_ENEMYWAVE_TOWERS:t=new BD.EnemyWaveTowers(e);break;case CONFIG_ENEMYWAVE_RTYPE:t=new BD.EnemyWaveRtype(e);break;case CONFIG_ENEMYWAVE_MATCH3:t=new BD.EnemyWaveMatch3(e);break;case CONFIG_ENEMYWAVE_TRUNDLE:t=new BD.EnemyWaveTrundle(e);break;case CONFIG_ENEMYWAVE_COLLAPSE:t=new BD.EnemyWaveCollapse(e);break;case BACKGROUND_TILES:t=new BD.BackgroundTiles(e);break;case BACKGROUND_TERRAIN:case CONFIG_COLLECTABLEWAVE_TERRAIN:t=new BD.BackgroundTerrain(e);break;case CONFIG_COLLECTABLEWAVE_RANDOM:t=new BD.EnemyWaveRandom(e,!0)}t&&(t.startCreate(),W.push(t),e.radar&&e.wave==CONFIG_COLLECTABLEWAVE_RANDOM&&(t.radar=!0,setTimeout(function(){t.getEnemies&&L.createRadar(t.getEnemies())},1e3)))}function o(){for(var e in W){var t=W[e];t&&t.destroy()}W=[]}function a(e){if(e){var t=W.indexOf(e);W.splice(t,1),e.destroy()}}function r(){CONFIG.HERO&&((L=new BD.Player).create(),BD.player=L)}function s(e,t,n,i,o){for(var a=0,r=e.length;ag.x-C&&E.x-Ig.y-x&&E.y-mCONFIG.GAME_COMPLETE_LEVEL?F.gamecompletecallback():u(t)}),t.repeatwave&&setTimeout(function(){EventDispatcher.trigger("createWave",{config:t})},t.repeatwavedelay||0)},500)}function c(e){return new Promise(function(t){e.showlevelcleared?((new BD.IntroText).execute({txt:"WELL DONE\n\nLEVEL CLEARED",duration:2}),setTimeout(t,2e3)):t()})}function u(e){return new Promise(function(t){e.showgetready&&(e.showgetready.intro?((new BD.InstructionsPage).execute({callback:t,config:CONFIG.INTRO}),L&&L.updatePlayerAsset()):((new BD.IntroText).execute({wrap:!0,txt:"GET READY\n\nLEVEL "+Global.level,duration:2}),setTimeout(t,2e3)))})}function h(e){var t=cloneObject(e.config);i(t),CONFIG.ENEMIES2&&CONFIG.ENEMIES2.waveId==t.childWaveId&&i(CONFIG.ENEMIES2)}function d(){if(L){var e=L.getMc();(new BD.AnimatedSprite).execute(e.position.x,e.position.y,CONFIG.HERO.explosion),L&&(L.destroy(),L=null),setTimeout(B,3e3)}}function p(){Global.gameactive=!1,A=!1,g();var e={};Global.score>Global.hiscore&&(Global.hiscore=Global.score,e.hiscore=!0),F.gameovercallback()}function f(){P=setInterval(E,1e3)}function E(){H--,BD.gui.refresh("time",H),0==H&&(g(),p())}function g(){clearInterval(P)}function v(){H=CONFIG.GAMETIMER&&CONFIG.GAMETIMER.secs||0}function y(e){if(Global.oktomoveBG){X=e.x,BD.distance+=X,BD.distanceY+=e.y;var t=Math.abs(BD.distance)/5;BD.gui.refresh("distance",t);var n=CONFIG.ENEMIES.levelCompleteTargetDistance;BD.distance<-n&&!BD.levelCompleteRoutine&&(BD.levelCompleteRoutine=!0),BD.distance<-(n+BASE_WIDTH)&&(BD.levelCompleteRoutine=!1,BD.distance=0,l({config:W[0].getConfig()}))}}function I(){if(!Global.gameactive)return!1;if(L){L.setAbility(null);for(var e in W){if(L&&W[e].hasOwnProperty("getEnemies")&&(s([L],W[e].getBullets(),C,W[e]),s([L],W[e].getEnemies(),C,W[e]),s(M.getBullets(),W[e].getEnemies(),m,W[e])),!W[e])return;W[e].radar&&L.updateRadar(W[e].getEnemies()),W[e].hasOwnProperty("inZone")&&L&&W[e].inZone(L.getMc())}for(var t in W)for(var n in W)W[t]!=W[n]&&(W[t].getBullets(),s(W[t].getBullets(),W[n].getEnemies(),m,W[n]))}}function m(e,t,n,i,o){if(!o.hasOwnProperty("onBulletHitEnemy")||!0!==o.onBulletHitEnemy(t,e)){M.destroyBullet(e),o.hasOwnProperty("checkWaveCleared")&&o.checkWaveCleared();var a=o.hasOwnProperty("getConfig")?o.getConfig():{};if("none"!==a.bulletHitOutcome){if(a.explosion){var r=cloneObject(a.explosion);a.explosionMatchEnemyScale&&(r.scale={x:a.explosionMatchEnemyScale.x*a.explosion.scale.x*t.getScale().x,y:a.explosionMatchEnemyScale.y*a.explosion.scale.y*t.getScale().y}),(new BD.AnimatedSprite).execute(t.getPos().x,t.getPos().y,r)}O("score",a.score)}}}function C(e,t,n,i,o){var a=o.hasOwnProperty("getConfig")?o.getConfig():{hitOutcome:"die"},r=e.getMc(),s=t.getMc(),l=s.hitOutcome||a.hitOutcome;if(o.hasOwnProperty("onHit")&&o.onHit(s),("bounce"===l||"bounceifjumping"===l&&L.getIsJumping())&&(e.setYSpeed(-20),s.scoreDone||(s.scoreDone=!0,O("score",a.score))),e.invincible||(l&&"die"!==l?"spindie"===l&&(L.setPreventPlayerUpdate(!0),TweenLite.to(r,3,{rotation:8,ease:Circ.easeOut}),TweenLite.to(r.position,.5,{y:r.position.y-200,ease:Circ.easeOut,onComplete:function(){TweenLite.to(r.position,.5,{y:r.position.y+400,ease:Circ.easeIn,onComplete:function(){L&&(L.destroy(),L=null),setTimeout(B,2e3)}})}}),Global.gameactive=!1):d()),"collect"===l){s.scoreDone||(s.scoreDone=!0,O("score",a.score),(new BD.Sparkle).execute({position:{x:s.position.x,y:s.position.y}},a.particle));var c=i.indexOf(t);i.splice(c,1),TweenLite.to(s.scale,.5,{x:0,y:0,ease:Circ.easeOut,onComplete:function(){return function(e,t){e.destroy(),e=null}(t)}})}}function x(e){O(e.key,e.value)}function O(e,t){Global[e]||(Global[e]=0),Global[e]+=t,BD.gui.refresh(e,Global[e])}function B(){BD.gui.lightUpLoseIcon(),Global.lives.length>1?r():p()}function G(){w(),(new BD.ModalSettings).execute()}function D(){w(),(new BD.ModalUpgradeMenu).execute()}function w(){Global.gameactive=!1,Global.oktomoveBG=!1}function N(){Global.buildmode=!1,Global.oktomove=!0,Global.gameactive=!0,Global.oktomoveBG=!0}function S(){T(),F.quitcallback()}function _(){T(),game=null,createGame()}function b(){Global.buildmode=!0,Global.oktomove=!1,Global.gameactive=!1,(new BD.BuildInterface).execute()}function T(){EventDispatcher.clearAll(),U.forEach(function(e){e.destroy()}),U=[],BD.gui&&(BD.gui.destroy(),BD.gui=null),L&&(L.destroy(),L=null),k&&(k.destroy(),k=null),M&&(M.destroy(),M=null),o()}Global.gameactive=!1,Global.documentFocused=!0,Global.lives=[],Global.oktomove=!1,Global.oktomoveBG=!0;var H,A,P,F,L,M,R,k,W=[],U=[];this.execute=function(t){F=t,Global.speed=Const.SPEED,Global.timeout=Const.TIMEOUT,Global.score=0,Global.damage=0,Global.chicks=0,Global.parts=0,Global.lives=[],Global.gameactive=!1,H=CONFIG.GAMETIMER&&CONFIG.GAMETIMER.secs||0,CONFIG.BACKGROUND&&(CONFIG.BACKGROUND.length?CONFIG.BACKGROUND:[CONFIG.BACKGROUND]).forEach(function(e){e.asset=e.assets?e.assets[Math.floor(Global.level/10)]:e.asset,U.push((new BD.Background).execute({config:e}))}),CONFIG.SNOW&&(k=(new BD.Snow).execute({asset:"snowflake1"})),BD.gui=(new BD.GUI).execute({container:stage4}),BD.gui.refresh("level",Global.level),BD.gui.refresh("score",Global.score),TESTING&&(BD.guidebug=(new BD.GUI_DEBUG).execute({container:stage4})),CONFIG.EXTERNAL_LEVEL_DATA?(new BD.TrundleDataLoader).load(e):e()};var X;this.destroy=T,this.getPlayerMc=function(){return L.getMc()}}}(),this.BD=this.BD||{},function(){"use strict";BD.GameCompletePanel=function(e){function t(){o.removeChild(r),n.destroy()}var n,i=e,o=stage4,a=window[CONFIG.GAMECOMPLETE.asset],r=new PIXI.Sprite(a);o.addChild(r),n=new BD.Button({text:CONFIG.GAMECOMPLETE.playButton?CONFIG.GAMECOMPLETE.playButton.text:"NEXT",asset:CONFIG.GAMECOMPLETE.playButton?CONFIG.GAMECOMPLETE.playButton.asset:null,position:CONFIG.GAMECOMPLETE.playButton?{x:BASE_WIDTH*CONFIG.GAMECOMPLETE.playButton.posPerc.x,y:BASE_HEIGHT*CONFIG.GAMECOMPLETE.playButton.posPerc.y}:{x:BASE_WIDTH/2,y:520},textOffset:CONFIG.GAMECOMPLETE.playButton?CONFIG.GAMECOMPLETE.playButton.textOffset:null,scale:CONFIG.GAMECOMPLETE.playButton?CONFIG.GAMECOMPLETE.playButton.scale:1,keypress:!0,onclick:function(){removeAll(),t(),i.callback()}}),new BD.Button({asset:CONFIG.GAMECOMPLETE.twitterButton?CONFIG.GAMECOMPLETE.twitterButton.asset:null,position:CONFIG.GAMECOMPLETE.twitterButton?{x:BASE_WIDTH*CONFIG.GAMECOMPLETE.twitterButton.posPerc.x,y:BASE_HEIGHT*CONFIG.GAMECOMPLETE.twitterButton.posPerc.y}:{x:BASE_WIDTH/2,y:520},textOffset:CONFIG.GAMECOMPLETE.twitterButton?CONFIG.GAMECOMPLETE.twitterButton.textOffset:null,scale:CONFIG.GAMECOMPLETE.twitterButton?CONFIG.GAMECOMPLETE.twitterButton.scale:1,onclick:function(){window.open("https://twitter.com/intent/tweet?hashtags=Gods%20and%20Monsters&original_referer=http://axians.berkeleydev.co.uk%2Fweb%2Ftweet-button&ref_src=twsrc%5Etfw&related=twitterapi%2Ctwitter&text=I won the battle against Network Security Monsters, can you? Play @axiansuk 8bit game +link #securitymonsters&tw_p=tweetbutton&url=http://axians.berkeleydev.co.uk")}}),new BD.Button({asset:CONFIG.GAMECOMPLETE.linkedInButton?CONFIG.GAMECOMPLETE.linkedInButton.asset:null,position:CONFIG.GAMECOMPLETE.linkedInButton?{x:BASE_WIDTH*CONFIG.GAMECOMPLETE.linkedInButton.posPerc.x,y:BASE_HEIGHT*CONFIG.GAMECOMPLETE.linkedInButton.posPerc.y}:{x:BASE_WIDTH/2,y:520},textOffset:CONFIG.GAMECOMPLETE.linkedInButton?CONFIG.GAMECOMPLETE.linkedInButton.textOffset:null,scale:CONFIG.GAMECOMPLETE.linkedInButton?CONFIG.GAMECOMPLETE.linkedInButton.scale:1,onclick:function(){window.open("https://www.linkedin.com/cws/share?url=http://axians.berkeleydev.co.uk")}}),this.destroy=t}}(),this.BD=this.BD||{},function(){"use strict";BD.GameOverPanel=function(e){function t(e){TweenLite.to(e,.5,{alpha:0,onComplete:function(){TweenLite.to(e,.5,{alpha:1,onComplete:function(){t(e)}})}})}function n(){s.removeChild(h),s.removeChild(p),s.removeChild(f),s.removeChild(E),i.destroy()}var i,o,a,r=e,s=stage4,l=window[CONFIG.GAMEOVER.asset],c=new PIXI.Sprite(l);s.addChild(c);var u=BASE_HEIGHT/2-100;if(CONFIG.UI.panelasset){var h=new PIXI.Sprite(window[CONFIG.UI.panelasset]);h.position={x:BASE_WIDTH/2,y:u+70},h.anchor={x:.5,y:.5},s.addChild(h)}if(!CONFIG.GAMEOVER.twitterButton){var d=r.hiscore?"New High Score":"Game Over",p=new PIXI.Text(d,{font:"50px "+CONFIG.FONT,fill:CONFIG.FONT_COLOUR,align:"center",stroke:CONFIG.FONT_COLOUR_STROKE,strokeThickness:4});p.position={x:BASE_WIDTH/2,y:u},p.anchor={x:.5,y:.5},s.addChild(p),u+=60;var d="You scored",f=new PIXI.Text(d,{font:"30px "+CONFIG.FONT,fill:CONFIG.FONT_COLOUR,wordWrap:!0,wordWrapWidth:700,align:"center",stroke:CONFIG.FONT_COLOUR_STROKE,strokeThickness:4});f.position={x:BASE_WIDTH/2,y:u},f.anchor={x:1,y:.5},s.addChild(f),u+=60;var E=new PIXI.Text(Global.score,{font:"70px "+CONFIG.FONT,fill:CONFIG.FONT_COLOUR_2,align:"center",stroke:CONFIG.FONT_COLOUR_STROKE,strokeThickness:4});E.position={x:BASE_WIDTH/2,y:u},E.anchor={x:0,y:.5},s.addChild(E),u+=70}if(i=new BD.Button({text:CONFIG.GAMEOVER.playButton?CONFIG.GAMEOVER.playButton.text:"NEXT",wrap:!0,asset:CONFIG.GAMEOVER.playButton?CONFIG.GAMEOVER.playButton.asset:null,position:CONFIG.GAMEOVER.playButton?{x:BASE_WIDTH*CONFIG.GAMEOVER.playButton.posPerc.x,y:BASE_HEIGHT*CONFIG.GAMEOVER.playButton.posPerc.y}:{x:BASE_WIDTH/2,y:520},textOffset:CONFIG.GAMEOVER.playButton?CONFIG.GAMEOVER.playButton.textOffset:null,scale:CONFIG.GAMEOVER.playButton?CONFIG.GAMEOVER.playButton.scale:1,keypress:!0,onclick:function(){removeAll(),n(),r.callback()}}),CONFIG.GAMEOVER.twitterButton&&((a=new BD.Button({asset:CONFIG.GAMEOVER.twitterButton?CONFIG.GAMEOVER.twitterButton.asset:null,position:CONFIG.GAMEOVER.twitterButton?{x:BASE_WIDTH*CONFIG.GAMEOVER.twitterButton.posPerc.x,y:BASE_HEIGHT*CONFIG.GAMEOVER.twitterButton.posPerc.y}:{x:BASE_WIDTH/2,y:520},textOffset:CONFIG.GAMEOVER.twitterButton?CONFIG.GAMEOVER.twitterButton.textOffset:null,scale:CONFIG.GAMEOVER.twitterButton?CONFIG.GAMEOVER.twitterButton.scale:1,onclick:function(){window.open("https://twitter.com/intent/tweet?hashtags=Gods%20and%20Monsters&original_referer=http://axians.berkeleydev.co.uk%2Fweb%2Ftweet-button&ref_src=twsrc%5Etfw&related=twitterapi%2Ctwitter&text=Have you tried to battle the network monsters yet? Play @axiansuk 8bit game +link #securitymonsters #cybersecurity&tw_p=tweetbutton&url=http://axians.berkeleydev.co.uk")}})).alpha=0,TweenLite.to(a,.5,{alpha:1})),CONFIG.GAMEOVER.linkedInButton&&((o=new BD.Button({asset:CONFIG.GAMEOVER.linkedInButton?CONFIG.GAMEOVER.linkedInButton.asset:null,position:CONFIG.GAMEOVER.linkedInButton?{x:BASE_WIDTH*CONFIG.GAMEOVER.linkedInButton.posPerc.x,y:BASE_HEIGHT*CONFIG.GAMEOVER.linkedInButton.posPerc.y}:{x:BASE_WIDTH/2,y:520},textOffset:CONFIG.GAMEOVER.linkedInButton?CONFIG.GAMEOVER.linkedInButton.textOffset:null,scale:CONFIG.GAMEOVER.linkedInButton?CONFIG.GAMEOVER.linkedInButton.scale:1,onclick:function(){window.open("https://www.linkedin.com/cws/share?url=http://axians.berkeleydev.co.uk")}})).alpha=0,TweenLite.to(o,.5,{alpha:1})),CONFIG.GAMEOVER.foreground)for(var g in CONFIG.GAMEOVER.foreground){var v=function(e){var t=Global.level||1,n=e.asset;return e.assetsLevels&&(n=e.assetsLevels[t>e.assetsLevels.length?0:t-1]),n}(CONFIG.GAMEOVER.foreground[g]),y=new PIXI.Sprite(root[v]);y.scale={x:CONFIG.GAMEOVER.foreground[g].scale,y:CONFIG.GAMEOVER.foreground[g].scale},y.anchor={x:.5,y:.5},y.position={x:BASE_WIDTH*CONFIG.GAMEOVER.foreground[g].posPerc.x,y:BASE_HEIGHT*CONFIG.GAMEOVER.foreground[g].posPerc.y},s.addChild(y),"pulse"==CONFIG.GAMEOVER.foreground[g].animate&&t(y)}this.destroy=n}}(),this.BD=this.BD||{},function(){"use strict";BD.GestureManager=function(){var e,t,n,i,o,a;this.execute=function(t){e=cloneObject(t),useTouch()?(document.addEventListener("touchstart",r),document.addEventListener("touchend",s),document.addEventListener("touchmove",l)):(document.onmousedown=r,document.onmouseup=s,document.onmousemove=l)};var r=function(e){e.preventDefault&&e.preventDefault();var o=c(e);for(var a in o)n=o[a].x,i=o[a].y,t=!0},s=function(e){e.preventDefault&&e.preventDefault();var r=c(e);for(var s in r)o=r[s].x,a=r[s].y,t=!1;var l=o-n,u=a-i;l>30&&Math.abs(u)<20?EventDispatcher.trigger("gesture","right"):l<-30&&Math.abs(u)<20?EventDispatcher.trigger("gesture","left"):Math.abs(l)<20&&u<-30?EventDispatcher.trigger("gesture","up"):Math.abs(l)<20&&u>30?EventDispatcher.trigger("gesture","down"):l>30&&u>30?EventDispatcher.trigger("gesture","rightdown"):l<-30&&u>30?EventDispatcher.trigger("gesture","leftdown"):l>30&&u<-30?EventDispatcher.trigger("gesture","rightup"):l<-30&&u<-30&&EventDispatcher.trigger("gesture","leftup")},l=function(e){if(t){e.preventDefault&&e.preventDefault();var n=c(e),i={position:{x:n[0].x,y:n[0].y,rotation:0}};new BD.Sparkle(stage).execute(i,particleStarSparkleGesture)}},c=function(e){var t=BASE_WIDTH/BD.canvasWidth,n=BASE_HEIGHT/BD.canvasHeight,i=[];if(useTouch()){for(var o in e.changedTouches)if(e.changedTouches[o].clientX){var a=(e.changedTouches[o].clientX-0)/1*t,r=(e.changedTouches[o].clientY-0)/1*n;i.push({x:a,y:r})}}else{var a=(e.clientX-0)/1*t,r=(e.clientY-0)/1*n;i.push({x:a,y:r})}return i};this.destroy=function(){}}}(),this.BD=this.BD||{},function(){"use strict";BD.GUIBAR=function(){function e(){var e=new PIXI.Graphics;e.beginFill("#000000"),e.drawRect(),e.endFill(),e.position={x:t.x-3,y:t.y+t.height+3},e.width=t.width+6,e.height=-t.height-6,o.addChild(e),(i=new PIXI.Graphics).beginFill("#660000"),i.drawRect(),i.endFill(),i.position={x:t.x,y:t.y+t.height},i.width=t.width,i.height=-t.height,o.addChild(i),(n=new PIXI.Graphics).beginFill("#FF0000"),n.drawRect(),n.endFill(),n.position={x:t.x,y:t.y+t.height},n.width=t.width,n.height=-t.height,o.addChild(n)}var t,n,i,o=stage4;this.execute=function(n){return t=n,o=n.container||o,e(),this},this.refresh=function(e){var o=e/t.max;o>1&&(o=1),o<0&&(o=0),i.width>i.height?n.width=t.width*o:n.height=-t.height*o},this.destroy=function(){}}}(),this.BD=this.BD||{},function(){"use strict";BD.GUI_DEBUG=function(){function e(){var e=150;for(var t in CONFIG.DEBUG.stats)i[t]={txt1:new PIXI.Text(t,{font:"bold 40px "+CONFIG.FONT,fill:CONFIG.FONT_COLOUR_UI,align:"left"}),txt2:new PIXI.Text("0",{font:"bold 40px "+CONFIG.FONT,fill:CONFIG.FONT_COLOUR_UI_2,align:"left"})},i[t].txt1.position={x:150,y:e},i[t].txt2.position={x:550,y:e},n.addChild(i[t].txt1),n.addChild(i[t].txt2),e+=40}var t,n=stage4,i=[];this.execute=function(i){return t=i,n=i.container||n,e(),this},this.refreshDebug=function(e){for(var t in e)i[t]&&(i[t].txt2.text=e[t])},this.destroy=function(){}}}(),this.BD=this.BD||{},function(){"use strict";BD.GUIRING=function(){function e(e){i(),e==a.clickEvent&&n()}function t(){if((s=new PIXI.Graphics).lineStyle(24,"#000000",1),s.arc(a.x,a.y,a.radius,0,2*Math.PI),s.endFill(),c.addChild(s),(r=new PIXI.Graphics).lineStyle(17,a.colour||"#FF00F0",1),r.arc(a.x,a.y,a.radius,0,-2*Math.PI),r.endFill(),c.addChild(r),a.icon){var e=new PIXI.Sprite(root[a.icon.asset]);e.anchor=new PIXI.Point(.5,.5),e.scale=a.icon.asset?{x:a.icon.scale,y:a.icon.scale}:{x:.6,y:.6},e.position.x=a.x,e.position.y=a.y,c.addChild(e)}o()}function n(){(l=new PIXI.Graphics).beginFill("#FFFFFF"),l.drawRect(),l.endFill(),l.position={x:a.x-a.radius,y:a.y+a.radius+15},l.width=100,l.height=10,c.addChild(l)}function i(){l&&(c.removeChild(l),l=null)}function o(){s.setColour("#CCCCCC"),r.setColour("#EEEEEE")}var a,r,s,l,c=stage4;this.execute=function(n){return a=n,c=n.container||c,t(),EventDispatcher.on("ACTIVATE_POWER",e),this},this.addMarker=n,this.removeMarker=i,this.refresh=function(e){var t=e/a.max;"DESC"==a.dir&&(t=1-t),t>1&&(t=1),t<0&&(t=0),r.endRad=2*Math.PI*t},this.destroy=function(){}}}(),this.BD=this.BD||{},function(){"use strict";BD.GUI=function(){function e(){var e=new PIXI.Graphics;e.beginFill(CONFIG.UI.backgroundColour,CONFIG.UI.backgroundOpacity||.4);for(var n in CONFIG.UI.fields){var r=CONFIG.UI.fields[n];if(r.pos&&"right"===r.pos.x&&(r.pos.x=BASE_WIDTH-80),r.icon&&new BD.Button({icon:r.icon.asset,position:{x:r.pos.x,y:r.pos.y},scale:1.1,alpha:.01,onclick:function(){var e=r.clickEvent;return function(){EventDispatcher.trigger("ACTIVATE_POWER",e)}}()}),a[n]={},r.bar&&(a[n].bar=(new BD.GUIBAR).execute(r.bar)),r.text&&(a[n].txt1=new PIXI.Text(r.text,{font:CONFIG.UI.fontsize+"px "+CONFIG.FONT,fill:CONFIG.FONT_COLOUR_UI,align:"right"}),r.pos&&(a[n].txt1.position={x:r.pos.x,y:r.pos.y}),r.icon&&((l=new PIXI.Sprite(root[r.icon.asset])).anchor=new PIXI.Point(0,0),r.icon.pos&&(l.position=r.icon.pos),r.icon.scale&&(l.scale={x:r.icon.scale,y:r.icon.scale}),o.addChild(l))),r.ring){var s=Object.assign({},r.pos,r.ring,{icon:r.icon,clickEvent:r.clickEvent});a[n].params=s,a[n].bar=(new BD.GUIRING).execute(s),a[n].txt1&&(a[n].txt1.position.y-=r.ring.radius+30)}r.number&&(a[n].txt1.align="right",a[n].txt2=new PIXI.Text("0",{font:CONFIG.UI.fontsize+"px "+CONFIG.FONT,fill:CONFIG.FONT_COLOUR_UI_2,align:"left"}),a[n].txt2.position=r.pos)}if(CONFIG.UI.hud_bg_left&&((l=new PIXI.Sprite(root.hud_left_rocket)).anchor=new PIXI.Point(0,0),l.width=280,l.height=BASE_HEIGHT,o.addChild(l)),CONFIG.UI.hud_bg_right){var l=new PIXI.Sprite(root.hud_right_rocket);l.anchor=new PIXI.Point(1,0),l.position.x=BASE_WIDTH,l.width=280,l.height=BASE_HEIGHT,o.addChild(l)}CONFIG.HERO&&CONFIG.HERO.compass&&((i=new PIXI.Sprite(root.compass)).anchor=new PIXI.Point(.5,.5),i.position.y=BASE_HEIGHT/2,i.position.x=BASE_WIDTH/2,stage1.addChild(i)),e.endFill(),o.addChild(e);for(var n in a)a[n].txt1&&o.addChild(a[n].txt1),a[n].txt2&&o.addChild(a[n].txt2);if(Array.isArray(CONFIG.BRANDING.logo)&&CONFIG.BRANDING.logo.forEach(function(e){var t=new PIXI.Sprite(root[e.asset]);t.anchor=new PIXI.Point(.5,.5),t.scale={x:e.scale,y:e.scale},t.position.x=e.posPerc.x*BASE_WIDTH,t.position.y=e.posPerc.y*BASE_HEIGHT,o.addChild(t)}),CONFIG.UI.gamemenu.forEach(function(e,t){new BD.Button({text:e.text,icon:e.icon,position:{x:BASE_WIDTH-80,y:250+100*t},scale:1.1,onclick:function(){EventDispatcher.trigger(e.event)}})}),CONFIG.HERO&&useTouch())for(var n in CONFIG.HERO.controls)!function(e){var t=CONFIG.UI["button_"+e];t&&new BD.Button({icon:t.asset,position:t.position,scale:t.scale,onclick:function(){EventDispatcher.trigger("mobileControlDown",CONFIG.HERO.controls[e])},onrelease:function(){EventDispatcher.trigger("mobileControlUp",CONFIG.HERO.controls[e])}})}(n);if(CONFIG.LIVES>1)for(var c=0;cCONFIG.HERO.assetsLevels.length?0:Global.level-1]),e}var n,i,o=stage4,a={};this.execute=function(t){return n=t,o=t.container||o,e(),this},this.refresh=function(e,t){a[e]&&(a[e].txt2&&(a[e].txt2.text=t,a[e].txt2.text=t),a[e].bar&&a[e].bar.refresh(t))},this.destroy=function(){},this.getMcByKey=function(e){return a[e].txt1},this.lightUpLoseIcon=function(){var e=Global.lives.length-1;Global.lives[e]&&setTimeout(function(){TweenLite.to(Global.lives[e].position,2,{y:Global.lives[e].position.y+50,onComplete:function(){Global.lives.pop(),Global.lives.length}})},1e3)}}}(),this.BD=this.BD||{},function(){"use strict";BD.InstructionsPage=function(){function e(){l.config.noFadeOut?t():createTransition(t,!0)}function t(){l.callback&&(o(),l.callback())}function n(e){var t=Global.level||1,n=e.mobile&&e.mobile.asset&&useTouch()?e.mobile.asset:e.asset,i=e.mobile&&e.mobile.assetsLevels&&useTouch()?e.mobile.assetsLevels:e.assetsLevels;return i&&(n=i[t>i.length?0:t-1]),n}function i(e){var t=e.duration;return e.durationLevels&&(t=e.durationLevels[Global.level>e.durationLevels.length?0:Global.level-1]),t}function o(){c.removeChild(a)}var a,r,s,l,c=stage4;this.execute=function(t){l=cloneObject(t),a=new PIXI.Container,c.addChild(a);var o=window[n(l.config)]||window[CONFIG.BACKGROUND.asset];if(r=new PIXI.Sprite(o),r.interactive=!0,r.mousedown=r.touchstart=function(e){},a.addChild(r),CONFIG.UI.panelasset){var u=new PIXI.Sprite(window[CONFIG.UI.panelasset]);u.position={x:BASE_WIDTH/2,y:BASE_HEIGHT/2-10},u.anchor={x:.5,y:.5},u.scale={x:1.25,y:1.25},a.addChild(u)}(s=new PIXI.Text(l.config.text,{font:"24px "+CONFIG.FONT,fill:CONFIG.FONT_COLOUR,wordWrap:!0,wordWrapWidth:700,align:"center",stroke:CONFIG.FONT_COLOUR_STROKE,strokeThickness:4})).position={x:BASE_WIDTH/2,y:BASE_HEIGHT/2-10},s.anchor={x:.5,y:.5},a.addChild(s);var h=i(l.config);return h?setTimeout(e,h):new BD.Button({text:l.config.playButton?l.config.playButton.text:"NEXT",asset:l.config.playButton?l.config.playButton.asset:null,position:l.config.playButton?{x:BASE_WIDTH*l.config.playButton.posPerc.x,y:BASE_HEIGHT*l.config.playButton.posPerc.y}:{x:BASE_WIDTH/2,y:520},textOffset:l.config.playButton?l.config.playButton.textOffset:null,scale:l.config.playButton?l.config.playButton.scale:1,onclick:e}),l.config.noFadeIn||createTransition(),this},this.destroy=o}}(),this.BD=this.BD||{},function(){"use strict";BD.IntroText=function(){function e(){clearInterval(n),o.removeChild(t)}var t,n,i,o=stage3;this.execute=function(a){var r=(i=cloneObject(a)).fontsize||40;(t=new PIXI.Text(i.txt,{font:"bold "+r+"px "+CONFIG.FONT,fill:CONFIG.FONT_COLOUR_UI,stroke:CONFIG.FONT_COLOUR_STROKE,strokeThickness:4,align:"center",wrap:!0})).anchor={x:.5,y:.5},t.position.x=500,t.position.y=i.y||BASE_HEIGHT/3,o.addChild(t),"float"==i.animation&&TweenLite.to(t,1,{y:i.y-50}),n=setInterval(e,i.duration?1e3*i.duration:3e3)}}}();var imagessource={},audiosource={};this.BD=this.BD||{};var Const={},Global={};Global.hiscore=0,Global.level=1;for(var i in CONFIG.UI)Global[i]=CONFIG.UI[i].max;Global.GAME_ID=parseInt(getQueryVariable("id"))||24,Global.STORAGE_ID="LEVELUP_ENHANCE_7_"+Global.GAME_ID;var TESTING,BASE_WIDTH=1024,BASE_HEIGHT=665;BD.SCALE=1;var root=this,curbg,stage,renderer,page,game=null,physics,sound,fontsReady=0,graphics,fassets,assetsToLoadLength=0;this.BD=this.BD||{},function(){"use strict";BD.Message=function(){function e(){clearInterval(t);for(var e in a)r.removeChild(a[e]);o&&o.destroy(),i&&i.destroy(),n.callback&&n.callback()}var t,n,i,o,a=[],r=stage4;this.execute=function(s){if((n=cloneObject(s)).bgasset){var l=new PIXI.Sprite(root[n.bgasset]);l.anchor=new PIXI.Point(.5,.5),l.position.x=BASE_WIDTH/2,l.position.y=BASE_HEIGHT/2,r.addChild(l),a.push(l)}("object"==typeof n.text?n.text:[{text:n.text}]).forEach(function(e,t){var n=new PIXI.Text(e.text,{font:"60px "+CONFIG.FONT,fill:CONFIG.FONT_COLOUR,align:"center"});if(n.anchor={x:.5,y:.5},n.position.x=BASE_WIDTH/2,n.position.y=BASE_HEIGHT/2+80*t,r.addChild(n),a.push(n),n.scale={x:0,y:0},TweenLite.to(n.scale,.2,{delay:0,x:1,y:1,ease:Back.easeOut}),e.icon){var i=new PIXI.Sprite(root[e.icon]);i.anchor=new PIXI.Point(.5,.5),i.position.x=BASE_WIDTH/2+200,i.position.y=BASE_HEIGHT/2+80*t,r.addChild(i),a.push(i),i.scale={x:0,y:0},TweenLite.to(i.scale,.2,{delay:0,x:1,y:1,ease:Back.easeOut})}}),n.duration&&(t=setInterval(e,n.duration||2e3)),n.closeButton&&(o=new BD.Button({text:"X",width:80,height:80,position:{x:BASE_WIDTH/2+l.width/2,y:BASE_HEIGHT/2-l.height/2},scale:1,onclick:e})),l.scale={x:.2,y:.2},TweenLite.to(l.scale,.3,{x:1,y:1,ease:Back.easeOut}),n.nextButton&&(i=new BD.Button({text:n.nextButton,position:{x:BASE_WIDTH/2,y:BASE_HEIGHT/2+300},scale:1,onclick:e}))}}}(),this.BD=this.BD||{},function(){"use strict";BD.ModalSettings=function(){function e(){for(var e in o)o[e].destroy();o=[],a.removeChild(n)}var t,n,i,o=[],a=stage3;this.execute=function(r){t=cloneObject(r),n=new PIXI.Container,a.addChild(n),CONFIG.UI.panelasset&&((i=new PIXI.Sprite(root[CONFIG.UI.panelasset])).position={x:BASE_WIDTH/2,y:BASE_HEIGHT/2},i.anchor={x:.5,y:.5},n.addChild(i));var s=new BD.Button({text:"Restart",position:{x:getGameCentre().x,y:getGameCentre().y-70},scale:1,onclick:function(){e(),EventDispatcher.trigger("restartLevel")}});o.push(s);var l=new BD.Button({text:"Continue",position:{x:getGameCentre().x,y:getGameCentre().y-0},scale:1,onclick:function(){e(),EventDispatcher.trigger("unPauseGame")}});o.push(l);var c=new BD.Button({text:"Quit",position:{x:getGameCentre().x,y:getGameCentre().y+70},scale:1,onclick:function(){e(),EventDispatcher.trigger("quitGame")}});o.push(c)}}}(),this.BD=this.BD||{},function(){"use strict";BD.ModalUpgradeMenu=function(){function e(){t(),EventDispatcher.trigger("unPauseGame")}function t(){for(var e in a)a[e].destroy();o.removeChild(i)}var n,i,o=stage4,a=[];this.execute=function(t){i=new PIXI.Container,o.addChild(i),n=cloneObject(t);var r;CONFIG.UI.panel&&((r=new PIXI.Sprite(root[CONFIG.UI.panel.asset])).position.x=BASE_WIDTH/2,r.position.y=BASE_HEIGHT/2,r.anchor={x:.5,y:.5},r.width=BASE_WIDTH,r.height=BASE_HEIGHT,i.addChild(r));var s=new BD.Button({text:"X",width:80,height:80,position:{x:BASE_WIDTH/2+r.width/2-100,y:BASE_HEIGHT/2-r.height/2+50},scale:1,onclick:e});a.push(s);var l={};for(var c in CONFIG.LEVELUP_ENHANCE){var u=CONFIG.LEVELUP_ENHANCE[c].col;l[u]||(l[u]=100),l[u]+=60;var h=l[u],d=1===u?50:550,p=new PIXI.Text(CONFIG.LEVELUP_ENHANCE[c].label,{font:"34px "+CONFIG.FONT,fill:CONFIG.FONT_COLOUR,align:"left"});p.anchor={x:0,y:.5},p.position={x:d,y:h},i.addChild(p);var f=new PIXI.Text(BD.LEVELUP_ENHANCE[c].value,{font:"61.2px "+CONFIG.FONT,fill:CONFIG.FONT_COLOUR_UI_2,align:"left"});f.anchor={x:0,y:.5},f.position={x:d+320,y:h+10},i.addChild(f),function(e,t){var n=new BD.Button({XXtext:"Upgrade",asset:"icon_upgrade",position:{x:d+400,y:h},scale:.8,onclick:function(){var n=BD.LEVELUP_ENHANCE[e];void 0===n.value&&(n.value=0),n.value+=n.step,n.value>n.max&&(n.value=n.max),t.text=n.value;var i=JSON.stringify(BD.LEVELUP_ENHANCE);console.log("data ",i),window.localStorage.setItem(Global.STORAGE_ID,i),EventDispatcher.trigger("updatePlayerParams")}});a.push(n)}(c,f)}}}}(),this.BD=this.BD||{},this.PIXI=this.PIXI||{},function(){"use strict";PIXI=new function(){function e(e,n){var i=[];return E.forEach(function(o){var a=t(e,n,o);a&&(i=[a]),o&&o.children&&"container"===o._type&&o.children.forEach(function(o){var a=t(e,n,o);a&&(i=[a]),o&&o.children&&"container"===o._type&&o.children.forEach(function(o){var a=t(e,n,o);a&&(i=[a])})})}),i}function t(e,t,i){var o;return i.interactive&&i.mousedown&&(i.children&&"container"===i._type?i.children.forEach(function(a){n(e,t,a)&&(o=i)}):n(e,t,i)&&(o=i)),o}function n(e,t,n){if(!n)return!1;var i=n.anchor.x,o=n.anchor.y;return e>n.___x-n.___w*i&&en.___y-n.___h*o&&to?(e.fillText(l,n,i),l=c[u]+" ",i+=a):l=h}e.fillText(l,n,i),i+=a}}function a(e,t,n,i){for(var o=0,a=String(t).split("\n"),r=0;rn?(s=l[c]+" ",o+=i):s=u}o+=i}return o}var r,s,l,c,u,h,d,p,f=BD?BD.SCALE||1:1,E=[],g=function(e){var t=Object.assign({},A(),{_type:"container",children:[],addChild:x,removeChild:O,removeAll:B,cid:1e16*Math.random()});return e&&E.push(t),t},v=function(e,t){if(e instanceof Image)return e.bounds=t,e;var n=v.fromImage(e);return n.bounds=t,n};v.fromImage=function(e){var t=new Image;return t.src=e,t};var y,I,m=function(e,t){return{_type:"point",x:e,y:t}},C=function(){function e(){for(var n=t.length;n--;)t[n]();requestAnimationFrame(e)}var t=[];return e(),{add:function(e){t.push(e)}}},x=function(e){return this.children.push(e),e},O=function(e){if(!e)return!1;"container"===e._type?E.forEach(function(t){t.cid===e.cid&&(t.children=[],E.splice(E.indexOf(t),1)),t.children&&"container"===t._type&&t.children.forEach(function(n){n.cid===e.cid&&(n.children=[],t.children.splice(t.children.indexOf(n),1)),n.children&&"container"===n._type&&n.children.forEach(function(t){t.cid===e.cid&&(t.children=[],n.children.splice(n.children.indexOf(t),1))})})}):this.children.splice(this.children.indexOf(e),1)},B=function(){this.children=[],E.forEach(function(e){e.children=[]})},G=function(t){t.preventDefault&&t.preventDefault();var n=N(t);for(var i in n)c=n[i].x,u=n[i].y,l=!0,e(c,u).forEach(function(e){e.mousedown&&e.mousedown(e)})},D=function(t){t.preventDefault&&t.preventDefault();var n=N(t);for(var i in n)h=n[i].x,d=n[i].y,l=!0,e(h,d).forEach(function(e){e.mouseup&&e.mouseup(e)})},w=function(t){t.preventDefault&&t.preventDefault();var n=N(t);for(var i in n){var o=e(n[i].x,n[i].y);o.forEach(function(e){e.mouseover&&!e.mouseOverActive&&(e.mouseover(e),e.mouseOverActive=!0,document.body.style.cursor="pointer")}),(p||[]).filter(function(e){return o.indexOf(e)<0}).forEach(function(e){e.mouseout&&e.mouseOverActive&&(e.mouseout(e),e.mouseOverActive=!1,document.body.style.cursor="initial")}),p=o}},N=function(e){var t=s.offsetLeft||0,n=s.offsetTop||0,i=BASE_WIDTH/BD.canvasWidth,o=BASE_HEIGHT/BD.canvasHeight,a=[];if(useTouch()){for(var r in e.changedTouches)if(e.changedTouches[r].clientX){var l=(e.changedTouches[r].clientX-t)/f*i,c=(e.changedTouches[r].clientY-n)/f*o;a.push({x:l,y:c})}}else{var l=(e.clientX-t)/f*i,c=(e.clientY-n)/f*o;a.push({x:l,y:c})}return a},S=function(){r.clearRect(0,0,s.width,s.height),BD.guidebug,E.forEach(function(e){e.children&&"container"===e._type&&e.children.forEach(function(t){"container"!==t._type&&i(t,e),t.children&&"container"===t._type&&t.children.forEach(function(e){"container"!==e._type&&i(e,t)})})})},_=function(e,t,n,i,o,a,s){if(e.texture&&i&&o){if(r.save(),r.globalAlpha=s,e.texture.bounds){var l=e.texture.bounds;r.translate(t,n),r.rotate(a*TO_RADIANS);var i=l.w*(e.scale.x||1),o=l.h*(e.scale.y||1);r.drawImage(e.texture,l.x,l.y,l.w,l.h,-i*e.anchor.x,-o*e.anchor.y,i,o)}else r.translate(t,n),r.rotate(a*TO_RADIANS),r.drawImage(e.texture,-i*e.anchor.x,-o*e.anchor.y,i,o);r.restore()}},b=[],T=function(){var e=b.pop();window[e.name]=v.fromImage(e.url),window[e.name].onload=function(e){b.length>0?(y({progress:b.length}),T()):I(e)},window[e.name].onerror=function(e){b.length>0?(y(e),T()):I(e)}},H={add:function(e,t){b.push({name:e,url:t})},on:function(e,t){y=t},once:function(e,t){I=t},load:function(e,t){T()}},A=function(){return{x:0,y:0,position:{x:0,y:0},scale:{x:1,y:1},rotation:0,alpha:1,anchor:new m(0,0)}};return this.Application=function(e,t,n){s=document.createElement(navigator.isCocoonJS?"screencanvas":"canvas"),r=s.getContext("2d"),s.width=e,s.height=t,n&&n.backgroundColor&&(s.style.backgroundColor=n.backgroundColor),useTouch()&&(document.addEventListener("touchstart",G),document.addEventListener("touchend",D),document.addEventListener("touchmove",w)),document.onmousedown=G,document.onmouseup=D,document.onmousemove=w;var i=new g;return{view:s,stage:i,ticker:new C,render:S}},this.Container=g,this.Sprite=function(e){if(!e)return A();var t=e.width,n=e.height;return Object.assign(A(),{_type:"sprite",texture:e,width:t,height:n,naturalWidth:t,naturalHeight:n})},this.Texture=v,this.Point=m,this.Rectangle=function(e,t,n,i){return{_type:"rectangle",x:e,y:t,w:n,h:i}},this.Graphics=function(){return Object.assign(A(),{beginFill:function(e){this.fillStyle=e},drawRect:function(){this._type="rectangle"},setColour:function(e){this.fillStyle=e},lineStyle:function(e,t,n){this.strokeWidth=e,this.strokeStyle=t,this.opacity=n},arc:function(e,t,n,i,o){this._type="arc",this.position.x=e,this.position.y=t,this.radius=n,this.startRad=i,this.endRad=o},endFill:function(e){}})},this.Text=function(e,t){return Object.assign(A(),{_type:"text",text:e,options:Object.assign({},t)})},this.Ticker=C,this.loader=H,this.addChild=x,this.removeChild=O,this.removeAll=B,this}}(),this.BD=this.BD||{},function(){"use strict";BD.Player=function(){function e(){A=CONFIG.HERO.accel*(BD.LEVELUP_ENHANCE.accel||1),P=CONFIG.HERO.speed*(BD.LEVELUP_ENHANCE.speed||1),F=CONFIG.HERO.deceleration*(BD.LEVELUP_ENHANCE.deceleration||1),L=CONFIG.HERO.rotatespeed*(BD.LEVELUP_ENHANCE.rotatespeed||1),M=CONFIG.HERO.rotateaccel*(BD.LEVELUP_ENHANCE.rotateaccel||1),R=CONFIG.HERO.rotatedeceleration*(BD.LEVELUP_ENHANCE.rotatedeceleration||1)}function t(e){s(CONFIG.HERO.controls.touchstart,!0)}function n(e){s(CONFIG.HERO.controls.touchstart,!1)}function i(e){s(e,!0)}function o(e){s(e,!1)}function a(e){s(e.keyCode,!0)}function r(e){s(e.keyCode,!1)}function s(e,t){if(!e)return!1;switch(e==CONFIG.HERO.controls.jump&&t&&h(),e==CONFIG.HERO.controls.bigjump&&t&&d(),e==CONFIG.HERO.controls.forwards&&(w=t),e==CONFIG.HERO.controls.right&&(B=t),CONFIG.HERO.controls.right_pressed&&(B=!0),e){case CONFIG.HERO.controls.left:G=t;break;case CONFIG.HERO.controls.up:D=t;break;case CONFIG.HERO.controls.down:N=t;break;case CONFIG.HERO.controls.rotate_left:b=t;break;case CONFIG.HERO.controls.rotate_right:T=t;break;case CONFIG.HERO.controls.fire:t&&u();break;default:return!1}}function l(e,t){j.invincible=e;var n;e&&(n=setInterval(function(){f.alpha=1==f.alpha||.6==f.alpha?.3:.6},150)),t&&setTimeout(function(){clearInterval(n),l(!1,0),f.alpha=1},t)}function c(){if(CONFIG.HERO.xspeedmultIncreasePerTick&&(k+=CONFIG.HERO.xspeedmultIncreasePerTick),!f)return!1;if(J)return!1;CONFIG.HERO.particle&&(CONFIG.HERO.particleOffset&&(CONFIG.HERO.particle.offset=CONFIG.HERO.particleOffset,CONFIG.HERO.particle.offsetEnd=CONFIG.HERO.particleOffsetEnd),new BD.Sparkle(Z).execute(f,CONFIG.HERO.particle));var e,t;if(C&&(e=(C-f.position.x)*P,g=e/100),x&&(t=(x-f.position.y)*P,v=t/100),e&&t){var n=Math.atan2(t,e);nO+Math.PI&&(n-=2*Math.PI),O+=(n-O)/5,f.rotation=O+Math.PI/2}B&&(f.position.x<(CONFIG.HERO.limitRightPerc||1)*BASE_WIDTH?g<=P&&(g+=A):g=0,C=0),f.position.x>(CONFIG.HERO.wrapRightPerc||999)*BASE_WIDTH&&(f.position.x=CONFIG.HERO.limitLeftPerc*BASE_WIDTH,f.position.y+=CONFIG.HERO.wrapRightStepDownPixels||0),G&&(f.position.x>(CONFIG.HERO.limitLeftPerc||0)*BASE_WIDTH?g>=-P&&(g-=A):g=0,C=0),f.position.x<(CONFIG.HERO.wrapLeftPerc||-999)*BASE_WIDTH&&(f.position.x=CONFIG.HERO.limitRightPerc*BASE_WIDTH),(D||S)&&(f.position.y>(CONFIG.HERO.limitTopPerc||0)*BASE_HEIGHT?v>=-P&&(0==v&&(v-=1.25*P),v-=A):v=0,x=0,_=!1),f.position.y<(CONFIG.HERO.wrapTopPerc||-999)*BASE_HEIGHT&&(f.position.y=CONFIG.HERO.limitBottomPerc*BASE_HEIGHT),N&&(f.position.y<(CONFIG.HERO.limitBottomPerc||1)*BASE_HEIGHT?v<=P&&(v+=A):v=0,x=0),f.position.y>(CONFIG.HERO.wrapBottomPerc||999)*BASE_HEIGHT&&(f.position.y=CONFIG.HERO.limitTopPerc*BASE_HEIGHT),B||G||(g*=1-F),CONFIG.HERO.gravity?(g+=CONFIG.HERO.gravity.x,v+=CONFIG.HERO.gravity.y*k,g>=P&&(g=P)):v*=1-F;var i=w,o=!1;if(81==Global.GAME_ID&&BD.distanceY>BD.seaLevel&&(i=!1,o=!0,V=50),i||CONFIG.HERO.controls.forwards_pressed){var a=f.rotation-Math.PI/2;y+=(Math.cos(a)*P-y)/5,I+=(Math.sin(a)*P-I)/5,U+=A,X+=A,o||(g/=1.01,(V-=1)<1&&(V=1)),v/=1.01}else o||(U*=1-F),X*=1-F;if(U>P&&(U=P),X>P&&(X=P),void 0!==CONFIG.HERO.limitRightPerc&&f.position.x>CONFIG.HERO.limitRightPerc*BASE_WIDTH&&(f.position.x=CONFIG.HERO.limitRightPerc*BASE_WIDTH,g=0),void 0!==CONFIG.HERO.limitLeftPerc&&f.position.xCONFIG.HERO.limitBottomPerc*BASE_HEIGHT&&(f.position.y=CONFIG.HERO.limitBottomPerc*BASE_HEIGHT,v>0&&(v=0),S=!1),b&&m>-L/40&&(m-=M/40),T&&mCONFIG.HERO.limitBottomPerc*BASE_HEIGHT-50&&2==f.animation.getAnim()&&f.animation.setAnim(0),CONFIG.HERO.scroll||CONFIG.HERO.scrollX?f.animation.setFPS(g*k*(CONFIG.HERO.spriteAnimationSpeed||1)):f.animation.setFPS(4*g||24)),81==Global.GAME_ID&&(BD.seaLevel=1150,BD.seaBed=-1500,BD.distanceY,BD.seaLevel,BD.distanceY0&&(v/=2),I>0&&(I=0)),BD.guidebug&&BD.guidebug.refreshDebug({height_stage:z.height_stage,depth_stage:z.depth_stage,horizJumpDist:z.horizJumpDist,horizJumping_stage:z.horizJumping_stage,rotation:Math.round(z.flipRotation),frontFlips:z.frontFlips,backFlips:z.backFlips,noseDive:z.noseDive,tailDive:z.tailDive}),BD.distanceY>BD.seaLevel+3e3&&(z.height_stage=Math.round(BD.distanceY/3e3)),BD.distanceY0?z.frontFlips=Math.round(z.flipRotation/(2*Math.PI)):z.backFlips=-Math.round(z.flipRotation/(2*Math.PI)),z.horizJumpDist=Math.abs(Math.round(z.horizJumpStart-BD.distance)),z.horizJumping_stage=Math.floor(z.horizJumpDist/5e3)),BD.distanceY<-450&&BD.distanceY>-550&&(z.noseDive=Math.floor(100*Math.abs(f.rotation-Math.PI).toFixed(2)),z.tailDive=Math.floor(100*Math.abs(f.rotation-Math.PI).toFixed(2))),(CONFIG.LEVELUP_AWARDS.active||BD.awardManager)&&BD.awardManager.check(z));var s=CONFIG.HERO.scrollX,l=CONFIG.HERO.scrollY;(s||l)&&Global.oktomoveBG&&"freezescroll"!=H&&(EventDispatcher.trigger("movebackground",{x:s&&k?-g*k:null,y:l&&W?-v*W:null}),EventDispatcher.trigger("movebackground",{x:s&&U?-y*U:null,y:l&&X?-I*X:null})),s||(f.position.x+=g*k,f.position.x+=y*U),l||(f.position.y+=v*W,f.position.y+=I*X)}function u(){EventDispatcher.trigger("fire",{startmc:f,type:"bullet"})}function h(){S||(S=!0,v=-25-k*k*k*(.8*k))}function d(){S||(S=!0,v=-32-k*k*k*(.8*k))}function p(){var e=CONFIG.HERO.asset;return CONFIG.HERO.assetsLevels&&(e=CONFIG.HERO.assetsLevels[Global.level>CONFIG.HERO.assetsLevels.length?0:Global.level-1]),e}var f,E,g,v,y,I,m,C,x,O,B,G,D,w,N,S,_,b,T,H,A,P,F,L,M,R,k=1,W=1,U=0,X=0,V=1,Y=[],z={},j=this,K=window,Z=stage3,J=!1;this.destroyRadar=function(){for(var e in Y)Z.removeChild(Y[e]);Y=[]},this.createRadar=function(e){this.destroyRadar();for(var t in e){var n=new PIXI.Sprite(arrow_34);n.scale={x:1,y:1},Z.addChild(n),Y[t]=n}};Math.PI;this.updateRadar=function(e){if(Y.length>e.length)for(;Y.length>e.length;){var t=Y.pop();Z.removeChild(t)}for(var n in e)if(e[n]){var i=e[n].getMc();if(i.position){var o=i.position.x-f.position.x,a=i.position.y-f.position.y,r=Math.atan2(o,a),s=150*Math.sin(r),l=150*Math.cos(r);Y[n]&&(Math.abs(a)=90&&e<=180||e>270&&e<360?{width:t,height:n}:{width:n,height:t}},this.getSpeed=function(){return{x:g||y,y:v||I}},this.setXSpeed=function(e){g=e},this.setXSpeedMulti=function(e){k=e},this.setYSpeed=function(e){v=e},this.setPreventPlayerUpdate=function(e){J=e},this.getIsJumping=function(){return S},this.yspeed=v}}(),this.BD=this.BD||{},function(){"use strict";BD.PopupResults=function(){function e(){clearInterval(t),a.removeChild(n);for(var e in o)a.removeChild(o[e])}var t,n,i,o=[],a=stage3;this.execute=function(r){var s=(i=cloneObject(r)).fontsize||40;(n=new PIXI.Text(i.txt,{font:"bold "+s+"px "+CONFIG.FONT,fill:CONFIG.FONT_COLOUR_UI,stroke:CONFIG.FONT_COLOUR_STROKE,strokeThickness:4,align:"center"})).anchor={x:.5,y:.5},n.position.x=500,n.position.y=i.y||BASE_HEIGHT/3,a.addChild(n),"float"==i.animation&&TweenLite.to(n,1,{y:i.y-50});for(var l=0;lBASE_WIDTH&&(r[e].x=0)}function n(e){for(var t in r)r[t].x+=e.x,r[t].y+=e.y}var i=new PIXI.Container;stage4.addChild(i);var o,a,r=[];this.execute=function(i){return o=i,EventDispatcher.on("update",t),EventDispatcher.on("movebackground",n),a=setInterval(e,400),this},this.destroy=function(){EventDispatcher.off("update",t),EventDispatcher.off("movebackground",n),clearInterval(a);for(var e in r)stage.removeChild(r[e]);r=null,stage3.removeChild(i)}}}(),this.BD=this.BD||{},function(){"use strict";BD.Sparkle=function(){function e(e){TweenLite.to(e,(Math.random()/2+1)*r,{alpha:0,onComplete:t,onCompleteParams:[e]}),TweenLite.to(e.scale,(Math.random()/2+1)*r,{x:0,y:0})}function t(e){l.splice(l.indexOf(e),1),s.removeChild(e),e=null,setTimeout(n,1e3)}function n(){for(var e in l)s.removeChild(l[e])}function i(){for(var e in l)l[e].velx&&(l[e].position.x+=l[e].velx),l[e].vely&&(l[e].position.y+=l[e].vely)}function o(e){for(var t in l)l[t].position.x+=e.x/2,l[t].position.y+=e.y/2}var a,r,s=stage3,l=[];this.execute=function(t,n){if(a=Object.assign({},n),EventDispatcher.on("update",i),EventDispatcher.on("movebackground",o),a){var c=t.position.x,u=t.position.y;CONFIG.HERO&&CONFIG.HERO.particle&&(c+=CONFIG.HERO.particle.offset?CONFIG.HERO.particle.offset.x:0,u+=CONFIG.HERO.particle.offset?CONFIG.HERO.particle.offset.y:0),r=a.speed?1/a.speed:1;for(var h=0;h<(a.count||6);h++){var d=window[a.asset],p=new PIXI.Sprite(d);p.anchor={x:.5,y:.5};var f=a.randomStart||10;if(p.position.x=c+Math.random()*f,p.position.y=u+Math.random()*f,CONFIG.HERO&&CONFIG.HERO.particle&&CONFIG.HERO.particle.velocity&&(p.velx=CONFIG.HERO.particle.velocity*Math.cos(t.rotation-Math.PI/2),p.vely=CONFIG.HERO.particle.velocity*Math.sin(t.rotation-Math.PI/2)),p.scale={x:.1,y:.1},a.spread){var E=a.spread||0,g=p.position.x-E/2+Math.random()*E,v=p.position.y-E/2+Math.random()*E;a.offsetEnd&&(g+=a.offsetEnd.x,v+=a.offsetEnd.y);var y=-Math.PI+Math.random()*(2*Math.PI)*45;TweenLite.to(p.position,(Math.random()/2+1.5)*r,{rotation:y,x:g,y:v}),TweenLite.to(p,(Math.random()/2+1.5)*r,{rotation:y})}if(a.scale){var I=1+Math.random()*(a.scaleMaxRandom||0);TweenLite.to(p.scale,(Math.random()/2+.5)*r,{x:a.scale.x*I,y:a.scale.y*I,onComplete:e,onCompleteParams:[p]})}else console.log("[WARNING sparkle] no scale");s.addChild(p),l.push(p)}}else log("[ERROR] Sparkle has no params")},this.destroy=n}}(),this.BD=this.BD||{},function(){"use strict";BD.SplashPage=function(){var e;this.execute=function(t){e=cloneObject(t);var n=window[CONFIG.SPLASH.asset]||window[CONFIG.BACKGROUND.asset],i=new PIXI.Sprite(n);i.interactive=!0,i.mousedown=i.touchstart=function(e){},stage.addChild(i);var o=new PIXI.Sprite(window[CONFIG.SPLASH.logo?CONFIG.SPLASH.logo.asset:CONFIG.BRANDING.logo]);o.anchor=new PIXI.Point(.5,.5),o.position={x:BASE_WIDTH/2,y:205},stage.addChild(o),o.scale={x:.2,y:.2},TweenLite.to(o.scale,1,{x:1,y:1,ease:Bounce.easeOut}),o.rotation=-180,TweenLite.to(o,2,{rotation:0,ease:Elastic.easeOut}),CONFIG.SPLASH.hideLogo&&(o.position.x=-9999);var a=new PIXI.Text(CONFIG.SPLASH.text,{font:"30px "+CONFIG.FONT,fill:CONFIG.FONT_COLOUR,wordWrap:!0,wordWrapWidth:700,align:"center",stroke:CONFIG.FONT_COLOUR_STROKE,strokeThickness:4});a.anchor=new PIXI.Point(.5,.5),a.position={x:BASE_WIDTH/2,y:430},stage.addChild(a),new BD.Button({text:CONFIG.SPLASH.playButton?CONFIG.SPLASH.playButton.text:"START",asset:CONFIG.SPLASH.playButton?CONFIG.SPLASH.playButton.asset:null,position:CONFIG.SPLASH.playButton?{x:BASE_WIDTH*CONFIG.SPLASH.playButton.posPerc.x,y:BASE_HEIGHT*CONFIG.SPLASH.playButton.posPerc.y}:{x:BASE_WIDTH/2,y:520},textOffset:CONFIG.SPLASH.playButton?CONFIG.SPLASH.playButton.textOffset:null,scale:CONFIG.SPLASH.playButton?CONFIG.SPLASH.playButton.scale:1,keypress:!0,onclick:function(){createTransition(function(){removeAll(),e.callback&&e.callback()},!0)}}),createTransition()}}}(),this.BD=this.BD||{},function(){"use strict";var e,t,n,i,o;BD.TermsPage=function(){var a,r=this;this.execute=function(t){a=t||{},(e=new PIXI.Sprite(bgasset)).interactive=!0,e.mousedown=e.touchstart=function(e){},stage.addChild(e),updateBackgroundSize(e);var s='\n\n1. This competition ("Competition") is organised by The Carphone Warehouse Ltd, 1 Portal Way, London W3 6RS ("Carphone Warehouse" or "The Promoter").';return s+='\n2. The Competition will be held at selected stores over various weekends (each a "Participating Store") The Competition will be held from 7th February 2015 to 7th March 2015 (the "Promotional Period"). ',s+="\n3. To be eligible for entry you must be a resident in the UK and be 18 years old or over.",s+="\n4. This Competition is free to enter and no purchase is necessary.",s+="\n5. This Competition is not open to employees of The Carphone Warehouse Ltd, or anyone professionally connected with the Competition.",s+="\n6. To enter the Competition, entrants must visit a Participating Store during the Promotional Period and enter the 'Carphone Match and Snap', enter your details and complete the game ('Entry').",s+="\n7. Participants have only two attempts at the game.",s+="\n8. There is one available prize available of a Samsung Level Box Bluetooth Speaker. ",s+="\n9. The winner will be the entrant with the highest overall score in all Participating Stores.",s+="\n10. The winner will be notified on or around 11 March 2015.",s+="\n11. The winner will have 7 days from the date of notification to claim their prize. In the event that a winner is unreachable, ineligible, or fails to claim the Prize in the time required, the winner shall forfeit their Prize and it will be awarded to a substitute winner, which shall be the next highest scored Entry.",s+="\n12. The Prize carries no cash value, is non-transferable and may not be substituted by the winner. The Promoter may substitute a prize of equal or greater value for any prize.",s+="\n13. Entry into the Competition signifies acceptance of these terms. The Carphone Warehouse Ltd also reserves the right to amend the Competition terms at any time. These terms will be governed by English law.",s+="\n14. Upon request, the surname and county of the winner can be obtained by writing to the above address no sooner than 28 days after the draw.",n=new PIXI.Text("TERMS & CONDITIONS: ",{font:"bold 14px Arial",fill:"white",wordWrap:!0,wordWrapWidth:900,align:"center"}),n.position.x=400,n.position.y=30,stage.addChild(n),i=new PIXI.Text(s,{font:"14px Arial",fill:"white",wordWrap:!0,wordWrapWidth:900,align:"left"}),i.position.x=80,i.position.y=30,stage.addChild(i),o=new PIXI.Sprite(btn_back),o.interactive=!0,o.position.x=450,o.position.y=580,stage.addChild(o),o.mousedown=o.touchstart=function(e){createTransition(function(){r.destroy(),a.callback&&a.callback()},!0)},o.mouseover=function(e){o.setTexture(btn_back_RO)},o.mouseout=function(e){o.setTexture(btn_back)},createTransition(),this},this.destroy=function(){stage.removeChild(e),stage.removeChild(t),stage.removeChild(o),stage.removeChild(n),stage.removeChild(i),document.getElementById("regscore").style.opacity=1}}}(),this.BD=this.BD||{},function(){"use strict";BD.EnemyWaveAsteroids=function(e){function t(){var n=e.maxCount+(Global.level-1)*(e.maxCountIncreasePerLevel||1);r=setTimeout(function(){if(c>=n)return!1;if(c++,Global.documentFocused&&Global.gameactive){for(var i=1+Math.floor(4*Math.random()),o=i;o==i;)o=1+Math.floor(4*Math.random());for(var a=i;a==i||a==o;)a=1+Math.floor(4*Math.random());var r,l,u=new BD.Enemy,h=(e.minSpeed||1)+Math.random()*(e.maxSpeed-e.minSpeed||1),d=Math.sin(Math.random()*Math.PI*2)*h,p=Math.cos(Math.random()*Math.PI*2)*h,f=(e.minSize||1)+Math.random()*(e.maxSize||1);switch(parseInt(4*Math.random())){case 0:r=Math.random()*BASE_WIDTH,l=-200;break;case 1:r=Math.random()*BASE_WIDTH,l=BASE_HEIGHT+200;case 2:r=-200,l=Math.random()*BASE_HEIGHT;case 3:default:r=BASE_WIDTH+200,l=Math.random()*BASE_HEIGHT}var E=parseInt(Math.random()*e.assets.length),g=e.assets[E];if("hero"==e.magnet){var v=r-game.getPlayerMc().position.x,y=l-game.getPlayerMc().position.y,I=Math.atan2(v,y);d=-Math.sin(I)*h,p=-Math.cos(I)*h}u.create(r,l,d,p,f,g),s.push(u),u.getMc().stage=e.stages,Global.timeout>MIN_TIMEOUT&&(Global.timeout-=REDUCE_TIMEOUT,Global.speed+=INCREASE_SPEED)}t()},e.interval||1e3)}function n(){for(var t=0;t0&&n.position.x>e.limitRightPerc*BASE_WIDTH+n.width*n.scale.x&&(n.position.x=e.limitLeftPerc*BASE_WIDTH-n.width*n.scale.x),n.ysp<0&&n.position.y0&&n.position.y>e.limitBottomPerc*BASE_HEIGHT+n.height*n.scale.x&&(n.position.y=e.limitTopPerc*BASE_HEIGHT-n.height*n.scale.x)}}function i(e){for(var t=0;t1){var l=new BD.Enemy;l.create(i.position.x,i.position.y,1.2*-i.xsp,1.2*-i.ysp,i.size/2,r),s.push(l),l.getMc().stage=o,(l=new BD.Enemy).create(i.position.x,i.position.y,1.2*i.xsp,1.2*-i.ysp,i.size/2,r),s.push(l),l.getMc().stage=o}},this.checkWaveCleared=function(){1==s.length&&EventDispatcher.trigger("levelCleared",{config:e})},this.destroy=a}}(),this.BD=this.BD||{},function(){"use strict";BD.EnemyWaveCollapse=function(e){function t(){for(var e=0;e=11&&Global.level<=20&&(BD.player.setXSpeedMulti(.7),i=Math.floor(3*Math.random())),o=CONFIG.ENEMIES.assets[i]);var a=new BD.Enemy,r=S+e*D+BD.distance,l=_+t*D;a.create(r,l,0,0,1,o,stage2);var d=a.getMc();d.pos_x=e,d.pos_y=t,d.type=i;var f=Math.floor(50*Math.random());if(1===f)d.special="ring-change",(E=new PIXI.Sprite(window.lemon)).scale={x:.8,y:.8},d.addChild(E);else if(2===f){d.special="ring-bomb";var E=new PIXI.Sprite(window.bomb);E.scale={x:.9,y:.9},d.addChild(E)}var g;return g=0==i?1.2:1==i?1.3:1.4,g*=1.6,d.width=D*g,d.height=D*g,-1==i&&(d.hitOutcome="none"),b[t]||(b[t]=[]),b[t][e]=d,d.mousedown=d.touchstart=function(e){if(!O)return!1;"ring-bomb"===this.special?EventDispatcher.trigger("fire",{startmc:this,type:"ring",outcome:"destroy"}):"ring-change"===this.special?(A=this.type,EventDispatcher.trigger("fire",{startmc:this,type:"ring",outcome:"change"})):(s(this.pos_x,this.pos_y,this.type),setTimeout(c,50),setTimeout(function(){u(),h();for(var e=0;e-1;t--)for(var n=b[0].length-w;nBASE_HEIGHT+100&&(T[e].inst.destroy(),T[e]=null))}function m(){var e=!1;if(Global.oktomoveBG){Global.oktomoveBG=!1;for(var t in b)for(var n in b[t])b[t]&&b[t][n]&&!b[t][n].tweening&&(b[t][n].tweening=!0,TweenLite.to(b[t][n].position,.5,{x:b[t][n].position.x+3*D}),e=!0);e&&(BD.distance+=3*D),setTimeout(function(){for(var e in b)for(var t in b[e])b[e]&&b[e][t]&&(b[e][t].tweening=!1);Global.oktomoveBG=!0},1e3)}}function C(e){e.getMc().popped=!0,c(),u(),h()}function x(e){var t=e.getMc();t.type!==A&&E(t.pos_x,t.pos_y)}var O,B,G,D=e.blockSize||75,w=e.gridX,N=e.gridY,S=e.gridOffsetX,_=e.gridOffsetY,b=[],T=[],H={},A=null;EventDispatcher.on("update",I),EventDispatcher.on("movebackground",y),EventDispatcher.on("ACTIVATE_POWER",function(e){switch(e){case"ACTIVATE_SMASH":M="smash";break;case"ACTIVATE_FREEZE":M="freeze";break;case"ACTIVATE_PUSH":M="push"}});var P,F,L=[],M=null;this.checkWaveCleared=function(){},this.startCreate=function(){G=new PIXI.Container,stage4.addChild(G),v()},this.getEnemies=function(){for(var e=[],t=b[0].length-w;t.5&&(t="lasergun2");var n=A+e*_,i=new BD.Enemy;i.create(60,n,0,0,1,t,stage4);var o=i.getMc();!function(e){e.mousedown=o.touchstart=function(){EventDispatcher.trigger("fire",{startmc:e,outcome:"ring",power:5})}}(o),Z.push({mc:o})}}function o(){console.log("BD.LEVELUP_ENHANCE ",BD.LEVELUP_ENHANCE);for(var e=0;e=11&&Global.level<=20)BD.player.setXSpeedMulti(1+(Global.level-10)/10),s(2),e=1,BD.LEVELUP_ENHANCE.weaponSpeed1.value=e,BD.LEVELUP_ENHANCE.weaponSpeed2.value=e,BD.LEVELUP_ENHANCE.weaponSpeed3.value=e,BD.LEVELUP_ENHANCE.weaponSpeed4.value=e,BD.LEVELUP_ENHANCE.weaponSpeed5.value=e,BD.LEVELUP_ENHANCE.weaponSpeed6.value=e,BD.LEVELUP_ENHANCE.weaponSpeed7.value=e;else if(Global.level>=21&&Global.level<=30)BD.player.setXSpeedMulti(1+(Global.level-20)/10),s(2.1),e=2,BD.LEVELUP_ENHANCE.weaponSpeed1.value=e,BD.LEVELUP_ENHANCE.weaponSpeed2.value=e,BD.LEVELUP_ENHANCE.weaponSpeed3.value=e,BD.LEVELUP_ENHANCE.weaponSpeed4.value=e,BD.LEVELUP_ENHANCE.weaponSpeed5.value=e,BD.LEVELUP_ENHANCE.weaponSpeed6.value=e,BD.LEVELUP_ENHANCE.weaponSpeed7.value=e;else if(Global.level>=31&&Global.level<=40)BD.player.setXSpeedMulti(1+(Global.level-30)/10),s(2.4),e=2,BD.LEVELUP_ENHANCE.weaponSpeed1.value=e,BD.LEVELUP_ENHANCE.weaponSpeed2.value=e,BD.LEVELUP_ENHANCE.weaponSpeed3.value=e,BD.LEVELUP_ENHANCE.weaponSpeed4.value=e,BD.LEVELUP_ENHANCE.weaponSpeed5.value=e,BD.LEVELUP_ENHANCE.weaponSpeed6.value=e,BD.LEVELUP_ENHANCE.weaponSpeed7.value=e;else if(Global.level>=41&&Global.level<=50)BD.player.setXSpeedMulti(1+(Global.level-40)/10),s(3),e=3,BD.LEVELUP_ENHANCE.weaponSpeed1.value=e,BD.LEVELUP_ENHANCE.weaponSpeed2.value=e,BD.LEVELUP_ENHANCE.weaponSpeed3.value=e,BD.LEVELUP_ENHANCE.weaponSpeed4.value=e,BD.LEVELUP_ENHANCE.weaponSpeed5.value=e,BD.LEVELUP_ENHANCE.weaponSpeed6.value=e,BD.LEVELUP_ENHANCE.weaponSpeed7.value=e;else if(Global.level>=51&&Global.level<=60)BD.player.setXSpeedMulti(1+(Global.level-50)/10),s(3),e=4,BD.LEVELUP_ENHANCE.weaponSpeed1.value=e,BD.LEVELUP_ENHANCE.weaponSpeed2.value=e,BD.LEVELUP_ENHANCE.weaponSpeed3.value=e,BD.LEVELUP_ENHANCE.weaponSpeed4.value=e,BD.LEVELUP_ENHANCE.weaponSpeed5.value=e,BD.LEVELUP_ENHANCE.weaponSpeed6.value=e,BD.LEVELUP_ENHANCE.weaponSpeed7.value=e;else if(Global.level>=61&&Global.level<=70)BD.player.setXSpeedMulti(1+(Global.level-60)/10),s(3.1),e=5,BD.LEVELUP_ENHANCE.weaponSpeed1.value=e,BD.LEVELUP_ENHANCE.weaponSpeed2.value=e,BD.LEVELUP_ENHANCE.weaponSpeed3.value=e,BD.LEVELUP_ENHANCE.weaponSpeed4.value=e,BD.LEVELUP_ENHANCE.weaponSpeed5.value=e,BD.LEVELUP_ENHANCE.weaponSpeed6.value=e,BD.LEVELUP_ENHANCE.weaponSpeed7.value=e;else if(Global.level>=71&&Global.level<=80)BD.player.setXSpeedMulti(1+(Global.level-70)/10),s(3.4),e=6,BD.LEVELUP_ENHANCE.weaponSpeed1.value=e,BD.LEVELUP_ENHANCE.weaponSpeed2.value=e,BD.LEVELUP_ENHANCE.weaponSpeed3.value=e,BD.LEVELUP_ENHANCE.weaponSpeed4.value=e,BD.LEVELUP_ENHANCE.weaponSpeed5.value=e,BD.LEVELUP_ENHANCE.weaponSpeed6.value=e,BD.LEVELUP_ENHANCE.weaponSpeed7.value=e;else if(Global.level>=81&&Global.level<=90)BD.player.setXSpeedMulti(1+(Global.level-80)/10),s(4),e=7,BD.LEVELUP_ENHANCE.weaponSpeed1.value=e,BD.LEVELUP_ENHANCE.weaponSpeed2.value=e,BD.LEVELUP_ENHANCE.weaponSpeed3.value=e,BD.LEVELUP_ENHANCE.weaponSpeed4.value=e,BD.LEVELUP_ENHANCE.weaponSpeed5.value=e,BD.LEVELUP_ENHANCE.weaponSpeed6.value=e,BD.LEVELUP_ENHANCE.weaponSpeed7.value=e;else if(Global.level>=91&&Global.level<=100){BD.player.setXSpeedMulti(1+(Global.level-90)/10),s(4);var e=8;BD.LEVELUP_ENHANCE.weaponSpeed1.value=e,BD.LEVELUP_ENHANCE.weaponSpeed2.value=e,BD.LEVELUP_ENHANCE.weaponSpeed3.value=e,BD.LEVELUP_ENHANCE.weaponSpeed4.value=e,BD.LEVELUP_ENHANCE.weaponSpeed5.value=e,BD.LEVELUP_ENHANCE.weaponSpeed6.value=e,BD.LEVELUP_ENHANCE.weaponSpeed7.value=e}}function s(e){X=e}function l(e,t,n){var i,o,a=0===t&&0===Math.floor(Math.random()*V),r=0===t&&0===Math.floor(Math.random()*Y),s=-1===n;s?i=-1:(i=Math.floor(Math.random()*X),o=CONFIG.ENEMIES.assets[i]),a&&(o="billionchar"),r&&(o="gunpart01"),s&&(o="a_block_grey_horiz");var l=new BD.Enemy,u=H+e*_+BD.distance,h=A+t*_;l.create(u,h,0,0,1,o,stage2);var d=l.getMc();if(d.pos_x=e,d.pos_y=t,d.type=i,a&&(d.type=R),r&&(d.type=k),a||s||0!==Math.floor(Math.random()*z))if(a||s||0!==Math.floor(Math.random()*j)){if(!a&&!s&&0===Math.floor(Math.random()*K)){var p=new PIXI.Sprite(window.livesheart);p.anchor={x:.5,y:.5},p.scale={x:.7,y:.7},d.addChild(p)}}else d.special="ring-bomb",(p=new PIXI.Sprite(window.bomb)).anchor={x:.5,y:.5},p.scale={x:.9,y:.9},d.addChild(p);else d.special="ring-change",(p=new PIXI.Sprite(window.lemon)).anchor={x:.5,y:.5},p.scale={x:.8,y:.8},d.addChild(p);var f;return Math.floor(3*Math.random()),f=0==i?1.2:1==i?1.3:1.4,f=1.1,f*=1.6,d.width=_*f,d.height=_*f,s&&(d.hitOutcome="none"),a&&(d.hitOutcome="none"),P[t]||(P[t]=[]),P[t][e]=d,d.mousedown=d.touchstart=function(e){if(!w)return!1;"ring-bomb"===this.special?EventDispatcher.trigger("fire",{startmc:this,type:"ring",outcome:"destroy"}):"ring-change"===this.special?(M=this.type,EventDispatcher.trigger("fire",{startmc:this,type:"ring",outcome:"change"})):c(this)},d}function c(e){u(e.pos_x,e.pos_y,e.type),setTimeout(p,50),setTimeout(function(){f(),E();for(var e=0;e-1;t--)for(var n=P[0].length-b;nBASE_HEIGHT+100&&(F[e].inst.destroy(),F[e]=null))}function B(){var e=!1;if(Global.oktomoveBG){Global.oktomoveBG=!1;for(var t in P)for(var n in P[t])P[t]&&P[t][n]&&!P[t][n].tweening&&(P[t][n].tweening=!0,TweenLite.to(P[t][n].position,.5,{x:P[t][n].position.x+3*_}),e=!0);e&&(BD.distance+=3*_),setTimeout(function(){for(var e in P)for(var t in P[e])P[e]&&P[e][t]&&(P[e][t].tweening=!1);Global.oktomoveBG=!0},1e3)}}function G(e){e.getMc().popped=!0,p(),f(),E()}function D(e){var t=e.getMc();t.type!==M&&I(t.pos_x,t.pos_y)}var w,N,S,_=e.blockSize||75,b=e.gridX,T=e.gridY,H=e.gridOffsetX,A=e.gridOffsetY,P=[],F=[],L={},M=null,R=999,k=998;EventDispatcher.on("update",O),EventDispatcher.on("movebackground",x),EventDispatcher.on("ACTIVATE_POWER",function(e){switch(e){case"ACTIVATE_SMASH":J="smash";break;case"ACTIVATE_FREEZE":J="freeze";break;case"ACTIVATE_PUSH":J="push"}});var W,U,X=2,V=2,Y=10,z=100,j=100,K=150,Z=[],J=null;this.checkWaveCleared=function(){},this.startCreate=function(){S=new PIXI.Container,stage4.addChild(S),C()},this.getEnemies=function(){for(var e=[],t=P[0].length-b;t100&&EventDispatcher.trigger("die")},this.inZone=function(e){}}}(),this.BD=this.BD||{},function(){"use strict";BD.EnemyWaveInvaders=function(e){function t(){var t=e.bullets.interval[0]+Math.floor(Math.random()*e.bullets.interval[1]);u=setTimeout(n,t)}function n(){f.length,e.bullets.maxCount;var n=Math.PI/2,o={x:Math.cos(n)*e.bullets.speed,y:Math.sin(n)*e.bullets.speed},a=Math.floor(Math.random()*p.length);if(p[a]){var r=p[a].getMc(),s=new BD.Bullet;s.execute({arr:f,self:s,rotation:n,position:r.position,speed:o}),f.push(s)}e.initFly&&i(),t()}function i(){var e=Math.floor(Math.random()*p.length);if(p[e]&&!p[e].flying){var t=p[e].getMc();t.addx=0,t.addy=0,p[e].flying=x}}function o(t,n,i){var o=Global.level;o>e.assetsLevels.length&&(o=1);var a=e.assetsLevels[o-1][t];if(a){var r=new BD.Enemy;r.create(n,i,0,0,1,a),h=C,d=0,p.push(r)}}function a(){for(var t=0,n=!1,i=!1,o=0;o0&&c.position.x>e.limitRightPerc*BASE_WIDTH||h<0&&c.position.xp.length-2&&(r(),n)){for(n=!1,o=0;oBASE_HEIGHT+50&&(p[o].flying=G,c.addy=-c.position.y-150);break;case O:c.addx-=2;break;case B:c.addx+=2;break;case G:c.addy+=6,c.addy>0&&(c.addx=0,c.addy=0,p[o].flying=!1)}}s()}function r(){for(var e=0;e4&&(n=4);for(var i=0;i0;)if(a--,O[n][a]){if(i!=O[n][a].type)break;o++}for(a=t;a2)return o;for(var r=1,s=n;s>0;)if(s--,O[s][t]){if(i!=O[s][t].type)break;r++}for(s=n;s2?r:void 0}function r(e,t,n){E&&O[t]&&O[t][e]&&O[t][e].type==n&&(O[t][e].popped||(O[t][e].popped=!0,O[t][e].alpha=0,new BD.Sparkle(stage).execute(O[t][e],CONFIG.ENEMIES.particle),f=!1,r(e+1,t,n),r(e-1,t,n),r(e,t+1,n),r(e,t-1,n)))}function s(){if(E){for(t=0;t-1;t--)for(var n=0;nCONFIG.UI.fields.score.bar.max&&(CONFIG.ENEMIES.resetscore&&(Global.score=0,BD.gui.refresh("score",Global.score)),CONFIG.ENEMIES.restarttimer&&EventDispatcher.trigger("restartTimer"),EventDispatcher.trigger("levelCleared",{detail:e})),s()},200)}var d,p,f,E,g,v,y=75,I=e.gridX,m=e.gridY,C=e.gridOffsetX,x=e.gridOffsetY,O=[],B={};this.startCreate=function(){u()},this.destroy=function(){EventDispatcher.off("update",update)}}}(),this.BD=this.BD||{},function(){"use strict";BD.EnemyWaveRandom=function(e){function t(){var n=e.maxCount+(Global.level-1)*(e.maxCountIncreasePerLevel||1);if(s>=n)return!1;o=setTimeout(function(){if(Global.documentFocused&&Global.gameactive){var n,i=BASE_WIDTH/2+(e.leftmost||-1e3)+Math.random()*(2*e.rightmost||2e3),o=e.topmost+Math.random()*e.bottommost;if(e.asset instanceof Array)if(e.randomAssets){var r=Math.floor(Math.random()*e.asset.length);n=e.asset[r]}else{var s=Global.level-1;s>=e.asset.length&&(s=e.asset.length-1),n=e.asset[s]}else n=e.asset;var l=new BD.Enemy,c=l.create(i,o,0,0,1,n);c.anchor=new PIXI.Point(.5,e.anchorX||.5),c.scale=e.scale?{x:e.scale.x,y:e.scale.y}:{x:1,y:1},a.push(l),Global.timeout>MIN_TIMEOUT&&(Global.timeout-=REDUCE_TIMEOUT,Global.speed+=INCREASE_SPEED)}t()},a.length<10?10:1e3),s++}function n(){}function i(){clearTimeout(o),EventDispatcher.off("update",n);for(var e=0;e1){var n=new BD.Enemy;n.create(e.x,e.y,1.2*-e.xsp,1.2*-e.ysp,e.size/2,e.asset),a.push(n),n.getMc().stage=t,(n=new BD.Enemy).create(e.x,e.y,1.2*e.xsp,1.2*-e.ysp,e.size/2,e.asset),a.push(n),n.getMc().stage=t}},this.checkWaveCleared=function(){if(l){var t=a[a.length-1];t&&t.getMc()&&t.getMc().position.x<0&&(EventDispatcher.trigger("levelCleared",{detail:e}),l=!1)}},this.destroy=i}}(),this.BD=this.BD||{},function(){"use strict";BD.EnemyWaveRtype=function(e){function t(){return n(0,BASE_WIDTH,100+Math.random()*(BASE_HEIGHT-200))}function n(t,n,i){var o=new BD.EnemyInvader,a=parseInt(Math.random()*e.assets.length),r=e.assets[a];return o.create(t,root[r],n,i),s.push(o),o.getMc().rotation=Math.PI/2*2,o.getMc().count=0,o.getMc()}function i(){for(var e=0;e=0&&r<10&&(t.count<100||(t.count<150?t.rotation+=.05:t.count<250&&(t.rotation+=.1))),r>=10&&r<20&&(t.count<100||(t.count<150?t.rotation+=.03:t.count<200?t.rotation-=.02:t.count<400&&(t.rotation-=.04))),20==r&&(t.rotation-=.15)}}e++}}function o(){i(),u++,0==r&&u>100&&(u=0,r++),1==r&&(++c>10&&(c=0,t()),u>100&&(u=0,r++)),2==r&&u>200&&(u=0,r++,EventDispatcher.trigger("createWave"),EventDispatcher.trigger("destroyWave",{wave:this})),10==r&&u>100&&(u=0,r++),11==r&&(++c>20&&(c=0,t().position.y+=50*s.length),u>100&&(u=0,r++)),12==r&&u>50&&(u=0,r++,EventDispatcher.trigger("createWave",{wave:"2"}),EventDispatcher.trigger("destroyWave",{wave:this})),20==r&&++c>200&&(c=0,t())}var a,r,s=[],l=[],c=0,u=0;r=20,EventDispatcher.on("update",o),this.startCreate=function(){},this.getEnemies=function(){return s},this.getBullets=function(){return l},this.getConfig=function(){return e},this.checkWaveCleared=function(){s.length},this.destroy=function(){for(var e in s)s[e].destroy();s=[],clearTimeout(a),EventDispatcher.off("update",o)}}}(),this.BD=this.BD||{},function(){"use strict";BD.EnemyWaveTowers=function(e){function t(e,t,n){var r;switch(e){case 1:r=tower_part_1;break;case 2:r=tower_part_2;break;case 3:r=tower_part_3;break;case-1:r=tower_part_4;break;default:r=tower_part_1}var s=new BD.EnemyInvader;s.create(e,r,t,n),i=d,o=0,a.push(s)}function n(){}var i,o,a=[],r=[],s=e.gridX,l=e.gridY,c=e.gridOffsetX,u=e.gridOffsetY,h=e.gridSpacing,d=8;EventDispatcher.on("update",function(){n()});for(var p=[],f=0;fS.x-n&&eS.y-n&&t_.x-n&&e<_.x+n&&t>_.y-n&&t<_.y+n&&(i=!0),e>b.x-150&&eb.y-n&&t