Files
monkeygg2.github.io/games/rookie-bowman/js/main.js
T
2023-08-25 13:31:04 +05:30

302 lines
142 KiB
JavaScript

var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,c,e){a!=Array.prototype&&a!=Object.prototype&&(a[c]=e.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX="jscomp_symbol_";
$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.Symbol=function(){var a=0;return function(c){return $jscomp.SYMBOL_PREFIX+(c||"")+a++}}();
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.iterator;a||(a=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[a]&&$jscomp.defineProperty(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};
$jscomp.initSymbolAsyncIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.asyncIterator;a||(a=$jscomp.global.Symbol.asyncIterator=$jscomp.global.Symbol("asyncIterator"));$jscomp.initSymbolAsyncIterator=function(){}};$jscomp.arrayIterator=function(a){var c=0;return $jscomp.iteratorPrototype(function(){return c<a.length?{done:!1,value:a[c++]}:{done:!0}})};
$jscomp.iteratorPrototype=function(a){$jscomp.initSymbolIterator();a={next:a};a[$jscomp.global.Symbol.iterator]=function(){return this};return a};$jscomp.makeIterator=function(a){$jscomp.initSymbolIterator();$jscomp.initSymbol();$jscomp.initSymbolIterator();var c=a[Symbol.iterator];return c?c.call(a):$jscomp.arrayIterator(a)};
var app={adStarted:function(){app.adRunning||(console.log("ad started",app.currentScene),app.adRunning=!0,app.adShowedTime=(new Date).getTime(),app.currentScene&&("game"==app.currentSceneName&&app.currentScene.pause(),app.soundManager.stopMusic()))},adEnded:function(){app.adRunning&&(console.log("ad ended",app.currentScene),app.adRunning=!1,app.currentScene&&("game"==app.currentSceneName?(app.currentScene.resume(),app.soundManager.playCurMusic(app.currentScene)):app.soundManager.playLoop(app.currentScene,
"menuLoop")))},SaveManager:function(a){function c(c,b){for(var d=$jscomp.makeIterator(a.curSection),e=d.next();!e.done;e=d.next())if(e=e.value,e.id==c){e.active=b;return}a.curSection.push({id:c,active:b})}var e=["lever","leverBlock","key","secretPlace","coin"];this.save=function(){var d=Array.from(a.children.list);d=$jscomp.makeIterator(d);for(var b=d.next();!b.done;b=d.next())if(b=b.value,b.parentObj)for(var f=$jscomp.makeIterator(e),g=f.next();!g.done;g=f.next())g=g.value,b.parentObj.type==g&&("secretPlace"==
g?c(b.parentObj.id,b.parentObj.opened):c(b.parentObj.id,b.parentObj.active))};this.saveOnlyImportant=function(){var d=Array.from(a.children.list);d=$jscomp.makeIterator(d);for(var b=d.next();!b.done;b=d.next())if(b=b.value,b.parentObj)for(var f=$jscomp.makeIterator(e),g=f.next();!g.done;g=f.next())g=g.value,b.parentObj.type==g&&("secretPlace"==g?c(b.parentObj.id,b.parentObj.opened):b.parentObj.important&&c(b.parentObj.id,b.parentObj.active))};this.saveOnlySecretPlaces=function(){var d=Array.from(a.children.list);
d=$jscomp.makeIterator(d);for(var b=d.next();!b.done;b=d.next())b=b.value,b.parentObj&&"secretPlace"==b.parentObj.type&&c(b.parentObj.id,b.parentObj.opened)};this.getWithId=function(c){for(var b=$jscomp.makeIterator(a.curSection),d=b.next();!d.done;d=b.next())if(d=d.value,d.id==c)return d.active;return"not found"};this.loadList=function(c){var b=0;c=$jscomp.makeIterator(c);for(var d=c.next();!d.done;d=c.next())a.sections["section"+b]=d.value,b++}},Speech:function(a,c){function e(){g&&g.complete&&
g.complete();b&&b.destroy();f++;if(g=c[f]){b=a.add.bitmapText(g.x,g.y,"font",g.text);b.alpha=0;var e=m?0:g.tween.delay;m=!1;a.tweens.add({targets:b,alpha:1,ease:"linear",duration:g.tween.duration,repeat:0,delay:e,onComplete:d})}else k.done=!0}function d(){a.tweens.add({targets:b,alpha:0,ease:"linear",duration:g.tween.duration,repeat:0,delay:g.tween.waitDelay,onComplete:e})}var b,f=-1,g,m=!1;this.done=!1;var k=this;this.start=function(){e()};this.next=function(){m=!0;a.tweens.killTweensOf(b);e()}},
Inventory:function(a){var c,e,d=[{type:"gameTip",id:0,taken:!1},{type:"gameTip",id:1,taken:!1},{type:"gameTip",id:2,taken:!1},{type:"gameTip",id:3,taken:!1},{type:"gameTip",id:4,taken:!1},{type:"gameTip",id:5,taken:!1}],b=[0,0,0,0],f=[{name:"PALETTE",desc:"HELP YOU SWIM FASTER.\nSWIM SPEED INCREASED",id:0,taken:!1,type:"swim"},{name:"STRING",desc:"A BRAND NEW STRING FOR THE BOW\n ARROW CHARGE SPEED INCREASED",id:1,taken:!1,type:"chargeSpeed"},{name:"SHOES",desc:" MAKE YOU MOVE FASTER\nMOVING SPEED INCREASED",
id:2,taken:!1,type:"move"},{name:"SNORKEL",desc:"USE LESS AIR IN WATER\nAIR CONSUME DECREASED",id:3,taken:!1,type:"airConsume"},{name:"SPEED",desc:" SUPER SPEED ABILITY\n USE Z KEY TO ACTIVATE\n5 SEC DURATION/20 SEC COOLDOWN",id:4,taken:!1,type:"superspeed",isAbility:!0,abilityNo:0},{name:"SHIELD",desc:" SHIELD ABILITY\n USE X KEY TO ACTIVATE\n5 SEC DURATION/40 SEC COOLDOWN",id:5,taken:!1,type:"shield",isAbility:!0,abilityNo:1},{name:"BINOCULAR",desc:" HOLD C KEY TO ZOOM OUT\n CANNOT BE USED UNDER WATER\n(YOU CAN'T MOVE WHILE USING THIS ITEM)",
id:6,taken:!1,type:"binocular",isAbility:!0,abilityNo:2},{name:"AIRTANK",desc:" BACKUP AIR TANK\n WHEN YOU ARE OUT OF OXYGEN\nFILLS UP HALF OF THE AIR TANK",id:7,taken:!1,type:"airbar"}],g=[],m=!1,k=!1,n=!1,h=!1,l=!1;this.getList=function(){return g};this.loadList=function(a){g=a;for(var c in a){var e=a[c];0==e.type?d[e.id].taken=!0:3==e.type?(f[e.id].taken=!0,this.updateCharAbilities(f[e.id].type)):4==e.type&&(b[e.id]=1)}};this.updateCharAbilities=function(b){for(var c=0,d=$jscomp.makeIterator(f),
e=d.next();!e.done;e=d.next())e=e.value,e.type==b&&e.taken&&c++;d={};d[b]=c;a["char"].updateAbilities(d);return c};this.closeCurrent=function(){m?this.closePaper():k?this.closeItem():n&&this.closeMap()};this.switchMenu=function(){h?this.closeMenu():a.gamePaused||this.openMenu()};this.getWithId=function(a,c,e){return c?f[a].taken:e?b[a]:d[a].taken};this.openItem=function(b,c){a.pause();k=f[b].taken=!0;g.push({type:3,id:b,text:f[b].name});var d=f[b].isAbility;if(d){g[g.length-1].dontShow=!0;var e=f[b].abilityNo}else this.updateCharAbilities(f[b].type);
var p=c.x-a.cameras.main.scrollX,h=c.y-a.cameras.main.scrollY,m=a.emitManager.addEmitter("star",{angle:{min:0,max:360},speed:{min:200,max:300},quantity:1,gravityY:0,lifespan:2E3,alpha:{start:.8,end:0},scale:{start:1.5,end:1},on:!1,x:400,y:250,scrollFactor:0});m.setScrollFactor(0);var n=a.add.sprite(0,0,"atlas",c.frame.name);n.setScrollFactor(0);n.x=p;n.y=h;var x=a.add.bitmapText(400,400,"font",f[b].name).setScrollFactor(0);x.setScale(2.5);x.x-=x.width/2;x.alpha=0;var z=a.add.bitmapText(400,460,"font",
f[b].desc).setScrollFactor(0);z.setScale(1.5);z.x-=z.width/2;z.alpha=0;var l=a.add.bitmapText(400,550,"font","PRESS SPACE TO CONTINUE").setScrollFactor(0);l.setScale(2);l.x-=l.width/2;l.alpha=0;a.tweens.add({targets:n,scaleX:7,scaleY:7,x:400,y:250,duration:1E3,onComplete:function(){m.on=!0;a.time.delayedCall(2E3,function(){m.on=!1},[],this);a.tweens.add({targets:[z,x],alpha:1,duration:500,onComplete:function(){a.tweens.add({targets:l,alpha:1,duration:500,onComplete:function(){a.curItem={particle:m,
item:n,text:z,text2:l,textM:x,isAbility:d,abilityNo:e}}})}})}})};this.closeItem=function(){if(a.curItem){var b=a.curItem;a.curItem=null;b.particle.on=!1;a.tweens.add({targets:[b.text,b.text2,b.textM],alpha:0,duration:500,onComplete:function(){this.targets[0].destroy();this.targets[1].destroy();this.targets[2].destroy();b.isAbility?a.tweens.add({targets:b.item,x:400+50*b.abilityNo,y:30,scaleX:1,scaleY:1,duration:500,onComplete:function(){var c=this.targets[0];h||a.resume();k=!1;a.addAbility(c.x,c.y,
c.frame.name,b.abilityNo);this.targets[0].destroy()}}):a.tweens.add({targets:b.item,x:10,y:10,scaleX:.5,scaleY:.5,duration:500,onComplete:function(){this.targets[0].destroy();a.resume();k=!1;a.tweens.add({targets:a.bag,scaleX:1.5,scaleY:1.5,duration:250,yoyo:!0})}})}})}};this.openAbility=function(b,c){a.pause();abilityList[b].taken=!0;g.push({type:3,id:b,text:f[b].name,dontShow:!0});var d=c.x-a.cameras.main.scrollX,e=c.y-a.cameras.main.scrollY,p=a.emitManager.addEmitter("star",{angle:{min:0,max:360},
speed:{min:200,max:300},quantity:1,gravityY:0,lifespan:2E3,alpha:{start:.8,end:0},scale:{start:1.5,end:1},on:!1,x:400,y:250,scrollFactor:0});p.setScrollFactor(0);var h=a.add.sprite(0,0,"atlas",c.frame.name);h.setScrollFactor(0);h.x=d;h.y=e;var k=a.add.bitmapText(400,400,"font",f[b].name).setScrollFactor(0);k.setScale(2.5);k.x-=k.width/2;k.alpha=0;var m=a.add.bitmapText(400,460,"font",f[b].desc).setScrollFactor(0);m.setScale(1.5);m.x-=m.width/2;m.alpha=0;var x=a.add.bitmapText(400,550,"font","PRESS SPACE TO CONTINUE").setScrollFactor(0);
x.setScale(2);x.x-=x.width/2;x.alpha=0;a.tweens.add({targets:h,scaleX:7,scaleY:7,x:400,y:250,duration:1E3,onComplete:function(){p.on=!0;a.time.delayedCall(2E3,function(){p.on=!1},[],this);a.tweens.add({targets:[m,k],alpha:1,duration:500,onComplete:function(){a.tweens.add({targets:x,alpha:1,duration:500,onComplete:function(){a.curItem={particle:p,item:h,text:m,text2:x,textM:k}}})}})}})};this.closeAbility=function(){if(a.curItem){var b=a.curItem;a.curItem=null;b.particle.on=!1;a.tweens.add({targets:[b.text,
b.text2,b.textM],alpha:0,duration:500,onComplete:function(){this.targets[0].destroy();this.targets[1].destroy();a.tweens.add({targets:b.item,x:10,y:10,scaleX:.5,scaleY:.5,duration:500,onComplete:function(){this.targets[0].destroy();a.resume();k=!1;a.tweens.add({targets:a.bag,scaleX:1.5,scaleY:1.5,duration:250,yoyo:!0})}})}})}};this.openMap=function(c,d,f){if(!n){a.pause();l=n=!0;d&&(g.push({type:4,id:c,text:"SECTION\n MAP-"+(Number(c)+1)}),b[c]=1);var p=a.add.container(50,50);p.setScrollFactor(0);
d=a.add.image(0,0,"atlas","mapBg");p.add(d);p.curScale=.45;c=Number(c)+1;var h=[4,5,2,3],k=2,m=2;d=1;2==c?(p.curScale=.3,h=[-1,13,14,10,11,12,8,9,-1],m=k=3,d=7):3==c&&(p.curScale=.2,h=[-1,25,24,23,22,21,20,19,18,17,-1,-1,-1,-1,16],k=3,m=5,d=15);var t=660*m,x=396*k;v=a.add.tileSprite(v,w,t,x,"tiledBg").setScale(p.curScale);p.add(v);for(var z=0;z<h.length;z++){var B=h[z]-d;if(!(0>B)){w=Math.floor(z/m);var v=-t/2+660*(z-w*m)+330;v*=p.curScale;var w=-x/2+396*w+198;w*=p.curScale;v=a.add.sprite(v,w,"atlas",
"s"+c+"r"+B).setScale(p.curScale);p.add(v)}}v=a.add.bitmapText(0,-220,"font"," A:ZOOM IN - S:ZOOM OUT\nARROW KEYS TO MOVE THE MAP").setScrollFactor(0);v.x-=v.width/2;p.add(v);v=a.add.bitmapText(0,180,"font","PRESS SPACE TO CLOSE").setScrollFactor(0);v.setScale(1.5);v.x-=v.width/2;p.add(v);v=a.add.graphics();v.fillStyle(16711680);v.fillCircle(0,0,3);v.visible=!1;p.marker=v;p.add(v);p.setScale(.1);f?(p.x=30,p.y=30):(p.x=a["char"].x-a.cameras.main.scrollX,p.y=a["char"].y-a.cameras.main.scrollY);a.tweens.add({targets:p,
x:400,y:300,scaleX:1.1,scaleY:1.1,duration:500,onComplete:function(){l=!1;p.curZoom=1.1;p.zoomState=0;a.input.keyboard.on("keydown_A",function(a){p.zoomState=1},this);a.input.keyboard.on("keydown_S",function(a){p.zoomState=2},this);a.input.keyboard.on("keyup_A",function(a){p.zoomState=0},this);a.input.keyboard.on("keyup_S",function(a){p.zoomState=0},this);var b=660*m,c=396*k;p.mapWidth=b;p.mapHeight=c;p.marker.visible=!1;for(var d=0;d<h.length;d++)if(h[d]==a.levelNo){var e=Math.floor(d/m);b=-b/2+
660*(d-e*m)+660*a["char"].x/2E3;b*=p.curScale;c=-c/2+396*e+396*a["char"].y/1200;c*=p.curScale;p.marker.x=b;p.marker.y=c;p.marker.visible=!0;c=a.add.graphics();c.fillStyle("0xff0000");c.fillCircle(0,0,3);c.x=p.marker.x;c.y=p.marker.y;p.add(c);a.tweens.add({targets:c,scaleX:3,scaleY:3,alpha:0,duration:500,repeat:-1});break}}});e=p}};this.closeMap=function(){n&&(n=!1,l=!0,a.tweens.add({targets:e,x:20,y:20,scaleX:.02,scaleY:.02,duration:500,onComplete:function(){n=l=!1;e.destroy();e=null;h||a.resume();
a.tweens.add({targets:a.bag,scaleX:1.5,scaleY:1.5,duration:250,yoyo:!0})}}))};this.updateMap=function(){if(!l&&n){var a=e,b=a.curZoom;1==a.zoomState?(a.curZoom+=.1,a.setScale(a.curZoom)):2==a.zoomState&&(a.curZoom-=.1,1.1>a.curZoom&&(a.curZoom=1.1),a.setScale(a.curZoom));if(1==a.zoomState||2==a.zoomState)a.x=400-(400-a.x)*a.curZoom/b,a.y=300-(300-a.y)*a.curZoom/b;b=a.mapWidth*a.curZoom*a.curScale;var c=a.mapHeight*a.curZoom*a.curScale;cursors.right.isDown?a.x-=Math.round(3*a.curZoom):cursors.left.isDown&&
(a.x+=Math.round(3*a.curZoom));cursors.down.isDown?a.y-=Math.round(3*a.curZoom):cursors.up.isDown&&(a.y+=Math.round(3*a.curZoom));700>a.x+b/2?a.x=700-b/2:100<a.x-b/2&&(a.x=100+b/2);450>a.y+c/2?a.y=450-c/2:200<a.y-c/2&&(a.y=200+c/2)}};this.openMapIfHaveIt=function(c){l||(n?this.closeMap():(b[c-1]||a.gamePaused)&&this.openMap(c-1,!1,!0))};this.openPaper=function(b,c,e){if(!m){a.pause();m=d[b].taken=!0;var f="GAME TIP",h=" GAME\nTIP-"+(10>b?"0"+(Number(b)+1):Number(b)+1);c&&g.push({type:0,id:b,text:h});
c=a.add.container(400,800).setScrollFactor(0);var k=a.add.graphics();k.fillStyle(16776868);k.fillRect(-240,-20,480,40);f=a.add.bitmapText(0,0,"fontDark",f);f.setScale(1.5);f.x=-f.width/2;spaceText=a.add.bitmapText(0,0,"fontDark","PRESS SPACE\nTO CONTINUE");spaceText.setScale(1.5);spaceText.x=-spaceText.width/2;h=a.add.image(0,-25,"atlas","paperLarge");var n=a.add.image(0,25,"atlas","paperLarge");c.add(k);c.add(f);c.add(spaceText);var l=[h,-200,n,200,f,-170,spaceText,120];if(0==b){b=a.add.bitmapText(0,
0,"fontDark","YOU NEED TO FIND THREE KEYS\nTO UNLOCK THE CHAMPION ROOM");b.setScale(1);b.x=-b.width/2;c.add(b);f=a.add.sprite(-50,0,"atlas","redKey");var x=a.add.sprite(0,0,"atlas","greenKey"),z=a.add.sprite(50,0,"atlas","blueKey");c.add(f);c.add(x);c.add(z);l.push(b,-100,f,-30,x,-30,z,-30);b=a.add.bitmapText(0,-20,"fontDark","ONE OF THE KEY IS IN THIS ROOM\nFOR THE REST OF THE KEYS YOU\nNEED TO SEARCH OTHER ROOMS");b.setScale(1);b.x=-b.width/2;c.add(b);l.push(b,20)}else 1==b?(b=a.add.bitmapText(0,
-80,"fontDark","THIS CAVE CONSIST OF 3 SECTIONS.\nEVERY SECTION HAS 6-12 ROOMS(SOME\nOF THEM ARE SECRET ROOMS). \n\nCURRENTLY YOU ARE IN THE FIRST \nSECTION. TO PASS THE NEXT SECTION\nYOU NEED TO FIND AND DEFEAT THE\nSECTION BOSS."),b.setScale(.9),b.x=-b.width/2,c.add(b),l.push(b,-80),b.alphaTransition=!0):2==b?(b=a.add.bitmapText(0,0,"fontDark","SOME OF THE GAME ELEMETS"),b.x=-b.width/2,b.alphaTransition=!0,c.add(b),l.push(b,-140),b=a.add.bitmapText(0,0,"fontDark","SECTION MAP"),b.x=-b.width/2,b.alphaTransition=
!0,c.add(b),l.push(b,-110),b=a.add.sprite(0,0,"atlas","map"),c.add(b),l.push(b,-80),b=a.add.bitmapText(0,0,"fontDark","A MAP SHOWING ALL OF THE ROOMS\n(EXCEPT SECRET ROOMS)IN A SECTION.\nTHESE MAPS ARE HARD TO FIND.THEY\nARE USUALLY FOUND IN SECRET ROOMS."),b.setScale(.9),b.alphaTransition=!0,b.x=-b.width/2,c.add(b),l.push(b,-65),b=a.add.bitmapText(0,0,"fontDark","CANNON"),b.x=-b.width/2,b.alphaTransition=!0,c.add(b),l.push(b,20),b=a.add.sprite(0,0,"atlas","cannon"),c.add(b),l.push(b,45),b=a.add.bitmapText(0,
0,"fontDark","A CANNON CAN FIRE 3 TYPE OF BULLET.\nCANNONBALL,LASER AND HOMING MISSILE"),b.setScale(.9),b.x=-b.width/2,b.alphaTransition=!0,c.add(b),l.push(b,60)):3==b?(b=a.add.bitmapText(0,0,"fontDark","WELCOME TO THE SECTION 2!"),b.x=-b.width/2,b.alphaTransition=!0,c.add(b),l.push(b,-105),b=a.add.bitmapText(0,0,"fontDark","LAST SECTION WAS SOME SORT OF\nTUTORIAL.NOW YOU KNOW MANY THINGS\nABOUT THE CAVE. GET READY FOR SOME\nREAL CHALLENGE"),b.setScale(.9),b.alphaTransition=!0,b.x=-b.width/2,c.add(b),
l.push(b,-70),b=a.add.bitmapText(0,0,"fontDark","THIS TIME THERE IS NO KEY.YOU JUST\nNEED TO FIND AND DEFEAT THE BOSS."),b.setScale(.9),b.alphaTransition=!0,b.x=-b.width/2,c.add(b),l.push(b,20)):4==b?(b=a.add.bitmapText(0,-80,"fontDark","THIS SECTION BOSS HAS A WEAKNESS\nHE TURNS SLOWLY. JUMP HIS BACK\nAND USE YOUR ARROW TO HIT HIM."),b.setScale(.9),b.x=-b.width/2,c.add(b),l.push(b,-80),b.alphaTransition=!0):5==b&&(b=a.add.bitmapText(0,0,"fontDark","WELCOME TO THE SECTION 3!"),b.x=-b.width/2,b.alphaTransition=
!0,c.add(b),l.push(b,-105),b=a.add.bitmapText(0,0,"fontDark","THIS IS THE MOST COMPLICATED SECTION.\nYOU SHOULD DEFINITLY FIND THE MAP.\nIT IS HIDDEN SOMEWHERE AS USUAL."),b.setScale(.9),b.x=-b.width/2,b.alphaTransition=!0,c.add(b),l.push(b,-70),b=a.add.bitmapText(0,0,"fontDark","ALSO IT WILL BE GOOD IF YOU HAVE\nCOLLECTED ALL THE ITEMS IN PREVIOUS\nSECTIONS. THEY CAN HELP YOU A LOT"),b.setScale(.9),b.x=-b.width/2,b.alphaTransition=!0,c.add(b),l.push(b,-10),b=a.add.bitmapText(0,0,"fontDark","IF YOU HAVEN'T FIND ALL OF THE ITEMS\nYOU CAN ALWAYS GO BACK WITH\n OPTIONS > LOBBY"),
b.setScale(.9),b.x=-b.width/2,b.alphaTransition=!0,c.add(b),l.push(b,50));c.add(h);c.add(n);c.scaleX=c.scaleY=.15;c.x=a["char"].x-a.cameras.main.scrollX;c.y=a["char"].y-a.cameras.main.scrollY;e&&(c.scaleX=c.scaleY=.05,c.x=30,c.y=30);e=$jscomp.makeIterator(l);for(h=e.next();!h.done;h=e.next())b=h.value,b.alphaTransition&&(b.alpha=0);a.tweens.add({targets:c,scaleX:1.2,scaleY:1.2,x:400,y:300,duration:500,onComplete:function(){a.tweens.add({targets:k,scaleY:10,y:0,duration:500,ease:"Sine.easeInOut"});
for(var b=0;b<l.length/2;b++)a.tweens.add({targets:l[2*b],y:l[2*b+1],alpha:1,duration:500,ease:"Sine.easeInOut"})}});a.curPaper=c}};this.closePaper=function(){if(a.curPaper){2==a.levelNo&&4==a.tutStep&&(a.tutStep=-1,a.tweens.add({targets:a.bossText,alpha:0,duration:300,delay:700,onComplete:function(){this.targets[0].destroy();a.bossText=a.addTweenText("THE SCROLLS ARE STORED IN YOUR\nINVENTORY CLICK BAG ICON OR \nPRESS 'B' TO OPEN/CLOSE\nYOUR INVENTORY.\nCLICK SCROLLS TO READ AGAIN.",a.bossBall.x+
50,a.bossBall.y-20,1,!1,1E3,function(){a.tutStep=5})}}));var b=a.curPaper;a.curPaper=null;for(var c=b.list,d=c.length-1;0<=d;d--){var e=0,f=0,g=1;d==c.length-1?(e=25,f=1):d==c.length-2?(e=-25,f=1):0==d&&(f=1,g=.1);a.tweens.add({targets:c[d],y:e,alpha:f,scaleY:g,duration:500,ease:"Sine.easeInOut"})}a.tweens.add({targets:b,scaleX:.05,scaleY:.05,x:30,y:30,duration:500,delay:700,onComplete:function(){b.destroy();h||a.resume();m=!1;a.tweens.add({targets:a.bag,scaleX:1.5,scaleY:1.5,duration:250,yoyo:!0})}})}};
this.getKey=function(a){g.push({type:2,no:a,id:{0:"red",1:"green",2:"blue",3:"yellow",4:"orange",5:"white"}[a]+"Key",text:"KEY"})};this.removeKey=function(a){};this.hasKey=function(a){for(var b=$jscomp.makeIterator(g),c=b.next();!c.done;c=b.next())if(c=c.value,2==c.type&&c.no==a)return!0;return!1};this.openMenu=function(){if(!(m||k||n||a.binocularActive)){h=!0;a.pause();c=a.add.container(400,300);var b=a.add.image(0,0,"atlas","inventoryBg").setScrollFactor(0),d=a.add.bitmapText(0,-180,"font","INVENTORY").setScrollFactor(0);
d.setScale(2);d.x=-d.width/2;c.add(b);c.add(d);for(var e,f=-320,l=-120,q={},r=0;r<g.length;q={data:q.data},r++)if(q.data=g[r],!q.data.dontShow){f+=80;240<f&&(f=-240,l+=70);var y=a.add.container(f,l).setScrollFactor(0).setSize(60,60);b=a.add.graphics().setScrollFactor(0);b.fillStyle(0,.5);b.fillRect(0,0,70,60);b.x=-35;b.y=-30;d="paper";2==q.data.type?d=q.data.id:3==q.data.type?d=q.data.text.toLowerCase():4==q.data.type&&(d="map");e=a.add.image(0,-15,"atlas",d).setScrollFactor(0);d=a.add.bitmapText(0,
0,"font",q.data.text).setScrollFactor(0);d.setScale(.7);d.x=-d.width/2;y.add(b);y.add(e);y.add(d);y.setInteractive();c.add(y);if(0==q.data.type)y.on("pointerdown",function(a){return function(){this.openPaper(a.data.id,!1,!0)}}(q),this);else if(4==q.data.type)y.on("pointerdown",function(a){return function(){this.openMap(a.data.id,!1,!0)}}(q),this)}a["char"].body.acceleration.x=0;a["char"].body.acceleration.y=0}};this.closeMenu=function(){if(!m&&c&&!n)return 2==a.levelNo&&5==a.tutStep&&(a.tutStep=-1,
a.tweens.add({targets:a.bossText,alpha:0,duration:300,delay:200,onComplete:function(){this.targets[0].destroy();a.tut2Showed=!0;a.save();var b=a.bossBall.x+50,c=a.bossBall.y-20,d=a.ladders.create(740,920,"atlas","ladder");a.children.sendToBack(d);d=a.ladders.create(740,960,"atlas","ladder");a.children.sendToBack(d);d=a.ladders.create(740,1E3,"atlas","ladder");a.children.sendToBack(d);a.children.sendToBack(a.bg);a.cameras.main.scrollX=0;a.tutStep=6;a.bossText=a.addTweenText("YOU CAN VISIT LOBBY TO CHECK\nACHIEVEMENTS, STATISTICS AND\nCHANGE ROOM.-OPTIONS(ESC) > LOBBY-\nTHIS IS ALL FOR NOW. GOOD LUCK!",
b,c,1,!0,1E4,function(){a.bossText.destroy();a.tweens.add({targets:a.bossBall,y:-50,duration:2E3,onComplete:function(){this.targets[0].destroy();a.bossBall=null}})})}})),h=!1,a.resume(),c.destroy(),c=null,!0}},RealGameTime:function(){var a,c=!1;this.getElapsedTime=function(){if(c)return 0;var e=a;a=(new Date).getTime();return e?a-e:0};this.pause=function(){c=!0};this.resume=function(){c=!1;a=(new Date).getTime()}},addAnimation:function(a,c,e,d,b,f,g){a.anims.get(c)||(void 0===g&&(g=0),a.anims.create({key:c,
frames:a.anims.generateFrameNumbers(e,{start:d,end:b,first:d}),frameRate:f,repeat:g}))},Char:function(a,c,e){var d=a.physics.add.sprite(c,e,"player");d.locked=!1;d.wasLocked=0;d.lockedTo=null;d.alive=!0;d.isThrowing=!1;d.onLadder=!1;d.onTopOfLadder=!1;d.onIce=!1;d.canThrow=!0;d.jumpSpotJump=!1;d.jumpSpotTimer=0;d.freeze=!1;d.freezeMovement=!1;d.freezeBow=!1;d.freezeTeleport=!1;d.arrowCharged=!1;d.upUp=!0;d.upTimer=0;d.immune=!1;d.hasAirTank=0;d.acc=400;d.windAcc=new Phaser.Geom.Point(0,0);d.maxVelocity=
250;d.swimAbility=0;d.chargeSpeed=2;d.air=100;d.airSpeed=.2;var b=[!1,!1,!1,!1,!1],f=0;d.powerBar=a.add.graphics();d.powerBar.dontDestroy=!0;d.waterBar=a.add.graphics();d.waterBar.dontDestroy=!0;d.waterBar.setScrollFactor(0);a.anims.create({key:"throw",frames:a.anims.generateFrameNames("player",{prefix:"Char_Throw instance ",start:1,end:4,zeroPad:2}),frameRate:60,repeat:0,onComplete:function(){}.bind(this)});d.reset=function(){this.air=100;this.locked=!1;this.wasLocked=0;this.lockedTo=null;this.alive=
!0;this.onIce=this.onTopOfLadder=this.onLadder=this.isThrowing=!1;this.canThrow=!0;this.jumpSpotJump=!1;this.jumpSpotTimer=0;this.arrowCharged=this.freezeTeleport=this.freezeBow=this.freezeMovement=this.freeze=!1;this.upUp=!0;this.upTimer=0;this.acc=400;this.immune=!1;0==this.hasAirTank?0:1};d.activateAbility=function(b){0==b?(this.acc=650,this.defMaxVelocity=this.maxVelocity,this.maxVelocity=450):1==b&&(this.immune=!0,this.shield||(this.shield=a.add.sprite(this.x,this.y,"atlas","bubble").setScale(2),
this.shield.alpha=.6))};d.deactivateAbility=function(a){0==a?(this.acc=400,this.maxVelocity=this.defMaxVelocity):1==a&&(this.immune=!1,this.shield&&(this.shield.destroy(),this.shield=null))};d.updateAbilities=function(a){a.swim&&(this.swimAbility=.02*a.swim);a.move&&(this.maxVelocity=250+50*a.move);a.chargeSpeed&&(this.chargeSpeed=2+a.chargeSpeed);a.airConsume&&(this.airSpeed=.2-.1*a.airConsume);a.airbar&&(this.hasAirTank=1)};d.update=function(){if(d.alive){this.shield&&(this.shield.x=this.x,this.shield.y=
this.y-2);var c=d.body,e=c.blocked.down||c.touching.down||this.locked;0<this.wasLocked&&!this.locked&&(this.wasLocked--,this.body.bottom<this.wasLockedTo.body.top&&(this.wasLocked=0,this.wasLockedTo=null));if(this.locked){var k=this.lockedTo.x-this.lockedTo.prevX;0<this.lockedTo.parentObj.vx&&!this.body.blocked.right?this.x+=k:this.body.blocked.left||(this.x+=k);this.body.velocity.y=10*this.lockedTo.parentObj.vy;this.body.position.y=this.lockedTo.y-30;this.y=this.lockedTo.y-30;if(this.body.blocked.left||
this.body.blocked.right)this.body.velocity.x=0;if(this.body.right+3<this.lockedTo.body.left||this.body.left-3>this.lockedTo.body.right||this.body.blocked.up&&0>this.body.velocity.y||this.body.blocked.down&&0<this.body.velocity.y)k=this.lockedTo.y-this.lockedTo.prevY,this.body.velocity.y=0<k?100*k:0,this.body.position.y+=5,this.locked=!1,this.wasLockedTo=this.lockedTo,this.lockedTo=null,this.wasLocked=30;this.lockedTo&&(this.lockedTo.prevX=this.lockedTo.x,this.lockedTo.prevY=this.lockedTo.y)}b[f]=
e;f++;f>=b.length&&(f=0);k=c.velocity.x;!a.keyController.right||this.freeze||this.freezeMovement?!a.keyController.left||this.freeze||this.freezeMovement?(c.acceleration.x=0,this.inWind&&0!=this.windAcc.x?0>c.velocity.x*this.windAcc.x&&(c.velocity.x*=.9):0==this.body.velocity.y&&this.onIce||(c.velocity.x=10>Math.abs(c.velocity.x)?0:this.onIce?.99*c.velocity.x:.9*c.velocity.x)):(0<c.velocity.x&&!this.inWind&&(c.velocity.x=0),this.body.acceleration.x=-this.acc,this.flipX=!0,this.jumpSpotTimer-=3,this.jumpSpotJump&&
0<c.velocity.x&&(this.jumpSpotTimer-=7)):(0>c.velocity.x&&!this.inWind&&(c.velocity.x=0),c.acceleration.x=this.acc,this.flipX=!1,this.jumpSpotTimer-=3,this.jumpSpotJump&&0>c.velocity.x&&(this.jumpSpotTimer-=7));var n=this.maxVelocity;this.inWind?(c.acceleration.x+=this.windAcc.x,c.acceleration.y=this.windAcc.y,0<c.velocity.x*this.windAcc.x?n*=2:c.velocity.x*=.98):c.acceleration.y=0;1E3<Math.abs(c.velocity.y)&&(c.velocity.y=1E3*c.velocity.y/Math.abs(c.velocity.y));Math.abs(c.velocity.x)>n&&(c.velocity.x=
n*c.velocity.x/Math.abs(c.velocity.x));this.jumpSpotJump&&(c.velocity.x=k,this.jumpSpotTimer--,0>this.jumpSpotTimer&&(c.velocity.x=.98*k,Math.abs(c.velocity.x)<d.maxVelocity&&(this.jumpSpotJump=!1)));20>this.x&&(this.x=20);2E3<this.x&&(this.x=2E3);a.keyController.up&&this.upCheck();a.keyController.up||(this.upTimer=0,this.upUp=!0);if(a.keyController.down&&!this.freeze&&!this.freezeTeleport){if(this.onLadder||this.onTopOfLadder){this.body.velocity.y=150;return}this.inWater&&(this.body.velocity.y=150)}this.arrowCharged&&
(this.chargeValue+=2,100<this.chargeValue&&(this.chargeValue=100),this.powerBar.clear(),this.powerBar.fillStyle(10027008),this.powerBar.fillRect(0,0,this.chargeValue/2,10),this.powerBar.x=this.x-25,this.powerBar.y=this.y-50);this.isThrowing||(e?!a.keyController.right&&!a.keyController.left||this.freeze?this.anims.play("stand",!0):this.anims.play("run",!0):(this.anims.play("jump"),this.anims.stop()));this.inWater?(0>=this.air&&this.alive&&(1==this.hasAirTank?(this.air=50,this.hasAirTank=2):(this.die(!0),
a.newLevel(!0))),this.air-=this.airSpeed,this.waterBar.clear(),this.waterBar.fillStyle(11398644),this.waterBar.fillRect(250,100,300,20),this.waterBar.fillStyle(3847876),this.waterBar.fillRect(250,100,3*this.air,20),this.body.velocity.x*=.95+this.swimAbility,this.body.velocity.y*=.9+2*this.swimAbility):(this.waterBar.clear(),this.air=100)}};d.moveBlockSeperator=function(a,b){!d.locked&&0==d.wasLocked&&d.body.bottom<b.body.top+5&&(d.locked=!0,d.lockedTo=b,b.prevX=b.x,b.prevY=b.y,b.playerLocked=!0,d.body.velocity.y=
0)};d.upCheck=function(){this.upTimer++;if(this.onLadder&&!this.onTopOfLadder)this.body.velocity.y=-150,this.upUp=!1;else if(this.inWater)this.body.velocity.y=-150,this.wasinWater=!0;else if(this.wasinWater)this.body.velocity.y=-300,this.wasinWater=!1;else{var a=!1;this.onTopOfLadder&&this.upUp&&(a=!0);this.onTopOfLadder=this.upUp=!1;if(!(30<this.upTimer)){for(var c=0;c<b.length;c++){if(b[c]){a=!0;break}b[c]=!1}a&&(this.locked&&(this.wasLockedTo=this.lockedTo,this.wasLocked=30),this.locked=!1,this.lockedTo=
null,this.jump(0,-320),this.jumpedBefore=!0)}}};d.jump=function(b,c,e){e||this.jumpedBefore||(app.soundManager.playSfx(a,"charjump"),a.time.addEvent({delay:100,callback:function(){d.jumpedBefore=!1},callbackScope:this,repeat:0}));this.freeze||this.freezeMovement||(b&&this.body.setVelocityX(b),c&&(d.locked&&0>this.lockedTo.parentObj.vy?this.body.setVelocityY(c+200*this.lockedTo.parentObj.vy):this.body.setVelocityY(c)))};d.chargeArrow=function(){a.gamePaused||this.isThrowing||!this.canThrow||!this.alive||
this.freeze||this.freezeBow||(this.arrowCharged=!0,this.chargeValue=0)};d["throw"]=function(b){if(this.alive&&this.arrowCharged){a.achievements.openCountable("arrowthrow");app.soundManager.playSfx(a,"throw");this.powerBar.clear();this.arrowCharged=!1;this.chargeValue=100<this.chargeValue?100:this.chargeValue;var c=300+7*this.chargeValue;this.isThrowing=!0;this.anims.play("throw",!0);this.once("animationcomplete",function(){d.isThrowing=!1;a.addBox(b,c)},this);this.canThrow=!1;a.time.addEvent({delay:300,
callback:function(){d.canThrow=!0},callbackScope:this,repeat:0})}};d.throwed=function(){this.isThrowing=!1};d.die=function(b){if(!this.alive||this.immune&&!b)return!1;a.achievements.openCountable("chardie");app.soundManager.playSfx(a,"chardie");this.powerBar.clear();this.lockedTo=null;this.locked=!1;this.wasLocked=0;this.alive=!1;this.anims.play("die",!0);this.body.velocity.x=0;this.body.acceleration.x=0;return!0};return d},Boss1:function(a,c,e,d,b,f){function g(){A=f.addEmitter("boxparticle",{angle:{min:180,
max:360},speed:{min:100,max:200},quantity:3,lifespan:1E3,alpha:{start:1,end:0},scale:{start:2,end:2},on:!1,tint:16711680})}function m(){if(!this.inView){var b=a.cameras.main;375>Math.abs(this.x-d.x)&&510>d.y&&(this.inView=!0,this.emit("inview",this),r.remove(m),r.add(k),q.start(),b.stopFollow(),a.tweens.add({targets:b,scrollX:1180,scrollY:0,duration:500,onComplete:function(){h.cameraX=b.scrollX;h.cameraY=b.scrollY}}))}}function k(){q.done&&(r.remove(k),a.children.bringToTop(u),a.tweens.add({targets:u,
y:220,ease:"linear",duration:1E3,repeat:0,delay:500,callback:function(){a.tweens.add({targets:u,y:-100,ease:"linear",duration:1E3,repeat:0,delay:3E3,callback:function(){h.isStarted=!0;h.emit("fight",this);r.add(n);h.immune=!1;l.showAll()}})}}))}function n(){if(0==this.state)this.state=1,this.anims.play("move");else if(1==this.state)d.x<this.x?(this.body.velocity.x=-this.speed,this.flipX=!0):(this.body.velocity.x=this.speed,this.flipX=!1),Math.random()<this.jumpChance&&150<Math.abs(d.x-this.x)&&this.jump(),
10>Math.abs(d.x-this.x)&&(this.body.velocity.x=0,80<Math.abs(d.y-this.y)&&this.jump());else if(2==this.state)this.body.onFloor()&&0<=this.body.velocity.y&&(this.state=1,this.shakeNext&&(a.cameras.main.shake(300,.01),this.shakeNext=!1),this.anims.play("move"));else if(5==this.state){this.state5Time--;0>this.state5Time&&(this.speed-=2,this.speed<this.defSpeed&&(this.state=1,this.immune=!1,this.speed=this.defSpeed,this.setTint(16777215)));if(0==this.body.velocity.x||1210>this.x||1900<this.x)this.flipX=
!this.flipX,this.body.velocity.x=this.flipX?-this.speed:this.speed;0==this.body.velocity.y&&110>Math.abs(d.x-this.x)&&50<Math.abs(d.y-this.y)&&(this.body.velocity.y=-350)}}var h=a.physics.add.sprite(c,e,"boss1");h.setBounce(0);h.setCollideWorldBounds(!0);h.flipX=!0;h.immune=!0;h.isStarted=!1;h.inView=!1;h.health=100;h.dead=!1;h.speed=100;h.wallTimer=0;h.jumpChance=.03;h.throwChance=.03;h.shakeNext=!1;var l=new app.BossHealth(a,200,50,h);l.hideAll();var p=a.physics.add.group(),t=a.physics.add.overlap(b,
p,function(a,b){A.emitParticleAt(b.x,b.y);b.destroy()}),w=a.physics.add.overlap(d,p,function(){h.emit("chardead",!0)}),A,u=a.add.bitmapText(0,-100,"font"," DEFEAT\n THE RABBID");u.setScale(2.5);u.setScrollFactor(0);u.x=400-u.width/2;h.state=0;h.reset=function(){h.flipX=!0;h.immune=!1;h.isStarted=!1;h.health=100;h.dead=!1;h.speed=100;h.wallTimer=0;h.state=0;h.jumpChance=.01;h.throwChance=.03;h.shakeNext=!1;h.x=c;h.y=e;h.body.velocity.x=0;h.body.velocity.y=0;h.body.allowGravity=!0;g();h.setTint(16777215);
for(var a=p.getChildren(),b=a.length-1;0<=b;b--)a[b].destroy();l.reset()};h.adjustDepths=function(){l.bringToTop()};g();var q=new app.BossSpeech(a,[{text:" WELL DONE!\nYOU MADE THIS FAR",x:c-150,y:e-80,tween:{duration:300,delay:500,waitDelay:2E3}},{text:"READY FOR A RIDE?",x:c-130,y:e-80,tween:{duration:300,delay:500,waitDelay:2E3}}]);a.anims.get("move")||(a.anims.create({key:"move",frames:a.anims.generateFrameNumbers("boss1",{start:6,end:11,first:6}),frameRate:10,repeat:-1}),a.anims.create({key:"bossjump",
frames:a.anims.generateFrameNumbers("boss1",{start:2,end:3,first:2}),frameRate:10}),a.anims.create({key:"brawl",frames:a.anims.generateFrameNumbers("boss1",{start:0,end:2,first:0}),frameRate:10,repeat:2}),a.anims.create({key:"bossdead",frames:a.anims.generateFrameNumbers("boss1",{start:12,end:17,first:12}),frameRate:10,repeat:0}));var r={list:[],add:function(a){this.list.push(a)},remove:function(a){this.list.splice(this.list.indexOf(a),1)}};r.add(m);h.update=function(){for(var c=$jscomp.makeIterator(r.list),
e=c.next();!e.done;e=c.next())e.value.call(h);e=p.children.entries;c=$jscomp.makeIterator(e);for(e=c.next();!e.done;e=c.next()){e=e.value;e.rotation+=0<e.body.velocity.x?.01:-.01;if(230>e.x||928<e.x)e.body.velocity.x=0;590<e.y&&(A.emitParticleAt(e.x,e.y),e.destroy())}e=b.children.entries;c=new Phaser.Geom.Rectangle(this.body.position.x+15,this.body.position.y+15,this.body.width-30,this.body.height-20);Phaser.Geom.Intersects.RectangleToRectangle(c,d.getBounds())&&h.emit("chardead",!0);var f=$jscomp.makeIterator(e);
for(e=f.next();!e.done;e=f.next())if(e=e.value,Phaser.Geom.Intersects.RectangleToRectangle(c,e.getBounds())&&(e.parentObj==a.arrow&&(a.arrow=null),e.mark.destroy(),e.destroy(),d.alive&&!this.immune)){this.health-=25;this.jumpChance+=.02;this.throwChance+=.02;this.defSpeed=this.speed+=20;this.body.velocity.x=0;this.state=4;this.immune=!0;l.reduce(4);if(h.dead)break;this.anims.play("brawl");this.setTint(16755370);this.once("animationcomplete",function(){this&&4==this.state&&(this.state=5,this.state5Time=
150,this.speed*=3,this.body.velocity.x=this.flipX?-this.speed:this.speed,this.anims.play("move"))},this)}};h.jump=function(){app.soundManager.playSfx(a,"jump");this.body.velocity.y=-500;this.state=2;this.anims.play("bossjump")};h.die=function(){this.anims.play("bossdead");this.dead=!0;this.once("animationcomplete",function(){this.emit("bossdead")})};h.clear=function(){for(var a=p.getChildren(),b=a.length-1;0<=b;b--)a[b].destroy();l.destroy();t&&t.destroy();w.destroy();u.destroy();this.destroy()};
return h},Boss2:function(a,c,e,d,b,f){function g(){A=f.addEmitter("boxparticle",{angle:{min:180,max:360},speed:{min:100,max:200},quantity:3,lifespan:1E3,alpha:{start:1,end:0},scale:{start:2,end:2},on:!1,tint:16711680})}function m(){if(!this.inView){var b=a.cameras.main;415>Math.abs(this.x-d.x)&&510>d.y&&(this.inView=!0,this.emit("inview",this),r.remove(m),r.add(k),q.start(),b.stopFollow(),a.tweens.add({targets:b,scrollX:1180,scrollY:0,duration:500,onComplete:function(){h.cameraX=b.scrollX;h.cameraY=
b.scrollY}}))}}function k(){q.done&&(r.remove(k),u.visible=!0,a.tweens.add({targets:u,y:220,ease:"linear",duration:1E3,repeat:0,delay:500,callback:function(){a.tweens.add({targets:u,y:-100,ease:"linear",duration:1E3,repeat:0,delay:3E3,callback:function(){h.isStarted=!0;h.emit("fight",this);r.add(n);h.immune=!1;l.showAll()}})}}))}function n(){if(0==this.state)this.turnTimer=this.shootTimer=0,this.state=1,this.anims.play("cowboymove");else if(1==this.state){if(this.flipX&&h.x>d.x||!this.flipX&&h.x<
d.x?this.body.velocity.x=this.speed*(this.flipX?-1:1):(this.body.velocity.x=0,this.state=2),this.shootTimer++,this.shootTimer>2*this.shootTime){this.shootTimer=0;this.state=5;this.anims.play("cowboyshoot");var a=this.x+20*(this.flipX?-1:1);a=p.create(a,this.y+10,"atlas","ball");a.body.velocity.x=300*(this.flipX?-1:1);a.body.allowGravity=!1}}else 2==this.state?(this.turnTimer++,this.turnTimer>this.turnTime&&(this.state=1,this.turnTimer=0,d.x<this.x?(this.body.velocity.x=-this.speed,this.flipX=!0):
(this.body.velocity.x=this.speed,this.flipX=!1))):4==this.state?(this.hitTimer++,this.hitTimer>this.hittedTime&&(this.hitTimer=0,this.state=1,this.anims.play("cowboymove"),this.immune=!1,this.setTint(16777215)),this.flipX=d.x<this.x?!0:!1,this.shootTimer++,this.shootTimer>2*this.shootTime&&(this.shootTimer=0,a=this.x+20*(this.flipX?-1:1),a=p.create(a,this.y+10,"atlas","ball"),a.body.velocity.x=300*(this.flipX?-1:1),a.body.allowGravity=!1)):5<=this.state&&(this.state++,15<this.state&&(this.state=1,
this.anims.play("cowboymove")))}var h=a.physics.add.sprite(c,e,"cowboy");h.setBounce(0);h.setCollideWorldBounds(!0);h.flipX=!0;h.immune=!0;h.isStarted=!1;h.inView=!1;h.health=100;h.dead=!1;h.speed=100;h.wallTimer=0;h.jumpChance=.03;h.throwChance=.03;h.shakeNext=!1;h.turnTime=80;h.hittedTime=150;h.shootTime=60;var l=new app.BossHealth(a,200,50,h);l.hideAll();var p=a.physics.add.group(),t=a.physics.add.overlap(b,p,function(a,b){a.destroy()}),w=a.physics.add.overlap(d,p,function(a,b){h.emit("chardead",
!0);b.destroy()}),A,u=a.add.bitmapText(400,-100,"font","DEFEAT\nCOWBEAR").setScrollFactor(0);u.setScale(2.5);u.x-=u.width/2;u.visible=!1;h.state=0;h.reset=function(){h.flipX=!0;h.immune=!1;h.isStarted=!1;h.health=100;h.dead=!1;h.speed=100;h.wallTimer=0;h.state=0;h.jumpChance=.01;h.throwChance=.03;h.shakeNext=!1;h.turnTime=80;h.hittedTime=150;h.shootTime=60;h.x=c;h.y=e;h.body.velocity.x=0;h.body.velocity.y=0;h.body.allowGravity=!0;g();h.setTint(16777215);for(var a=p.getChildren(),b=a.length-1;0<=b;b--)a[b].destroy();
l.reset()};h.adjustDepths=function(){l.bringToTop()};g();var q=new app.BossSpeech(a,[{text:"Well well well..\n Good Job",x:c-150,y:e-50,tween:{duration:300,delay:500,waitDelay:2E3}},{text:"Whatch out!\nI maybe slow",x:c-150,y:e-50,tween:{duration:300,delay:500,waitDelay:2E3}},{text:"But I have a gun!",x:c-130,y:e-50,tween:{duration:300,delay:500,waitDelay:2E3}}]);a.anims.get("cowboyidle")||(a.anims.create({key:"cowboyidle",frames:a.anims.generateFrameNumbers("cowboy",{start:0,end:1,first:0}),frameRate:6,
repeat:-1}),a.anims.create({key:"cowboymove",frames:a.anims.generateFrameNumbers("cowboy",{start:2,end:9,first:1}),frameRate:6,repeat:-1}),a.anims.create({key:"cowboyshoot",frames:a.anims.generateFrameNumbers("cowboy",{start:11,end:11,first:11}),frameRate:10,repeat:5}),a.anims.create({key:"cowboydefend",frames:a.anims.generateFrameNumbers("cowboy",{start:12,end:12,first:12}),frameRate:10}),a.anims.create({key:"cowboydead",frames:a.anims.generateFrameNumbers("cowboy",{start:13,end:18,first:13}),frameRate:10,
repeat:0}));h.anims.play("cowboyidle");var r={list:[],add:function(a){this.list.push(a)},remove:function(a){this.list.splice(this.list.indexOf(a),1)}};r.add(m);h.update=function(){for(var c=$jscomp.makeIterator(r.list),e=c.next();!e.done;e=c.next())e.value.call(h);var f=p.children.entries;c=$jscomp.makeIterator(f);for(f=c.next();!f.done;f=c.next())f=f.value,f.rotation+=0<f.body.velocity.x?.01:-.01,590<f.y&&(A.emitParticleAt(f.x,f.y),f.destroy());f=b.children.entries;c=new Phaser.Geom.Rectangle(this.body.position.x+
15,this.body.position.y+15,this.body.width-30,this.body.height-20);Phaser.Geom.Intersects.RectangleToRectangle(c,d.getBounds())&&h.emit("chardead",!0);e=!1;var g=$jscomp.makeIterator(f);for(f=g.next();!f.done;f=g.next()){f=f.value;if(3!=this.state&&30>Math.abs(f.y-this.y)){var k=this.x-f.x;if(this.flipX&&0<k&&100>k||!this.flipX&&0>k&&-100<k)this.wasImmune=this.immune,this.immune=!0,this.anims.play("cowboydefend"),e=!0,this.lastState=this.state,this.lastAnim=this.anims.currentAnim.key,this.state=3}if(Phaser.Geom.Intersects.RectangleToRectangle(c,
f.getBounds())&&(f.parentObj==a.arrow&&(a.arrow=null),f.mark.destroy(),f.destroy(),d.alive&&!this.immune)){this.health-=25;this.jumpChance+=.01;this.throwChance+=.02;this.defSpeed=this.speed+=20;this.shootTime-=8;this.turnTime-=5;this.body.velocity.x=0;this.state=4;this.immune=!0;l.reduce(4);if(h.dead){this.state=-1;return}this.hitTimer=0;this.anims.play("cowboyshoot");this.setTint(16755370)}}e||3!=this.state||(this.anims.play(this.lastAnim),this.immune=this.wasImmune,this.state=this.lastState)};
h.jump=function(){};h.die=function(){this.anims.play("cowboydead");this.dead=!0;this.once("animationcomplete",function(){this.emit("bossdead")})};h.clear=function(){for(var a=p.getChildren(),b=a.length-1;0<=b;b--)a[b].destroy();l.destroy();t.destroy();w.destroy();u.destroy();this.destroy()};return h},Boss3:function(a,c,e,d,b,f,g){function m(){u=f.addEmitter("boxparticle",{angle:{min:180,max:360},speed:{min:100,max:200},quantity:3,lifespan:1E3,alpha:{start:1,end:0},scale:{start:2,end:2},on:!1,tint:16711680})}
function k(){if(!this.inView){var b=a.cameras.main;590>Math.abs(this.x-d.x)&&510>d.y&&(this.inView=!0,this.emit("inview",this),y.remove(k),y.add(n),r.start(),b.stopFollow(),a.tweens.add({targets:b,scrollX:1180,scrollY:0,duration:500,onComplete:function(){l.cameraX=b.scrollX;l.cameraY=b.scrollY}}))}}function n(){r.done&&(y.remove(n),q.visible=!0,a.tweens.add({targets:q,y:220,ease:"linear",duration:1E3,repeat:0,delay:500,callback:function(){a.tweens.add({targets:q,y:-100,ease:"linear",duration:1E3,
repeat:0,delay:3E3,callback:function(){l.isStarted=!0;l.emit("fight",this);y.add(h);l.immune=!1;p.showAll()}})}}))}function h(){0==this.state?(this.shootTimer++,this.shootTimer>this.shootTime&&(this.shootTimer=0,this.state=1,this.anims.play("foxstomp"),this.once("animationcomplete",function(){this&&1==this.state&&(this.state=0,this.throwRock(),this.anims.play("foxidle"))},this))):1==this.state||2!=this.state||this.furyAnim||(this.anims.play("foxstomp"),this.furyAnim=!0,this.once("animationcomplete",
function(){this&&2==this.state&&(this.throwRock(),this.furyRocksLeft--,0>=this.furyRocksLeft&&(this.state=0,this.immune=!1,this.setTint(16777215)),this.furyAnim=!1)},this))}var l=a.physics.add.sprite(c,e,"boss3");l.setBounce(0);l.setCollideWorldBounds(!0);l.flipX=!0;l.immune=!0;l.isStarted=!1;l.inView=!1;l.health=100;l.dead=!1;l.hittedTime=60;l.shootTime=100;l.furyRocks=8;l.weakBlocks=[];l.shakeNext=!1;var p=new app.BossHealth(a,200,50,l);p.hideAll();var t=a.physics.add.group(),w=a.physics.add.overlap(b,
t,function(a,b){u.emitParticleAt(b.x,b.y);a.destroy();b.destroy()}),A=a.physics.add.overlap(d,t,function(a,b){l.emit("chardead",!0)});g.on("change",function(){l.emit("addblocks",!0)});var u,q=a.add.bitmapText(400,-100,"font","DEFEAT\nTHE FOX").setScrollFactor(0);q.setScale(2.5);q.x-=q.width/2;q.visible=!1;l.state=0;l.reset=function(){l.flipX=!0;l.immune=!1;l.health=100;l.dead=!1;l.shootTime=100;l.hittedTime=60;l.visible=!0;l.state=0;l.shakeNext=!1;l.furyRocks=8;l.x=c;l.y=e;l.body.velocity.x=0;l.body.velocity.y=
0;l.body.allowGravity=!0;l.weakBlocks=[];m();l.setTint(16777215);for(var a=t.getChildren(),b=a.length-1;0<=b;b--)a[b].destroy();p.reset()};l.adjustDepths=function(){p.bringToTop()};m();var r=new app.BossSpeech(a,[{text:"Here you are!\n Finally",x:c-130,y:e-80,tween:{duration:300,delay:500,waitDelay:2E3}},{text:"I am the guardian\n of the exit",x:c-130,y:e-80,tween:{duration:300,delay:500,waitDelay:2E3}},{text:"So I won't be\neasy on you",x:c-130,y:e-80,tween:{duration:300,delay:500,waitDelay:2E3}}]);
a.anims.get("foxidle")||(a.anims.create({key:"foxidle",frames:a.anims.generateFrameNumbers("boss3",{start:0,end:1,first:0}),frameRate:6,repeat:-1}),a.anims.create({key:"foxstomp",frames:a.anims.generateFrameNumbers("boss3",{start:2,end:6,first:2}),frameRate:10,repeat:0}),a.anims.create({key:"foxdie",frames:a.anims.generateFrameNumbers("boss3",{start:7,end:11,first:7}),frameRate:10,repeat:0}));l.anims.play("foxidle");l.shootTimer=0;var y={list:[],add:function(a){this.list.push(a)},remove:function(a){this.list.splice(this.list.indexOf(a),
1)},removeAll:function(){this.list=[]}};y.add(k);l.update=function(){for(var c=$jscomp.makeIterator(y.list),e=c.next();!e.done;e=c.next())e.value.call(l);if(this.isStarted)if(this.inView&&this.visible&&1210>d.x&&(d.x=1210),this.inView&&!this.visible&&1210>d.x)d.scene.cameras.main.startFollow(d,!0,.05,.05,-100,0),this.clear(),y.removeAll(),this.destroy(),d.scene.boss=null,g.dontDestroy=!1,g.parentObj.infoTxt.dontDestroy=!1;else{e=t.children.entries;c=$jscomp.makeIterator(e);for(e=c.next();!e.done;e=
c.next())e=e.value,e.rotation+=.05,400<e.body.velocity.y&&(e.body.velocity.y=400),50<e.y&&a.tilePointCheck(e.x,e.y+20)&&(u.emitParticleAt(e.x,e.y),e.destroy(),app.soundManager.playSfx(a,"rockexplode"));e=b.children.entries;c=new Phaser.Geom.Rectangle(this.body.position.x+15,this.body.position.y+15,this.body.width-30,this.body.height-20);Phaser.Geom.Intersects.RectangleToRectangle(c,d.getBounds())&&l.emit("chardead",!0);var f=$jscomp.makeIterator(e);for(e=f.next();!e.done;e=f.next())if(e=e.value,Phaser.Geom.Intersects.RectangleToRectangle(c,
e.getBounds())&&(e==a.arrow&&(a.arrow=null),e.mark.destroy(),e.destroy(),d.alive&&!this.immune)){this.health-=25;this.body.velocity.x=0;this.state=2;this.immune=!0;p.reduce(4);if(l.dead){this.state=-1;this.anims.play("foxdie");this.once("animationcomplete",function(){this.visible=!1});p.hideAll();break}this.furyRocksLeft=this.furyRocks;this.furyRocks++;this.furyAnim=!1;this.setTint(16755370)}}};l.jump=function(){};l.throwRock=function(){app.soundManager.playSfx(a,"stomp");var b=Math.round(1200+600*
Math.random());.5>Math.random()&&(b=d.x);b=t.create(b,-80,"atlas","rock").setScale(2);b.body.allowGravity=!0;b.rotation=2*Math.PI*Math.random()};l.die=function(){this.anims.play("cowboydead");this.dead=!0;this.once("animationcomplete",function(){this.emit("bossdead")})};l.clear=function(){for(var a=t.getChildren(),b=a.length-1;0<=b;b--)a[b].destroy();p.destroy();w.destroy();A.destroy();q.destroy();this.destroy()};return l},BossHealth:function(a,c,e,d){var b=a.add.graphics().setScrollFactor(0);b.dontDestroy=
!0;b.fillStyle(6684672,1);b.fillRect(c,e,405,70);for(var f=[],g=0;16>g;g++){var m=a.add.image(c+25*g+5,e+5,"atlas","health").setScrollFactor(0);m.setOrigin(0);f.push(m)}var k=15;this.reduce=function(b){for(var c=0;c<b;c++){var e=f[k];k--;a.tweens.add({targets:e,alpha:0,ease:"Sine.easeInOut",duration:500,repeat:0,delay:150*c});if(0>k){d.die();break}}};this.reset=function(){for(var a=$jscomp.makeIterator(f),b=a.next();!b.done;b=a.next())b.value.alpha=1;k=15};this.destroy=function(){for(var a=f.length-
1;0<=a;a--)f[a].destroy();b.destroy()};this.hideAll=function(){b.alpha=0;for(var a=f.length-1;0<=a;a--)f[a].alpha=0};this.showAll=function(){b.alpha=1;for(var a=f.length-1;0<=a;a--)f[a].alpha=1};this.bringToTop=function(){a.children.bringToTop(b);for(var c=f.length-1;0<=c;c--)a.children.bringToTop(f[c])}},BossSpeech:function(a,c){function e(){f++;(g=c[f])?(b=a.add.bitmapText(g.x,g.y,"font",g.text),b.alpha=0,a.tweens.add({targets:b,alpha:1,ease:"linear",duration:g.tween.duration,repeat:0,delay:g.tween.delay,
callback:d})):m.done=!0}function d(){a.tweens.add({targets:b,alpha:0,ease:"linear",duration:g.tween.duration,repeat:0,delay:g.tween.waitDelay,callback:e})}var b,f=-1,g;this.done=!1;var m=this;this.start=function(){e()}},EmitManager:function(a){var c=[],e={},d={x:0,y:0,lifespan:500,speed:{min:-100,max:-200},angle:{min:45,max:135},gravityY:300,gravityX:0,scale:{start:.5,end:0},quantity:2,on:!0};this.addEmitter=function(b,f){b=b?b:"particle";f=f?f:{};setDefaultTo(f,d);e[b]||(e[b]=a.add.particles("atlas",
b));var g=e[b].createEmitter(f);c.push(g);return g};this.getEmitter=function(){for(var a=0;a<c.length;a++)if(!c[a].running)return c[a];return this.addEmitter()};this.getEmitterAt=function(a){return c[a]};this.clear=function(){for(var a in e)e.hasOwnProperty(a)&&e[a].destroy();e={};c=[]}}};function setDefaultTo(a,c){for(var e in c)void 0===a[e]&&(a[e]=c[e])}
app.ObjectFactory=function(a,c){function e(a,b,c,d,e,f){this.type="hideblock";this.time=c;this.changeTime=d+c;this.active=e;this.obj=f.create(a,b,"atlas","hideBlock");this.obj.body.enable=this.obj.visible=e;this.obj.parentObj=this;this.holdIt=!1;this.lastGameTime}function d(a){this.type="moveblock";this.obj=a.holder.create(a.x,a.y,"atlas",a.key);this.obj.body.allowGravity=!1;this.obj.body.immovable=!0;this.obj.parentObj=this;this.playerLocked=!1;this.vx=a.speedx;this.vy=a.speedy;this.vx&&(this.left=
a.left,this.right=a.right);this.vy&&(this.top=a.top,this.bottom=a.bottom)}function b(a,b,c,d,e){this.type="jumpspot";this.obj=c.create(a,b,"atlas","jumpSpot");this.obj.body.allowGravity=!1;this.obj.body.immovable=!0;this.vx=d;this.vy=e;this.x=a;this.y=b;this.obj.parentObj=this;this.rot=a=Math.atan2(e,d);this.obj.rotation=a+Math.PI/2}function f(a,b,c,d){this.type="weakBlock";this.obj=c.create(a,b,"atlas","weakBlock");this.obj.parentObj=this;this.baseX=a;this.baseY=b;this.startDestroy=!1;this.destroyTimer=
50;this.active=!0}function g(a,b,c,d){this.type="keyblock";this.obj=c.create(a,b,"atlas",q[d]+"Block");this.no=d;this.active=!0;this.obj.parentObj=this}function m(b){this.type="cannon";this.obj=b.holder.create(b.x,b.y,"atlas","cannon");this.obj.parentObj=this;this.shootTime=b.shootTime;this.changeTime=b.gameTime+b.delay+b.shootTime;this.holder=b.holder;this.cannonType=b.cannonType;this.power=b.power;this.isHoming=b.isHoming;this.obj.rotation=b.rot*Math.PI/180;this.rotSpeed=b.rotSpeed?b.rotSpeed:0;
this.minRot=isNaN(b.minRot)?"none":app.degreeToRadian(b.minRot);this.maxRot=isNaN(b.maxRot)?"none":app.degreeToRadian(b.maxRot);this.locateTo=b.locateToTarget;this.locateRatio=b.locateRatio;this.canFire=!1;this.startX=this.obj.x+20*Math.cos(this.obj.rotation);this.startY=this.obj.y+20*Math.sin(this.obj.rotation);if("laser"==this.cannonType){var d=a.add.graphics();d.lineStyle(5,16711680);d.beginPath();a.children.sendToBack(d);this.laserHolder=d;this.line=null;this.laserActive=b.laserActive;this.codeControl=
b.controlWithCode;this.particles=c.addEmitter("particle",{x:200,y:300,lifespan:500,speed:{min:-100,max:-200},angle:{min:240,max:300},gravityY:300,scale:{start:.4,end:0},quantity:0});this.laserActive&&this.particles.setQuantity(2)}}function k(a,b,c,d,e){this.type="cannonball";this.obj=c.create(a,b,"atlas","ball");this.obj.parentObj=this;this.doExplode=this.isDestroyable=this.isDeathly=!0;this.vx=d;this.vy=e}function n(b,c,d,e,f,h,g){this.type="missile";this.obj=d.create(b,c,"atlas","rocket");this.obj.parentObj=
this;this.isDestroyable=this.isDeathly=!0;this.vx=e;this.vy=f;this.isHoming=h;this.power=Math.sqrt(e*e+f*f);this.obj.rotation=Math.atan2(f,e);this.curving=g?g:3;a.children.sendToBack(this.obj);a.children.sendToBack(a.bg2);a.children.sendToBack(a.bg);this.graphics=a.add.graphics();this.misRot=this.obj.rotation}function h(a,b,c,d,e){this.type="box";this.obj=c.create(a,b,"atlas","box");this.obj.setScale(e/25);"none"!=d&&(this.obj.body.velocity.x=500*(d?-1:1));this.frozen=!1;this.health=20;this.obj.parentObj=
this}function l(a,b,c,d,e,f,h,g,k,l,m,n){this.delay=m?m:0;this.type="leverBlock";this.important=n;k?(k.hasSpike?(this.obj=c.create(a,b,"atlas","leverBlockBigSpike"),this.hasSpike=!0):this.obj=c.create(a,b,"atlas","leverBlockBig"),n=k.height/400,c=100*n,k=400*n,this.obj.setScale(n),l?(this.obj.setRotation(Math.PI/2),this.obj.body.setSize(k,c),m=this.obj.x-k/2,n=this.obj.y-c/2):(this.obj.body.setSize(c,k),m=this.obj.body.x+(100-100*n)/2,n=this.obj.body.y+(400-400*n)/2),this.obj.body.x=m,this.obj.body.y=
n,this.hasSpike&&(this.width=c,this.height=k,l&&(this.doRotate=!0,this.width=k,this.height=c))):(this.obj=c.create(a,b,"atlas","leverBlock"),c=40,k=120,l&&(this.obj.setRotation(Math.PI/2),this.obj.body.setSize(k,c),m=this.obj.body.x-c,n=this.obj.body.y+c,this.obj.body.x=m,this.obj.body.y=n));this.obj.parentObj=this;this.moved=!1;this.baseX=a;this.baseY=b;this.targetX=a+d;this.targetY=b+e;this.bodyBaseX=this.obj.body.x;this.bodyBaseY=this.obj.body.y;this.bodyTargetX=this.obj.body.x+d;this.bodyTargetY=
this.obj.body.y+e;this.active=g;g||(d=this.obj.body.x,e=this.obj.body.y,this.baseX=this.targetX,this.baseY=this.targetY,this.targetX=a,this.targetY=b,this.bodyBaseX=this.bodyTargetX,this.bodyBaseY=this.bodyTargetY,this.bodyTargetX=d,this.bodyTargetY=e,this.obj.setPosition(this.baseX,this.baseY),this.obj.body.x=this.bodyBaseX,this.obj.body.y=this.bodyBaseY);this.duration=f;this.id=h}function p(b,c,d,e,f,h,g,k){this.type="lever";this.id=g;this.important=k;this.obj=d.create(b,c,"atlas","lever2").setOrigin(.5,
1);this.infoTxt=a.add.bitmapText(b,c-80,"font","PRESS SPACE");this.infoTxt.x=b-this.infoTxt.width/2;this.infoTxt.bringToTop=!0;this.infoTxt.visible=!1;this.obj.parentObj=this;this.changing=!1;this.duration=f;this.active=e;this.connectedObjects=h.split(",");this.obj.rotation=e?Math.PI/4:-Math.PI/4}function t(a,b,c,d,e,f,h){this.type="enemy";this.obj=c.create(a,b,"enemy");this.obj.parentObj=this;this.obj.anims.play("enemyMove");this.id=h;this.vx=f/50;this.right=d;this.left=e;this.active=!0;this.obj.flipX=
0<this.vx?!0:!1}function w(b,c,d,e){this.type="checkpoint";this.obj=d.create(b,c,"fire");this.obj.parentObj=this;this.checked=!1;this.text=a.add.bitmapText(b,c-20,"font","CHECKPOINT");this.text.x=b-this.text.width/2;this.text.alpha=0;this.text.bringToTop=!0;this.id=e;this.obj.id=e}function A(a,b,c,d,e,f){this.type="bubbleHole";this.obj=c.create(a,b,"atlas","bubbleHole");this.obj.parentObj=this;this.quantity=f;this.bubbleHolder=c;this.vx=d;this.vy=e;this.rot=a=Math.atan2(e,d);this.obj.rotation=a+Math.PI/
2}function u(a,b,c,d,e,f){this.type="bubble";this.obj=c.create(a,b,"atlas","bubble");this.obj.setScale(.5);this.obj.parentObj=this;this.vx=d+.5-1*Math.random();this.vy=e;this.waterTop=f}var q={0:"red",1:"green",2:"blue",3:"yellow",4:"orange",5:"white"},r;this.addBoxParticle=function(){r=c.addEmitter("boxparticle",{angle:{min:180,max:360},speed:{min:100,max:200},quantity:.2,lifespan:1E3,alpha:{start:1,end:0},scale:{start:.7,end:0},on:!1})};e.prototype={update:function(a){this.holdIt?this.changeTime+=
a-this.lastGameTime:(a>=this.changeTime&&(this.obj.body.enable=this.active=this.obj.visible=!this.active,this.changeTime=a+this.time),this.lastGameTime=a)},stopAndHide:function(){this.holdIt=!0;this.obj.body.enable=this.active=this.obj.visible=!1},"continue":function(){this.holdIt=!1}};d.prototype={update:function(){this.vx&&(this.obj.x+=this.vx,0<this.vx&&this.obj.x>this.right||0>this.vx&&this.obj.x<this.left)&&(this.vx*=-1);this.vy&&(this.obj.y+=this.vy,0<this.vy&&this.obj.y>this.bottom||0>this.vy&&
this.obj.y<this.top)&&(this.vy*=-1)}};b.prototype={jump:function(){a.tweens.add({targets:this.obj,x:this.x-10*Math.round(Math.cos(this.rot)),y:this.y-10*Math.round(Math.sin(this.rot)),ease:"linear",duration:200,yoyo:!0,repeat:0})}};f.prototype={destroy:function(){r.setScale({start:.7,end:0});r.setQuantity(10);r.emitParticleAt(this.obj.x,this.obj.y)}};g.prototype={unlock:function(){this.obj.body.enable=!1;this.obj.visible=!1}};m.prototype={update:function(a,b){"laser"!=this.cannonType&&a>=this.changeTime&&
(this.locateTo?this.canFire=!0:this.fire(a));var c=!1;this.locateTo&&(check=app.checkLine(this.startX,this.startY,this.locateTo.x,this.locateTo.y,b,10),check.didReach&&Math.abs(this.obj.rotation-check.rot)<Math.PI/2&&(c=!0,this.obj.rotation+=(check.rot-this.obj.rotation)*this.locateRatio),this.canFire&&.2>Math.abs(this.obj.rotation-check.rot)&&this.fire(a));!c&&0!=this.rotSpeed&&(this.obj.rotation+=this.rotSpeed,this.obj.rotation>this.maxRot||this.obj.rotation<this.minRot)&&(this.rotSpeed*=-1,this.obj.rotation+=
this.rotSpeed)},laserUpdate:function(a,b){!this.codeControl&&a>=this.changeTime&&(this.laserActive=!this.laserActive,this.laserHolder.clear(),this.changeTime=a+this.shootTime,this.particles.setQuantity(0),this.laserActive&&this.particles.setQuantity(2));this.line=null;if(this.laserActive){var c=app.checkLine(this.startX,this.startY,this.obj.x+800*Math.cos(this.obj.rotation),this.obj.y+800*Math.sin(this.obj.rotation),b,25);this.laserHolder.clear();this.laserHolder.lineStyle(5,16711680);this.laserHolder.moveTo(this.obj.x,
this.obj.y);this.laserHolder.lineTo(c.x,c.y);this.laserHolder.strokePath();this.line=new Phaser.Geom.Line(this.obj.x,this.obj.y,c.x,c.y);this.particles.setPosition(c.x,c.y);c=180*this.obj.rotation/Math.PI+180;this.particles.setAngle({min:c-50,max:c+50})}},checkVolumeDist:function(){var b=this.obj.x-a["char"].x,c=this.obj.y-a["char"].y;this.dist=Math.sqrt(b*b+c*c);this.volume=200/this.dist;1<this.volume&&(this.volume=1)},fire:function(b){this.checkVolumeDist();.3<this.volume&&app.soundManager.playSfx(a,
"fire",this.volume);this.changeTime=b+this.shootTime;this.canFire=!1;var c=Math.cos(this.obj.rotation),d=Math.sin(this.obj.rotation);b=this.obj.x+25*c;var e=this.obj.y+25*d;c*=this.power;d*=this.power;"ball"==this.cannonType?new k(b,e,this.holder,c,d):"missile"==this.cannonType&&new n(b,e,this.holder,c,d,this.isHoming);a.tweens.add({targets:this.obj,x:this.obj.x-10*Math.round(Math.cos(this.obj.rotation)),y:this.obj.y-10*Math.round(Math.sin(this.obj.rotation)),ease:"linear",duration:200,yoyo:!0,repeat:0})}};
n.prototype={remove:function(){this.graphics.destroy()},update:function(a,b,c){this.obj.rotation+=.05;var d=this.obj;if(app.checkLine(d.x,d.y,a,b,c,25,this.graphics).didReach){c=this.curving;var e=180*this.misRot/Math.PI,f=Math.atan((b-d.y)/(a-d.x))/Math.PI*180;b>d.y&&a<d.x&&(f=180- -1*f);b<d.y&&a<d.x&&(f=180+f);b<d.y&&a>d.x&&(f=360- -1*f);a=e;0>a&&(a+=360);a=f-a;3<Math.abs(a)&&(e=0<a?180>a?e+c:e-c:-180>a?e+c:e-c);e=e*Math.PI/180;this.vx=this.power*Math.cos(e);this.vy=this.power*Math.sin(e);this.misRot=
e}}};h.prototype={hitted:function(a){this.health-=a;r.setScale({start:.7,end:0});r.setQuantity(a/10);r.emitParticleAt(this.obj.x,this.obj.y);0>=this.health&&(this.isDead=!0,r.setScale({start:2,end:2}),r.setQuantity(5),r.emitParticleAt(this.obj.x,this.obj.y),this.obj.destroy())},jump:function(a,b){a&&this.obj.body.setVelocityX(a);b&&this.obj.body.setVelocityY(b)},freeze:function(){this.obj.setTint(11184810);this.obj.body.immovable=!0;this.obj.body.allowGravity=!1;this.obj.body.velocity.x=0;this.obj.body.velocity.y=
0;this.frozen=!0;this.health=100}};l.prototype={change:function(){this.moved=!this.moved;this.active=!this.active;a.tweens.add({targets:this.obj,x:this.moved?this.targetX:this.baseX,y:this.moved?this.targetY:this.baseY,ease:"linear",delay:this.delay,duration:this.duration,repeat:0});a.tweens.add({targets:this.obj.body,x:this.moved?this.bodyTargetX:this.bodyBaseX,y:this.moved?this.bodyTargetY:this.bodyBaseY,ease:"linear",delay:this.delay,duration:this.duration,repeat:0})},changeQuick:function(){this.moved=
!this.moved;this.active=!this.active;this.obj.x=this.moved?this.targetX:this.baseX;this.obj.y=this.moved?this.targetY:this.baseY;this.obj.body.x=this.moved?this.bodyTargetX:this.bodyBaseX;this.obj.body.y=this.moved?this.bodyTargetY:this.bodyBaseY}};p.prototype={change:function(){this.changing=!0;for(var b=$jscomp.makeIterator(this.connectedObjects),c=b.next();!c.done;c=b.next()){c=c.value;var d=a.holders.blockHolder.getChildren();d=$jscomp.makeIterator(d);for(var e=d.next();!e.done;e=d.next())(e=
e.value.parentObj)&&e.id==c&&e.change()}this.active=!this.active;a.tweens.add({targets:this.obj,rotation:this.active?Math.PI/4:-Math.PI/4,ease:"linear",duration:this.duration,repeat:0,onComplete:function(){this.targets[0].parentObj.changing=!1}});this.obj.emit("change",!0)},changeQuick:function(){this.active=!this.active;this.obj.rotation=this.active?Math.PI/4:-Math.PI/4}};t.prototype={update:function(){this.obj.x+=this.vx;if(this.obj.x>this.right||this.obj.x<this.left)this.vx*=-1,this.obj.flipX=
0<this.vx?!0:!1},destroy:function(){this.active=!1;this.vx=0;a.tweens.add({targets:this.obj,scaleY:0,y:this.obj.y+16,duration:800,delay:200,ease:"Elastic",easeParams:[1.1,.5]})}};w.prototype={check:function(){if(!this.checked){var b=this.text;a.tweens.add({targets:b,y:b.y-30,alpha:1,duration:500,onComplete:function(){a.tweens.add({targets:b,alpha:0,duration:500,delay:1E3})}});this.checked=!0;this.obj.anims.play("checkPointFire")}},uncheck:function(){this.obj.anims.stop();this.checked=!1}};var y="palette string shoes snorkel speed shield binocular airtank".split(" ");
A.prototype={update:function(){this.water&&100*Math.random()<this.quantity&&new u(this.obj.x+10*Math.cos(this.rot),this.obj.y+10*Math.sin(this.rot),this.bubbleHolder,this.vx,this.vy,this.water.y-this.water.height/2)}};u.prototype={update:function(){this.obj.x+=this.vx;this.obj.y+=this.vy;this.vy-=.05;if(this.obj.y<this.waterTop){var b=a.add.sprite(this.obj.x,this.waterTop-5,"splash");b.play("waterSplash");var c=this.obj.x-a["char"].x,d=this.obj.y-a["char"].y;this.dist=Math.sqrt(c*c+d*d);c=100/this.dist;
.25<c&&app.soundManager.playSfx(a,"splash",c);b.once("animationcomplete",function(){this.destroy()});this.obj.destroy()}}};this.addTimeBlock=e;this.addMoveBlock=d;this.addJumpBlock=b;this.addMoveSpike=function(b,c,d,e,f,h,g){this.type="movespike";this.obj=g.create(b,c,"atlas","moveSpike");this.obj.rotation=Math.atan2(d,e);a.tweens.add({targets:this.obj,x:this.obj.x+d,y:this.obj.y+e,delay:h,ease:"linear",duration:f,yoyo:!0,repeat:-1});this.obj.parentObj=this};this.addKeyBlock=g;this.addKey=function(b,
c,d,e,f,h){this.type="key";this.obj=d.create(b,c,"atlas",q[e]+"Key");this.no=e;this.active=!0;this.obj.parentObj=this;this.id=f;h||a.tweens.add({targets:this.obj,y:this.obj.y-10,duration:500,ease:"Sine.easeInOut",yoyo:!0,repeat:-1})};this.addCannon=m;this.addBox=h;this.addEnemy=t;this.addItem=function(b,c,d,e,f){this.type="item";this.obj=d.create(b,c,"atlas",y[e]);this.obj.parentObj=this;this.id=e;this.active=!0;this.name=y[e];f||a.tweens.add({targets:this.obj,y:this.obj.y-10,duration:500,ease:"Sine.easeInOut",
yoyo:!0,repeat:-1})};this.addBubbleHole=A;this.addLever=p;this.addPaper=function(b,c,d,e,f){this.type="paper";this.obj=d.create(b,c,"atlas","paper");this.obj.parentObj=this;this.id=e;a.tweens.add({targets:this.obj,y:this.obj.y-10,duration:500,ease:"Sine.easeInOut",yoyo:!0,repeat:-1})};this.addMap=function(b,c,d,e){this.type="map";this.obj=d.create(b,c,"atlas","map");this.obj.parentObj=this;this.id=e;a.tweens.add({targets:this.obj,y:this.obj.y-10,duration:500,ease:"Sine.easeInOut",yoyo:!0,repeat:-1})};
this.addCheckPoint=w;this.addLeverBlock=l;this.addWeakBlock=f;this.addMissile=n;this.setGroundLayer=function(a){}};app.degreeToRadian=function(a){return a*Math.PI/180};app.pixelToGrid=function(a,c,e){e||(e=40);return{col:Math.floor(a/e),row:Math.floor(c/e)}};app.asd=function(){for(var a='if( w i n do w.l oc at i on . h r e f .in d exOf ( " k o n g " ) > 0 ) { qq=true;}',c=0;50>c;c++)a=a.replace(" ","");eval(a);return!1};
app.checkLine=function(a,c,e,d,b,f,g){g=Math.atan2(d-c,e-a);f=0<f?f:20;var m=f*Math.cos(g);f*=Math.sin(g);var k=a,n=c;a=Math.floor((e-a)/m)||Math.floor((d-c)/f);c=!0;for(e=0;e<a;e++){if(0>k||2E3<k||0>n||1200<n){c=!1;break}d=$jscomp.makeIterator(b);for(var h=d.next();!h.done;h=d.next()){var l=h.value;if(l.layer){if(h=app.pixelToGrid(k,n),(l=l.layer.data[h.row])&&(h=l[h.col])&&-1!=h.index){c=!1;break}}else if(l.body.enable&&l.getBounds().contains(k,n)){c=!1;break}}if(!c)break;k+=m;n+=f}return{x:k,y:n,
didReach:c,rot:g}};var saveData={levelNo:2,startPointNo:1,curSectionNo:0,tut1Showed:!0,tut2Showed:!0,sections:{section0:[],section1:[],section2:[],section3:[]},inventory:[],achievements:{},abilities:[]};app.canAccessStorage=!0;try{var storage=window.localStorage}catch(a){app.canAccessStorage=!1}app.curSlot=0;app.selectedLevel;app.selectedSection;app.scenes="boot preloader menu levelSelect game none".split(" ");app.musicVolume=.2;app.sfxVolume=.85;
for(var i=0;i<app.scenes.length;i++)app[app.scenes[i]]=app.scenes[i]=new Phaser.Scene(app.scenes[i]);app.config={type:Phaser.AUTO,width:800,height:600,physics:{"default":"arcade",arcade:{gravity:{y:600},debug:!1}},scene:app.scenes};app.gameObject=new Phaser.Game(app.config);app.boot.preload=function(){this.load.image("tiledBg","assets/preloader/tiled_bg.png");this.load.image("title","assets/preloader/title.png");this.load.image("preloadBar","assets/preloader/preloadbar.png")};app.boot.create=function(){this.scene.start("preloader")};
app.SoundManager=function(){var a,c,e,d=[3,4,7,9,11,13,18,20,21,22,25],b=[];this.playSfx=function(a,b,c){app.adRunning||(c=void 0==c?app.sfxVolume:c*app.sfxVolume,a.cache.audio.entries.entries.sfx2&&a.sound.playAudioSprite("sfx2",b,{delay:0,volume:c}))};this.playLoop=function(c,d){if(!app.adRunning&&(a&&a.stop(),c.cache.audio.entries.entries[d])){e=d;for(var f=$jscomp.makeIterator(b),g=f.next();!g.done;g=f.next())if(g=g.value,g.name==d){a=g.soundObj;a.loop=!0;a.resume();a.play();a.volume=app.musicVolume;
"horrorLoop"==d&&0<app.musicVolume&&(a.volume+=.2);this.loopStartTransition(c);return}a=c.sound.add(d);f={delay:0,loop:!0,volume:app.musicVolume};"horrorLoop"==d&&0<app.musicVolume&&(f.volume=app.musicVolume+.2);a.play("",f);this.loopStartTransition(c);b.push({name:d,soundObj:a})}};this.loopStartTransition=function(b){a&&(a.volume=0,b.tweens.add({targets:a,volume:app.musicVolume,duration:1E3}))};this.setMusicVolume=function(b){a.volume=b};this.playCurMusic=function(a){this.playLoop(a,e)};this.playLastMusic=
function(a){e!=c&&(c?this.changeMusic(a,c):this.changeMusic(a,e))};this.changeMusic=function(b,g,m){if("gameLoop"==g){g="calmLoop";for(var f=$jscomp.makeIterator(d),n=f.next();!n.done;n=f.next())if(n.value==m){g="actionLoop";break}}if(e!=g){var h=this;c=e;a?b.tweens.add({targets:a,volume:0,duration:1E3,onComplete:function(){h.playLoop(b,g)}}):this.playLoop(b,g)}};this.stopMusic=function(){a&&(a.stop(),a=null)}};app.soundManager=new app.SoundManager;
app.achievementList=[{name:"Get the bow",desc:"Find the hidden bow.",difficulty:0,img:"bow"},{name:"First of many tips",desc:"Find the first game tip",difficulty:0,img:"paper"},{name:"A little key ",desc:"Find a key",difficulty:0,img:"redKey"},{name:"Secret Room - Water",desc:"Find the water secret room",difficulty:1,img:"secret"},{name:"Secret Room - Blocks",desc:"Find the blocks secret room",difficulty:1,img:"secret"},{name:"Secret Room\nDeep Water",desc:"Find the deep water secret room",difficulty:1,
img:"secret"},{name:"I know a lot",desc:"Collect all of the game tips",difficulty:2,img:"paper"},{name:"Rookie Killer",desc:"Kill 10 monsters",difficulty:0,img:"enemy",frame:1},{name:"Expert Killer",desc:"Kill 25 monster",difficulty:1,img:"enemy",frame:1},{name:"Master Killer",desc:"Kill 50 monster",difficulty:2,img:"enemy",frame:1},{name:"Rookie Slayer",desc:"Defeat 1 champion",difficulty:0,img:"boss1",frame:0},{name:"Expert Slayer",desc:"Defeat 2 champions",difficulty:1,img:"cowboy",frame:0},{name:"Master Slayer",
desc:"Defeat all champions",difficulty:2,img:"boss3",frame:0},{name:"An old map",desc:"Find a section map",difficulty:1,img:"map"},{name:"Map collector",desc:"Find all of the section maps",difficulty:2,img:"map"},{name:"Swim item",desc:"Find a swimming item",difficulty:0,img:"snorkel"},{name:"Ready to swim",desc:"Find all of the swimming items",difficulty:2,img:"airtank"},{name:"Collector",desc:"Collect all of the collectables",difficulty:2,img:"bag"},{name:"Key Collector",desc:"Collect 5 keys",difficulty:1,
img:"whiteKey"},{name:"Item Collector",desc:"Collect all items",difficulty:2,img:"shoes"},{name:"Secret Room\nDeeper Water",desc:"Find the deeper water secret room",difficulty:2,img:"secret"},{name:"No more Rookie",desc:"Complete the game",difficulty:2,img:"player",frame:"Char_Throw instance 01"},{name:"Place not room",desc:"Find a secret place",difficulty:1,img:"secret"},{name:"Many places",desc:"Find all secret places",difficulty:2,img:"secret"},{name:"Speedster",desc:"Use speed ability 3 times",
difficulty:0,img:"speed"},{name:"Shields up",desc:"Use shield ability 3 times",difficulty:0,img:"shield"},{name:"My first coin",desc:"Get a silver coin",difficulty:0,img:"silverCoin",frame:0},{name:"All silvers",desc:"Get all silver coins",difficulty:1,img:"silverCoin",frame:0},{name:"Only gold",desc:"Get a gold coin",difficulty:1,img:"coin",frame:0},{name:"Die hard",desc:"Die less than 10 times in the entire game",difficulty:3,img:"player",frame:0},{name:"Who needs a bow",desc:"Use less than 50 arrows in the entire game",
difficulty:3,img:"arrow"},{name:"Who needs abilities",desc:"Use both abilities less than 4 times in the entire game",difficulty:3,img:"speed"},{name:"Bonk time",desc:"Bonk a monster",difficulty:0,img:"bonk"}];
app.Achievements=function(a,c){c||(c=app.achievementList);var e={gametip:{num:1,achievementNo:1},gametip2:{num:6,achievementNo:6},monster:{num:10,achievementNo:7},monster2:{num:25,achievementNo:8},monster3:{num:50,achievementNo:9},map:{num:1,achievementNo:13},map2:{num:3,achievementNo:14},swimmingitem:{num:1,achievementNo:15},swimmingitem2:{num:3,achievementNo:16},key:{num:5,achievementNo:18},key2:{num:1,achievementNo:2},item:{num:6,achievementNo:19},secretplace:{num:1,achievementNo:22},secretplace2:{num:4,
achievementNo:23},speedability:{num:3,achievementNo:24},shieldability:{num:3,achievementNo:25},silvercoin:{num:1,achievementNo:26},silvercoin2:{num:3,achievementNo:27},goldcoin:{num:1,achievementNo:28}},d=0,b={},f=0;this.bossDefeated=function(a){};this.secretRoomFound=function(a){};this.isOpened=function(a){return b["a"+a]};this.getList=function(){return b};this.openCountable=function(a,c){var d=!1;if(c){if("speed"==c||"shield"==c)return;if("palette"==c||"snorkel"==c||"airtank"==c)d=!0,b.swimmingitem=
b.swimmingitem?b.swimmingitem+1:1}b[a]=b[a]?b[a]+1:1;this.checkAllCollectibles();for(var f in e)0==f.indexOf(a)&&b[a]>=e[f].num&&this.open(e[f].achievementNo),d&&0==f.indexOf("swimmingitem")&&b.swimmingitem>=e[f].num&&this.open(e[f].achievementNo)};this.checkForExtraDifficult=function(){10>b.chardie&&this.open(29);50>b.arrowthrow&&this.open(30);4>b.speedability&&4>b.shieldability&&this.open(31)};this.checkAllCollectibles=function(){this.isOpened(17)||this.isOpened(14)&&this.isOpened(18)&&this.isOpened(19)&&
this.isOpened(6)&&this.isOpened(27)&&this.isOpened(28)&&6<=Number(b.key)&&this.open(17)};this.loadList=function(a){for(var c in a)b[c]=a[c]};this.getAchievementNums=function(){return d};this.resetAchievementNums=function(){d=0};this.resetAddY=function(){f=0};this.open=function(e,m){if(!c[e].opened&&!this.isOpened(e)){var g=100*f;f++;d++;c[e].opened=!0;b["a"+e]=!0;var n=a.add.container().setScrollFactor(0),h=a.add.graphics().setScrollFactor(0);h.fillStyle(0,.7);h.fillRect(-160,-50,320,100);var l=a.add.bitmapText(0,
-30,"font","ACHIEVEMENT UNLOCKED").setScrollFactor(0);l.x=-l.width/2;var p=a.add.bitmapText(0,0,"font",c[e].name.toUpperCase()).setScrollFactor(0);p.x=-p.width/2;n.add(h);n.add(l);n.add(p);n.destroyOnLevelChange=!0;n.x=640;m&&(n.x=160);n.y=-150;a.tweens.add({targets:n,y:50+g,duration:500,ease:"Sine.easeInOut",onComplete:function(){a.tweens.add({targets:n,y:-150,duration:500,delay:2E3,ease:"Sine.easeInOut",onComplete:function(){n.destroy();f--}})}})}}};
app.preloader.init=function(){document.getElementsByTagName("canvas")[0].addEventListener("click",function(){showAd()});this.add.tileSprite(0,0,800,600,"tiledBg").setOrigin(0,0);this.add.sprite(400,20,"title").setOrigin(.5,0);var a=this.add.graphics();a.fillStyle(0);a.fillRect(140,345,520,71);this.bar=this.add.tileSprite(150,350,500,61,"preloadBar").setOrigin(0,0);this.bar.width=0};
app.preloader.preload=function(){this.load.audioSprite("sfx2","sounds/sfx.json",["sounds/sfx.ogg","sounds/sfx.mp3"]);this.load.audio("menuLoop",["sounds/POL-jungle-hideout-short.ogg","sounds/POL-jungle-hideout-short.mp3"]);this.load.audio("loopHorror",["sounds/loopHorrorShort.ogg","sounds/loopHorrorShort.mp3"]);this.load.audio("calmLoop",["sounds/POL-boring-cavern-short.ogg","sounds/POL-boring-cavern-short.mp3"]);this.load.audio("actionLoop",["sounds/POL-mutant-jackrabbit-short.ogg","sounds/POL-mutant-jackrabbit-short.mp3"]);
this.load.audio("bossLoop",["sounds/POL-mission-cobra-short.ogg","sounds/POL-mission-cobra-short.mp3"]);this.load.tilemapTiledJSON("map2","assets/tiles.json");this.load.atlas("player","assets/char2.png","assets/char2.json");this.load.atlas("atlas","assets/atlas.png","assets/atlas.json");this.load.image("font","assets/fonts/font30b.png");this.load.image("fontDark","assets/fonts/font30b_dark.png");this.load.image("water","assets/water.png");this.load.image("tileset","assets/tileset.png");this.load.image("windHorizantal",
"assets/windhorizantal.png");this.load.image("windVertical","assets/windvertical.png");this.load.spritesheet("boss1","assets/boss1.png",{frameWidth:40,frameHeight:40});this.load.spritesheet("cowboy","assets/boss2.png",{frameWidth:60,frameHeight:60});this.load.spritesheet("boss3","assets/boss3.png",{frameWidth:40,frameHeight:40});this.load.spritesheet("fire","assets/fire.png",{frameWidth:14,frameHeight:56});this.load.spritesheet("enemy","assets/enemy.png",{frameWidth:32,frameHeight:32});this.load.spritesheet("splash",
"assets/splash.png",{frameWidth:24,frameHeight:28});this.load.spritesheet("explosion","assets/explosion.png",{frameWidth:32,frameHeight:32});this.load.spritesheet("coin","assets/coin.png",{frameWidth:16,frameHeight:16});this.load.spritesheet("silverCoin","assets/silverCoin.png",{frameWidth:16,frameHeight:16});this.load.on("progress",function(a){this.bar.width=500*a},this)};
app.preloader.create=function(){this.makeAnims();var a={image:"font",width:14,height:18,chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,@:?!-_\u00e7#\"'\u00fc()[]|&/\u00e9\u00f6+=*$\u20ac\u20ac\u011f<>\u015f ",charsPerRow:9,spacing:{x:0,y:0},align:"center"};this.cache.bitmapFont.add("font",Phaser.GameObjects.RetroFont.Parse(this,a));a={image:"fontDark",width:14,height:18,chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,@:?!-_\u00e7#\"'\u00fc()[]|&/\u00e9\u00f6+=*$\u20ac\u20ac\u011f<>\u015f ",
charsPerRow:9,spacing:{x:0,y:0},align:"center"};this.cache.bitmapFont.add("fontDark",Phaser.GameObjects.RetroFont.Parse(this,a));a=this.add.bitmapText(400,500,"font","CLICK ANYWHERE TO CONTINUE").setScale(2);a.x-=a.width/2;this.tweens.add({targets:a,y:a.y-10,ease:"Sine.easeInOut",duration:500,yoyo:!0,repeat:-1});this.clicked=!1;this.input.on("pointerdown",function(){this.clicked||(this.clicked=!0,this.cameras.main.fadeOut(1E3),this.cameras.main.once("camerafadeoutcomplete",function(a){this.scene.start("menu")},
this))},this)};
app.preloader.makeAnims=function(){app.addAnimation(this,"waterSplash","splash",0,7,20,0);app.addAnimation(this,"coinSpin","coin",0,3,7,-1);app.addAnimation(this,"coinSpinSilver","silverCoin",0,3,10,-1);app.addAnimation(this,"checkPointFire","fire",1,4,20,-1);app.addAnimation(this,"enemyMove","enemy",1,7,10,-1);this.anims.create({key:"stand",frames:this.anims.generateFrameNames("player",{prefix:"Char_Idle instance ",start:1,end:4,zeroPad:2}),frameRate:10,repeat:-1});this.anims.create({key:"run",frames:this.anims.generateFrameNames("player",
{prefix:"Char_Run instance ",start:1,end:10,zeroPad:2}),frameRate:10,repeat:-1});this.anims.create({key:"jump",frames:this.anims.generateFrameNames("player",{prefix:"Char_Jump instance ",start:1,end:1,zeroPad:2}),frameRate:5,repeat:-1});this.anims.create({key:"die",frames:this.anims.generateFrameNames("player",{prefix:"Char_Die instance ",start:1,end:9,zeroPad:2}),frameRate:10,repeat:0})};app.preloader.update=function(){};
app.menu.create=function(){app.currentScene=this;app.currentSceneName="menu";app.soundManager.changeMusic(this,"menuLoop");this.cameras.main.fadeIn(1E3);app.loadedValue=null;var a=app.loadStatus()||app.newSave();this.onHold=!1;a=JSON.parse(a);this.curSaveValue=app.lastSave=a;this.askDelete=!1;this.add.tileSprite(0,0,800,600,"tiledBg").setOrigin(0,0);var c=["playButton","creditsButton"],e=[];this.add.sprite(400,20,"title").setOrigin(.5,0);var d=this.add.sprite(790,10,"atlas",app.musicVolume?"soundOn":
"soundOff").setOrigin(1,0).setInteractive({useHandCursor:!0});d.on("pointerdown",function(){0==app.musicVolume?(app.musicVolume=.2,app.sfxVolume=.85,d.setFrame("soundOn"),app.soundManager.playLoop(this,"menuLoop")):(app.musicVolume=0,app.sfxVolume=0,d.setFrame("soundOff"),app.soundManager.stopMusic())},this);for(var b={},f=0;3>f;b={slot:b.slot},f++){b.slot=this.add.container();b.slot.state=0;b.slot.no=f;var g=this.add.sprite(0,0,"atlas","inventoryBg").setScale(.38);b.slot.setSize(228,152);b.slot.setInteractive({useHandCursor:!0});
b.slot.add(g);b.slot.bg=g;g=a[f];b.slot.sectionNo=g.curSection;g.active?(b.slot.state=2,slotAddText(b.slot,"SLOT "+"ABC".charAt(b.slot.no),-100,-70,1),slotAddText(b.slot,"SECTION:"+g.curSection,"center",-20,1.7),slotAddText(b.slot,"ACHIEVEMENTS:"+g.achievementCollected,"center",20,1),g=this.add.sprite(95,-60,"atlas","closeButton").setScale(.7),g.slot=b.slot,g.no=f,g.setInteractive({useHandCursor:!0}),b.slot.add(g),g.on("pointerdown",function(a){return function(){var b=[],c=this.scene;c.askDelete=
!0;var d=c.add.graphics();d.fillRect(0,0,800,600);var e=c.add.image(400,300,"atlas","inventoryBg").setScale(.7,.5),f=c.add.bitmapText(400,250,"font"," ARE YOU SURE TO \nDELETE YOUR PROGRESS?").setScale(1.2);f.x-=f.width/2;var g=c.add.image(300,340,"atlas","inventoryBg").setScale(.2,.1).setInteractive({useHandCursor:!0}).setOrigin(.5,.2),m=c.add.image(500,340,"atlas","inventoryBg").setScale(.2,.1).setInteractive({useHandCursor:!0}).setOrigin(.5,.2);b.push(e,f,g,m,d);f=c.add.bitmapText(300,340,"font",
"YES").setScale(1.2);f.x-=f.width/2;b.push(f);g.txt=f;f=c.add.bitmapText(500,340,"font","NO").setScale(1.2);f.x-=f.width/2;m.txt=f;b.push(f);g.on("pointerover",function(){buttonHover.call(this)});g.on("pointerout",function(){buttonOut.call(this)});g.on("pointerdown",function(){for(var d=$jscomp.makeIterator(b),e=d.next();!e.done;e=d.next())e.value.destroy();c.askDelete=!1;d=a.slot.list;for(e=d.length-1;0<=e;e--)d[e]!=a.slot.bg&&d[e].destroy();slotTextChange(a.slot,"NEW GAME");c.resetSlot(a.slot.no);
a.slot.active=!1;a.slot.state=0;a.slot.sectionNo=0});m.on("pointerover",function(){buttonHover.call(this)});m.on("pointerout",function(){buttonOut.call(this)});m.on("pointerdown",function(){for(var a=$jscomp.makeIterator(b),d=a.next();!d.done;d=a.next())d.value.destroy();c.askDelete=!1});d.alpha=0;c.tweens.add({targets:d,alpha:.5,duration:250})}}(b))):slotTextChange(b.slot,"NEW GAME");b.slot.x=150+250*f;b.slot.y=400;b.slot.text="";b.slot.visible=!1;e.push(b.slot);b.slot.on("pointerover",function(){this.scene.askDelete||
buttonHover.call(this)});b.slot.on("pointerout",function(){buttonOut.call(this)});b.slot.on("pointerdown",function(){if(!this.scene.askDelete&&!this.scene.onHold){this.scene.onHold=!0;0==this.state&&(this.state=1,this.scene.curSaveValue[this.no].active=!0,app.saveStatus(this.scene.curSaveValue));app.curSlot=this.no;app.latestSection=this.sectionNo;var a=this.scene;app.soundManager.playSfx(a,"switch");a.cameras.main.fadeOut(1E3);a.cameras.main.once("camerafadeoutcomplete",function(b){0==app.latestSection?
(app.selectedLevel=1,this.scene.scene.start("game")):this.scene.scene.start("levelSelect");a.onHold=!0},this)}})}app.asd();for(a=0;a<c.length;a++)b=this.add.sprite(400,350+110*a,"atlas",c[a]).setScale(.8),b.no=a,b.setInteractive({useHandCursor:!0}),b.on("pointerover",function(){this.scene.onHold||buttonHover.call(this)}),b.on("pointerout",function(){buttonOut.call(this)}),b.on("pointerdown",function(){this.scene.onHold||(app.soundManager.playSfx(this.scene,"switch"),0==this.no?(showAd(),this.scene.onHold=
!0,this.scene.tweens.add({targets:c,alpha:0,duration:500,ease:"Sine.easeInOut",onComplete:function(){this.parent.scene.onHold=!1;for(var a=$jscomp.makeIterator(e),b=a.next();!b.done;b=a.next())b=b.value,b.visible=!0,b.alpha=0;this.parent.add({targets:e,alpha:1,duration:500,ease:"Sine.easeInOut"})}})):1==this.no&&this.scene.openCredits())}),c[a]=b};
app.menu.openCredits=function(){this.onHold=this.creditsOpened=!0;var a=this.add.container(),c=this.add.image(0,0,"atlas","inventoryBg");c.setScale(800/c.width,600/c.height);var e=this.add.bitmapText(0,-260,"font","CREDITS");e.setScale(2);e.x=-e.width/2;a.add(c);a.add(e);a.x=400;a.y=-500;c=-200;var d={},b=$jscomp.makeIterator([{text:"PROGRAMMING-GAME DESIGN",scale:2,tint:"0x333333"},{text:"MAPACARTA",scale:3,topMargin:20,addLink:"http://www.mapacarta.com"},{text:"(OMER FARUK GUNDUZ)",scale:1.5},{text:"-MUSICS-",
scale:2,topMargin:50,tint:"0x333333"},{text:"All background musics from",scale:1.8,topMargin:20},{text:"(except the loop during conversations)",scale:1.3},{text:"PLAYONLOOP.COM",scale:3,addLink:"https://www.playonloop.com",topMargin:10},{text:"Licensed under Creative Commons by Attribution 4.0",scale:1,addLink:"https://creativecommons.org/licenses/by/4.0/",topMargin:0}]);for(e=b.next();!e.done;d={str:d.str},e=b.next()){d.str=e.value;d.str.topMargin&&(c+=d.str.topMargin);e=this.add.bitmapText(0,c,
"font",d.str.text.toUpperCase());e.setScale(d.str.scale);d.str.tint&&e.setTint(d.str.tint);e.x=-e.width/2;c+=e.height;if(d.str.addLink){var f=this.add.sprite(e.x,e.y,"atlas","hideBlock").setOrigin(0);f.setScale(e.width/f.width,e.height/f.height);f.txt=e;f.alpha=.1;a.add(f);f.setInteractive({useHandCursor:!0});f.on("pointerdown",function(a){return function(){visitLink(a.str.addLink)}}(d));f.on("pointerover",function(){buttonHover.call(this.txt)});f.on("pointerout",function(){buttonOut.call(this.txt)})}a.add(e)}c=
this.add.sprite(0,230,"atlas","buttonBack").setInteractive({useHandCursor:!0}).setOrigin(.5,.25);e=this.add.bitmapText(0,230,"font","BACK").setScale(1.5);e.x-=e.width/2;c.txt=e;a.add(c);a.add(e);c.on("pointerover",function(){app.soundManager.playSfx(this.scene,"hover");this.tw?this.tw.resume():this.tw=this.scene.tweens.add({targets:[this,this.txt],y:this.y-5,duration:250,ease:"Sine.easeInOut",yoyo:!0,repeat:-1})});c.on("pointerout",function(){this.tw&&this.tw.pause()});c.on("pointerdown",function(){this.scene.onHold&&
(app.soundManager.playSfx(this.scene,"switch"),this.scene.tweens.add({targets:a,y:-300,duration:500,ease:"Sine.easeInOut",onComplete:function(){this.targets[0].destroy();this.parent.scene.onHold=!1;this.parent.scene.creditsOpened=!1;this.parent.scene.menuState=0}}))});this.tweens.add({targets:a,y:300,duration:500,ease:"Sine.easeInOut"})};
function buttonHover(){app.soundManager.playSfx(this.scene,"hover");if(this.tw)this.tw.resume();else{var a=[this];this.txt&&a.push(this.txt);this.tw=this.scene.tweens.add({targets:a,y:this.y-5,duration:250,ease:"Sine.easeInOut",yoyo:!0,repeat:-1})}}function buttonOut(){this.tw&&this.tw.pause()}function slotTextChange(a,c){a.curText&&a.curText.destroy();c=a.scene.add.bitmapText(0,0,"font",c).setScale(1.8);c.x-=c.width/2;c.y-=c.height/2;a.add(c);a.curText=c}
function slotAddText(a,c,e,d,b){c=a.scene.add.bitmapText(0,0,"font",c).setScale(b);c.x="center"==e?c.x-c.width/2:e;c.y="center"==d?c.y-c.height/2:d;a.add(c);return c}app.saveStatus=function(a){app.canAccessStorage&&(app.lastSave=a,a=JSON.stringify(a),window.localStorage.setItem("rookieBowman",a))};
app.saveSlot=function(a,c,e){if(app.lastSave&&(app.lastSave[a].curSection!=c||e)){var d=app.lastSave[a].achievementCollected;c>app.lastSave[a].curSection&&(app.lastSave[a].curSection=c,app.latestSection=c);app.lastSave[a].achievementCollected=d+e;app.saveStatus(app.lastSave)}};app.loadStatus=function(){if(app.canAccessStorage)return window.localStorage.getItem("rookieBowman")};
app.newSave=function(){for(var a={},c=0;3>c;c++)a[c]={active:!1,no:c,curSection:0,achievementCollected:0};app.lastSave=a;a=JSON.stringify(a);app.canAccessStorage&&window.localStorage.setItem("rookieBowman",a);return a};app.menu.resetSlot=function(a){if(app.canAccessStorage){this.curSaveValue[a]={active:!1,no:i,curSection:0,achievementCollected:0};var c=JSON.stringify(this.curSaveValue),e=window.localStorage;e.setItem("rookieBowman",c);e.setItem("rookie"+a,"")}};
app.menu.newSave2=function(){for(var a={},c=[],e=[],d=0;3>d;d++){var b={active:!1,no:d,curSection:0,achievementCollected:0};c.push(b);a[d]=b;e.push({levelNo:1,startPointNo:1,curSectionNo:0,tut1Showed:!1,tut2Showed:!1,sections:{section0:[],section1:[],section2:[],section3:[]},inventory:[],achievements:{},abilities:[]})}a=JSON.stringify(a);window.localStorage.setItem("rookieBowman",a);return a};
app.levelSelect.create=function(){app.currentScene=this;app.currentSceneName="levelSelect";var a=this.loadSave();this.add.tileSprite(0,0,800,600,"tiledBg").setOrigin(0,0);this.menuState=0;for(var c=["achievements","statistics","back"],e=-1;e<c.length;e++){if(-1==e){var d=this.add.sprite(400,0,"atlas","buttonBack").setInteractive({useHandCursor:!0}).setScale(2,1.3).setOrigin(.5,.1);d.y=470;var b=this.add.bitmapText(0,-10,"font","CONTINUE").setScale(2.5);b.x-=b.width/2;var f=this.add.bitmapText(0,30,
"font","FROM LAST SAVE").setScale(1.5);f.x-=f.width/2;var g=this.add.container();g.add(b);g.add(f);d.txt=g;g.x=d.x;g.y=d.y}else d=this.add.sprite(660,0,"atlas","buttonBack").setInteractive({useHandCursor:!0}).setOrigin(.5,.25).setScale(.95),b=this.add.bitmapText(660,0,"font",c[e].toUpperCase()).setScale(1.4),b.x-=b.width/2,d.y=560,b.y=560,d.x=140+260*e,b.x=140+260*e-b.width/2,d.txt=b;d.no=e;d.on("pointerover",function(){this.scene.menuOpened||(app.soundManager.playSfx(this.scene,"hover"),this.tw?
this.tw.resume():this.tw=this.scene.tweens.add({targets:[this,this.txt],y:this.y-5,duration:250,ease:"Sine.easeInOut",yoyo:!0,repeat:-1}))});d.on("pointerout",function(){this.tw&&this.tw.pause()});d.on("pointerdown",function(){if(!this.scene.menuOpened&&(app.soundManager.playSfx(this.scene,"switch"),this.tw&&this.tw.pause(),-1!=this.scene.menuState)){var a=this.no;2==a?this.scene.toTheOtherScene("menu"):-1==a?(app.selectedLevel=null,this.scene.toTheOtherScene("game")):0==a?(this.scene.menuState=-1,
this.scene.openAchievements()):1==a&&(this.scene.menuState=-1,this.scene.openStatistics())}})}c=1;a&&a.highestLevelNo&&(c=a.highestLevelNo);a=app.latestSection;var m=[];for(e=1;e<=a;e++)d=this.makeSectionMap(e,c),d.no=e-1,m.push(d),d=m[e-2],b=m[e-3],d&&(d.x-=800),b&&(b.x-=800);var k=m[m.length-1],n=this.add.sprite(30,250,"atlas","arrowMark").setScale(4).setInteractive({useHandCursor:!0});n.flipX=!0;n.moveLeft=!0;var h=this.add.sprite(770,250,"atlas","arrowMark").setScale(4).setInteractive({useHandCursor:!0});
n.visible=h.visible=!1;1<m.length&&(e=function(){if(-1!=this.scene.menuState&&this.visible){this.scene.menuState=-1;var a=this.moveLeft;if(a){var b=1200;var c=m[k.no-1];var d=400;0==m[k.no-1].no&&(n.visible=!1)}else b=-400,c=m[k.no+1],d=400,m[k.no+1].no==m.length-1&&(h.visible=!1);this.scene.tweens.add({targets:k,x:b,duration:500});this.scene.tweens.add({targets:c,x:d,duration:500,onComplete:function(){this.parent.scene.menuState=0;a?h.visible=!0:n.visible=!0;k=this.targets[0]}})}},n.visible=!0,n.on("pointerdown",
e),h.on("pointerdown",e))};
app.levelSelect.openStatistics=function(){this.menuOpened=!0;var a=this.add.container(),c=this.add.image(0,0,"atlas","inventoryBg");c.setScale(800/c.width,600/c.height);var e=this.add.bitmapText(0,-230,"font","STATISTICS");e.setScale(2);e.x=-e.width/2;a.add(c);a.add(e);a.x=400;a.y=-500;c=-180;e=[{text:"PROGRAMMING-GAME DESIGN",scale:2,tint:"0x333333"},{text:"MAPACARTA",scale:3,topMargin:20,addLink:"http://www.mapacarta.com"},{text:"(OMER FARUK GUNDUZ)",scale:1.5},{text:"-MUSICS-",scale:2,topMargin:50,
tint:"0x333333"},{text:"All background musics from",scale:1.8,topMargin:20},{text:"(except the loop during conversations)",scale:1.3},{text:"PLAYONLOOP.COM",scale:3,addLink:"http://www.playonloop.com",topMargin:10}];e=[{text:"Number of deaths",value:"chardie",scale:1.5},{text:"Arrow used",value:"arrowthrow",scale:1.5},{text:"Speed ability used",value:"speedability",scale:1.5},{text:"Shield ability used",value:"shieldability",scale:1.5},{text:"Monsters killed",value:"monster",scale:1.5},{text:"Item collected",
value:"item",scale:1.5},{text:"Key collected",value:"key",scale:1.5},{text:"Section map found",value:"map",scale:1.5},{text:"Game tip collected",value:"gametip",scale:1.5},{text:"Secret place discovered",value:"secretplace",scale:1.5},{text:"Silver coin collected",value:"silvercoin",scale:1.5}];var d=this.openedAchievements,b=$jscomp.makeIterator(e);for(e=b.next();!e.done;e=b.next()){var f=e.value;f.topMargin&&(c+=f.topMargin);(e=d[f.value])||(e=0);e=this.add.bitmapText(0,c,"font",f.text.toUpperCase()+
": "+e);e.setScale(f.scale);f.tint&&e.setTint(f.tint);e.x=-e.width/2;c+=e.height+5;a.add(e)}c=this.add.sprite(0,230,"atlas","buttonBack").setInteractive({useHandCursor:!0}).setOrigin(.5,.25);e=this.add.bitmapText(0,230,"font","BACK").setScale(1.5);e.x-=e.width/2;c.txt=e;a.add(c);a.add(e);c.on("pointerover",function(){app.soundManager.playSfx(this.scene,"hover");this.tw?this.tw.resume():this.tw=this.scene.tweens.add({targets:[this,this.txt],y:this.y-5,duration:250,ease:"Sine.easeInOut",yoyo:!0,repeat:-1})});
c.on("pointerout",function(){this.tw&&this.tw.pause()});c.on("pointerdown",function(){this.scene.menuOpened&&(app.soundManager.playSfx(this.scene,"switch"),this.scene.tweens.add({targets:a,y:-300,duration:500,ease:"Sine.easeInOut",onComplete:function(){this.targets[0].destroy();this.parent.scene.menuOpened=!1;this.parent.scene.menuState=0}}))});this.tweens.add({targets:a,y:300,duration:500,ease:"Sine.easeInOut"})};
app.levelSelect.openAchievements=function(){this.menuOpened=!0;var a=this.add.container(),c=this.add.image(0,0,"atlas","inventoryBg");c.setScale(800/c.width,600/c.height);var e=this.add.bitmapText(0,-260,"font","ACHIEVEMENTS");e.setScale(2);e.x=-e.width/2;var d=[[],[],[],[]];for(f in app.achievementList){var b=app.achievementList[f];b.no=f;d[b.difficulty].push(b)}a.add(c);a.add(e);a.x=400;a.y=-500;var f=-330;b=-200;var g=0,m=["-EASY-","-MEDIUM","-DIFFICULT-","-EXTRA DIFFICULT-"];d=$jscomp.makeIterator(d);
for(c=d.next();!c.done;c=d.next()){var k=c.value;e=this.add.bitmapText(0,b,"font",m[g]);e.setScale(1.5);e.x=-e.width/2;b+=30;a.add(e);g++;for(e=0;e<k.length;e++){var n=k[e],h=this.openedAchievements.hasOwnProperty("a"+Number(n.no));c=this.add.graphics();c.fillStyle("0x333333");c.fillRoundedRect(0,0,60,60,10);c.x=f;c.y=b;a.add(c);c=n.frame;c=void 0!==c?this.add.image(f+30,b+30,n.img,c).setInteractive():this.add.image(f+30,b+30,"atlas",n.img).setInteractive();c.setScale(45/Math.max(c.width,c.height));
c.desc=n.desc;c.name=n.name.toUpperCase();h||(c.alpha=.3);a.add(c);f+=65;320<f&&(f=-330,b+=65);c.on("pointerover",function(){var a=this.scene;a.explanationText||(a.explanationText=a.add.container());a.explanationText.removeAll(!0);0<=this.name.indexOf("\n")&&(this.name=this.name.replace("\n"," "));var b=a.add.bitmapText(0,0,"font",this.name),c=a.add.bitmapText(0,0,"font",this.desc);c.y=b.height;var d=Math.max(b.width,c.width),e=b.height+c.height;b.x=d/2-b.width/2;var f=a.add.graphics();f.fillStyle(0);
f.fillRect(-5,-5,d+10,e+10);a.explanationText.add(f);a.explanationText.add(b);a.explanationText.add(c);a.explanationText.x=400+this.x+30;a.explanationText.y=300+this.y+30;800<a.explanationText.x+d+10&&(a.explanationText.x=800-d-10)});c.on("pointerout",function(){var a=this.scene;a.explanationText&&a.explanationText.removeAll(!0)})}f=-330;b+=75}f=this.add.sprite(0,230,"atlas","buttonBack").setInteractive({useHandCursor:!0}).setOrigin(.5,.25);e=this.add.bitmapText(0,230,"font","BACK").setScale(1.5);
e.x-=e.width/2;f.txt=e;a.add(f);a.add(e);f.on("pointerover",function(){app.soundManager.playSfx(this.scene,"hover");this.tw?this.tw.resume():this.tw=this.scene.tweens.add({targets:[this,this.txt],y:this.y-5,duration:250,ease:"Sine.easeInOut",yoyo:!0,repeat:-1})});f.on("pointerout",function(){this.tw&&this.tw.pause()});f.on("pointerdown",function(){this.scene.menuOpened&&(app.soundManager.playSfx(this.scene,"switch"),this.scene.explanationText=null,this.scene.tweens.add({targets:a,y:-300,duration:500,
ease:"Sine.easeInOut",onComplete:function(){this.targets[0].destroy();this.parent.scene.menuOpened=!1;this.parent.scene.menuState=0}}))});this.tweens.add({targets:a,y:300,duration:500,ease:"Sine.easeInOut"})};
app.levelSelect.makeSectionMap=function(a,c){var e=[4,5,2,3],d=2,b=2,f=1,g=.4;2==a?(e=[-1,13,14,10,11,12,8,9,-1],b=d=3,f=7,g=.3):3==a&&(e=[-1,25,24,23,22,21,20,19,18,17,-1,-1,-1,-1,16],f=15,d=3,b=5,g=.22);var m=this.add.container();m.x=400;m.y=250;var k=this.add.bitmapText(20,-240,"font","SECTION "+a).setScale(2);k.x-=k.width/2;m.add(k);var n=660*b;d*=396;for(var h=0;h<e.length;h++){k=e[h];var l=e[h]-f;if(!(0>l)){var p=Math.floor(h/b),t=h-p*b,w=-n/2+660*t+330;w*=g;w+=10*t-10*(b-3);t=-d/2+396*p+198;
t*=g;t+=10*p;p=this.add.tileSprite(w,t,660,396,"tiledBg").setScale(g).setTint("0xcccccc");m.add(p);k>c?(k=this.add.bitmapText(w,t,"font","NOT DISCOVERED YET").setScale(g/.4),k.x-=k.width/2,m.add(k)):(l=this.add.sprite(w,t,"atlas","s"+a+"r"+l).setScale(g).setInteractive({useHandCursor:!0}),l.selectedLevel=k,l.selectedSection=a,l.bg=p,m.add(l),l.defx=w,l.defy=t,l.on("pointerover",function(){var a=800<this.x+400+99?202:this.x;a=0>this.x+400-99?-202:a;this.scene.tweens.add({targets:[this,this.bg],scaleX:.6,
scaleY:.6,x:a,duration:250,ease:"Sine.easeInOut"});m.bringToTop(this.bg);m.bringToTop(this)}),l.on("pointerout",function(){this.scene.tweens.add({targets:[this,this.bg],scaleX:g,scaleY:g,x:this.defx,y:this.defy,duration:250,ease:"Sine.easeInOut"})}),l.on("pointerdown",function(){-1!=this.scene.menuState&&(app.selectedLevel=this.selectedLevel,app.selectedSection=this.selectedSection,this.scene.toTheOtherScene("game"))}))}}return m};
app.levelSelect.toTheOtherScene=function(a){this.menuState=-1;this.cameras.main.fadeOut(1E3);this.cameras.main.once("camerafadeoutcomplete",function(c){this.clear();this.scene.stop("levelSelect");this.scene.start(a)},this)};app.levelSelect.clear=function(){this.tweens.killAll();var a=Array.from(this.children.list);a=$jscomp.makeIterator(a);for(var c=a.next();!c.done;c=a.next())c=c.value,c.destroy&&c.destroy()};
app.levelSelect.loadSave=function(){if(app.canAccessStorage){var a=window.localStorage.getItem("rookie"+app.curSlot);a=a?JSON.parse(a):{};this.openedAchievements=(app.loadedValue=a)&&a.achievements?a.achievements:{};return a}};
app.game.init=function(){var a=document.getElementsByTagName("canvas")[0];a&&(a.style.cursor="");this.saveNo=app.curSlot;this.startPointNo=this.highestLevelNo=this.levelNo=1;this.groundLayer=null;this.spaceUp=!0;this.infoText;this.info;this.maxBoxNum=2;this.bg;this.exitPoints=[];this.gamePaused=!1;this.checkPoint=this.optionsMenu=null;this.tut2Showed=this.tut1Showed=!1;this.saveManager=new app.SaveManager(this);this.inventory=new app.Inventory(this);this.achievements=new app.Achievements(this);this.realTime=
new app.RealGameTime;this.infos=[];this.sectionStartLevels=[1,2,8,16];this.sections={section0:[],section1:[],section2:[],section3:[]};this.curSection=this.sections.section0;this.curSectionNo=0;this.binocularActive=!1;this.bossLevels=[5,14,25];this.secretLevels=[6,7,15,26];this.abilities=[]};
app.game.save=function(){if(app.canAccessStorage){for(var a=!1,c=$jscomp.makeIterator(this.secretLevels),e=c.next();!e.done;e=c.next())e.value==this.levelNo&&(a=!0);!a&&this.levelNo>this.highestLevelNo&&(this.highestLevelNo=this.levelNo);a={levelNo:this.levelNo,startPointNo:this.startPointNo,curSectionNo:this.curSectionNo,tut1Showed:this.tut1Showed,tut2Showed:this.tut2Showed,sections:this.sections,inventory:this.inventory.getList(),achievements:this.achievements.getList(),abilities:this.abilities,
highestLevelNo:this.highestLevelNo};a=JSON.stringify(a);window.localStorage.setItem("rookie"+this.saveNo,a);app.saveSlot(this.saveNo,this.curSectionNo,this.achievements.getAchievementNums());this.achievements.resetAchievementNums()}};
app.game.loadSave=function(a){if(a){for(var c in a)"inventory"!=c&&"achievements"!=c&&(this[c]=a[c]);app.selectedLevel&&(this.levelNo=app.selectedLevel,this.curSectionNo=app.selectedSection,this.startPointNo=1);this.highestLevelNo=a.highestLevelNo?a.highestLevelNo:1;this.curSection=this.sections["section"+this.curSectionNo];this.inventory.loadList(a.inventory);this.achievements.loadList(a.achievements);a=this.abilities;for(c=0;c<a.length;c++){var e=a[c];this.addAbility(e.x,e.y,e.texture,e.no,!0)}app.loadedValue=
null}};app.game.pause=function(){this.gamePaused=!0;this.physics.pause();this.realTime.pause()};app.game.resume=function(){this.gamePaused=!1;this.physics.resume();this.realTime.resume()};
app.game.create=function(){app.currentScene=this;app.currentSceneName="game";var a=document.getElementsByTagName("canvas")[0];a&&(a.style.cursor="");this.keys=this.input.keyboard.addKeys("W,A,S,D");this.keyController={up:!1,down:!1,left:!1,right:!1,space:!1,teleport:!1};this.bag=this.add.sprite(10,10,"atlas","bag").setOrigin(0,0).setScrollFactor(0).setInteractive({useHandCursor:!0});this.bag.on("pointerdown",function(){this.inventory.switchMenu()},this);this.options=this.add.sprite(790,10,"atlas",
"optionsButton").setOrigin(1,0).setScrollFactor(0).setInteractive({useHandCursor:!0});this.options.on("pointerdown",function(){this.openCloseOptions()},this);this.anims.create({key:"explosionAnim",frames:this.anims.generateFrameNumbers("explosion",{start:0,end:7,first:0}),frameRate:10,repeat:0});this.input.keyboard.on("keydown",function(a){a=a.key.toLowerCase();if("b"==a)this.inventory.switchMenu();else if("m"==a)this.inventory.openMapIfHaveIt(this.curSectionNo);else if("escape"==a)this.inventory.closeMenu()||
this.openCloseOptions();else if(" "==a)this.speech&&this.speech.next();else for(var b=0;3>b;b++){var c=this["ability"+b];if(c)if(2!=c.no||a!=c.key||this.gamePaused||this["char"].inWater||!this.cameras.main._follow)0==c.state&&a==c.key&&2!=c.no&&(0==c.no?(app.soundManager.playSfx(this,"speed"),this.achievements.openCountable("speedability")):1==c.no&&(app.soundManager.playSfx(this,"shield"),this.achievements.openCountable("shieldability")),this["char"].activateAbility(c.no),c.cooldownTimer=c.cooldown,
c.timer=c.duration,c.state=1,c.xlist=[-20,20,20,-20,-20],c.ylist=[-20,-20,20,20,-20],c.curPos=0);else{this.cameras.main.zoom=.99;this.tweens.add({targets:this.cameras.main,zoom:.5,duration:500});this.binocularActive=this["char"].freeze=!0;for(c=0;3>c;c++){var d=this["ability"+c];d&&(d.visible=!1,d.cover&&(d.cover.visible=!1))}this.bag.visible=!1;this.options.visible=!1}}},this);this.input.keyboard.on("keyup",function(a){a=a.key.toLowerCase();this.ability2&&a==this.ability2.key&&1>this.cameras.main.zoom&&
(this.tweens.add({targets:this.cameras.main,zoom:1,duration:500}),this["char"].freeze=!1)},this);this.bg=this.add.tileSprite(0,0,800,600,"tiledBg").setOrigin(0,0).setScrollFactor(0);this.bg2=this.add.tileSprite(1E3,600,2E3,1200,"tiledBg");this.gamePaused=this.bg2.visible=!1;this.gameTime=0;this.emitManager=new app.EmitManager(this);this.objectFactory=new app.ObjectFactory(this,this.emitManager);this.ladders=this.add.group();var c=this.add.group();a=this.physics.add.group();var e=this.add.group(),
d=this.add.group(),b=this.physics.add.staticGroup(),f=this.physics.add.group(),g=this.physics.add.group(),m=this.physics.add.group();this.tutorial=this.add.group();this.winds=[];this.waters=[];this.holders={blockHolder:b,jumpHolder:a,moveBlocksHolder:f,spikeHolder:e,boxHolder:g,spriteHolder:d,arrowHolder:m,checkpoints:c,tutorialHolder:this.tutorial,ladders:this.ladders};this.boxHolder=g;this.arrowHolder=m;c=new app.Char(this,200,200);c.scaleX=c.scaleY=.8;c.setSize(35,65);c.displayOriginX=35;c.displayOriginY=
34;c.setCollideWorldBounds(!1);this["char"]=c;app.canAccessStorage&&(window.localStorage.getItem("rookie"+this.saveNo),this.loadSave(app.loadedValue));1!=this.levelNo&&app.soundManager.changeMusic(this,"gameLoop",this.levelNo);this.map=this.make.tilemap({key:"map2"});this.groundTiles=this.map.addTilesetImage("tile2","tileset");this.tileLevel();this.physics.add.collider(b,c);this.physics.add.collider(a,c,function(a,b){.7>Math.abs(Math.atan2(a.y-b.y,a.x-b.x)-b.parentObj.rot)&&(b.parentObj.jump(),app.soundManager.playSfx(this,
"blockjump"),a.jump(b.parentObj.vx,b.parentObj.vy,!0),b.parentObj.vx&&(a.jumpSpotJump=!0,a.jumpSpotTimer=100),b.parentObj.vy&&(a.willUpdateVy=!0,a.newVy=b.parentObj.vy))},null,this);this.physics.add.collider(g,a,function(a,b){20>Math.abs(Math.atan2(a.y-b.y,a.x-b.x)-b.parentObj.rot)&&(b.parentObj.jump(),a.parentObj.jump(b.parentObj.vx,b.parentObj.vy))},null,this);this.physics.add.collider(f,c,c.moveBlockSeperator,null,this);this.physics.add.collider(g,c);this.physics.add.collider(g,g);this.physics.add.collider(g,
f);this.physics.add.collider(g,b);this.physics.add.collider(m,b,function(a,b){a==this.arrow&&(this.arrow=null);a.mark.destroy();a.destroy()},null,this);cursors=this.input.keyboard.createCursorKeys();this.cameras.main.setBounds(0,0,this.map.widthInPixels,this.map.heightInPixels);this.cameras.main.startFollow(this["char"],!0,.05,.05,-100,0);this.cameras.main.setVisible(!0);this.setTileCollider(this.groundLayer);if(this["level"+this.levelNo])this["level"+this.levelNo](this.gameTime);this.levelStuffs()};
app.game.openCloseOptions=function(){if(this.optionsMenu)this.optionsMenu.destroy(),this.optionsMenu=null,this.resume(),1==this.levelNo?app.soundManager.changeMusic(this,"menuLoop"):app.soundManager.playLastMusic(this);else if(!this.gamePaused){this.pause();app.soundManager.changeMusic(this,"menuLoop");var a=this.add.container(),c=this.add.image(0,0,"atlas","inventoryBg").setScrollFactor(0);c.setScale(.7,1.3);var e=this.add.bitmapText(0,-220,"font","OPTIONS").setScrollFactor(0);e.setScale(2);e.x=
-e.width/2;var d=this.add.bitmapText(-120,-170,"font","VOLUME").setScrollFactor(0).setTint(0),b=this.add.graphics().setScrollFactor(0);b.fillStyle(0).fillRoundedRect(-120,-145,240,15,5);var f=this.add.sprite(-110,-137.5,"atlas","soundButton").setScrollFactor(0).setInteractive({useHandCursor:!0}).setScale(.7);f.volumeName="musicVolume";var g=this.add.bitmapText(-120,-120,"font","SFX").setScrollFactor(0).setTint(0),m=this.add.graphics().setScrollFactor(0);m.fillStyle(0).fillRoundedRect(-120,-85,240,
15,5);var k=this.add.sprite(110,-77.5,"atlas","soundButton").setScrollFactor(0).setInteractive({useHandCursor:!0}).setScale(.7);k.volumeName="sfxVolume";f.x=-110+220*app.musicVolume;k.x=-110+220*app.sfxVolume;this.input.setDraggable(f);this.input.setDraggable(k);this.input.on("drag",function(a,b,c,d){b.x=c;b.x=-110>b.x?-110:b.x;b.x=110<b.x?110:b.x;app[b.volumeName]=(b.x- -110)/220;"musicVolume"==b.volumeName&&app.soundManager.setMusicVolume(app.musicVolume)});a.add(c);a.add(e);a.add(d);a.add(b);a.add(f);
a.add(g);a.add(m);a.add(k);d=[e,d,b,f,g,m,k];b=[];f=["continue","lobby","quit"];for(g=0;g<f.length;g++)c=this.add.sprite(0,0,"atlas","buttonBack").setScrollFactor(0).setInteractive({useHandCursor:!0}).setOrigin(.5,.25),e=this.add.bitmapText(0,0,"font",f[g].toUpperCase()).setScrollFactor(0).setScale(1.5),e.x-=e.width/2,c.y=-20+70*g,e.y=-20+70*g,c.txt=e,c.no=g,a.add(c),a.add(e),4==g?(c.visible=e.visible=!1,c.alpha=e.alpha=0,b.push(c,e),c.y-=70,e.y-=70):d.push(c,e),c.on("pointerover",function(){app.soundManager.playSfx(this.scene,
"hover");this.tw?this.tw.resume():this.tw=this.scene.tweens.add({targets:[this,this.txt],y:this.y-5,duration:250,ease:"Sine.easeInOut",yoyo:!0,repeat:-1})}),c.on("pointerout",function(){this.tw&&this.tw.pause()}),c.on("pointerdown",function(){;app.soundManager.playSfx(this.scene,"switch");this.tw&&this.tw.pause();var a=this.no,b=this.scene;0==a?(b.optionsMenu.destroy(),b.optionsMenu=null,b.resume(),1==b.levelNo?app.soundManager.changeMusic(b,"menuLoop"):app.soundManager.playLastMusic(b)):
1==a?(b.saveManager.saveOnlyImportant(),b.save(),b.clearScene(),b.scene.start("levelSelect")):2==a&&(b.saveManager.saveOnlyImportant(),b.save(),b.levelNo=-1,b.clearScene(),b.scene.start("menu"))});a.x=400;a.y=300;this.optionsMenu=a}};
app.game.updateObjects=function(){var a=this.children.list,c=new Phaser.Geom.Rectangle(this["char"].flipX?this["char"].body.position.x-3:this["char"].body.position.x,this["char"].body.position.y+5,this["char"].body.width,this["char"].body.sourceHeight-17);this["char"].touchingLever=null;for(var e=Phaser.Geom.Intersects.RectangleToRectangle,d=0;d<a.length;d++){var b=a[d].parentObj;if(b){if("hideblock"==b.type)b.update(this.gameTime);else if("bubbleHole"==b.type||"moveblock"==b.type)b.update();else if("weakBlock"==
b.type)!b.startDestroy&&e(c,b.obj.getBounds())&&this["char"].body.blocked.down&&(b.startDestroy=!0),b.startDestroy&&(b.destroyTimer--,b.obj.x=b.baseX+1-2*Math.random(),b.obj.y=b.baseY+1-2*Math.random(),0>b.destroyTimer&&(b.destroy(),b.active=!1,b.obj.destroy()));else if("leverBlock"==b.type)b.hasSpike&&this["char"].alive&&(b.doRotate?30>Math.abs(this["char"].y-b.obj.y)&&this["char"].x-23<b.obj.x+b.width/2&&this["char"].x+23>b.obj.x-b.width/2&&this["char"].die()&&this.newLevel(!0):40>Math.abs(this["char"].x-
b.obj.x)&&this["char"].y-32<b.obj.y+b.height/2&&this["char"].y+32>b.obj.y-b.height/2&&this["char"].die()&&this.newLevel(!0));else if("secretPlace"==b.type){if(!b.opened&&e(c,b.rect)){this.achievements.openCountable("secretplace");b.opened=!0;app.soundManager.playSfx(this,"checkpoint");var f=this.add.bitmapText(this["char"].x,this["char"].y-50,"font","SECRET PLACE\n DISCOVERED!");f.x-=f.width/2;this.tweens.add({targets:b.obj,alpha:0,duration:500,onComplete:function(){}});this.tweens.add({targets:f,
alpha:0,y:f.y-20,duration:500,delay:1E3,onComplete:function(){this.targets[0].destroy()}})}}else if("coin"==b.type)!b.active&&b.obj.visible&&e(c,b.obj.getBounds())&&(b.active=!0,app.soundManager.playSfx(this,"getitem"),b.isGold?this.achievements.openCountable("goldcoin"):this.achievements.openCountable("silvercoin"),b.obj.visible=!1);else if("bubble"==b.type)b.update(),this["char"].alive&&Phaser.Geom.Intersects.RectangleToRectangle(c,b.obj.getBounds())&&(app.soundManager.playSfx(this,"bubble"),this["char"].air+=
5,100<this["char"].air&&(this["char"].air=100),b.obj.destroy()),this.tilePointCheck(b.obj.x,b.obj.y)&&b.obj.destroy();else if("keyblock"==b.type)b.active&&this.inventory.hasKey(b.no)&&40>Math.abs(this["char"].x-b.obj.x)&&70>Math.abs(this["char"].y-b.obj.y)&&(b.active=!1,b.obj.body.enable=!1,this.tweens.add({targets:b.obj,scaleX:1.5,scaleY:1.5,alpha:0,duration:500,onComplete:function(){this.targets[0].destroy()}}));else if("paper"==b.type)this["char"].alive&&e(c,b.obj.getBounds())&&(app.soundManager.playSfx(this,
"getitem"),this.inventory.openPaper(b.id,!0),b.obj.destroy(),this.achievements.openCountable("gametip"));else if("map"==b.type)this["char"].alive&&e(c,b.obj.getBounds())&&(app.soundManager.playSfx(this,"getitem"),this.inventory.openMap(b.id,!0),b.obj.destroy(),this.achievements.openCountable("map"));else if("item"==b.type)this["char"].alive&&e(c,b.obj.getBounds())&&(app.soundManager.playSfx(this,"getitem"),this.inventory.openItem(b.id,b.obj),b.active=!1,b.obj.destroy(),this.achievements.openCountable("item",
b.name));else if("enemy"==b.type){if(b.update(),this["char"].alive&&b.active&&e(c,b.obj.getBounds())&&(this["char"].y<b.obj.y&&0<this["char"].body.velocity.y?(this["char"].jump(0,-250),b.destroy(),app.soundManager.playSfx(this,"bonk"),this.achievements.openCountable("monster"),this.achievements.open(32)):this["char"].die()&&this.newLevel(!0)),b.active&&(f=this.spriteGroupCollision(b.obj,this.holders.arrowHolder,0)))b.destroy(),app.soundManager.playSfx(this,"bonk"),this.achievements.openCountable("monster"),
f==this.arrow&&(this.arrow=null),f.mark.destroy(),f.destroy()}else if("checkpoint"==b.type)!b.checked&&e(c,b.obj.getBounds())&&(this.checkPoint&&this.getObjectWithId(this.checkPoint.id).parentObj.uncheck(),app.soundManager.playSfx(this,"checkpoint"),b.check(),this.saveManager.save(),this.checkPoint={x:b.obj.x,y:b.obj.y,id:b.id});else if("lever"==b.type)b.infoTxt.visible=!1,e(c,b.obj.getBounds())&&!b.changing&&(b.infoTxt.visible=!0,this["char"].touchingLever=b);else if("cannon"==b.type){if(f=[this.groundLayer].concat(this.boxHolder.children.entries,
this.holders.blockHolder.children.entries),b.update(this.gameTime,f),"laser"==b.cannonType&&(b.laserUpdate(this.gameTime,f),b.line)){this["char"].alive&&Phaser.Geom.Intersects.LineToRectangle(b.line,c)&&this["char"].die()&&this.newLevel(!0);f=$jscomp.makeIterator(this.boxHolder.children.entries);for(var g=f.next();!g.done;g=f.next())g=g.value,Phaser.Geom.Intersects.LineToRectangle(b.line,g.getBounds())&&g.parentObj.hitted(1);g=$jscomp.makeIterator(this.arrowHolder.children.entries);for(f=g.next();!f.done;f=
g.next())f=f.value,Phaser.Geom.Intersects.LineToRectangle(b.line,f.getBounds())&&(f==this.arrow&&(this.arrow=null),f.mark.destroy(),f.destroy())}}else if("movespike"==b.type&&this["char"].alive)f=b.obj,e(this["char"].getBounds(),f.getBounds())&&this["char"].body.bottom-8>f.getBounds().top&&this["char"].die()&&this.newLevel(!0);else if("cannonball"==b.type||"missile"==b.type){b.obj.x+=b.vx;b.obj.y+=b.vy;f=this.spriteGroupCollision(b.obj,this.boxHolder,1);g=this.spriteGroupCollision(b.obj,this.holders.blockHolder,
1);var m=this.spriteGroupCollision(b.obj,this.holders.moveBlocksHolder,1);if(this.tilePointCheck(b.obj.x,b.obj.y)||this.checkScreenBounds(b.obj.x,b.obj.y)||f||g||m)this.addExplosion(b.obj.x,b.obj.y),b.obj.destroy(),b.remove&&b.remove();f&&f.parentObj.hitted(10);b.update&&b.isHoming&&(f=[this.groundLayer].concat(this.boxHolder.children.entries),b.update(this["char"].x,this["char"].y,f))}else if("key"==b.type){if(b.active&&(f=b.obj,30>Math.abs(this["char"].x-f.x)&&20>Math.abs(this["char"].y-f.y))){f.visible=
!1;b.active=!1;app.soundManager.playSfx(this,"getitem");this.achievements.openCountable("key");this.inventory.getKey(b.no);var k=this.add.sprite(f.x-this.cameras.main.scrollX,f.y-this.cameras.main.scrollY,"atlas",f.frame.name);k.setScrollFactor(0);var n=this;this.tweens.add({targets:k,scaleX:.3,scaleY:.3,x:40,y:40,duration:500,onComplete:function(){k.destroy();n.tweens.add({targets:n.bag,scaleX:1.5,scaleY:1.5,duration:250,yoyo:!0})}})}}else"box"==b.type?10>b.obj.x||1990<b.obj.x||1210<b.obj.y?b.obj.destroy():
0!=b.obj.body.velocity.x&&(b.obj.body.velocity.x*=.98,50>Math.abs(b.obj.body.velocity.x)&&(b.obj.body.velocity.x=0)):"arrow"==b.type&&(f=b.obj.body,b.obj.rotation=Math.atan2(f.velocity.y,f.velocity.x),b.obj.inWind&&(0>b.obj.windVx*b.obj.body.velocity.x||1E3<Math.abs(b.obj.body.velocity.x))&&(b.obj.body.velocity.x*=.9),0>b.obj.x||2E3<b.obj.x||1210<b.obj.y)&&(b.obj==this.arrow&&(this.arrow=null),b.obj.mark.destroy(),b.obj.destroy());b.isDeathly&&this["char"].alive&&c.contains(b.obj.x,b.obj.y)&&(b.doExplode&&
this.addExplosion(b.obj.x,b.obj.y),b.obj.destroy(),this["char"].die()&&this.newLevel(!0))}}this.arrow&&(f=this.arrow,f.mark.visible=!1,a=this.cameras.main,f.x<a.scrollX&&(f.mark.visible=!0,f.mark.x=a.scrollX+6,f.mark.y=f.y,f.mark.flipX=!0),f.x>a.scrollX+800&&(f.mark.visible=!0,f.mark.x=a.scrollX+800-6,f.mark.y=f.y))};
app.game.update=function(){if(this.binocularActive&&(1>this.cameras.main.zoom&&(this.bg2.visible=!0),1==this.cameras.main.zoom)){for(var a=0;3>a;a++){var c=this["ability"+a];c&&(c.visible=!0,c.cover&&(c.cover.visible=!0))}this.bag.visible=!0;this.options.visible=!0;this.binocularActive=!1;this.bg2.visible=!1}this.keyController.up=cursors.up.isDown||this.keys.W.isDown;this.keyController.down=cursors.down.isDown||this.keys.S.isDown;this.keyController.right=cursors.right.isDown||this.keys.D.isDown;this.keyController.left=
cursors.left.isDown||this.keys.A.isDown;this.keyController.space=cursors.space.isDown;this.keyController.teleport=cursors.down.isDown||this.keys.S.isDown;1==this.levelNo&&this.tutorial1();if(2==this.levelNo&&6==this.tutStep&&720<this["char"].x){var e=this.cameras.main;this.tweens.add({targets:e,scrollX:this["char"].x-300,duration:500,onComplete:function(){e.startFollow(this.parent.scene["char"],!0,.05,.05,-100,0)}});this.tutStep=-1}this.keyController.space&&this.inventory.closeCurrent();this.inventory.updateMap();
if(!this.gamePaused){a=this.realTime.getElapsedTime();for(c=0;3>c;c++){var d=this["ability"+c];if(d)if(1!=d.state||this.binocularActive)2==d.state&&(d.cooldownTimer-=a,d.cover||(d.cover=this.add.graphics().setScrollFactor(0),d.cover.dontDestroy=!0,d.cover.x=d.x-20,d.cover.y=d.y-20,d.setTint("0x333333")),m=Math.round(40-40*d.cooldownTimer/d.cooldown),d.posy!=m&&(d.cover.clear(),d.cover.fillStyle(0,.5),d.cover.fillRect(0,m,40,40-m)),d.posy=m,0>=d.cooldownTimer&&(d.state=0,d.cover.destroy(),d.cover=
null,d.setTint("0xffffff"),this.tweens.add({targets:d,scaleX:1.2,scaleY:1.2,duration:300,yoyo:!0})));else{d.timer-=a;0>=d.timer&&(this["char"].deactivateAbility(d.no),d.state=2);1==d.no&&this["char"].shield&&1500>d.timer&&0==this.gameTime%3&&(this["char"].shield.visible=!this["char"].shield.visible);var b=d.curPos,f=Math.floor(b/10);b=b/10-f;void 0==d.xlist[f+1]&&(b=f=d.curPos=0);var g=d.x+d.xlist[f]+(d.xlist[f+1]-d.xlist[f])*b,m=d.y+d.ylist[f]+(d.ylist[f+1]-d.ylist[f])*b;f=this.add.image(g,m,"atlas",
"glow").setScrollFactor(0);f.destroyOnLevelChange=!0;d.curPos++;this.tweens.add({targets:f,alpha:0,duration:200})}}this.cameras.main.followOffset.x=this["char"].flipX?100:-100;this.gameTime++;a=$jscomp.makeIterator(this.exitPoints);for(c=a.next();!c.done;c=a.next())if(c=c.value,this.keyController[c.key]&&20>Math.abs(this["char"].x-c.x)&&40>Math.abs(this["char"].y-c.y)){this.gamePaused=!0;this.newLevel(!1,{level:c.toLevel,startPoint:c.toPoint});return}a=new Phaser.Geom.Rectangle(this["char"].x-12,
this["char"].y-20,17,36);this.inWater=!1;d=$jscomp.makeIterator(this.waters);for(c=d.next();!c.done;c=d.next()){f=c.value;if(Phaser.Geom.Rectangle.ContainsRect(f.rectArea,a)){this.inWater=!0;var k=f.rectArea.y}b=$jscomp.makeIterator(this.arrowHolder.getChildren());for(c=b.next();!c.done;c=b.next())c=c.value,Phaser.Geom.Rectangle.ContainsRect(f.rectArea,c.getBounds())&&(c.body.velocity.x*=.95,c.body.velocity.y++)}this.inWater&&!this["char"].inWater&&(k=this.add.sprite(this["char"].x,k-5,"splash"),
k.play("waterSplash"),app.soundManager.playSfx(this,"splash"),k.once("animationcomplete",function(){this.destroy()}));this["char"].inWater=this.inWater;this["char"].windAcc.x=0;this["char"].windAcc.y=0;this["char"].inWind=!1;k=$jscomp.makeIterator(this.winds);for(c=k.next();!c.done;c=k.next())for(d=c.value,d.changeTime&&this.gameTime>d.changeTime&&(d.changeTime=this.gameTime+d.changeDuration,d.vx*=-1,d.vy*=-1),d.posx-=d.vx,d.posy+=2*d.vy,d.tilePositionX=d.posx,d.tilePositionY=d.posy,Phaser.Geom.Rectangle.ContainsRect(d.rectArea,
a)&&(this["char"].inWind=!0,this["char"].windAcc.x=20*d.vx,this["char"].windAcc.y=100*d.vy),f=$jscomp.makeIterator(this.arrowHolder.getChildren()),c=f.next();!c.done;c=f.next())c=c.value,Phaser.Geom.Rectangle.ContainsRect(d.rectArea,c.getBounds())&&(c.body.acceleration.x+=3*d.vx,c.windVx=d.vx,c.body.acceleration.y+=3*d.vy,c.inWind=!0);this.touchLadder=!1;k=this.ladders.getChildren();k=$jscomp.makeIterator(k);for(a=k.next();!a.done;a=k.next())if(a=a.value,Phaser.Geom.Intersects.RectangleToRectangle(this["char"].getBounds(),
a.getBounds())&&20>Math.abs(this["char"].x-a.x)){var n=n?n:a;n=n.y<a.y?n:a;this.touchLadder=!0}this["char"].body.allowGravity=!this.touchLadder;this["char"].onLadder=this.touchLadder;n&&(this["char"].onTopOfLadder=!1,0<this["char"].body.velocity.y&&30<n.y-this["char"].y&&!this.keyController.down&&(this["char"].y=n.y-38,this["char"].onTopOfLadder=!0),37<n.y-this["char"].y&&(this["char"].onTopOfLadder=!0));this.touchLadder&&(this["char"].body.velocity.y=0);this["char"].willUpdateVy&&(this["char"].willUpdateVy=
!1,this["char"].body.velocity.y=this["char"].newVy);this.updateObjects();this["char"].alive&&this["char"].body.bottom>this.physics.world.bounds.height&&this["char"].die()&&this.newLevel(!0);this.keyController.teleport&&!this["char"].freeze&&!this["char"].freezeTeleport&&this.arrow&&this["char"].alive&&(app.soundManager.playSfx(this,"teleport"),this["char"].x=this.arrow.x,this["char"].y=this.arrow.y-20,this["char"].body.velocity.x=0,this["char"].body.velocity.y=0,this["char"].locked=!1,this["char"].lockedTo=
null,this.arrow.mark.destroy(),this.arrow.destroy(),this.arrow=null,3==this.tutStep&&(this.tutStep=-1,g=this.bossBall.x+50,m=this.bossBall.y-20,this.tweens.add({targets:this.bossText,alpha:0,duration:300,onComplete:function(){this.targets[0].destroy();var a=this.parent.scene;a.bossText=a.addTweenText("GOOD JOB!",g,m,1,!0,1E3,function(){a.bossText.destroy();a.tutStep=4;a["char"].freezeMovement=!1;new a.objectFactory.addPaper(400,980,a.holders.spriteHolder,0);a.bossText=a.addTweenText("YOU SEE THERE IS A SCROLL BELOW ME!\nTHESE SCROLLS GIVE YOU INFORMATION \nABOUT THE GAME. GO TAKE IT",
g,m,1,!1,1E3,function(){})})}})));if(this.keyController.space&&this.spaceUp){this.spaceUp=!1;if(this["char"].touchingLever){app.soundManager.playSfx(this,"switch");this["char"].touchingLever.change();return}if(1==this.levelNo)return;this["char"].chargeArrow()}this.keyController.space||(this.spaceUp=!0,this["char"]["throw"](0));if(this.infos)for(n=$jscomp.makeIterator(this.infos),k=n.next();!k.done;k=n.next())k=k.value,a=k.text,a.visible&&(a.alpha-=.05,0>=a.alpha&&(a.alpha=0,a.visible=!1)),Phaser.Geom.Intersects.RectangleToRectangle(this["char"].getBounds(),
k.getBounds())&&(a.visible=!0,a.alpha=1);this["char"].update();this.boss&&this.boss.update();this.gamePaused&&(this["char"].body.acceleration.x=0,this["char"].body.acceleration.y=0)}};
app.game.addBox=function(a,c){this.arrow&&(this.arrow.mark.visible=!1);this.arrow=this.holders.arrowHolder.create(this["char"].x,this["char"].y,"atlas","arrow");this.arrow.parentObj={type:"arrow"};this.arrow.parentObj.obj=this.arrow;this.arrow.mark=this.add.image(0,0,"atlas","arrowMark");this.arrow.mark.visible=!1;this.arrow.mark.destroyOnLevelChange=!0;this.arrow.body.velocity.x=c*(this["char"].flipX?-1:1)+this["char"].body.velocity.x;this.arrow.body.gravity.y=-570;if(2==this.levelNo&&this.bossBall){var e=
this.bossBall.x+50,d=this.bossBall.y-20;if(1==this.tutStep)this.tutStep=-1,this.tweens.add({targets:this.bossText,alpha:0,duration:300,onComplete:function(){this.targets[0].destroy();var a=this.parent.scene;a.addTweenText("WELL DONE!",e,d,1,!0,1E3,function(){a.tutStep=2;a.bossText=a.addTweenText("NOW SHOOT AN ARROW WITH FULL SPEED\nHOLD SPACE TO SHOOT ARROW FASTER",e,d,1,!1,1E3,function(){})})}});else if(2==this.tutStep){var b=!1;1E3<=c&&(b=!0,this.tutStep=-1);this.tweens.add({targets:this.bossText,
alpha:0,duration:300,onComplete:function(){this.targets[0].destroy();var a=this.parent.scene;a.bossText=a.addTweenText(b?"NICE!":"HOLD SPACE UNTIL RED BAR FILLS\nTHEN RELEASE",e,d,1,b,1E3,function(){b&&(a["char"].freezeTeleport=!1,a.tutStep=3,a.bossText=a.addTweenText("THE ARROWS ARE SPECIAL. YOU CAN\nTELEPORT TO YOUR ARROWS. SHOOT\nAN ARROW AND PRESS DOWN KEY\nTO TELEPORT YOUR ARROW",e,d,1,!1,1E3,function(){b&&(a.tutStep=3)}))})}})}}};
app.game.addTweenText=function(a,c,e,d,b,f,g){var m=this.add.bitmapText(c,e,"font",a);m.alpha=0;var k=this;this.tweens.add({targets:m,alpha:d,duration:300,onComplete:function(){b?k.tweens.add({targets:m,alpha:1==d?0:1,duration:300,delay:f,onComplete:function(){g()}}):g()}});return m};
app.game.newLevel=function(a,c,e){a&&!e&&this.cameras.main.shake(500,.01);if(a&&!e&&.3>Math.random()){var d=this.add.bitmapText(400,300,"font"," YOU ARE DEAD!\nCLICK ANYWHERE TO RESTART").setScale(2).setScrollFactor(0);d.x-=d.width/2;this.tweens.add({targets:d,y:d.y-10,ease:"Sine.easeInOut",duration:500,yoyo:!0,repeat:-1});this.input.once("pointerdown",function(){d.destroy();this.newLevel(!0,null,!0);this.resume()},this)}else{this["char"].body.allowGravity=!1;var b=!0;this.time.delayedCall(50,
function(){if(a)b=!1,this.saveManager.saveOnlyImportant();else{this.saveManager.save();this.checkPoint=null;this.levelNo++;c&&(this.levelNo=c.level,this.startPointNo=c.startPoint);for(var d=0;d<this.sectionStartLevels.length;d++){var e=this.sectionStartLevels[d],m=this.sectionStartLevels[d+1];m=m?m:100;this.levelNo>=e&&this.levelNo<m&&(this.curSection=this.sections["section"+d],this.curSectionNo=d)}}this.save();this.cameras.main.fadeOut(1E3);this.cameras.main.once("camerafadeoutcomplete",function(c){a||
app.soundManager.changeMusic(this,"gameLoop",this.levelNo);this.clearLevel();this.tileLevel(!0,b);if(this["level"+this.levelNo])this["level"+this.levelNo](this.gameTime);this.levelStuffs();c.fadeIn(1E3)},this)},[],this)}};app.game.clearScene=function(){this.groundLayer=this.groundCollider3=this.groundCollider2=this.groundCollider=null;this.clearLevel(!0);var a=Array.from(this.children.list);a=$jscomp.makeIterator(a);for(var c=a.next();!c.done;c=a.next())c=c.value,c.destroy&&c.destroy();this.pause()};
app.game.clearLevel=function(a){for(var c=0;3>c;c++){var e=this["ability"+c];e&&(1==e.state&&this["char"].deactivateAbility(e.no),e.state=0,e.setTint("0xffffff"),e.cover&&(e.cover.destroy(),e.cover=null))}this.achievements.resetAddY();e=this.tweens._active;for(c=0;c<e.length;c++)e[c].pause();this.tweens.killAll();this.gamePaused=!1;this.infos=[];for(var d in this.holders)if(this.holders.hasOwnProperty(d))for(e=this.holders[d].getChildren(),c=e.length-1;0<=c;c--)25==this.levelNo&&e[c].dontDestroy||
(e[c].parentObj&&e[c].parentObj.remove&&e[c].parentObj.remove(),e[c].destroy());c=!1;d=$jscomp.makeIterator(this.bossLevels);for(e=d.next();!e.done;e=d.next())this.levelNo==e.value&&(c=!0);a&&(c=!1);!this.boss||c&&!this.boss.dead||(this.boss.clear(),this.boss=null,this.bossCollider&&(this.bossCollider.destroy(),this.bossCollider=null));this.emitManager.clear();a=$jscomp.makeIterator(this.waters);for(c=a.next();!c.done;c=a.next())c.value.destroy();a=$jscomp.makeIterator(this.winds);for(c=a.next();!c.done;c=
a.next())c.value.destroy();this.waters=[];this.winds=[];a=Array.from(this.children.list);a=$jscomp.makeIterator(a);for(c=a.next();!c.done;c=a.next())c=c.value,c.dontDestroy||"Graphics"!=c.type&&"Text"!=c.type&&"BitmapText"!=c.type&&!c.destroyOnLevelChange||c.destroy();this.arrow=this.box=null;this["char"].x=0;this["char"].y=0;this["char"].alive=!0;this["char"].body.allowGravity=!0;this["char"].scaleX=this["char"].scaleY=.8;this.cameras.main.startFollow(this["char"],!0,.05,.05,-100,0)};
app.game.levelStuffs=function(){if(!(28<=this.levelNo)){this.gamePaused=!1;this.inventory.closeMenu();this["char"].body.velocity.x=0;this["char"].body.velocity.y=0;this.addLevelObjects();2<this.levelNo&&this["char"].reset();this.boss&&this.boss.inView?(this["char"].x=this.boss.checkX,this["char"].y=this.boss.checkY,this.cameras.main.scrollX=this.boss.cameraX,this.cameras.main.scrollY=this.boss.cameraY):(this.cameras.main.scrollX=this["char"].x-200,this.cameras.main.scrollY=this["char"].y-200);this.children.sendToBack(this.bg2);
this.children.sendToBack(this.bg);this.children.bringToTop(this.groundLayer);this.children.bringToTop(this["char"]);for(var a=$jscomp.makeIterator(this.waters),c=a.next();!c.done;c=a.next())this.children.bringToTop(c.value);this.boss&&this.boss.adjustDepths();if(this.infos)for(a=0;a<this.infos.length;a++){c=this.infos[a];var e=c.text;e.x=c.x-e.width/2;e.y=c.y-c.height/2-e.height/2-20;e.visible=!1;c.destroyOnLevelChange=!0;this.children.bringToTop(e)}a=$jscomp.makeIterator(this.children.list);for(c=
a.next();!c.done;c=a.next())c=c.value,c.parentObj&&"secretPlace"==c.parentObj.type&&this.children.bringToTop(c),c.bringToTop&&this.children.bringToTop(c);for(a=0;3>a;a++)if(c=this["ability"+a])this.children.bringToTop(c),c.cover&&this.children.bringToTop(c.cover);this.children.bringToTop(this.bag);this.children.bringToTop(this.options);this.children.bringToTop(this["char"].waterBar);this.children.bringToTop(this["char"].powerBar);this.secretTxt&&(this.children.bringToTop(this.secretTxt),this.secretTxt=
null);this.children.bringToTop(this.g);this.objectFactory.addBoxParticle();this.bag.visible=!0;this.options.visible=!0;2>this.levelNo&&(this.bag.visible=!1);for(a=0;a<this.sectionStartLevels.length;a++)c=this.sectionStartLevels[a],e=(e=this.sectionStartLevels[a+1])?e:100,this.levelNo>=c&&this.levelNo<e&&(this.curSection=this.sections["section"+a],this.curSectionNo=a)}};
app.game.clearTiles=function(a){a&&(this.groundCollider2&&(this.groundCollider2.destroy(),this.groundCollider2=null),this.groundCollider3&&(this.groundCollider3.destroy(),this.groundCollider3=null),this.groundCollider.destroy(),this.groundLayer.destroy(),this.groundLayer=null)};
app.game.tileLevel=function(a,c){this.clearTiles(c);if(!(28<=this.levelNo)){if(!this.groundLayer){var e=this.map.createDynamicLayer("Tile Layer "+this.levelNo,this.groundTiles,0,0);e.setCollisionByExclusion([-1,2,3,4,5]);this.physics.world.bounds.width=e.width;this.physics.world.bounds.height=e.height;this.groundLayer=e;this.objectFactory.setGroundLayer(e)}a&&c&&this.setTileCollider(this.groundLayer)}};
app.game.addLevelObjects=function(){for(var a,c=$jscomp.makeIterator(this.cache.tilemap.entries.entries.map2.data.layers),e=c.next();!e.done;e=c.next())e=e.value,e.name=="Object Layer "+this.levelNo&&(a=e.objects);if(a){c=this.objectFactory;e=this.holders;this.exitPoints=[];a=$jscomp.makeIterator(a);for(var d=a.next();!d.done;d=a.next()){var b=d.value;d=b.properties;if("movingBlock"==b.type)new c.addMoveBlock({x:b.x+24,y:b.y,key:"movingBlock",holder:e.moveBlocksHolder,left:d.left,right:d.right,top:d.top,
bottom:d.bottom,speedx:d.vx,speedy:d.vy});else if("jumpBlock"==b.type)new c.addJumpBlock(b.x+17,b.y-12,e.jumpHolder,d.vx,d.vy);else if("lever"==b.type){var f=this.saveManager.getWithId(b.id);f="not found"==f?d.active:f;new c.addLever(b.x+6,b.y,e.spriteHolder,f,d.duration,d.targets,b.id,d.important)}else if("leverBlock"==b.type){f=this.saveManager.getWithId(b.id);f="not found"==f?!0:f;var g=null;d.isBig&&(g={width:b.width,height:b.height,hasSpike:d.hasSpike});new c.addLeverBlock(b.x+b.width/2,b.y-
b.height/2,e.blockHolder,d.dx,d.dy,d.duration,b.id,f,g,d.doRotate,d.delay,d.important)}else if("moveSpikeGroup"==b.type){if(0==d.direction)var m=b.x+b.width,k=b.y-b.height/2;for(b=0;b<d.num;b++)new c.addMoveSpike(m+b*d.dx,k+b*d.dy,d.mx,d.my,d.duration,d.delay*b,e.spikeHolder)}else if("cannon"==b.type)new c.addCannon({x:b.x+b.width/2,y:b.y,holder:e.spriteHolder,shootTime:d.shootTime,delay:d.delay,gameTime:this.gameTime,power:d.power,rot:b.rotation,cannonType:d.cannonType,rotSpeed:d.rotSpeed,minRot:d.minRot,
maxRot:d.maxRot,laserActive:d.laserActive,isHoming:d.isHoming,locateToTarget:d.locateToChar?this["char"]:null,locateRatio:.05});else if("hideBlock"==b.type)new c.addTimeBlock(b.x+b.width/2,b.y-b.height/2,d.time,this.gameTime+d.delay,d.active,e.blockHolder);else if("startPoint"==b.type)d.no==this.startPointNo&&(this["char"].x=b.x,this["char"].y=b.y);else if("exitPoint"==b.type)this.exitPoints.push({x:b.x,y:b.y,toLevel:d.toLevel,toPoint:d.toPoint,key:d.key});else if("changePoint"==b.type)this.exitPoints.push({x:b.x,
y:b.y,toLevel:d.toLevel,toPoint:d.toPoint,key:d.key}),d.startPointNo==this.startPointNo&&(this["char"].x=b.x+d.startDistx,this["char"].y=b.y+d.startDisty);else if("ladder"==b.type)this.ladders.create(b.x+20,b.y-24,"atlas","ladder");else if("checkpoint"==b.type)new c.addCheckPoint(b.x+20,b.y-30,this.holders.checkpoints,b.id);else if("box"==b.type)new this.objectFactory.addBox(b.x+b.width/2,b.y-b.height/2,this.holders.boxHolder,"none",b.width);else if("enemy"==b.type)new this.objectFactory.addEnemy(b.x+
b.width/2,b.y-20,this.holders.spriteHolder,d.right,d.left,d.vx,b.id);else if("key"==b.type){if(f=this.saveManager.getWithId(b.id),f="not found"==f?!0:f)new this.objectFactory.addKey(b.x+b.width/2,b.y-16,this.holders.spriteHolder,d.no,b.id),this.inventory.removeKey(d.no)}else"info"==b.type?(b=this.add.sprite(b.x+b.width/2,b.y-24,"atlas","info"),b.text=this.add.bitmapText(0,0,"font",d.data),b.text.bringToTop=!0,this.infos.push(b)):"paper"==b.type?(f=this.inventory.getWithId(d.id))||new c.addPaper(b.x+
10,b.y-10,e.spriteHolder,d.id):"map"==b.type?(f=this.inventory.getWithId(d.id,!1,!0))||new c.addMap(b.x+10,b.y-10,e.spriteHolder,d.id):"water"==b.type?(d=this.add.tileSprite(b.x+b.width/2,b.y+b.height/2,b.width,b.height,"water"),d.alpha=.6,d.topSprite=this.add.tileSprite(b.x+b.width/2,b.y,b.width,4,"atlas","waterTop"),d.topSprite.destroyOnLevelChange=!0,b=new Phaser.Geom.Rectangle(b.x,b.y,b.width,b.height),d.rectArea=b,this.waters.push(d)):"wind"==b.type?(g="windVertical",d.vx&&(g="windHorizantal"),
f=this.add.tileSprite(b.x+b.width/2,b.y+b.height/2,b.width,b.height,g),f.changeTime=null,d.changeTime&&(f.changeTime=this.gameTime+d.changeTime,f.changeDuration=d.changeTime),f.flipY=!0,f.alpha=.5,b=new Phaser.Geom.Rectangle(b.x,b.y,b.width,b.height),f.rectArea=b,f.vx=d.vx,f.vy=d.vy,f.posx=0,f.posy=0,this.winds.push(f)):"item"==b.type?(f=this.inventory.getWithId(d.id,!0))||new c.addItem(b.x+20,b.y-20,e.spriteHolder,d.id):"keyblock"==b.type?new this.objectFactory.addKeyBlock(b.x+20,b.y-20,e.blockHolder,
d.no):"weakBlock"==b.type?new this.objectFactory.addWeakBlock(b.x+20,b.y-20,e.blockHolder,d.time):"bubbleHole"==b.type?new this.objectFactory.addBubbleHole(b.x+20,b.y,e.spriteHolder,d.vx,d.vy,d.quantity):"secretPlace"==b.type?(f=this.saveManager.getWithId(b.id),f="not found"==f?!1:f,f||(f=this.add.graphics(),f.fillStyle(658191),f.fillRect(b.x,b.y,b.width,b.height),f.parentObj={type:"secretPlace",obj:f,id:b.id,rect:new Phaser.Geom.Rectangle(b.x,b.y,b.width,b.height),opened:!1,key:d.key})):"coin"==
b.type&&(f=this.saveManager.getWithId(b.id),f="not found"==f?!1:f,f||(g=d.isgold?"coin":"silverCoin",f=d.isgold?"coinSpin":"coinSpinSilver",g=this.add.sprite(b.x,b.y,g),g.destroyOnLevelChange=!0,g.anims.play(f),g.parentObj={type:"coin",obj:g,id:b.id,active:!1,important:!0,isGold:d.isgold}))}m=$jscomp.makeIterator(this.children.list);for(k=m.next();!k.done;k=m.next())if(k=k.value,k.parentObj&&"bubbleHole"==k.parentObj.type)for(c=$jscomp.makeIterator(this.waters),e=c.next();!e.done;e=c.next())d=e.value,
Phaser.Geom.Rectangle.ContainsRect(d.rectArea,k.getBounds())&&(k.parentObj.water=d);this.checkPoint&&(this["char"].x=this.checkPoint.x,this["char"].y=this.checkPoint.y)}};
app.game.setTileCollider=function(a){this.groundCollider=this.physics.add.collider(a,this["char"],null,function(a,e){40==e.index?a.onIce=!0:-1!=e.index&&(a.onIce=!1);if(2==e.index)a.alive&&a.body.right>e.pixelX&&a.body.left+5<e.pixelX+40&&a.body.bottom>e.pixelY+30&&this["char"].die()&&this.newLevel(!0);else if(6==e.index&&(a.alive&&a.body.right>e.pixelX&&a.body.left+5<e.pixelX+40&&a.body.top<e.pixelY+10&&this["char"].die()&&this.newLevel(!0),a.alive))return!1;return!0},this);this.groundCollider3=
this.physics.add.collider(a,this.boxHolder);this.groundCollider2=this.physics.add.collider(a,this.holders.arrowHolder,function(a,e){for(var c=$jscomp.makeIterator([2,3,4,5,6]),b=c.next();!b.done;b=c.next())if(e.index==b.value)return!1;a==this.arrow&&(this.arrow=null);a.mark.destroy();a.destroy();return!0},null,this)};
app.game.addAbility=function(a,c,e,d,b){var f=[{cooldown:2E4,duration:5E3,key:"z",no:0},{cooldown:4E4,duration:5E3,key:"x",no:1},{cooldown:5E3,duration:5E3,key:"c",no:2}],g=this.add.sprite(a,c,"atlas",e).setScrollFactor(0);g.cooldown=f[d].cooldown;g.duration=f[d].duration;g.key=f[d].key;g.no=d;g.state=0;this["ability"+d]=g;b||this.abilities.push({x:a,y:c,texture:e,no:d})};
app.game.tutorial1=function(){this.speech&&this.tut1&&this.tut2&&700<this["char"].y&&this.speech.done&&!this["char"].freeze&&(400<this["char"].x?this.tut2.alpha-=.03:200<this["char"].x?(this.tut1.alpha-=.03,this.tut2.alpha+=.03):(this.tut1.alpha+=.03,this.tut2.alpha-=.03));!this.bow&&1990<this["char"].x&&!this.gamePaused&&(this.gamePaused=!0,this.newLevel());!this.bossBall&&!this.bow&&500<this["char"].y&&0==this["char"].body.velocity.y&&(this.bossBall=this.add.sprite(2100,800,"atlas","bossBall"),
app.soundManager.changeMusic(this,"loopHorror"),this.tweens.add({targets:this.bossBall,x:1800,duration:2E3,ease:"linear",onComplete:function(){var a=this.parent.scene,e=a.bossBall.x,d=a.bossBall.y-50,b=a["char"].x,f=a["char"].y-50;a.speech=new app.Speech(a,[{text:"WHO ARE YOU?",x:e-100,y:d,tween:{duration:300,delay:200,waitDelay:1500}},{text:"????",x:b-30,y:f,tween:{duration:300,delay:200,waitDelay:1500}},{text:"YOU WANT THE BOW\n I ASSUME",x:e-120,y:d-20,tween:{duration:300,delay:200,waitDelay:2E3}},
{text:"YES...",x:b-50,y:f,tween:{duration:300,delay:200,waitDelay:1500}},{text:" YOU CAN\nKEEP THE BOW..",x:e-80,y:d-20,tween:{duration:300,delay:200,waitDelay:2E3}},{text:" BUT FIRST YOU\nHAVE TO DESERVE IT",x:e-100,y:d-20,tween:{duration:300,delay:200,waitDelay:2500}},{text:" SURVIVE IN THIS CAVE\nAND DEFEAT MY CHAMPIONS",x:e-200,y:d-20,tween:{duration:300,delay:200,waitDelay:3E3}},{text:" LET ME TEACH YOU\nHOW TO USE THE BOW",x:e-120,y:d-20,tween:{duration:300,delay:200,waitDelay:2E3}},{text:"FOLLOW ME!",
x:e-50,y:d-20,tween:{duration:300,delay:200,waitDelay:1500},complete:function(){a["char"].freeze=!1;a.gamePaused=!1;a.tweens.add({targets:a.bossBall,x:2100,ease:"linear",duration:500,repeat:0,delay:0})}}]);a.speech.start()}}),this.tweens.add({targets:this.bossBall,y:this.bossBall.y-10,duration:500,ease:"Sine.easeInOut",yoyo:!0,repeat:-1}));if(this.bow&&Phaser.Geom.Intersects.RectangleToRectangle(this["char"].getBounds(),this.bow.getBounds())){this.achievements.open(0,!0);var a=this.add.bitmapText(this.bow.x,
this.bow.y-50,"font"," WAIT...\nWHATS GOING ON???");a.x=this.bow.x-a.width/2;a.alpha=0;this.tweens.add({targets:a,alpha:1,duration:500,delay:250,onComplete:function(){this.parent.add({targets:a,alpha:0,duration:500,delay:1500})}});this.tweens.add({targets:this["char"],x:this.bow.x,y:this.bow.y,duration:500});this.bow.destroy();this["char"].freeze=!0;this.bow=null;this.cameras.main.shake(3E3,.003);app.soundManager.playSfx(this,"earthquake");this.cameras.main.once("camerashakecomplete",function(a){this.cameras.main.shake(1200,
.01);a=this.add.graphics().setScrollFactor(0);a.fillStyle(16777215);a.fillRect(0,0,800,600);a.alpha=0;app.soundManager.playSfx(this,"flicker");this.tweens.add({targets:a,alpha:1,duration:50,yoyo:!0,repeat:10,onYoyo:function(){.3>Math.random()&&app.soundManager.playSfx(this.parent.scene,"flicker")},onComplete:function(){var a=this.parent.scene;a["char"].flipX=!1;a.cameras.main.followOffset.x=-100;for(var c=a.holders.blockHolder.getChildren(),b=c.length-1;0<=b;b--)c[b].destroy();a.gamePaused=!0;a.particle1.emitParticleAt(1500,
140);a.particle1.emitParticleAt(1780,330);a.particle1.emitParticleAt(1880,330);a.particle1.emitParticleAt(1850,460);a.particle1.emitParticleAt(1650,460);a.particle1.emitParticleAt(1450,460);a.map.putTileAt(-1,39,3);a.map.putTileAt(-1,40,3);a.map.putTileAt(-1,41,3);for(b=27;49>=b;b++)for(c=5;15>c;c++)a.map.putTileAt(-1,b,c);for(b=20;31>=b;b++)for(c=9;29>=c;c++)a.map.putTileAt(-1,b,c)}},this)},this)}};
app.game.level1=function(a){this["char"].x=1830;this["char"].y=150;this.bow&&this.bow.destroy();this.bow=this.add.sprite(1625,90,"atlas","bow");this.tweens.add({targets:this.bow,y:this.bow.y-10,duration:500,ease:"Sine.easeInOut",yoyo:!0,repeat:-1});this.particle1=this.emitManager.addEmitter("particle2",{angle:{min:180,max:360},speed:{min:200,max:300},quantity:10,lifespan:5E3,gravityY:1E3,alpha:{start:1,end:0},scale:{start:1.5,end:1},on:!1});if(!this.tut1Showed){this["char"].freeze=!0;var c=this;this.speech=
new app.Speech(this,[{text:" I AM JUST \nAN ORDINARY MAN",x:50,y:800,tween:{duration:300,delay:500,waitDelay:1500}},{text:" I HEARD RUMORS\nABOUT AN ANCIENT BOW...",x:30,y:800,tween:{duration:300,delay:500,waitDelay:3E3}},{text:"..HIDDEN IN THIS CAVE",x:50,y:800,tween:{duration:300,delay:500,waitDelay:2E3}},{text:"NOW ALL I WANT\nIS TO HAVE IT",x:50,y:800,tween:{duration:300,delay:500,waitDelay:4E3},complete:function(){c.tut1Showed=!0;c.tweens.add({targets:e,alpha:1,ease:"linear",duration:500,
repeat:0,delay:0,onComplete:function(){c["char"].freeze=!1;c.speechTip&&this.parent.add({targets:c.speechTip,y:600,duration:500,ease:"Sine.easeInOut",onComplete:function(){this.targets[0].destroy();c.speechTip=null}})}})}}]);var e=this.add.image(80,800,"atlas","tutorial1");a=this.add.image(280,800,"atlas","tutorial2");e.alpha=a.alpha=0;this.tut1=e;this.tut2=a;this.speechTip=this.add.container().setScrollFactor(0);a=this.add.graphics();a.fillStyle(0);a.fillRect(-400,0,800,50);var d=this.add.bitmapText(0,
18,"font","PRESS SPACE TO SPEED UP SPEECHES");d.x-=d.width/2;this.speechTip.add(a);this.speechTip.add(d);this.speechTip.x=400;this.speechTip.y=600;this.tweens.add({targets:this.speechTip,y:550,delay:1500,duration:500,ease:"Sine.easeInOut"});this.speech.start()}};
app.game.level2=function(a){app.soundManager.changeMusic(this,"gameLoop",this.levelNo);this.tut2Showed?(a=this.ladders.create(740,920,"atlas","ladder"),this.children.sendToBack(a),a=this.ladders.create(740,960,"atlas","ladder"),this.children.sendToBack(a),a=this.ladders.create(740,1E3,"atlas","ladder"),this.children.sendToBack(a),this.children.sendToBack(this.bg)):(this.cameras.main.stopFollow(),this["char"].freezeMovement=!0,this["char"].freezeTeleport=!0,this.tutStep=1,this.bossBall=this.add.sprite(200,
900,"atlas","bossBall"),this.tweens.add({targets:this.bossBall,y:this.bossBall.y-10,duration:500,ease:"Sine.easeInOut",yoyo:!0,repeat:-1}),this.bossText=this.add.bitmapText(this.bossBall.x+50,this.bossBall.y-20,"font","FIRST THING FIRST.\nPRESS SPACE TO SHOOT AN ARROW"))};
app.game.level5=function(){var a=this.objectFactory,c=this.holders;this.achievements.isOpened(10)||(this.bossCollider&&this.bossCollider.destroy(),this.boss?this.boss.inView&&(this.boss.reset(),this.cameras.main.stopFollow()):(this.boss=new app.Boss1(this,1700,450,this["char"],c.arrowHolder,this.emitManager),this.boss.checkX=1300,this.boss.checkY=450,this.boss.once("inview",function(){this["char"].freeze=!0;app.soundManager.changeMusic(this,"loopHorror")},this),this.boss.once("fight",function(){this["char"].freeze=
!1;app.soundManager.changeMusic(this,"bossLoop")},this),this.boss.on("chardead",function(){!this.boss.dead&&this["char"].alive&&this["char"].die()&&this.newLevel(!0)},this),this.boss.on("bossdead",function(){var e=this.getObjectWithId(252);app.soundManager.changeMusic(this,"gameLoop",this.levelNo);e&&e.parentObj.change();this.achievements.bossDefeated(0);this.achievements.open(10);if(!this.inventory.getWithId(4,!0)){var d=(new a.addItem(this.boss.x,this.boss.y,c.spriteHolder,4,!0)).obj;d.setScale(.1);
this.tweens.add({targets:d,scaleX:1,scaleY:1,y:400,duration:1500,ease:"Sine.easeInOut",onComplete:function(){this.parent.add({targets:d,y:d.y-10,duration:500,ease:"Sine.easeInOut",yoyo:!0,repeat:-1})}})}},this)),this.bossCollider=this.physics.add.collider(this.boss,this.groundLayer))};
app.game.level6=function(){if(!this.achievements.isOpened(3)){this.achievements.secretRoomFound(0);var a=this.add.bitmapText(400,-100,"font","SECRET ROOM DISCOVERED");a.setScrollFactor(0);a.setScale(2);a.x-=a.width/2;var c=this;this.tweens.add({targets:a,y:50,duration:500,delay:500,onComplete:function(){c.tweens.add({targets:a,y:-100,duration:500,delay:1500,onComplete:function(){c.achievements.open(3)}})}});this.secretTxt=a}};
app.game.level7=function(){if(!this.achievements.isOpened(4)){this.achievements.secretRoomFound(1);var a=this.add.bitmapText(400,-100,"font","SECRET ROOM DISCOVERED");a.setScrollFactor(0);a.setScale(2);a.x-=a.width/2;var c=this;this.tweens.add({targets:a,y:50,duration:500,delay:500,onComplete:function(){c.tweens.add({targets:a,y:-100,duration:500,delay:1500,onComplete:function(){c.achievements.open(4)}})}});this.secretTxt=a}};
app.game.level14=function(){var a=this.objectFactory,c=this.holders;this.achievements.isOpened(11)||(this.bossCollider&&this.bossCollider.destroy(),this.boss?this.boss.inView&&(this.boss.reset(),this.cameras.main.stopFollow()):(this.boss=new app.Boss2(this,1700,450,this["char"],c.arrowHolder,this.emitManager),this.boss.checkX=1300,this.boss.checkY=450,this.boss.once("inview",function(){this["char"].freeze=!0;app.soundManager.changeMusic(this,"loopHorror")},this),this.boss.once("fight",function(){this["char"].freeze=
!1;app.soundManager.changeMusic(this,"bossLoop")},this),this.boss.on("chardead",function(){!this.boss.dead&&this["char"].alive&&this["char"].die()&&this.newLevel(!0)},this),this.boss.on("bossdead",function(){app.soundManager.changeMusic(this,"gameLoop",this.levelNo);this.getObjectWithId(427)&&this.getObjectWithId(427).parentObj.change();this.achievements.bossDefeated(1);this.achievements.open(11);if(!this.inventory.getWithId(5,!0)){var e=(new a.addItem(this.boss.x,this.boss.y,c.spriteHolder,5,!0)).obj;
e.setScale(.1);this.tweens.add({targets:e,scaleX:1,scaleY:1,y:400,duration:1500,ease:"Sine.easeInOut",onComplete:function(){this.parent.add({targets:e,y:e.y-10,duration:500,ease:"Sine.easeInOut",yoyo:!0,repeat:-1})}})}},this)),this.bossCollider=this.physics.add.collider(this.boss,this.groundLayer))};
app.game.level15=function(){if(!this.achievements.isOpened(5)){this.achievements.secretRoomFound(2);var a=this.add.bitmapText(400,-100,"font","SECRET ROOM DISCOVERED");a.setScrollFactor(0);a.setScale(2);a.x-=a.width/2;var c=this;this.tweens.add({targets:a,y:50,duration:500,delay:500,onComplete:function(){c.tweens.add({targets:a,y:-100,duration:500,delay:1500,onComplete:function(){c.achievements.open(5)}})}});this.secretTxt=a}};
app.game.level25=function(){var a=this.objectFactory,c=this.holders;if(this.achievements.isOpened(12))this.inventory.hasKey(5)||new a.addKey(1780,200,c.spriteHolder,5,1001);else{this.bossCollider&&this.bossCollider.destroy();if(this.boss)this.boss.inView&&(this.boss.reset(),this.cameras.main.stopFollow());else{var e=new a.addLever(1880,363,c.spriteHolder,!1,500,"",724);e.obj.dontDestroy=!0;e.infoTxt.dontDestroy=!0;this.boss=new app.Boss3(this,1860,150,this["char"],c.arrowHolder,this.emitManager,e.obj);
this.boss.checkX=1300;this.boss.checkY=390;this.boss.once("inview",function(){this["char"].freeze=!0;app.soundManager.changeMusic(this,"loopHorror")},this);this.boss.once("fight",function(){this["char"].freeze=!1;app.soundManager.changeMusic(this,"bossLoop")},this);this.boss.on("addblocks",function(){for(var d=$jscomp.makeIterator(this.weakBlocks),b=d.next();!b.done;b=d.next())b=b.value,b.parentObj&&b.destroy&&b.parentObj.active&&(b.parentObj.destroy(),b.destroy());d=new a.addWeakBlock(1670,280,c.blockHolder,
500);b=new a.addWeakBlock(1470,280,c.blockHolder,500);var e=new a.addWeakBlock(1270,200,c.blockHolder,500);d.obj.alpha=b.obj.alpha=e.obj.alpha=0;this.weakBlocks=[d.obj,b.obj,e.obj];this.scene.tweens.add({targets:this.weakBlocks,duration:500,alpha:1})});this.boss.on("chardead",function(){!this.boss.dead&&this["char"].alive&&this["char"].die()&&this.newLevel(!0)},this);this.boss.on("bossdead",function(){app.soundManager.changeMusic(this,"gameLoop",this.levelNo);this.achievements.bossDefeated(2);this.achievements.open(12);
if(!this.inventory.hasKey(5)){var d=(new a.addKey(this.boss.x,this.boss.y,c.spriteHolder,5,1001,!0)).obj;d.setScale(.1);this.tweens.add({targets:d,scaleX:1,scaleY:1,y:200,x:1780,duration:1500,ease:"Sine.easeInOut",onComplete:function(){this.parent.add({targets:d,y:190,duration:500,ease:"Sine.easeInOut",yoyo:!0,repeat:-1})}})}},this)}this.bossCollider=this.physics.add.collider(this.boss,this.groundLayer)}};
app.game.level26=function(){if(!this.achievements.isOpened(20)){this.achievements.secretRoomFound(3);var a=this.add.bitmapText(400,-100,"font","SECRET ROOM DISCOVERED");a.setScrollFactor(0);a.setScale(2);a.x-=a.width/2;var c=this;this.tweens.add({targets:a,y:50,duration:500,delay:500,onComplete:function(){c.tweens.add({targets:a,y:-100,duration:500,delay:1500,onComplete:function(){c.achievements.open(20)}})}});this.secretTxt=a}};
app.game.level27=function(){if(!this.achievements.isOpened(21)){this.achievements.checkForExtraDifficult();this.achievements.open(21);this.save();this.bossBall=this.add.sprite(1440,250,"atlas","bossBall");this.tweens.add({targets:this.bossBall,y:this.bossBall.y-10,duration:500,ease:"Sine.easeInOut",yoyo:!0,repeat:-1});var a=this;this.speech=new app.Speech(this,[{text:"WELL DONE!",x:1480,y:240,tween:{duration:300,delay:2E3,waitDelay:2E3}},{text:"YOU MANAGED TO FIND THE EXIT",x:1480,y:240,tween:{duration:300,
delay:200,waitDelay:2E3}},{text:"YOU DESERVE THE BOW",x:1480,y:240,tween:{duration:300,delay:200,waitDelay:2E3}},{text:"CLIMB THE STAIRS\nAND YOU ARE OUT",x:1480,y:240,tween:{duration:300,delay:200,waitDelay:2E3},complete:function(){a.tweens.add({targets:a.bossBall,y:-100,ease:"linear",duration:2E3,repeat:0,delay:0,onComplete:function(){a.bossBall.destroy()}})}}]);this.speech.start()}};
app.game.level28=function(){this.clearScene();this.gamePaused=!0;var a=this.add.bitmapText(400,100,"font","GAME OVER!").setScale(3);a.x-=a.width/2;a=this.add.bitmapText(400,200,"font","THANKS FOR PLAYING").setScale(2);a.x-=a.width/2;var c=this.add.sprite(400,500,"atlas","buttonBack").setScrollFactor(0).setInteractive({useHandCursor:!0}).setOrigin(.5,.25);a=this.add.bitmapText(400,500,"font","MENU").setScrollFactor(0).setScale(1.5);a.x-=a.width/2;c.txt=a;c.on("pointerover",function(){app.soundManager.playSfx(this.scene,
"hover");this.tw?this.tw.resume():this.tw=this.scene.tweens.add({targets:[this,this.txt],y:this.y-5,duration:250,ease:"Sine.easeInOut",yoyo:!0,repeat:-1})});c.on("pointerout",function(){this.tw&&this.tw.pause()});c.on("pointerdown",function(){app.soundManager.playSfx(this.scene,"switch");this.tw&&this.tw.pause();var a=this.scene;a.levelNo=-1;a.scene.start("menu")})};
app.game.getObjectWithId=function(a){var c=Array.from(this.children.list);c=$jscomp.makeIterator(c);for(var e=c.next();!e.done;e=c.next())if(e=e.value,e.id===a||e.parentObj&&e.parentObj.id===a)return e;return null};app.game.tilePointCheck=function(a,c){var e=app.pixelToGrid(a,c),d=this.groundLayer.layer.data[e.row];if(!d)return!1;e=d[e.col];if(!e)return!1;d=$jscomp.makeIterator([-1,2,3,4,5,6]);for(var b=d.next();!b.done;b=d.next())if(e.index==b.value)return!1;return!0};
app.game.checkScreenBounds=function(a,c){return 0>a||a>this.map.widthInPixels||0>c||c>this.map.heightInPixels?!0:!1};app.game.spriteGroupCollision=function(a,c,e){var d=c.children.entries;c=a.getBounds();d=$jscomp.makeIterator(d);for(var b=d.next();!b.done;b=d.next())if(b=b.value,0==e){if(Phaser.Geom.Intersects.RectangleToRectangle(c,b.getBounds()))return b}else{if(b.body&&!b.body.enable)break;if(b.getBounds().contains(a.x,a.y))return b}return!1};
app.game.addExplosion=function(a,c){var e=this.add.sprite(a,c,"explosion");e.setScale(2);e.anims.play("explosionAnim");e.once("animationcomplete",function(){this.destroy()})};