text: !function(){function a(a,b){if(z.time.elapsedSince(a.lastTheft)>200&&z.score>0){z.score--,a.game.playsound("thief_sound"),a.lastTheft=z.time.time,z.coinsleftText.count.setText(z.level.goal-z.score);var c=z.add.text(a.x,a.top-100,"-1",{font:C.textFont,fill:C.textstyle.interactions.color_thief,fontSize:C.textstyle.interactions.size});z.street&&z.street.add(c),z.add.tween(c).from({y:a.y,alpha:0},1e3,Phaser.Easing.Linear.None,!0).onComplete.add(c.destroy,c)}}function b(){for(var a=0;a<this.children.length;a++)z.path.updateDirection(this.children[a])}function c(){for(var a=0;a<z.treasures.length;a++){var b=z.treasures.children[a];if(z.physics.arcade.distanceBetween(z.player,b)<50)if(b.data.life--,C.playsound("hit_sound"),b.data.life>0){var c=z.add.text(b.x,b.top-120,b.data.life,{font:this.game.textFont,fill:C.textstyle.interactions.color_treasure,fontSize:C.textstyle.interactions.size});z.street&&z.street.add(c),z.add.tween(c).from({y:b.top,alpha:0},500,Phaser.Easing.Linear.None,!0).onComplete.add(c.destroy,c)}else z.treasures.breack(b)}}function d(a){this.game.playsound("break_sound");for(var b=new Phaser.Point(500,0),c=2*Math.PI/a.data.coins,d=0;d<a.data.coins;d++){var e=z.coins.create(a.x,a.y,"coin",0);e.body.velocity.setTo(b.x,b.y),e.body.collideWorldBounds=!0,e.anchor.setTo(.5,1),e.body.setSize(e.width/2,A),z.keepInTheStreet.push(e),z.add.tween(e.body.velocity).to({x:0,y:0},1e3,Phaser.Easing.Linear.None,!0),e.animations.add("spin",[0,1,2,3,4,5,6,7],10,!0),e.animations.play("spin"),b.rotate(0,0,c)}a.destroy()}function e(){for(var a=0;a<z.level.objects.boots.length;a++)if(z.level.objects.boots[a].time===z.level.time-z.timer.left){var b=this.create(z.level.objects.boots[a].x,z.level.objects.boots[a].y,"boots");r(b)}}function f(a,b){b.destroy();var c=C.add.tween(a);if(z.player.speed_bonus.isRunning){var d=z.player.speed_bonus.timeline[0],e=d.duration-d.dt,f=z.player.speed;z.player.speed=C.conf.speed_player,z.player.speed_bonus.stop(),z.player.speed_bonus=c.from({speed:2*f},4e3+e,"Linear",!0)}else z.player.speed_bonus=c.from({speed:2*a.speed},4e3,"Linear",!0)}function g(a,b){if(b.destroy(),a.game.playsound("coin_sound"),z.currentCoin<z.level.coins.length){var c=z.coins.create(z.level.coins[z.currentCoin].x,z.level.coins[z.currentCoin].y,"coin");c.animations.add("spin",[0,1,2,3,4,5,6,7],10,!0),c.animations.play("spin"),r(c),z.currentCoin++}var d=z.level.goal-z.score-1;d>=0&&(z.score++,z.coinsleftText.count.setText(d),0==d&&z.levelpassed())}function h(a,b){a.allowTeleport&&(a.animation="fall",a.isTeleporting?a.body.velocity.setTo(0,0):(a.isTeleporting=!0,z.timer.add(500,this.go,this,a,b),a.game.playsound("drain_sound")))}function j(a,b){var c=z.drains.children[b.go];z.camera.unfollow(),z.player.exists=!1,a.position.setTo(c.x+c.width/2,c.y+c.height/2),z.add.tween(z.camera.view).to({x:a.position.x-z.camera.view.halfWidth,y:a.position.y-z.camera.view.halfHeight},500).start().onComplete.add(function(){z.camera.follow(a),z.player.exists=!0},z),a.allowTeleport=!1,a.isTeleporting=!1}function k(a,b){a.allowSlip&&(a.allowSlip=!1,a.game.playsound("oil_sound"),console.log(a.body.velocity.x),a.body.facing==Phaser.UP||a.body.facing==Phaser.DOWN?z.add.tween(a.body.velocity).to({y:0},1500,"Linear",!0):z.add.tween(a.body.velocity).to({x:0},1500,"Linear",!0))}function l(){z.joystick.resetFrames(),z.joystick.down.isDown?(z.joystick.down.frame=1,this.body.velocity.setTo(0,this.speed),this.animation="down"):z.joystick.left.isDown?(z.joystick.left.frame=1,this.body.velocity.setTo(-this.speed,0),this.animation="left"):z.joystick.right.isDown?(z.joystick.right.frame=1,this.body.velocity.setTo(this.speed,0),this.animation="right"):z.joystick.up.isDown&&this.y>505?(z.joystick.up.frame=1,this.body.velocity.setTo(0,-this.speed),this.animation="up"):(this.body.velocity.setTo(0,0),this.animation=null)}function m(){u.down.isDown||C.input.keyboard.isDown(Phaser.Keyboard.S)?(this.body.velocity.setTo(0,this.speed),this.animation="down"):u.left.isDown||C.input.keyboard.isDown(Phaser.Keyboard.A)?(this.body.velocity.setTo(-this.speed,0),this.animation="left"):u.right.isDown||C.input.keyboard.isDown(Phaser.Keyboard.D)?(this.body.velocity.setTo(this.speed,0),this.animation="right"):u.up.isDown||C.input.keyboard.isDown(Phaser.Keyboard.W)?this.y>505&&(this.body.velocity.setTo(0,-this.speed),this.animation="up"):(this.body.velocity.setTo(0,0),this.animation=null)}function n(){this.animation?this.animations.play(this.animation):this.animations.stop()}function o(){for(button in this)this[button].frame=0}function p(a){this.label.text.text=a,this.label.width=this.label.text.width+50}function q(){this.left--,0===this.left?(this.remove(this.timeLeftEvent),z.gameover()):this.left<=10&&(this.game.playsound("beep_sound"),this.text.addColor("#FF0000",0),this.text.count.addColor("#FF0000",0)),z.timer.text.count.setText(this.left),z.boots.generate()}function r(a){if(a instanceof Phaser.Group)for(var b=0;b<a.length;b++)r(a.children[b]);else a.anchor.setTo(.5,1),a.body.setSize(2*a.width/3,A)}function s(a){switch(a){case B.up:return"up";case B.down:return"down";case B.right:return"right";case B.left:return"left"}}function t(a){var b=Math.PI/4;return-b>a&&a>3*-b?B.up:a>b&&3*b>a?B.down:a>-b&&b>a?B.right:B.left}Phaser.Group.prototype.drawCache=[],Phaser.Group.prototype.renderDrawCache=!1,Phaser.Group.prototype._recursiveCache=function(a){for(var b=0;b<a.length;b++)a[b]instanceof Phaser.Group?this._recursiveCache(a[b].children):this.drawCache.push(a[b])},Phaser.Group.prototype.updateDrawCache=function(){this.drawCache.length=0,this._recursiveCache(this.children)},Phaser.Group.prototype._renderWebGL=function(a){if(this.visible&&!(this.alpha<=0)){if(this._cacheAsBitmap)return void this._renderCachedSprite(a);var b,c;if(c=this.renderDrawCache?this.drawCache:this.children,this._mask||this._filters){for(this._mask&&(a.spriteBatch.stop(),a.maskManager.pushMask(this.mask,a),a.spriteBatch.start()),this._filters&&(a.spriteBatch.flush(),a.filterManager.pushFilter(this._filterBlock)),b=0;b<c.length;b++)c[b]._renderWebGL(a);a.spriteBatch.stop(),this._filters&&a.filterManager.popFilter(),this._mask&&a.maskManager.popMask(a),a.spriteBatch.start()}else for(b=0;b<c.length;b++)c[b]._renderWebGL(a)}},Phaser.Group.prototype._renderCanvas=function(a){if(this.visible!==!1&&0!==this.alpha){if(this._cacheAsBitmap)return void this._renderCachedSprite(a);this._mask&&a.maskManager.pushMask(this._mask,a);var b;b=this.renderDrawCache?this.drawCache:this.children;for(var c=0;c<b.length;c++)b[c]._renderCanvas(a);this._mask&&a.maskManager.popMask(a)}},Phaser.Group.prototype.sort=function(a,b,c){if(!(this.children.length<2)){"undefined"==typeof a&&(a="z"),"undefined"==typeof b&&(b=Phaser.Group.SORT_ASCENDING),this._sortProperty=a;var d;c?(this.updateDrawCache(),this.renderDrawCache=!0,d=this.drawCache):(this.renderDrawCache&&(this.renderDrawCache=!1),d=this.children),b===Phaser.Group.SORT_ASCENDING?d.sort(this.ascendingSortHandler.bind(this)):d.sort(this.descendingSortHandler.bind(this)),this.updateZ()}};var u,v={init:function(){this.scale.scaleMode=Phaser.ScaleManager.USER_SCALE,this.scale.setMinMax(200,100,1200,750),this.scale.pageAlignHorizontally=!0,this.scale.setResizeCallback(this.onResizeCallback,this),this.game.device.desktop||(this.scale.forceOrientation(!0,!1),this.scale.enterIncorrectOrientation.add(this.enterIncorrectOrientation,this),this.scale.leaveIncorrectOrientation.add(this.leaveIncorrectOrientation,this)),C.host=window.location.host},onResizeCallback:function(){var a=Math.min(window.innerWidth/this.game.width,window.innerHeight/this.game.height);this.scale.setUserScale(a,a,0,0)},enterIncorrectOrientation:function(){document.getElementById("orientation").style.display="block",document.getElementById("game").style.display="none",this.game.paused=!0},leaveIncorrectOrientation:function(){document.getElementById("orientation").style.display="none",document.getElementById("game").style.display="block",this.game.paused=!1},preload:function(){this.load.text("conf","./config.json"),this.load.image("preloadbar","assets/images/preloader-bar.png"),this.load.image("rotatescreen","assets/images/rotatescreen.png"),this.physics.startSystem(Phaser.Physics.ARCADE),this.game.soundOn=!0},create:function(){this.game.input.maxPointers=2,C.conf=JSON.parse(this.game.cache.getText("conf")),C.textFont=C.conf.textfont.name,C.textstyle=C.conf.text_styles,localStorage.lastUnblockedLevel||localStorage.setItem("lastUnblockedLevel",1),C.current_lev=parseInt(localStorage.lastUnblockedLevel),WebFont.load({google:{families:[C.conf.textfont.family]},active:function(){C.state.start("Load")}})}},w={preload:function(){this.preloadBar=this.add.image(180,this.world.centerY,"preloadbar"),this.preloadBar.scale.setTo(17,7),this.load.setPreloadSprite(this.preloadBar);var a={font:C.textFont,fill:C.textstyle.loading.color,fontSize:C.textstyle.loading.size};this.add.text(this.world.centerX,this.preloadBar.y-80,"Loading...",a).anchor.setTo(.5,.5),this.load.image("menu_title","assets/images/menu_title.png"),this.load.spritesheet("coin_menu","assets/images/coin_menu.png",100,100),this.load.image("arrow_left","assets/images/arrow_left.png"),this.load.image("arrow_right","assets/images/arrow_right.png"),this.load.image("lock","assets/images/lock.png"),this.load.text("language","assets/languages/"+C.conf.lang+".json"),this.load.image("panel","assets/images/panel.png"),this.load.image("level_label","assets/images/level_label.png"),this.load.spritesheet("button","assets/images/button.png",293,112.5),this.load.spritesheet("speaker","assets/images/speaker.png",60,60),this.load.image("pause_button","assets/images/pause_button.png"),this.load.spritesheet("star","assets/images/star.png",95,97),this.load.spritesheet("player","assets/images/player.png",64,96),this.load.image("city","assets/images/city.png"),this.load.spritesheet("joystick","assets/images/joystick.png",180,144),this.load.image("hitButton","assets/images/hitButton.png"),this.load.spritesheet("coin","assets/images/coin.png",64,64),this.load.image("boots","assets/images/boots.png"),this.load.image("oil","assets/images/oil_spot.png"),this.load.image("drain","assets/images/drain.png"),this.load.image("trash","assets/images/trash.png"),this.load.image("box","assets/images/box.png"),this.load.spritesheet("robber","assets/images/robber.png",64,96),this.load.spritesheet("treasure","assets/images/treasure.png",64,96);for(var b=1;b<C.conf.total_levels+1;b++)this.load.text("level"+b,"assets/levels/level"+b+".json");this.load.audio("click_sound",["assets/sounds/click.ogg","assets/sounds/click.wma","assets/sounds/click.mp3"]),this.load.audio("music",["assets/sounds/music.ogg","assets/sounds/music.wma","assets/sounds/music.mp3"],!0),this.load.audio("coin_sound",["assets/sounds/coin.ogg","assets/sounds/coin.wma","assets/sounds/coin.mp3"]),this.load.audio("thief_sound",["assets/sounds/thief.ogg","assets/sounds/thief.wma","assets/sounds/thief.mp3"]),this.load.audio("hit_sound",["assets/sounds/hit.ogg","assets/sounds/hit.wma","assets/sounds/hit.mp3"]),this.load.audio("break_sound",["assets/sounds/break.ogg","assets/sounds/break.wma","assets/sounds/break.mp3"]),this.load.audio("drain_sound",["assets/sounds/drain.ogg","assets/sounds/drain.wma","assets/sounds/drain.mp3"]),this.load.audio("oil_sound",["assets/sounds/oil.ogg","assets/sounds/oil.wma","assets/sounds/oil.mp3"]),this.load.audio("win_sound",["assets/sounds/win.ogg","assets/sounds/win.wma","assets/sounds/win.mp3"]),this.load.audio("gameover_sound",["assets/sounds/gameover.ogg","assets/sounds/gameover.wma","assets/sounds/gameover.mp3"]),this.load.audio("bad_sound",["assets/sounds/bad.ogg","assets/sounds/bad.wma","assets/sounds/bad.mp3"]),this.load.audio("beep_sound",["assets/sounds/beep.ogg","assets/sounds/beep.wma","assets/sounds/beep.mp3"]),this.load.onLoadComplete.add(function(){this.game.music=this.add.audio("music",1,!0),this.game.music.play(),this.game.state.start("Menu")},this)}},x={init:function(){this.world.width=this.game.width},preload:function(){this.game.lang=JSON.parse(this.game.cache.getText("language"))},create:function(){this.game.background?(this.add.existing(this.game.background),this.game.background.width=this.world.width):(this.game.background=this.add.tileSprite(0,0,this.world.width,this.world.height,"city"),this.game.background.alpha=.5);var a=this.world.centerX,b=this.world.centerY;this.add.image(a,100,"menu_title").anchor.setTo(.5,.5),this.coin=this.add.image(278,58,"coin_menu",4),this.coin.animations.add("flip",[5,6,7,0,1,2,3,4],10),this.timer=this.time.create(),this.timer.loop(1500,this.coin.animations.play,this.coin.animations,"flip"),this.timer.start(),this.textLevel=this.add.text(a,b+50,C.current_lev,{font:C.textFont,fill:C.textstyle.menu.level_number.color,fontSize:C.textstyle.menu.level_number.size}),this.textLevel.anchor.setTo(.5,.5),this.add.text(a,this.textLevel.y-150,C.lang.level_selector,{font:C.textFont,fill:C.textstyle.menu.maintext.color,fontSize:C.textstyle.menu.maintext.size}).anchor.setTo(.5,.5),this.lock=this.add.image(this.textLevel.x,this.textLevel.y,"lock"),this.lock.anchor.setTo(.5,.5),this.lock.visible=!1;var c=150;this.arrowLeft=this.add.image(a-c,this.textLevel.y,"arrow_left"),this.arrowLeft.anchor.setTo(.5,.5),this.arrowLeft.inputEnabled=!0,this.arrowLeft.events.onInputDown.add(function(){this.updateLevel(-1)},this),this.arrowRight=this.add.image(a+c,this.textLevel.y,"arrow_right"),this.arrowRight.anchor.setTo(.5,.5),this.arrowRight.inputEnabled=!0,this.arrowRight.events.onInputDown.add(function(){this.updateLevel(1)},this),this.playButton=this.game.createButton(a,b+250,C.lang.play_button,!1),this.playButton.onInputDown.add(function(){this.textLevel.locked?this.playButton.goDown("bad_sound"):this.playButton.goDown("click_sound")},this),this.playButton.onInputUp.add(function(){this.playButton.goUp(),this.textLevel.locked||this.state.start("Play-intro")},this),this.game.speaker?(this.add.existing(this.game.speaker),this.game.speaker.cameraOffset.y=this.game.conf.positions.speaker.y):(this.game.speaker=this.add.image(this.game.conf.positions.speaker.x,this.game.conf.positions.speaker.y,"speaker",0),this.game.speaker.scale.setTo(1.5,1.5),this.game.speaker.fixedToCamera=!0,this.game.speaker.inputEnabled=!0,this.game.speaker.events.onInputDown.add(this.switchSound,this)),this.scale.fullScreenScaleMode=Phaser.ScaleManager.EXACT_FIT,this.input.onDown.add(this.goFullscreen,this)},shutdown:function(){this.world.remove(this.game.speaker),this.world.remove(this.game.background)},updateLevel:function(a){var b=C.current_lev+a;return 1>b||b>C.conf.total_levels?void this.game.playsound("bad_sound"):(C.current_lev=b,this.game.playsound("click_sound"),b>localStorage.lastUnblockedLevel?this.textLevel.locked||(this.textLevel.fill="#BDBDBD",this.textLevel.alpha=.3,this.lock.visible=!0,this.textLevel.locked=!0):this.textLevel.locked&&(this.textLevel.fill=C.textstyle.menu.level_number.color,this.textLevel.alpha=1,this.lock.visible=!1,this.textLevel.locked=!1),void this.textLevel.setText(C.current_lev))},switchSound:function(){this.sound.play("click_sound"),0==this.game.speaker.frame?(this.game.speaker.frame=1,this.game.speaker.alpha=.7,this.game.soundOn=!1,this.game.music.stop()):(this.game.speaker.frame=0,this.game.speaker.alpha=1,this.game.soundOn=!0,this.game.music.play())},goFullscreen:function(){this.scale.startFullScreen()}},y={init:function(){this.world.width=this.game.width,z.level=JSON.parse(this.game.cache.getText("level"+this.game.current_lev))},create:function(){this.add.existing(this.game.background),this.add.existing(this.game.speaker),this.game.speaker.cameraOffset.y=this.game.conf.positions.speaker.y,this.board=this.game.createBoard(this.world.centerX,this.world.centerY),this.board.visible=!0,this.board.fixedToCamera=!1,this.board.label.y+=60,this.board.label.text.y+=60,this.board.setTitle(this.game.lang.level+" "+this.game.current_lev),this.textStyle={font:C.textFont,fill:C.textstyle.panels.content.color,fontSize:C.textstyle.panels.content.size,align:"center"},this.board.button=this.game.createButton(this.board.panel.x,this.board.panel.y+250,"",!0,"click_sound"),this.board.add(this.board.button),z.level.tuto&&this.game.lang.tutos[this.game.current_lev]?this.showTuto():this.showInfos()},shutdown:function(){this.world.remove(this.game.speaker),this.world.remove(this.game.background)},showTuto:function(){this.hasTuto=!0;var a=this.game.lang.tutos[this.game.current_lev];this.tutoTitle=this.add.text(this.board.label.x,this.board.label.y+80,a.title,this.textStyle),this.tutoImg=this.add.image(this.board.panel.x,this.tutoTitle.y+70,z.level.tuto.image,z.level.tuto.frame),this.tutoTxt=this.add.text(this.board.panel.x,this.tutoImg.bottom,a.text,this.textStyle),this.board.button.setText(this.game.lang.tutos.button),this.tutoElements=this.add.group(),this.tutoElements.addMultiple([this.tutoTitle,this.tutoImg,this.tutoTxt]),this.tutoElements.setAll("anchor.x",.5),this.board.addMultiple([this.tutoElements]),this.add.tween(this.board).from({y:-720},300,"Linear").start(),this.board.button.onInputUp.add(function(){this.showInfos()},this)},showInfos:function(){this.hasTuto&&this.tutoElements.destroy();var a=z.level.goal>1?C.lang.symbol_coins:C.lang.symbol_coin;this.infos=this.add.text(0,this.board.panel.y-130,this.game.lang.text_goal+" "+z.level.goal+" "+a+"\n"+this.game.lang.text_time+" "+z.level.time+" "+this.game.lang.symbol_seconds,this.textStyle),this.infos.x=this.board.panel.x-this.infos.width/2,this.infos.align="left",this.text_preLevel=this.add.text(this.board.panel.x,this.board.panel.y+100,this.game.lang.text_preLevel,this.textStyle),this.text_preLevel.anchor.setTo(.5),this.board.button.setText(this.game.lang.start_button),this.board.button.onInputUp.add(function(){this.state.start("Play")},this),this.board.addMultiple([this.infos,this.text_preLevel]),this.hasTuto||this.add.tween(this.board).from({y:-720},300,"Linear").start()}},z={preload:function(){this.world.setBounds(0,0,this.level.width,750),this.keepInTheStreet=[]},create:function(){this.add.existing(this.game.background),this.game.background.width=this.world.width,this.game.background.alpha=1,this.player=this.createPlayer(),this.coins=this.createCoins(),this.robbers=this.createRobbers(),this.treasures=this.createTreasures(),this.drains=this.createDrains(),this.oilSpots=this.createOilSpots(),this.boots=this.createBoots(),this.boxes=this.createObstacles("box"),this.trashes=this.createObstacles("trash");var a=[this.robbers,this.treasures];this.path.setProperties(a);var b=[this.robbers,this.treasures];for(i=0;i<b.length;i++)b[i].callAll("animations.add","animations","down",[0,1,2,3],10,!0),b[i].callAll("animations.add","animations","left",[4,5,6,7],10,!0),b[i].callAll("animations.add","animations","right",[8,9,10,11],10,!0),b[i].callAll("animations.add","animations","up",[12,13,14,15],10,!0);this.groundObjects=this.add.group(),this.groundObjects.addMultiple([this.oilSpots,this.drains]),this.entitiesToSort=this.add.group(),this.entitiesToSort.addMultiple([this.player,this.robbers,this.treasures,this.coins,this.boxes,this.trashes]),r(this.entitiesToSort),this.entitiesToSort.add(this.boots);var c;for(i=0;i<this.drains.length;i++)c=this.drains.children[i],c.body.setSize(10,10,c.width/2-5,c.height/2-5);for(i=0;i<this.oilSpots.length;i++)c=this.oilSpots.children[i],c.body.setSize(c.width/2,c.height/2,c.width/4,c.height/4);if(this.game.device.desktop)u=this.input.keyboard.createCursorKeys(),this.spacebar=this.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR),this.spacebar.onDown.add(this.treasures.hit),this.buttonsToPause=[];else{var d=393;this.street=this.add.group(),this.street.addMultiple([this.game.background,this.groundObjects,this.entitiesToSort]),this.street.y-=d,this.hitButton=this.createHitButton(this.game.conf.positions.hitButton.x,this.game.conf.positions.hitButton.y),this.joystick=this.createJoystick(this.game.conf.positions.joystick.x,this.game.conf.positions.joystick.y,this.game.conf.positions.joystick.radius),this.buttonsToPause=[this.joystick.up,this.joystick.down,this.joystick.right,this.joystick.left,this.hitButton]}var e=this.game.width/2;this.textStyle={font:C.textFont,fill:C.textstyle.gameinfo.color,fontSize:C.textstyle.gameinfo.size},this.score=0;var f=this.game.conf.positions.text_score;this.coinsleftText=this.add.text(f.x,f.y,this.game.lang.text_score,this.textStyle),this.coinsleftText.count=this.add.text(this.coinsleftText.right+20,this.coinsleftText.y,z.level.goal,this.textStyle),this.coinsleftText.fixedToCamera=!0,this.coinsleftText.count.fixedToCamera=!0,this.timer=this.createTimer(),this.timer.start();var g=this.game.conf.positions.text_timeleft;this.timer.text=this.add.text(g.x,g.y,this.game.lang.text_timer,this.textStyle),this.timer.text.count=this.add.text(this.timer.text.right+20,this.timer.text.y,this.timer.left,this.textStyle),this.timer.text.fixedToCamera=!0,this.timer.text.count.fixedToCamera=!0,this.camera.follow(this.player),this.add.existing(this.game.speaker),this.pauseButton=this.add.button(this.game.conf.positions.pauseButton.x,this.game.conf.positions.pauseButton.y,"pause_button"),this.pauseButton.scale.setTo(1.5,1.5),this.pauseButton.fixedToCamera=!0,this.pauseButton.onInputDown.add(this.startPause,this),this.buttonsToPause.push(this.pauseButton),this.game.device.desktop||(this.coinsleftText.cameraOffset.y+=this.world.height-d,this.coinsleftText.count.cameraOffset.y+=this.world.height-d,this.timer.text.cameraOffset.y+=this.world.height-d,this.timer.text.count.cameraOffset.y+=this.world.height-d,this.pauseButton.cameraOffset.y+=this.world.height-d,this.game.speaker.cameraOffset.y=this.game.conf.positions.speaker.y+this.world.height-d),this.board=this.game.createBoard(e,400,550,550),this.restartButton=this.game.createButton(this.board.panel.x,this.board.panel.y-105,this.game.lang.restart_button,!0,"click_sound"),this.restartButton.onInputUp.add(function(){this.game.state.start("Play-intro")},this),this.menuButton=this.game.createButton(this.board.panel.x,this.board.panel.y+35,this.game.lang.menu_button,!0,"click_sound"),this.menuButton.onInputUp.add(function(){this.game.state.start("Menu")},this),this.resumeButton=this.game.createButton(this.board.panel.x,this.board.panel.y+175,this.game.lang.resume_button,!0,"click_sound"),this.resumeButton.onInputUp.add(this.stopPause,this),this.nextlevelButton=this.game.createButton(e+170,500,this.game.lang.goNextLevel_button,!1),this.nextlevelButton.onInputDown.add(function(){this.game.current_lev>=this.game.conf.total_levels?this.nextlevelButton.goDown("bad_sound"):this.nextlevelButton.goDown("click_sound")},this),this.nextlevelButton.onInputUp.add(function(){this.nextlevelButton.goUp(),this.startNextLevel()},this),this.board.buttons.addMultiple([this.restartButton,this.menuButton,this.resumeButton,this.nextlevelButton]),this.board.buttons.setAllChildren("visible",!1),this.board.buttons.fixedToCamera=!0,this.pauseMenu=[this.restartButton,this.menuButton,this.resumeButton],this.gameoverMenu=[this.restartButton,this.menuButton],this.levelpassedMenu=[this.restartButton,this.nextlevelButton],this.elementsToPause=this.world.createSubGroup(),this.world.addMultiple([this.game.speaker,this.board,this.board.buttons])},update:function(){for(this.player.move(),this.keepInTheStreet.forEach(function(a){a.y<505?a.y=505:a.y>this.game.height&&(a.y=this.game.height)},this),i=0;i<this.treasures.children.length;i++)this.path.updateDirection(this.treasures.children[i]);this.physics.arcade.overlap(this.player,this.coins,this.coins.collect),this.physics.arcade.overlap(this.player,this.boots,this.boots.getBonus),this.physics.arcade.overlap(this.player,this.oilSpots,this.oilSpots.slip)||(this.player.allowSlip=!0),!this.physics.arcade.overlap(this.player,this.drains,this.drains.teleport)&&this.player.exists&&(this.player.allowTeleport=!0),this.physics.arcade.collide(this.player,this.treasures),this.physics.arcade.collide(this.player,this.robbers,this.robbers.steal),this.physics.arcade.collide(this.player,this.boxes),this.physics.arcade.collide(this.player,this.trashes),this.entitiesToSort.sort("bottom",Phaser.Group.SORT_ASCENDING,!0)},render:function(){},shutdown:function(){this.world.remove(this.game.speaker),this.game.background.parent.removeChild(this.game.background),this.game.background.alpha=.5,this.game.background.tint=16777215,this.input.keyboard.enabled||(this.input.keyboard.enabled=!0)},startPause:function(){this.game.playsound("click_sound"),this.board.visible=!0;for(var a=0;a<this.pauseMenu.length;a++)this.pauseMenu[a].visible=!0;this.board.setTitle(C.lang.pause_menu),this.pauseGame()},stopPause:function(){this.board.visible=!1;for(var a=0;a<this.pauseMenu.length;a++)this.pauseMenu[a].visible=!1;this.game.unsetPause([this.elementsToPause],[this.timer],this.buttonsToPause,!0),this.elementsToPause.setAllChildren("tint",16777215),this.game.renderType==Phaser.CANVAS&&(this.game.background.alpha=1)},gameover:function(){this.board.panel.height=400,this.board.label.text.fontSize=80,this.board.label.y=this.board.panel.top,this.board.label.text.y=this.board.panel.top,this.board.buttons.cameraOffset.y+=70,this.game.playsound("gameover_sound"),this.board.visible=!0;for(var a=0;a<this.gameoverMenu.length;a++)this.gameoverMenu[a].visible=!0;this.board.setTitle(C.lang.gameover_menu),this.pauseGame()},levelpassed:function(){this.pauseGame(),localStorage.lastUnblockedLevel<C.conf.total_levels&&localStorage.lastUnblockedLevel==C.current_lev&&localStorage.lastUnblockedLevel++;var a=C.current_lev==C.conf.total_levels;this.game.playsound("win_sound");var b=a?C.lang.game_completed:C.lang.levelpassed,c=this.add.text(this.camera.x+this.game.width/2,200,b,{font:C.textFont,fill:C.textstyle.levelpassed.color,fontSize:C.textstyle.levelpassed.size});c.anchor.setTo(.5);for(var d=[],e=0;3>e;e++)d.push(this.add.image(c.x-150+150*e,c.y+120,"star",0)),d[e].anchor.setTo(.5);this.timer.left<6&&(d[2].frame=1,this.timer.left<4&&(d[1].frame=1));for(var e=0;e<this.levelpassedMenu.length;e++)this.levelpassedMenu[e].visible=!0;this.restartButton.x=this.nextlevelButton.x-340,this.restartButton.y=this.nextlevelButton.y,a&&(this.menuButton.x=this.nextlevelButton.x,this.menuButton.y=this.nextlevelButton.y,this.menuButton.visible=!0,this.nextlevelButton.visible=!1)},startNextLevel:function(){this.game.current_lev>=this.game.conf.total_levels||(this.game.current_lev++,this.state.start("Play-intro"))},pauseGame:function(){this.game.setPause([this.elementsToPause],[this.timer],this.buttonsToPause,!0),this.elementsToPause.setAllChildren("tint",1842203),this.game.renderType==Phaser.CANVAS&&(this.game.background.alpha=.2)}};z.path={setProperties:function(a){for(var b=0;b<a.length;b++)a[b].setAll("goingTo",0,!1,!1,0,!0),a[b].setAll("direction",0,!1,!1,0,!0),a[b].setAll("waiting",!1,!1,!1,0,!0)},updateDirection:function(a){z.path.arrived(a,a.data.path[a.goingTo])&&0==a.waiting&&(a.data.path[a.goingTo].wait>0?(a.body.velocity.setTo(0,0),a.waiting=!0,z.timer.add(a.data.path[a.goingTo].wait,this.goNext,z,a),a.animations.stop()):this.goNext(a))},arrived:function(a,b){switch(a.direction){case B.up:return a.y<=b.y;case B.down:return a.y>=b.y;case B.right:return a.x>=b.x;case B.left:return a.x<=b.x}},goNext:function(a){if(!a.body)return!1;a.data.path[a.goingTo+1]?a.goingTo++:a.goingTo=0;var b=z.physics.arcade.moveToXY(a,a.data.path[a.goingTo].x,a.data.path[a.goingTo].y,a.data.speed);a.direction=t(b),a.animations.play(s(a.direction)),a.waiting=!1}},z.createRobbers=function(){var c=this.add.group();c.enableBody=!0;for(var d=0;d<this.level.personages.robbers.length;d++)c.create(this.level.personages.robbers[d].path[0].x,this.level.personages.robbers[d].path[0].y,"robber"),c.children[d].body.immovable=!0,c.children[d].data=this.level.personages.robbers[d];return c.steal=a,c.update=b,c},z.createTreasures=function(){var a=this.add.group();for(a.enableBody=!0,i=0;i<z.level.personages.treasures.length;i++)a.create(z.level.personages.treasures[i].path[0].x,z.level.personages.treasures[i].path[0].y,"treasure"),a.children[i].data=this.level.personages.treasures[i],a.children[i].body.immovable=!0;return a.hit=c,a.breack=d,a},z.createBoots=function(){var a=this.add.group();return a.enableBody=!0,a.generate=e,a.getBonus=f,z.timer={left:z.level.time},a.generate(),a},z.createCoins=function(){var a=this.add.group();for(a.enableBody=!0,this.currentCoin=0;this.currentCoin<this.level.startingCoins;this.currentCoin++)a.create(this.level.coins[this.currentCoin].x,this.level.coins[this.currentCoin].y,"coin",0);return a.callAll("animations.add","animations","spin",[0,1,2,3,4,6,7],10,!0),a.callAll("animations.play","animations","spin"),a.collect=g,a},z.createDrains=function(){var a=this.add.group();for(a.enableBody=!0,i=0;i<z.level.objects.drains.length;i++)a.create(z.level.objects.drains[i].x,z.level.objects.drains[i].y,"drain").go=z.level.objects.drains[i].go;return a.teleport=h,a.teleport.go=j,a},z.createObstacles=function(a){var b=this.add.group();b.enableBody=!0;for(var c=this.level.obstacles[a],d=0;d<c.length;d++){var e=b.create(c[d].x,c[d].y,a);e.body.immovable=!0}return b},z.createOilSpots=function(){var a=this.add.group();a.enableBody=!0;for(var b=0;b<z.level.objects.oil.length;b++)a.create(this.level.objects.oil[b].x,z.level.objects.oil[b].y,"oil");return a.slip=k,a},z.createPlayer=function(){var a=this.add.sprite(this.level.playerStarts.x,this.level.playerStarts.y,"player",0);return this.physics.arcade.enable(a),a.animations.add("down",[0,1,2,3],10,!0),a.animations.add("left",[4,5,6,7],10,!0),a.animations.add("right",[8,9,10,11],10,!0),a.animations.add("up",[12,13,14,15],10,!0),a.animations.add("fall",[0,4,8,12],10,!0),a.body.collideWorldBounds=!0,a.speed=C.conf.speed_player,a.speed_bonus=this.add.tween(a),a.lastTheft=0,this.keepInTheStreet.push(a),a.allowTeleport=!0,a.isTeleporting=!1,a.move=this.game.device.desktop?m:l,a.update=n,a},Phaser.Button.prototype.goDown=function(a){this.frame=1,this.text.y+=5,this.game.soundOn&&a&&this.game.sound.play(a)},Phaser.Button.prototype.goUp=function(a){this.frame=0,this.text.y-=5,this.game.soundOn&&a&&this.game.sound.play(a)},Phaser.Button.prototype.setText=function(a){this.text?this.text.text=a:(this.text=this.game.add.text(0,0,a,{font:C.textFont,fill:C.textstyle.buttons.color,fontSize:C.textstyle.buttons.size}),this.addChild(this.text),this.text.anchor.setTo(.5,.5))},Phaser.Game.prototype.createButton=function(a,b,c,d,e,f){var g=this.add.button(a,b,"button");return g.anchor.setTo(.5,.5),d&&(g.onInputDown.add(function(){this.goDown(e)},g),g.onInputUp.add(function(){this.goUp(f)},g)),c&&g.setText(c),g},z.createHitButton=function(a,b){var c=this.add.button(a,b,"hitButton",z.treasures.hit);return c.anchor.setTo(.5,.5),c.fixedToCamera=!0,c.text=this.add.text(c.x,c.y,this.game.lang.hit_button,{font:this.game.textFont,fill:C.textstyle.hit_button.color.released,fontSize:C.textstyle.hit_button.size}),c.text.anchor.setTo(.5,.5),c.text.fixedToCamera=!0,c.onInputDown.add(function(){c.text.fill=C.textstyle.hit_button.color.pressed}),c.onInputUp.add(function(){c.text.fill=C.textstyle.hit_button.color.released}),c},z.createJoystick=function(a,b,c){for(var d=["left","up","right","down"],e={},f=0;4>f;f++){var g=this.add.button(a-c,b,"joystick");g.anchor.setTo(.5,.5);var h=new Phaser.Polygon([-g.width/2,g.height/2,-g.width/2,-g.height/2,g.width/2-75,-g.height/2,g.width/2,0,g.width/2-75,g.height/2]);g.hitArea=h,g.position.rotate(a,b,Math.PI*f/2,!1,c),g.rotation=Math.PI*f/2,g.fixedToCamera=!0,g.forceOut=!0,g.onInputDown.add(function(){this.isDown=!0},g),g.onInputOver.add(function(a,b){a.input._pointerData[b.id].isUp=!1,a.input._pointerData[b.id].isDown=!0,this.isDown=!0},g),g.onInputUp.add(function(a,b){a.input._pointerData[b.id].isOut=!0,a.input._pointerData[b.id].isOver=!1,this.isDown=!1},g),g.onInputOut.add(function(){this.isDown=!1},g),g.alpha=.7,e[d[f]]=g}return e.resetFrames=o,e},Phaser.Game.prototype.createBoard=function(a,b,c,d){
  var e=this.add.group();return e.buttons=this.add.group(),e.fixedToCamera=!0,e.visible=!1,e.panel=this.make.image(a,b,"panel"),e.panel.anchor.setTo(.5,.5),c&&(e.panel.height=c),d&&(e.panel.width=d),e.label=this.make.image(a,e.panel.top,"level_label"),e.label.anchor.setTo(.5),e.label.text=this.make.text(e.label.x,e.label.y,"",{font:this.textFont,fill:C.textstyle.panels.label.color,fontSize:C.textstyle.panels.label.size}),e.label.text.anchor.setTo(.5),e.setTitle=p,e.addMultiple([e.panel,e.label,e.label.text]),e},z.createTimer=function(){var a=this.time.create(!1);return a.left=this.level.time,a.updateTime=q,a.timeLeftEvent=a.loop(1e3,a.updateTime.bind(a)),a};var A=30;Phaser.Group.prototype.createSubGroup=function(){for(var a=new Phaser.Group(this.game,null);this.length>0;)a.add(this.children[0]);return this.add(a),a},Phaser.Game.prototype.setPause=function(a,b,c,d){var e;if(a)for(e=0;e<a.length;e++)a[e].exists=!1;if(b)for(e=0;e<b.length;e++)b[e].pause();if(c)for(e=0;e<c.length;e++)c[e].inputEnabled=!1;d&&(this.input.keyboard.enabled=!1,this.input.reset(!1))},Phaser.Game.prototype.unsetPause=function(a,b,c,d){var e;if(a)for(e=0;e<a.length;e++)a[e].exists=!0;if(b)for(e=0;e<b.length;e++)b[e].resume();if(c)for(e=0;e<c.length;e++)c[e].inputEnabled=!0;d&&(this.input.keyboard.enabled=!0)};var B={up:0,down:1,right:2,left:3};Phaser.Game.prototype.playsound=function(a){this.soundOn&&this.sound.play(a)};var C;window.onload=function(){C=new Phaser.Game(1200,750,Phaser.AUTO,"game"),C.state.add("Boot",v),C.state.add("Load",w),C.state.add("Menu",x),C.state.add("Play-intro",y),C.state.add("Play",z),C.state.start("Boot")}}();