function onLoad() { new game.Main } var game; ! function(t) { var e = function() { function t() {} return t.GAME_WIDTH = 640, t.GAME_HEIGHT = 832, t.HALF_GAME_WIDTH = .5 * t.GAME_WIDTH, t.HALF_GAME_HEIGHT = .5 * t.GAME_HEIGHT, t.LEVELS_NUM = 60, t } (); t.Config = e } (game || (game = {})); var __extends = this.__extends || function(t, e) { function i() { this.constructor = t } for (var a in e) e.hasOwnProperty(a) && (t[a] = e[a]); i.prototype = e.prototype, t.prototype = new i }, game; ! function(t) { var e = function(e) { function i() { e.apply(this, arguments) } return __extends(i, e), i.prototype.init = function() { this.game.device.android && !this.game.device.chrome && (this.game.canvas.parentElement.style.overflow = "visible"); var t = { font: "10px GrilledCheeseBTNToasted" }, e = this.add.text(0, 0, "0", t); e.destroy() }, i.prototype.preload = function() { this.load.image("rotate", "assets/graphics/rotate-phone.png"), this.load.image("LoadingBar_Outer", "assets/graphics/LoadingBar_Outer.png"), this.load.image("LoadingBar_Inner", "assets/graphics/LoadingBar_Inner.png") }, i.prototype.create = function() { var e = this.game.scale; e.scaleMode = Phaser.ScaleManager.SHOW_ALL, e.minWidth = .25 * t.Config.GAME_WIDTH, e.minHeight = .25 * t.Config.GAME_HEIGHT, e.aspectRatio = t.Config.GAME_WIDTH / t.Config.GAME_HEIGHT, e.pageAlignHorizontally = !0, e.pageAlignVertically = !0, this.game.device.desktop || e.forceOrientation(!1, !0), e.enterIncorrectOrientation.add(this.onEnterIncorrectOrientation, this), e.leaveIncorrectOrientation.add(this.onLeaveIncorrectOrientation, this), e.setScreenSize(!0), this.input.maxPointers = 1, this.stage.disableVisibilityChange = !0, this.stage.backgroundColor = 8179412, this.game.state.start("Preloader", !0, !1) }, i.prototype.onEnterIncorrectOrientation = function() { document.getElementById("orientation").style.display = "block", document.body.style.marginBottom = "0px" }, i.prototype.onLeaveIncorrectOrientation = function() { document.getElementById("orientation").style.display = "none", document.body.style.marginBottom = "100px", this.game.device.android && !this.game.device.chrome && this.game.scale.setScreenSize(!0) }, i } (Phaser.State); t.Boot = e } (game || (game = {})); var game; ! function(t) { var e = function(t) { function e() { t.apply(this, arguments) } return __extends(e, t), e.prototype.create = function() {}, e.prototype.addSplash = function() {}, e.prototype.gotoMainMenu = function() { this.game.state.start("MainMenu", !0, !1, !0) }, e } (Phaser.State); t.SplashScreen = e } (game || (game = {})); var game; ! function(t) { var e = function(e) { function i(i, a) { e.call(this, i, a), this.overlayDuration = 300; var n = i.add.bitmapData(t.Config.GAME_WIDTH, t.Config.GAME_HEIGHT, "overlay", !0); n.context.fillStyle = "rgba(0, 0, 0, 1)", n.context.fillRect(0, 0, t.Config.GAME_WIDTH, t.Config.GAME_HEIGHT), this.overlay = new Phaser.Image(i, 0, 0, n), this.overlay.visible = !1, this.game.stage.addChild(this.overlay) } return __extends(i, e), i.prototype.changeState = function(t, e) { this.showOverlay(t, e) }, i.prototype.showOverlay = function(t, e) { var i = this; this.game.input.disabled = !0, this.overlayTween && this.overlayTween.isRunning && this.overlayTween.stop(), this.overlay.visible = !0, this.overlay.alpha = 0, this.overlayTween = this.game.add.tween(this.overlay).to({ alpha: 1 }, this.overlayDuration, Phaser.Easing.Cubic.Out, !0), this.overlayTween.onComplete.addOnce(function() { i.doChangeState(t, e) }, this) }, i.prototype.doChangeState = function(t, e) { var i = this; this.game.state.start(t, !0, !1, e), setTimeout(function() { i.hideOverlay() }, 100), setTimeout(function() { i.overlay.visible && (i.overlay.visible = !1) }, 100 + this.overlayDuration) }, i.prototype.hideOverlay = function() { this.game.input.disabled = !1, this.overlayTween && this.overlayTween.isRunning && this.overlayTween.stop(), this.overlayTween = this.game.add.tween(this.overlay).to({ alpha: 0 }, this.overlayDuration, Phaser.Easing.Cubic.Out, !0) }, i } (Phaser.Plugin); t.StateTransition = e } (game || (game = {})); var game; ! function(t) { var e = function(e) { function i() { e.apply(this, arguments) } return __extends(i, e), i.prototype.init = function() { this.addLoadingText() }, i.prototype.addLoadingText = function() { var e = { font: "45px GrilledCheeseBTNToasted", fill: "#FFFFFF", align: "center" }, i = this.game.add.text(0, 0, "Loading...", e); i.anchor.set(.5, .5), i.position.set(t.Config.HALF_GAME_WIDTH, t.Config.HALF_GAME_HEIGHT + 100), i.setShadow(2, 2, "#249BC8") }, i.prototype.preload = function() { this.addPreloadBar(), this.loadAssets() }, i.prototype.addPreloadBar = function() { if (t.Main.development === !1) { var e = this.game.add.sprite(0, 0, "LoadingBar_Inner"); e.x = t.Config.HALF_GAME_WIDTH - .5 * e.width - .5, e.y = t.Config.HALF_GAME_HEIGHT - .5 * e.height - 1.5; var i = this.add.image(0, 0, "LoadingBar_Outer"); i.anchor.set(.5, .5), i.x = t.Config.HALF_GAME_WIDTH - .5, i.y = t.Config.HALF_GAME_HEIGHT, this.load.setPreloadSprite(e) } }, i.prototype.loadAssets = function() { this.load.audio("main_loop", ["assets/audio/MainLoop.ogg", "assets/audio/MainLoop.m4a"], !0), this.game.device.webAudio && (this.load.audio("tap", ["assets/audio/TapSound.wav"], !0), this.load.audio("onLevelComplete", ["assets/audio/LevelCompleteSound.wav"], !0), this.load.audio("on_down", ["assets/audio/OnDown.wav"], !0), this.load.audio("on_up", ["assets/audio/OnUp.wav"], !0), this.load.audio("star", ["assets/audio/Star.wav"], !0), this.load.audio("star_taken", ["assets/audio/StarTaken.wav"], !0)), // this.load.image("splash_screen", "assets/graphics/Splash_Image_play68.png"), this.load.atlasJSONHash("gui", "assets/graphics/gui.png", "assets/graphics/gui.json"), this.load.atlasJSONHash("level_graphics", "assets/graphics/level_graphics.png", "assets/graphics/level_graphics.json"), this.load.atlasJSONHash("manta_ray", "assets/graphics/manta_ray.png", "assets/graphics/manta_ray.json"), this.load.atlasJSONHash("level_complete", "assets/graphics/level_complete.png", "assets/graphics/level_complete.json"), this.load.atlasJSONHash("tutor_hand", "assets/graphics/tutorial_hand.png", "assets/graphics/tutorial_hand.json"), this.load.atlasJSONHash("tutorial", "assets/graphics/tutorial.png", "assets/graphics/tutorial.json"), this.load.atlasJSONHash("yellow_fish", "assets/graphics/yellow_fish.png", "assets/graphics/yellow_fish.json"), this.load.atlasJSONHash("pink_fish", "assets/graphics/pink_fish.png", "assets/graphics/pink_fish.json"), this.load.json("texts", "assets/texts.json"), t.Main.development ? this.load.json("startLevel", "assets/levels/StartLevel.json") : this.load.json("levelConfigs", "assets/levels/Levels.json") }, i.prototype.create = function() { this.initLanguage(), this.prepareTextures(), this.game.plugins.add(t.StateTransition), this.game.cache.removeImage("LoadingBar_Outer"), this.game.cache.removeImage("LoadingBar_Inner"), t.Main.development && this.cache.getJSON("startLevel").level, this.game.state.start("MainMenu", !0, !1, !0) }, i.prototype.initLanguage = function() { var e = this.game.cache.getJSON("texts"); t.Main.texts = e[t.Main.language] }, i.prototype.prepareTextures = function() {}, i } (Phaser.State); t.Preloader = e } (game || (game = {})); var game; ! function(t) { var e = function(t) { function e(e, i, a, n, s) { var o = this; t.call(this, e, i, a, n, s), this._callback = new Phaser.Signal, this.anchor.set(.5, .5), this.inputEnabled = !0, this.game.device.desktop && (this.input.useHandCursor = !0), this.inputEnabled && (this.events.onInputDown.add(function() { o.game.device.webAudio && o.game.sound.play("tap"), o.game.add.tween(o.scale).to({ x: .9, y: .9 }, 200, Phaser.Easing.Cubic.Out, !0) }), this.events.onInputUp.add(function() { o.game.add.tween(o.scale).to({ x: 1, y: 1 }, 100, Phaser.Easing.Cubic.Out, !0).onComplete.addOnce(o._callback.dispatch, o) })) } return __extends(e, t), e.prototype.destroy = function() { t.prototype.destroy.call(this), this._callback.dispose() }, Object.defineProperty(e.prototype, "callback", { get: function() { return this._callback }, enumerable: !0, configurable: !0 }), e } (Phaser.Image); t.SimpleButton = e } (game || (game = {})); var game; ! function(t) { var e = function(t) { function e(e, i, a, n, s) { t.call(this, e, i, a, "gui", n), this.textureKey1 = n, this.textureKey2 = s, this.activeTextureKey = this.textureKey1, this._state = 1, this.events.onInputUp.add(this.switchTextures, this, 2) } return __extends(e, t), e.prototype.switchTextures = function() { this.activeTextureKey = this.activeTextureKey === this.textureKey1 ? this.textureKey2: this.textureKey1, this.loadTexture("gui", this.activeTextureKey), this._state = this.activeTextureKey === this.textureKey1 ? 1 : 2 }, Object.defineProperty(e.prototype, "state", { get: function() { return this._state }, enumerable: !0, configurable: !0 }), e } (game.SimpleButton); t.ToggleButton = e } (game || (game = {})); var game; ! function(t) { var e = function(e) { function i() { e.apply(this, arguments), this.fromPreloader = !1 } return __extends(i, e), i.prototype.init = function(t) { this.fromPreloader = t }, i.prototype.create = function() { this.initImages(), this.addCreatures(), this.initButtons(), this.initLogo(), this.initCredits(), this.initAnimation(), this.fromPreloader && (this.soundButton.input.enabled = !1, this.soundButton.switchTextures(), this.game.input.onTap.addOnce(this.startMusic, this), this.stage.disableVisibilityChange = !1, this.game.onBlur.add(this.onFocusLost, this), this.game.onFocus.add(this.onFocus, this)) }, i.prototype.onFocusLost = function() { this.game.tweens.pauseAll(), t.Main.wasMuted = this.game.sound.mute, this.game.sound.mute = !0 }, i.prototype.onFocus = function() { this.game.tweens.resumeAll(), t.Main.wasMuted === !1 && (this.game.sound.mute = !1) }, i.prototype.initImages = function() { this.game.add.image( - 32, 0, "gui", "BG_20000"), this.title = this.add.image(0, 0, "gui", "GameTitle0000"), this.title.anchor.set(.5, .5), this.title.x = t.Config.HALF_GAME_WIDTH - .5, this.title.y = 150 }, i.prototype.addCreatures = function() { this.needlefish = this.game.add.image(t.Config.HALF_GAME_WIDTH + 15, 550, "gui", "Needlefish0000"), this.needlefish.angle = 120, this.octopus = this.game.add.image(t.Config.HALF_GAME_WIDTH + 190, 760, "gui", "Octopus0000"), this.jelly = this.game.add.image(t.Config.HALF_GAME_WIDTH - 145, 740, "gui", "Jelly0000"), [this.needlefish, this.octopus, this.jelly].forEach(function(t) { t.anchor.set(.5, .5) }) }, i.prototype.initButtons = function() { var e = this, i = 60; this.soundButton = new t.ToggleButton(this.game, t.Config.GAME_WIDTH - i, i, "Music_On_Button0000", "Music_Off_Button0000"), this.soundButton.callback.add(function() { e.game.sound.mute = !e.game.sound.mute }), this.game.sound.mute && this.soundButton.switchTextures(), this.playButton = new t.SimpleButton(this.game, t.Config.HALF_GAME_WIDTH, 330, "gui", "Play_Button0000"), this.playButton.callback.addOnce(function() { e.game.changeState("LevelsMenu") }, this), this.creditsButton = new t.SimpleButton(this.game, this.playButton.x + 130, this.playButton.y, "gui", "Credits_Button0000"), this.creditsButton.callback.add(this.toggleCredits, this), this.moreGamesButton = new t.SimpleButton(this.game, this.playButton.x - 130, this.playButton.y, "gui", "MoreGames_Button0000"), this.moreGamesButton.callback.add(this.gotoDeveloperWebsite, this), this.buttons = [this.playButton, this.soundButton, this.moreGamesButton, this.creditsButton], this.buttons.forEach(function(t) { e.world.add(t) }) }, i.prototype.gotoDeveloperWebsite = function() { // Play68.goHome() }, i.prototype.initLogo = function() {}, i.prototype.initCredits = function() { this.credits = this.game.add.image(0, 0, "gui", "CreditsBoard0000"), this.credits.position.set(Math.round(.5 * (t.Config.GAME_WIDTH - this.credits.width)), Math.round(.5 * (t.Config.GAME_HEIGHT - this.credits.height))), this.credits.visible = !1 }, i.prototype.toggleCredits = function() { this.credits.visible ? this.hideCredits() : this.showCredits() }, i.prototype.hideCredits = function() { var t = this; this.game.add.tween(this.credits).to({ y: this.credits.y + 200, alpha: 0 }, 500, Phaser.Easing.Back.In, !0).onComplete.addOnce(function() { t.playButton.input.enabled = !0, t.creditsButton.input.enabled = !0, t.credits.visible = !1 }, this) }, i.prototype.showCredits = function() { var e = this; this.credits.visible = !0, this.credits.alpha = 0, this.credits.y = Math.round(.5 * (t.Config.GAME_HEIGHT - this.credits.height)) + 200, this.game.add.tween(this.credits).to({ y: this.credits.y - 200, alpha: 1 }, 500, Phaser.Easing.Back.Out, !0), this.playButton.input.enabled = !1, this.creditsButton.input.enabled = !1, this.game.input.onTap.addOnce(function() { e.hideCredits() }, this) }, i.prototype.startMusic = function() { this.game.sound.play("main_loop", .33, !1), this.soundButton.switchTextures(), this.soundButton.input.enabled = !0 }, i.prototype.initAnimation = function() { var t = this; this.title.y -= 280, this.game.add.tween(this.title).to({ y: this.title.y + 280 }, 600, Phaser.Easing.Back.Out, !0, 300); var e = 800; this.needlefish.y += 500, this.octopus.x += 400, this.jelly.x -= 400, this.game.add.tween(this.needlefish).to({ y: this.needlefish.y - 500, angle: 354 }, 700, Phaser.Easing.Back.Out, !0, e), this.game.add.tween(this.octopus).to({ x: this.octopus.x - 400 }, 600, Phaser.Easing.Back.Out, !0, e + 300), this.game.add.tween(this.jelly).to({ x: this.jelly.x + 400 }, 600, Phaser.Easing.Back.Out, !0, e + 300); var i = 1600; this.buttons.forEach(function(e) { e.scale.set(0, 0), t.game.add.tween(e.scale).to({ x: 1, y: 1 }, 300, Phaser.Easing.Back.Out, !0, i), i += 200 }) }, i.prototype.destroy = function() { this.buttons = null }, i } (Phaser.State); t.MainMenu = e } (game || (game = {})); var game; ! function(t) { var e = function(t) { function e(e, i, a, n, s) { var o = this; void 0 === s && (s = !1), t.call(this, e, i, a, "gui", "Button_Clear0000"), this.inputEnabled = !s, this.locked = s, this._levelNumber = n, this.anchor.set(.5, .5), this.createGraphics(), this.inputEnabled && (this.game.device.desktop && (this.input.useHandCursor = !0), this.events.onInputDown.add(function() { o.game.sound.play("tap", .75), o.game.add.tween(o.scale).to({ x: .9, y: .9 }, 200, Phaser.Easing.Cubic.Out, !0) }), this.events.onInputUp.add(function() { o.game.add.tween(o.scale).to({ x: 1, y: 1 }, 200, Phaser.Easing.Cubic.Out, !0) })) } return __extends(e, t), e.prototype.createGraphics = function() { this.locked ? this.createLockedGraphics() : this.createUnlockedGraphics() }, e.prototype.createLockedGraphics = function() { this.loadTexture("gui", "Button_Lock0000") }, e.prototype.createUnlockedGraphics = function() { var t = -2; this.game.device.firefox && (t = 8); var e = { font: "42px GrilledCheeseBTNToasted", fill: "#218DB7", align: "center" }, i = this.game.add.text(0, 0, this._levelNumber.toString(), e); i.anchor.set(.5, .5); var a = this.game.add.renderTexture(this.width, this.height); a.renderXY(this, .5 * this.width, .5 * this.height), a.renderXY(i, Math.floor(.5 * this.width) - 2, Math.floor(.5 * this.height) + t), this.setTexture(a), i.destroy() }, Object.defineProperty(e.prototype, "levelNumber", { get: function() { return this._levelNumber }, enumerable: !0, configurable: !0 }), e } (Phaser.Image); t.LevelIcon = e } (game || (game = {})); var game; ! function(t) { var e = function(t) { function e(e, i, a, n) { t.call(this, e, i), this._width = 0; for (var s = 0, o = 30, r = 0; a > r; r++) { var h = e.add.image(s, 0, "gui", "Star_NO0000", this); h.anchor.set(.5, .5), s += o, this._width += o } s = 0; for (var r = 0; n > r; r++) { var u = e.add.image(s, 0, "gui", "Star_YES0000", this); u.anchor.set(.5, .5), s += o } } return __extends(e, t), e.prototype.getWidth = function() { return this._width }, e } (Phaser.SpriteBatch); t.LevelIconStars = e } (game || (game = {})); var game; ! function(t) { var e = function() { function t() {} return t } (); t.LevelResult = e } (game || (game = {})); var game; ! function(t) { var e = function(e) { function i(t, i) { e.call(this, t, i), this.distanceBetweenPages = 560, this.isTweening = !1, this._iconClicked = new Phaser.Signal, this.initIconSets(), this.calculateWidth(), this.currentPage = 0, this.pages[this.currentPage].visible = !0 } return __extends(i, e), i.prototype.initIconSets = function() { this.pages = []; for (var t = 1, e = 20, i = 0, a = 0; 3 > a; a++) { var n = t, s = n + e - 1, o = this.createIconSet(n, s); o.visible = !1, o.x = i, i += this.distanceBetweenPages, t += e, this.pages[a] = o } }, i.prototype.createIconSet = function(e, i) { for (var a = this.game.add.group(this), n = 120, s = 144, o = 0, r = 0, h = e; i >= h; h++) { var u = h, l = this.levelIsLocked(u), d = new t.LevelIcon(this.game, o, r, u, l); l === !1 && d.events.onInputUp.addOnce(this.dispatchIconClicked, this); var c = this.getLevelResult(u); if (c) { var g = new t.LevelIconStars(this.game, a, c.starsAvailable, c.starsEarned), p = o - .5 * g.getWidth() + 13; g.position.set(p, r + 62) } a.add(d), o += n, h % 4 === 0 && (o = 0, r += s) } return a }, i.prototype.levelIsLocked = function(e) { if (1 === e) return ! 1; var i = e - 1, a = i.toString(), n = t.Main.storage.getValue(a); return null === n }, i.prototype.getLevelResult = function(e) { var i = e.toString(), a = t.Main.storage.getValue(i); return a && a.length > 0 ? JSON.parse(a) : null }, i.prototype.dispatchIconClicked = function(t) { this.game.time.events.add(200, this._iconClicked.dispatch, this, t.levelNumber) }, i.prototype.calculateWidth = function() { var t = 0, e = this.pages[0].getTop().x; this._width = e - t }, i.prototype.showPage = function(t) { if (!this.isTweening) { var e; if ("next_page" === t ? e = Math.min(this.currentPage + 1, this.pages.length - 1) : "prev_page" === t && (e = Math.max(0, this.currentPage - 1)), e !== this.currentPage) { this.isTweening = !0; var i = "next_page" === t ? -this.distanceBetweenPages: this.distanceBetweenPages; this.currentPage = e, this.pages.forEach(function(t) { t.visible = !0 }), this.game.add.tween(this).to({ x: this.x + i }, 600, Phaser.Easing.Cubic.InOut, !0).onComplete.addOnce(this.onTweenComplete, this) } } }, i.prototype.onTweenComplete = function() { this.isTweening = !1; for (var t = 0; t < this.pages.length; t++) t !== this.currentPage && (this.pages[t].visible = !1) }, i.prototype.getWidth = function() { return this._width }, i.prototype.isFirstPage = function() { return 0 === this.currentPage }, i.prototype.isLastPage = function() { return this.currentPage === this.pages.length - 1 }, i.prototype.destroy = function() { e.prototype.destroy.call(this, !0), this._iconClicked.dispose(), this._iconClicked = null, this.pages = null }, Object.defineProperty(i.prototype, "iconClicked", { get: function() { return this._iconClicked }, enumerable: !0, configurable: !0 }), i } (Phaser.Group); t.LevelIcons = e } (game || (game = {})); var utils; ! function(t) { var e = function() { function e() {} return e.createArrayWithNumbers = function(t, e, i) { arguments.length <= 1 && (e = t || 0, t = 0), i = arguments[2] || 1; for (var a = Math.max(Math.ceil((e - t) / i), 0), n = 0, s = new Array(a); a > n;) s[n++] = t, t += i; return s }, e.getRandomItem = function(e) { var i = t.MathUtil.integerInRange(0, e.length - 1); return e[i] }, e } (); t.ArrayUtil = e } (utils || (utils = {})); var utils; ! function(t) { var e = function() { function t() {} return t.distanceSquared = function(t, e, i, a) { var n = i - t, s = a - e; return n * n + s * s }, t.distance = function(e, i, a, n) { var s = t.distanceSquared(e, i, a, n); return Math.sqrt(s) }, t.realInRange = function(t, e) { return Math.random() * (e - t) + t }, t.integerInRange = function(e, i) { return Math.round(t.realInRange(e, i)) }, t.DEG_TO_RAD = .017453292519943295, t.RAD_TO_DEG = 57.29577951308232, t } (); t.MathUtil = e } (utils || (utils = {})); var game; ! function(t) { var e = function(e) { function i(t, i, a, n) { e.call(this, t, i, a, n), this.anchor.set(.5, .5); var s = t.rnd.realInRange(1, 2); this.scale.set(s, s), this.target = new Phaser.Point, this.velocity = new Phaser.Point, this.setTarget(), this.addAnimation("main", 0, 19), this.play("main") } return __extends(i, e), i.prototype.addAnimation = function(t, e, i) { var a = utils.ArrayUtil.createArrayWithNumbers(e, i + 1); this.animations.add(t, a, 30, !0) }, i.prototype.setTarget = function() { this.target.x = this.x < t.Config.HALF_GAME_WIDTH ? t.Config.GAME_WIDTH + 100 : -100, this.target.y = this.game.rnd.integerInRange(60, t.Config.GAME_HEIGHT - 60), this.maxSpeed = this.game.rnd.realInRange(2, 3), this.velocity = this.target.clone().subtract(this.x, this.y).normalize().multiply(this.maxSpeed, this.maxSpeed), this.scale.x = this.velocity.x > 0 ? -1 * Math.abs(this.scale.x) : Math.abs(this.scale.x) }, i.prototype.update = function() { var t = utils.MathUtil.distanceSquared(this.x, this.y, this.target.x, this.target.y); t < this.maxSpeed * this.maxSpeed && this.setTarget(), this.x += this.velocity.x, this.y += this.velocity.y }, i.prototype.destroy = function() { e.prototype.destroy.call(this, !0), this.target = null, this.velocity = null }, i } (Phaser.Sprite); t.Fish = e } (game || (game = {})); var game; ! function(t) { var e = function(t) { function e(e, i, a) { var n = this; t.call(this, e, 0, 0, i, a), this.hidden = !1, this.anchor.set(.5, .5), this.inputEnabled = !0, this.events.onInputDown.add(function() { n.game.device.webAudio && n.game.sound.play("tap"), n.game.add.tween(n.scale).to({ x: .9, y: .9 }, 200, Phaser.Easing.Cubic.Out, !0) }), this.events.onInputUp.add(function() { n.game.add.tween(n.scale).to({ x: 1, y: 1 }, 200, Phaser.Easing.Cubic.Out, !0) }, this, 1) } return __extends(e, t), e.prototype.show = function() { this.hidden && (this.hidden = !1, this.input.enabled = !0, this.game.add.tween(this).to({ alpha: 1 }, 100, Phaser.Easing.Linear.None, !0)) }, e.prototype.hide = function(t) { void 0 === t && (t = !1), this.hidden === !1 && (this.hidden = !0, this.input.enabled = !1, t ? this.alpha = 0 : this.game.add.tween(this).to({ alpha: 0 }, 100, Phaser.Easing.Linear.None, !0)) }, e } (Phaser.Image); t.ArrowButton = e } (game || (game = {})); var game; ! function(t) { var e = function(e) { function i() { e.call(this) } return __extends(i, e), i.prototype.create = function() { this.game.add.image( - 32, 0, "gui", "BG_20000"), this.addFishes(), this.initLevelIcons(), this.initNavigationArrows(), this.initButtons(), t.Main.development && (this.addFPSMeter(), this.game.input.keyboard.addKey(Phaser.Keyboard.C).onDown.add(this.clearSavedData, this)) }, i.prototype.clearSavedData = function() { var e = window.confirm("Do you want to clear all saved data?"); e && (t.Main.storage.clear(), this.game.state.restart(!0, !1)) }, i.prototype.addFishes = function() { var e = this, i = new t.Fish(this.game, this.game.rnd.integerInRange(0, t.Config.GAME_WIDTH), 100, "yellow_fish"), a = new t.Fish(this.game, this.game.rnd.integerInRange(0, t.Config.GAME_WIDTH), 300, "yellow_fish"), n = new t.Fish(this.game, this.game.rnd.integerInRange(0, t.Config.GAME_WIDTH), 600, "pink_fish"); [i, a, n].forEach(function(t) { e.world.add(t) }) }, i.prototype.initLevelIcons = function() { this.levelIcons = new t.LevelIcons(this.game, this.world), this.levelIcons.iconClicked.addOnce(this.onLevelIconClicked, this), this.levelIcons.x = .5 * (t.Config.GAME_WIDTH - this.levelIcons.getWidth()) + 2, this.levelIcons.y = 155 }, i.prototype.onLevelIconClicked = function(t) { this.changeState("Level", t) }, i.prototype.initNavigationArrows = function() { var e = this, i = t.Config.HALF_GAME_HEIGHT + 27; this.leftArrow = new t.ArrowButton(this.game, "gui", "Button_L0000"), this.leftArrow.events.onInputUp.add(function() { e.changeLevelIconsPage("prev_page") }, this, 2), this.leftArrow.x = 41, this.leftArrow.y = i, this.leftArrow.hide(!0), this.world.add(this.leftArrow), this.rightArrow = new t.ArrowButton(this.game, "gui", "Button_R0000"), this.rightArrow.events.onInputUp.add(function() { e.changeLevelIconsPage("next_page") }, this, 2), this.rightArrow.x = t.Config.GAME_WIDTH - 38, this.rightArrow.y = i, this.world.add(this.rightArrow) }, i.prototype.changeLevelIconsPage = function(t) { this.levelIcons.showPage(t), this.levelIcons.isFirstPage() ? this.leftArrow.hide() : this.levelIcons.isLastPage() ? this.rightArrow.hide() : (this.leftArrow.show(), this.rightArrow.show()) }, i.prototype.initButtons = function() { var e = this, i = 60; this.backButton = new t.SimpleButton(this.game, i, i, "gui", "Home_Button0000"), this.backButton.callback.addOnce(function() { e.changeState("MainMenu") }, this), this.world.add(this.backButton), this.soundButton = new t.ToggleButton(this.game, t.Config.GAME_WIDTH - i + .5, i, "Music_On_Button0000", "Music_Off_Button0000"), this.soundButton.callback.add(function() { e.game.sound.mute = !e.game.sound.mute }), this.game.sound.mute && this.soundButton.switchTextures(), this.world.add(this.soundButton) }, i.prototype.changeState = function(t, e) { this.game.changeState(t, e) }, i.prototype.addFPSMeter = function() { new utils.FPSMeter(this.game, 0, t.Config.GAME_HEIGHT - 22) }, i } (Phaser.State); t.LevelsMenu = e } (game || (game = {})); var game; ! function(t) { var e = function() { function t(t) { this._ballsToSpawn = 20, this._baseSpeed = 20, this._levelNumber = t } return Object.defineProperty(t.prototype, "levelNumber", { get: function() { return this._levelNumber }, enumerable: !0, configurable: !0 }), Object.defineProperty(t.prototype, "ballsToSpawn", { get: function() { return this._ballsToSpawn }, enumerable: !0, configurable: !0 }), Object.defineProperty(t.prototype, "baseSpeed", { get: function() { return this._baseSpeed }, enumerable: !0, configurable: !0 }), t } (); t.LevelSettings = e } (game || (game = {})); var utils; ! function(t) { var e = function(t) { function e(e, i, a) { void 0 === i && (i = 0), void 0 === a && (a = 0), t.call(this, e, e.world, "FPS Meter"), this.x = i, this.y = a, this.initBackground(), this.initText(), this.game.time.advancedTiming = !0, this.loopEvent = this.game.time.events.loop(500, this.updateText, this) } return __extends(e, t), e.prototype.initBackground = function() { var t = 80; this.bg = new Phaser.Graphics(this.game, 0, 0), this.bg.beginFill(0, 1), this.bg.drawRect(0, 0, t, 22), this.bg.endFill(), this.add(this.bg) }, e.prototype.initText = function() { var t = { font: "18px Consolas", fill: "#FFFFFF", align: "center" }; this.statsText = this.game.add.text(5, 0, "0 fps", t, this) }, e.prototype.updateText = function() { var t = "FPS: " + this.game.time.fps; this.statsText.setText(t) }, e.prototype.destroy = function() { this.game.time.events.remove(this.loopEvent), this.loopEvent = null, this.game.time.advancedTiming = !1, t.prototype.destroy.call(this) }, e } (Phaser.Group); t.FPSMeter = e } (utils || (utils = {})); var game; ! function(t) { var e = function(t) { function e(e, i, a, n) { t.call(this, e, i, a, "debug_gui", n), this.inputEnabled = !0, this.input.useHandCursor = !0 } return __extends(e, t), e } (Phaser.Image); t.DebugButton = e } (game || (game = {})); var game; ! function(t) { var e = function(t) { function e(e, i) { t.call(this, e, i, "SandTilesLabel"), this.initBack(), this.initText() } return __extends(e, t), e.prototype.initBack = function() { var t = new Phaser.Image(this.game, 0, 0, "gui", "SandTiles_Label0000"); this.add(t) }, e.prototype.initText = function() { var t = { font: "42px TF2 Build", fill: "#FDF490", align: "center" }; this.text = new Phaser.Text(this.game, 55, 6, "0", t), this.add(this.text) }, e.prototype.updateText = function(t) { this.text.setText(t.toString()) }, e } (Phaser.SpriteBatch); t.SandTilesLabel = e } (game || (game = {})); var game; ! function(t) { var e = function(e) { function i(t, i, a, n) { e.call(this, t, i, "Level Complete Board"), this.levelNumber = a, this.starsNum = n, this.boardGroup = this.game.add.group(this), this.addBoard(), this.addLabel(), this.addStars(), this.addButtons() } return __extends(i, e), i.prototype.addBoard = function() { var t = this.game.add.image(0, 0, "level_complete", "LevelComplete_Board0000", this.boardGroup); this._width = t.width }, i.prototype.addLabel = function() { var e = t.Main.texts.level_complete, i = { font: "45px GrilledCheeseBTNToasted", fill: "#249BC8", align: "center" }, a = new Phaser.Text(this.game, 50, 20, e, i); a.anchor.set(.5, .5), a.x = .5 * this._width, a.y = 60, this.boardGroup.add(a) }, i.prototype.addStars = function() { var t = this.game.add.group(this.boardGroup, "stars"); this.stars = []; for (var e = 0, i = 100, a = 0, n = 0; n < this.starsNum; n++) { var s = this.game.add.image(e, 0, "level_complete", "NoStar0000", t); s.anchor.set(.5, .5); var o = this.game.add.image(e - 2, -1, "level_complete", "Star0000", t); o.anchor.set(.5, .5), o.visible = !1, this.stars.push(o), e += i, a += i } a -= i, t.x = .5 * (this._width - a), t.y = 146 }, i.prototype.addButtons = function() { var t = this, e = this.game.add.group(this), i = 116, a = new game.SimpleButton(this.game, 0, 0, "level_complete", "Home_Button0000"); a.callback.addOnce(function() { t.game.changeState("LevelsMenu") }, this); var n = new game.SimpleButton(this.game, i, 0, "level_complete", "Restart_Button0000"); n.callback.add(function() { var e = t.game.state.getCurrentState(); e.restart() }, this); var s = new game.SimpleButton(this.game, 2 * i, 0, "level_complete", "NextLevel_Button0000"); s.callback.addOnce(function() { t.levelNumber === game.Config.LEVELS_NUM ? t.game.changeState("LevelsMenu") : t.game.changeState("Level", t.levelNumber + 1) }, this), this.buttons = [a, n, s], this.buttons.forEach(function(t) { e.add(t) }), e.position.set(118, 300) }, i.prototype.show = function(t) { this.showStars(t), this.startAnimation() }, i.prototype.showStars = function(t) { this.stars.forEach(function(t) { t.visible = !1 }); for (var e = 0; e < t.starsEarned; e++) this.stars[e].visible = !0 }, i.prototype.startAnimation = function() { var t = this; this.visible = !0, this.boardGroup.y -= 200, this.boardGroup.alpha = 0, this.game.add.tween(this.boardGroup).to({ alpha: 1 }, 200, Phaser.Easing.Linear.None, !0), this.game.add.tween(this.boardGroup).to({ y: this.boardGroup.y + 200 }, 500, Phaser.Easing.Back.Out, !0); var e = 600, i = 800; this.stars.forEach(function(a) { a.visible && (a.scale.set(3, 3), a.alpha = 0, t.game.add.tween(a).to({ alpha: 1 }, .5 * i, Phaser.Easing.Cubic.Out, !0, e), t.game.add.tween(a.scale).to({ x: 1, y: 1 }, i, Phaser.Easing.Bounce.Out, !0, e).onStart.addOnce(function() { t.game.sound.usingWebAudio && t.game.sound.play("star") }), e += 500) }); var a = 200; this.buttons.forEach(function(e) { e.scale.set(0, 0), e.visible = !1, e.y += 200, t.game.add.tween(e).to({ y: e.y - 200 }, 500, Phaser.Easing.Back.Out, !0, a), t.game.add.tween(e.scale).to({ x: 1, y: 1 }, 500, Phaser.Easing.Back.Out, !0, a).onStart.addOnce(function() { e.visible = !0 }, t), a += 100 }) }, i.prototype.hide = function() { var t = this; this.game.add.tween(this).to({ alpha: 0 }, 200, Phaser.Easing.Cubic.Out, !0).onComplete.addOnce(function() { t.visible = !1, t.alpha = 1 }, this) }, i.prototype.getWidth = function() { return this._width }, i.prototype.destroy = function() { e.prototype.destroy.call(this, !0), this.buttons = null, this.stars = null }, i } (Phaser.Group); t.LevelCompleteBoard = e } (game || (game = {})); var game; ! function(t) { var e = function(e) { function i(t, i) { e.call(this, t, t.world, "gui"), this.levelSettings = i, this.initLevelLabel(), this.initButtons() } return __extends(i, e), i.prototype.initLevelLabel = function() { var t = "Level " + this.levelSettings.levelNumber, e = { font: "45px GrilledCheeseBTNToasted", fill: "#249BC8", align: "center" }; this.label = new Phaser.Text(this.game, 50, 20, t, e), this.add(this.label), this.label.x = .5 * (game.Config.GAME_WIDTH - this.label.getLocalBounds().width), this.label.y = 20 }, i.prototype.initButtons = function() { var t = this, e = 55, i = new game.ToggleButton(this.game, 505, e, "Music_On_Button0000", "Music_Off_Button0000"); i.callback.add(function() { t.game.sound.mute = !t.game.sound.mute }), this.game.sound.mute && i.switchTextures(); var a = new game.SimpleButton(this.game, 590, e, "gui", "Home_Button0000"); a.callback.addOnce(function() { t.game.changeState("LevelsMenu") }), this.buttons = [a, i], this.buttons.forEach(function(e) { t.add(e) }) }, i.prototype.gotoNextLevel = function() { this.levelSettings.levelNumber === game.Config.LEVELS_NUM ? this.game.state.start("Level", !0, !1, 1) : this.game.state.start("Level", !0, !1, this.levelSettings.levelNumber + 1) }, i.prototype.gotoPrevLevel = function() { 1 === this.levelSettings.levelNumber ? this.game.state.start("Level", !0, !1, t.Config.LEVELS_NUM) : this.game.state.start("Level", !0, !1, this.levelSettings.levelNumber - 1) }, i.prototype.initCompleteBoard = function(t) { this.completeBoard = new game.LevelCompleteBoard(this.game, this, this.levelSettings.levelNumber, t), this.completeBoard.position.set(.5 * (game.Config.GAME_WIDTH - this.completeBoard.getWidth()), 200), this.completeBoard.visible = !1 }, i.prototype.onLevelComplete = function(t) { this.buttons.forEach(function(t) { t.visible = !1 }), this.completeBoard.show(t) }, i.prototype.onRestart = function() { this.buttons.forEach(function(t) { t.visible = !0 }), this.completeBoard.hide() }, i.prototype.destroy = function() { e.prototype.destroy.call(this, !0), this.buttons = null }, i } (Phaser.Group); t.LevelGUI = e } (game || (game = {})); var game; ! function(t) { var e = function(t) { function e(e, i, a) { t.call(this, e, i, a, "level_graphics", "HexCell0000"), this.anchor.set(.5, .5) } return __extends(e, t), e.RADIUS = 55, e.RADIUS_SQUARED = e.RADIUS * e.RADIUS, e } (Phaser.Image); t.HexCell = e } (game || (game = {})); var game; ! function(t) { var e = function() { function t(t, e) { this.numericValue = t, this.stringValue = e.toUpperCase() } return t.getDelta = function(t, e) { if (t === e) return 0; var i = 6, a = 3, n = Math.abs(t.numericValue - e.numericValue); return n > a && (n = i - n), n }, t.getDirectionByAngle = function(e) { switch (e) { case 0: return t.TOP; case 60: return t.RIGHT_TOP; case 120: return t.RIGHT_BOTTOM; case 180: return t.BOTTOM; case 240: return t.LEFT_BOTTOM; case 300: return t.LEFT_TOP; default: return null } }, t.getAngleByDirection = function(e) { switch (e) { case t.TOP: return 0; case t.RIGHT_TOP: return 60; case t.RIGHT_BOTTOM: return 120; case t.BOTTOM: return 180; case t.LEFT_BOTTOM: return 240; case t.LEFT_TOP: return 300; default: return null } }, t.prototype.toString = function() { return "[Direction: " + this.stringValue + "]" }, t.TOP = new t(1, "top"), t.RIGHT_TOP = new t(2, "right_top"), t.RIGHT_BOTTOM = new t(3, "right_bottom"), t.BOTTOM = new t(4, "bottom"), t.LEFT_BOTTOM = new t(5, "left_bottom"), t.LEFT_TOP = new t(6, "left_top"), t } (); t.HandDirection = e } (game || (game = {})); var game; ! function(t) { ! function(t) { t[t.Octopus = 0] = "Octopus", t[t.Crab = 1] = "Crab", t[t.Jellyfish = 2] = "Jellyfish", t[t.Needlefish = 3] = "Needlefish", t[t.ElectricRay = 4] = "ElectricRay" } (t.CreatureType || (t.CreatureType = {})), t.CreatureType } (game || (game = {})); var game; ! function(t) { var e = function(t) { function e(e, i) { this.happyTexture = i + "_HappyFace0000", this.sadTexture = i + "_SadFace0000", this.isHappy = !1, t.call(this, e, 0, 0, "level_graphics", this.sadTexture), this.anchor.set(.5, .5) } return __extends(e, t), e.prototype.setHappiness = function(t) { t !== this.isHappy && (this.isHappy = t, this.game.add.tween(this.scale).to({ x: 0, y: 0 }, 150, Phaser.Easing.Back.In, !0).onComplete.addOnce(this.changeTexture, this)) }, e.prototype.changeTexture = function() { this.isHappy ? this.loadTexture("level_graphics", this.happyTexture) : this.loadTexture("level_graphics", this.sadTexture), this.game.add.tween(this.scale).to({ x: 1, y: 1 }, 150, Phaser.Easing.Back.Out, !0) }, e } (Phaser.Image); t.Face = e } (game || (game = {})); var game; ! function(t) { var e = function(e) { function i(t, i, a) { e.call(this, t, i), this.isHappy = !1, this.onHappyArea = !1, this.isRayAround = !1, this.hasHands = !1, this._type = a, this.addBody(), this.addFace() } return __extends(i, e), i.prototype.addBody = function() { var e = t.CreatureType[this._type] + "_Body0000"; this.body = this.game.add.image(0, 0, "level_graphics", e, this), this.body.anchor.set(.5, .5) }, i.prototype.addFace = function() { var e = t.CreatureType[this._type]; this.face = new game.Face(this.game, e), this.add(this.face) }, i.prototype.onDragComplete = function() {}, i.prototype.updateHappiness = function() {}, i.prototype.returnToLastCell = function() { var t = Phaser.Math.distance(this.position.x, this.position.y, this.cell.x, this.cell.y), e = Math.min(200, 1.5 * t); this.game.add.tween(this.position).to({ x: this.cell.x, y: this.cell.y }, e, Phaser.Easing.Cubic.Out, !0) }, Object.defineProperty(i.prototype, "type", { get: function() { return this._type }, enumerable: !0, configurable: !0 }), i.CONTACT_RADIUS = 2 * t.HexCell.RADIUS, i.CONTACT_RADIUS_SQUARED = i.CONTACT_RADIUS * i.CONTACT_RADIUS, i.BODY_RADIUS = 48, i.BODY_RADIUS_SQUARED = i.BODY_RADIUS * i.BODY_RADIUS, i } (Phaser.SpriteBatch); t.BaseCreature = e } (game || (game = {})); var game; ! function(t) { var e = function(e) { function i(i, a, n) { e.call(this, i, 0, 0, "level_graphics", a), this.free = !0, this.anchor.set(.5, 1), this.angle = n, this.currentDirection = t.HandDirection.getDirectionByAngle(n) } return __extends(i, e), i.prototype.connect = function(e, i) { this.free && (this.free = !1, this.connectedHand = e, this.currentDirection = t.HandDirection.getDirectionByAngle(i), this.rotateTo(i)) }, i.prototype.rotateTo = function(t) { this.tween && this.tween.stop(); var e = 360, i = (t - this.angle) % e; i !== i % (e / 2) && (i = 0 > i ? i + e: i - e); var a = 4 * Math.abs(i); this.tween = this.game.add.tween(this).to({ angle: this.angle + i }, a, Phaser.Easing.Cubic.Out, !0) }, i.prototype.disconnect = function() { this.free === !1 && (this.free = !0, this.connectedHand.disconnect(), this.connectedHand = null, this.angle = t.HandDirection.getAngleByDirection(this.currentDirection), this.tween && this.tween.stop()) }, i.prototype.destroy = function() { this.connectedHand = null }, i } (Phaser.Image); t.Hand = e } (game || (game = {})); var game; ! function(t) { var e = function(t) { function e(e, i, a, n) { t.call(this, e, i, a), this.hasHands = !0, this.addHands(n) } return __extends(e, t), e.prototype.addHands = function() {}, e.prototype.addHand = function(t) { this.addAt(t, 0), this.hands.push(t) }, e.prototype.getFreeHands = function() { var t = []; return this.hands.forEach(function(e) { e.free && t.push(e) }), t }, e.prototype.getFreeHand = function(t) { if (this.isDirectionTaken(t)) return null; var e = 6, i = null; return this.hands.forEach(function(a) { if (a.free) { var n = game.HandDirection.getDelta(a.currentDirection, t); e > n && (i = a, e = n) } }), i }, e.prototype.isDirectionTaken = function(t) { for (var e = 0; e < this.hands.length; e++) { var i = this.hands[e]; if (i.free === !1 && i.currentDirection === t) return ! 0 } return ! 1 }, e.prototype.onDragComplete = function() { t.prototype.onDragComplete.call(this), this.disconnectAllHands() }, e.prototype.disconnectAllHands = function() { this.hands.forEach(function(t) { t.disconnect() }) }, e.prototype.hasFreeHands = function() { return this.hands.some(function(t) { return t.free }) }, e.prototype.updateHappiness = function() { var t = this.isHappy; this.isHappy = this.onHappyArea ? !0 : this.isRayAround ? !1 : this.hasFreeHands() === !1, this.face.setHappiness(this.isHappy), this.isHappy && t === !1 && this.shake() }, e.prototype.shake = function() { this.bodyTween && this.bodyTween.isRunning && (this.bodyTween.stop(), this.body.angle = 0), this.bodyTween = this.game.add.tween(this.body).to({ angle: 15 }, 100, Phaser.Easing.Cubic.Out, !0, 0, 5, !0) }, e.prototype.destroy = function() { t.prototype.destroy.call(this, !0, !1), this.hands = null }, e } (t.BaseCreature); t.CreatureWithHands = e } (game || (game = {})); var game; ! function(t) { var e = function(e) { function i(t, i, a, n) { e.call(this, t, i, a, n) } return __extends(i, e), i.prototype.addHands = function(e) { this.hands = []; for (var i = this.getHandAngles(e), a = 0; e > a; a++) { var n = i[a], s = t.CreatureType[this.type] + "_Hand0000", o = new t.Hand(this.game, s, n); this.addHand(o) } }, i.prototype.getHandAngles = function(t) { switch (t) { case 1: return [180]; case 2: return [120, 240]; case 3: return [120, 180, 240]; case 4: return [300, 60, 120, 240]; case 5: return [300, 60, 120, 180, 240]; case 6: return [300, 0, 60, 120, 180, 240]; default: return null } }, i } (t.CreatureWithHands); t.Octopus = e } (game || (game = {})); var game; ! function(t) { var e = function(t) { function e(e, i) { t.call(this, e, i, 3), this.areCreaturesAround = !0 } return __extends(e, t), e.prototype.updateHappiness = function() { this.isHappy = this.onHappyArea ? !0 : this.areCreaturesAround === !1, this.face.setHappiness(this.isHappy) }, e } (t.BaseCreature); t.Needlefish = e } (game || (game = {})); var game; ! function(t) { var e = function(e) { function i(t, i, a) { e.call(this, t, i, a), this.initialAngle = a, this.currentAngle = a } return __extends(i, e), i.prototype.connect = function(t) { this.free && (this.free = !1, this.connectedHand = t) }, i.prototype.disconnect = function() { this.free === !1 && (this.free = !0, this.connectedHand.disconnect(), this.connectedHand = null) }, i.prototype.setRotation = function(e) { this.currentAngle = (e + this.initialAngle + 360) % 360, this.currentDirection = t.HandDirection.getDirectionByAngle(this.currentAngle) }, i } (t.Hand); t.CrabHand = e } (game || (game = {})); var game; ! function(t) { var e = function(e) { function i(t, i, a) { e.call(this, t, i, 1, 2), this._rotatedSignal = new Phaser.Signal, this.rotation = Phaser.Math.degToRad(a), this.currentRotation = this.rotation, this.updateHands(), this.body.x -= 1, this.body.y += 3 } return __extends(i, e), i.prototype.addFace = function() { e.prototype.addFace.call(this), this.face.x -= 1, this.face.y -= 16 }, i.prototype.addHands = function() { this.hands = []; var e = new t.CrabHand(this.game, "Crab_Hand0000", 300), i = new t.CrabHand(this.game, "Crab_Hand0000", 60); this.addHand(e), this.addHand(i) }, i.prototype.getFreeHand = function(t) { for (var e = 0; e < this.hands.length; e++) { var i = this.hands[e]; if (i.free && i.currentDirection === t) return i } return null }, i.prototype.rotate = function() { this.currentRotation += Phaser.Math.degToRad(60), this.game.add.tween(this).to({ rotation: this.currentRotation }, 100, Phaser.Easing.Linear.None, !0), this.updateHands(), this._rotatedSignal.dispatch(this) }, i.prototype.updateHands = function() { var t = Phaser.Math.radToDeg(this.currentRotation); t = Math.round(t), this.hands.forEach(function(e) { e.setRotation(t), e.disconnect() }) }, i.prototype.destroy = function() { e.prototype.destroy.call(this), this._rotatedSignal.dispose(), this._rotatedSignal = null }, Object.defineProperty(i.prototype, "rotatedSignal", { get: function() { return this._rotatedSignal }, enumerable: !0, configurable: !0 }), i } (t.CreatureWithHands); t.Crab = e } (game || (game = {})); var game; ! function(t) { var e = function(t) { function e(e, i, a) { t.call(this, e, i, 2, a) } return __extends(e, t), e.prototype.addFace = function() { t.prototype.addFace.call(this), this.face.y -= 3 }, e } (t.Octopus); t.Jelly = e } (game || (game = {})); var game; ! function(t) { var e = function(t) { function e(e, i, a) { t.call(this, e, i, a), this.isHappy = !0 } return __extends(e, t), e.prototype.addFace = function() {}, e.prototype.addBody = function() { this.body = this.game.add.sprite(0, 0, "manta_ray", "", this), this.body.anchor.set(.5, .45), this.body.animations.add("main", null, 30, !0), this.body.animations.play("main") }, e } (t.BaseCreature); t.ElectricRay = e } (game || (game = {})); var game; ! function(t) { var e = function() { function e() {} return e.create = function(i, a, n) { var s = n.hands, o = n.type.split("_")[0], r = e.TYPES[o]; switch (r) { case 0: return new t.Octopus(i, a, r, s); case 2: return new t.Jelly(i, a, s); case 1: return new t.Crab(i, a, n.rotation); case 3: return new t.Needlefish(i, a); case 4: return new t.ElectricRay(i, a, 4); default: return null } }, e.TYPES = { Octopus: 0, Jellyfish: 2, Crab: 1, Needlefish: 3, ElectricRay: 4 }, e } (); t.CreatureFactory = e } (game || (game = {})); var game; ! function(t) { ! function(t) { t[t.Stone = 0] = "Stone", t[t.Happy = 1] = "Happy", t[t.Star = 2] = "Star" } (t.ObjectType || (t.ObjectType = {})), t.ObjectType } (game || (game = {})); var game; ! function(t) { var e = function(t) { function e(e, i, a) { t.call(this, e, 0, 0, "level_graphics", i), this._type = a, this.anchor.set(.5, .5) } return __extends(e, t), Object.defineProperty(e.prototype, "type", { get: function() { return this._type }, enumerable: !0, configurable: !0 }), e } (Phaser.Image); t.GridObject = e } (game || (game = {})); var game; ! function(t) { var e = function(t) { function e(e, i) { t.call(this, e, i, 0) } return __extends(e, t), e } (t.GridObject); t.Stone = e } (game || (game = {})); var game; ! function(t) { var e = function(t) { function e(e, i) { t.call(this, e, i, 1), this.game.add.tween(this).to({ angle: 360 }, 5e3, Phaser.Easing.Linear.None, !0, 0, 1e4) } return __extends(e, t), e } (t.GridObject); t.HappyArea = e } (game || (game = {})); var game; ! function(t) { var e = function(t) { function e(e) { t.call(this, e, "Star0000", 2), this._isTaken = !1, this.freeTexture = "Star0000", this.takenTexture = "Star_Taken0000", this.anchor.set(.48, .5), this.startFreeTween() } return __extends(e, t), e.prototype.startFreeTween = function() { (this.angleTween || this.scaleTween) && (this.angleTween.stop(), this.scaleTween.stop()); var t = 800; this.angle = -15, this.angleTween = this.game.add.tween(this).to({ angle: 15 }, t, Phaser.Easing.Cubic.Out, !0, 0, 1e4, !0), this.scaleTween = this.game.add.tween(this.scale).to({ x: 1.1, y: 1.1 }, .5 * t, Phaser.Easing.Cubic.Out, !0, 0, 1e4, !0) }, e.prototype.onTaken = function() { this._isTaken === !1 && (this.game.sound.usingWebAudio && this.game.sound.play("star_taken", .25), this._isTaken = !0, this.loadTexture("level_graphics", this.takenTexture), this.scaleTween && this.scaleTween.stop(), this.scale.set(1, 1)) }, e.prototype.onFree = function() { this._isTaken && (this._isTaken = !1, this.loadTexture("level_graphics", this.freeTexture), this.startFreeTween()) }, Object.defineProperty(e.prototype, "isTaken", { get: function() { return this._isTaken }, enumerable: !0, configurable: !0 }), e } (t.GridObject); t.Star = e } (game || (game = {})); var game; ! function(t) { var e = function(e) { function i(t) { e.call(this, t, t.world, "grid"), this.startDragPosition = new Phaser.Point, this.cells = [], this.creatures = [], this.stars = [], this.stones = [], this.happyAreas = [], this._levelCompleteSignal = new Phaser.Signal, this.bottomLayer = this.game.add.group(this, "cells_rocks"), this.topLayer = this.game.add.group(this, "creatures_objects"), this.initInput() } return __extends(i, e), i.prototype.initInput = function() { this.game.input.onDown.add(this.onDown, this), this.game.input.onUp.add(this.onUp, this) }, i.prototype.disableInput = function() { this.game.input.onDown.remove(this.onDown, this), this.game.input.onUp.remove(this.onUp, this) }, i.prototype.addCell = function(t) { this.bottomLayer.add(t), this.cells.push(t) }, i.prototype.addCreature = function(t) { var e = this.getCellUnderPoint(t.x, t.y), i = game.CreatureFactory.create(this.game, this.topLayer, t); i.position.set(e.x, e.y), i.cell = e, this.creatures.push(i), 1 === i.type && i.rotatedSignal.add(this.onCrabRotate, this) }, i.prototype.onCrabRotate = function() { this.updateCreatures(), this.checkLevelComplete(), this.crabRotateSignal && this.crabRotateSignal.dispatch() }, i.prototype.addGridObject = function(e) { var i, a = e.type, n = a + "0000"; if (a.indexOf("Stone") > -1 ? (i = new t.Stone(this.game, n), this.stones.push(i)) : a.indexOf("Happy") > -1 ? (i = new t.HappyArea(this.game, n), this.happyAreas.push(i)) : a.indexOf("Star") > -1 && (i = new t.Star(this.game), this.stars.push(i)), i) { 0 === i.type ? this.bottomLayer.add(i) : this.topLayer.addAt(i, 0); var s = this.getCellUnderPoint(e.x, e.y); s ? (i.cell = s, i.x = s.x, i.y = s.y, 1 === i.type && (s.alpha = .66)) : (i.x = e.x, i.y = e.y) } }, i.prototype.onDown = function(t) { var e = this.getCreatureUnderPoint(t.worldX - this.x, t.worldY - this.y); e && (this.game.sound.usingWebAudio && this.game.sound.play("on_down", .5), 1 === e.type ? (this.selectedCrab = e, this.startDragPosition.set(t.worldX, t.worldY)) : this.startDragCreature(e)) }, i.prototype.getCreatureUnderPoint = function(e, i) { for (var a = 0; a < this.creatures.length; a++) { var n = this.creatures[a], s = utils.MathUtil.distanceSquared(n.position.x, n.position.y, e, i); if (s < t.BaseCreature.BODY_RADIUS_SQUARED) return n } return null }, i.prototype.onUp = function() { if (this.selectedCrab && (this.selectedCrab.rotate(), this.selectedCrab = null), this.draggedCreature) { this.game.sound.usingWebAudio && this.game.sound.play("on_up", .5); var t = this.getCellUnderPoint(this.draggedCreature.position.x, this.draggedCreature.position.y), e = this.getCreatureInCell(t); ! t || this.getRockInCell(t) ? this.draggedCreature.returnToLastCell() : (e ? this.swapCreatures(this.draggedCreature, e) : (this.game.add.tween(this.draggedCreature.position).to({ x: t.x, y: t.y }, 150, Phaser.Easing.Cubic.Out, !0), this.draggedCreature.cell = t, this.draggedCreature.onDragComplete()), this.updateCreatures(), this.updateStars(), this.checkLevelComplete()), this.cellHighlight.visible = !1, this.game.add.tween(this.draggedCreature.scale).to({ x: 1, y: 1 }, 150, Phaser.Easing.Cubic.In, !0), this.draggedCreature = null } }, i.prototype.swapCreatures = function(t, e) { var i = t.cell, a = e.cell; t.cell = null, e.cell = null, this.game.add.tween(t.position).to({ x: a.x, y: a.y }, 150, Phaser.Easing.Cubic.Out, !0), t.cell = a, t.onDragComplete(), this.game.add.tween(e.position).to({ x: i.x, y: i.y }, 150, Phaser.Easing.Cubic.Out, !0), e.cell = i, e.onDragComplete() }, i.prototype.cellIsEmpty = function(t) { var e = this.creatures.some(function(e) { return e.cell === t }), i = this.stones.some(function(e) { return e.cell === t }); return e === !1 && i === !1 }, i.prototype.updateCreatures = function() { var t = this; this.creatures.forEach(function(e) { e.onHappyArea = null !== t.getHappyAreaInCell(e.cell), e.isRayAround = t.getNeighbourCreatures(e).some(function(t) { return 4 === t.type }); var i = t.getNeighbourCreatures(e); if (3 === e.type) { var a = e; a.areCreaturesAround = i.length > 0 } else e.hasHands && t.connectCreaturesAround(e, i); e.updateHappiness() }) }, i.prototype.getRockInCell = function(t) { for (var e = 0; e < this.stones.length; e++) { var i = this.stones[e]; if (i.cell === t) return i } return null }, i.prototype.getHappyAreaInCell = function(t) { for (var e = 0; e < this.happyAreas.length; e++) { var i = this.happyAreas[e]; if (i.cell === t) return i } return null }, i.prototype.getCreatureInCell = function(t) { for (var e = 0; e < this.creatures.length; e++) { var i = this.creatures[e]; if (i.cell === t) return i } return null }, i.prototype.getCellUnderPoint = function(e, i) { for (var a = 0; a < this.cells.length; a++) { var n = this.cells[a], s = utils.MathUtil.distanceSquared(e, i, n.x, n.y); if (s < t.HexCell.RADIUS_SQUARED) return n } return null }, i.prototype.connectCreaturesAround = function(t, e) { var i = this; 0 !== e.length && e.forEach(2 === t.type ? function(e) { if (2 === e.type) { var a = e; a.hasFreeHands() && i.connectHands(t, a) } }: function(e) { if (1 === e.type || 0 === e.type) { var a = e; a.hasFreeHands() && i.connectHands(t, a) } }) }, i.prototype.getNeighbourCreatures = function(t) { for (var e = t.cell.x, i = t.cell.y, a = [], n = 0; n < this.creatures.length; n++) { var s = this.creatures[n]; if (s !== t) { var o = utils.MathUtil.distanceSquared(s.cell.x, s.cell.y, e, i); o < game.BaseCreature.CONTACT_RADIUS_SQUARED && a.push(s) } } return a }, i.prototype.connectHands = function(t, e) { var i = this.getAngleBetweenCells(t.cell, e.cell), a = (i + 180) % 360, n = game.HandDirection.getDirectionByAngle(i), s = game.HandDirection.getDirectionByAngle(a), o = t.getFreeHand(n), r = e.getFreeHand(s); o && r && (o.connect(r, i), r.connect(o, a)) }, i.prototype.getAngleBetweenCells = function(t, e) { var i = t.x - e.x, a = t.y - e.y, n = Math.atan2(a, i) * utils.MathUtil.RAD_TO_DEG - 90; return n = (n + 720) % 360, n = Phaser.Math.snapTo(n, 10, 0) }, i.prototype.checkLevelComplete = function() { this.allCreaturesHappy() && this.game.time.events.add(1e3, this.finalCheckLevelComplete, this) }, i.prototype.finalCheckLevelComplete = function() { if (this.allCreaturesHappy()) { if (this.draggedCreature) { var t = this.draggedCreature.cell; this.game.add.tween(this.draggedCreature.position).to({ x: t.x, y: t.y }, 150, Phaser.Easing.Cubic.Out, !0), this.draggedCreature.cell = t, this.draggedCreature.onDragComplete(), this.draggedCreature = null } this.disableInput(), this.onLevelComplete() } }, i.prototype.allCreaturesHappy = function() { return this.creatures.every(function(t) { return t.isHappy }) }, i.prototype.onLevelComplete = function() { var e = new t.LevelResult; e.starsAvailable = this.stars.length, e.starsEarned = this.getStarsEarnedNum(), e.starsAvailable > 3 && (e.starsAvailable = 3), this._levelCompleteSignal.dispatch(e) }, i.prototype.getStarsAvailable = function() { return this.stars.length }, i.prototype.getStarsEarnedNum = function() { var t = 0; return this.stars.forEach(function(e) { e.isTaken && t++ }), t }, i.prototype.init = function() { this.bottomLayer.cacheAsBitmap = !0, this.initBounds(), this.addCellHighlight(), this.sortCreatures(), this.updateCreatures(), this.updateStars() }, i.prototype.initBounds = function() { var t = 1e3, e = 0, i = 1e3, a = 0; this.cells.forEach(function(n) { n.x < t && (t = n.x), n.x > e && (e = n.x), n.y < i && (i = n.y), n.y > a && (a = n.y) }), this.bounds = new Phaser.Rectangle(t, i, e - t, a - i) }, i.prototype.addCellHighlight = function() { this.cellHighlight = this.game.add.image(0, 0, "level_graphics", "HexCell_Highlight0000", this), this.cellHighlight.anchor.set(.5, .5), this.cellHighlight.visible = !1, this.bringToTop(this.topLayer) }, i.prototype.sortCreatures = function() { var t = this.creatures.filter(function(t) { return 1 === t.type }), e = this.creatures.filter(function(t) { return 0 === t.type }); e.sort(function(t, e) { return e.getFreeHands().length - t.getFreeHands().length }); var i = this.creatures.filter(function(t) { return 2 === t.type }); i.sort(function(t, e) { return e.getFreeHands().length - t.getFreeHands().length }); var a = this.creatures.filter(function(t) { return 3 === t.type || 4 === t.type }); this.creatures = [].concat(t, e, i, a) }, i.prototype.update = function() { if (this.selectedCrab) { var t = this.game.input.activePointer, e = Phaser.Math.distance(t.x, t.y, this.startDragPosition.x, this.startDragPosition.y); e > 20 && (this.startDragCreature(this.selectedCrab), this.selectedCrab = null) } if (this.draggedCreature) { var i = this.game.input.activePointer.worldX - this.x, a = this.game.input.activePointer.worldY - this.y; this.draggedCreature.position.set(i, a); var n = this.getCellUnderPoint(i, a); n ? (this.cellHighlight.visible = !0, this.cellHighlight.x = n.x, this.cellHighlight.y = n.y) : this.cellHighlight.visible = !1 } }, i.prototype.startDragCreature = function(t) { this.draggedCreature = t, this.topLayer.bringToTop(t), this.game.add.tween(this.draggedCreature.scale).to({ x: 1.25, y: 1.25 }, 150, Phaser.Easing.Cubic.Out, !0), this.creatureDragSignal && this.creatureDragSignal.dispatch() }, i.prototype.updateStars = function() { var t = this; this.stars.forEach(function(e) { var i = t.getCreatureInCell(e.cell); i ? e.onTaken() : e.onFree() }) }, i.prototype.render = function() { this.renderCells() }, i.prototype.renderCreatures = function() { var e = this, i = new Phaser.Circle(0, 0, t.BaseCreature.CONTACT_RADIUS); this.creatures.forEach(function(a) { i.radius = t.BaseCreature.CONTACT_RADIUS, i.x = a.position.x + e.x, i.y = a.position.y + e.y, e.game.debug.geom(i, "red", !1), i.radius = t.BaseCreature.BODY_RADIUS, i.x = a.position.x + e.x, i.y = a.position.y + e.y, e.game.debug.geom(i, "blue", !0) }) }, i.prototype.renderCells = function() { var e = this, i = new Phaser.Circle(0, 0, 10); this.cells.forEach(function(a) { i.radius = t.HexCell.RADIUS, i.x = a.x + e.x, i.y = a.y + e.y, e.game.debug.geom(i, "red", !1) }) }, i.prototype.onRestart = function() { this.visible = !0, this.initInput() }, i.prototype.destroy = function(t, i) { void 0 === t && (t = !0), void 0 === i && (i = !1), e.prototype.destroy.call(this, t, i), this.bounds = null, this._levelCompleteSignal.dispose(), this._levelCompleteSignal = null, this.stars = null, this.creatures = null, this.happyAreas = null, this.stones = null, this.cells = null, this.selectedCrab = null, this.draggedCreature = null, this.startDragPosition = null }, Object.defineProperty(i.prototype, "levelCompleteSignal", { get: function() { return this._levelCompleteSignal }, enumerable: !0, configurable: !0 }), i } (Phaser.Group); t.Grid = e } (game || (game = {})); var game; ! function(t) { var e = function(t) { function e(e, i, a, n) { t.call(this, e, i, a, "tutor_hand"), this.start = new Phaser.Point(i, a), this.destination = n, this.show(), this.initAnimation(), this.initTweens() } return __extends(e, t), e.prototype.show = function() { this.alpha = 0, this.game.add.tween(this).to({ alpha: 1 }, 500, Phaser.Easing.Cubic.Out, !0, 1e3) }, e.prototype.initAnimation = function() { this.animations.add("main", utils.ArrayUtil.createArrayWithNumbers(5, 20), 30, !1) }, e.prototype.initTweens = function() { this.repeatEvent = this.game.time.events.repeat(1700, Number.MAX_VALUE, this.startTween, this) }, e.prototype.startTween = function() { this.x = this.start.x, this.y = this.start.y, this.animations.play("main", 30, !1, !1), this.game.add.tween(this).to({ x: this.destination.x, y: this.destination.y }, 800, Phaser.Easing.Cubic.Out, !0, 600) }, e.prototype.hideAndDestroy = function() { this.game.time.events.remove(this.repeatEvent), this.repeatEvent = null, this.start = null, this.destination = null, this.visible = !1 }, e } (Phaser.Sprite); t.MovingTutorHand = e } (game || (game = {})); var game; ! function(t) { var e = function(t) { function e(e, i, a) { t.call(this, e, i, a, "tutor_hand"), this.initAnimation() } return __extends(e, t), e.prototype.initAnimation = function() { this.animations.add("main", null), this.play("main", 30, !0) }, e.prototype.hideAndDestroy = function() { this.animations.stop(), this.game.add.tween(this).to({ alpha: 0 }, 300, Phaser.Easing.Linear.None, !0).onComplete.addOnce(this.destroy, this) }, e } (Phaser.Sprite); t.TutorHand = e } (game || (game = {})); var game; ! function(t) { var e = function(e) { function i(t, i, a, n, s) { e.call(this, t, i), this._closedSignal = new Phaser.Signal, this.addBack(), this.addTitle(a), this.addImage(n), this.addDescription(s), this.addCloseButton() } return __extends(i, e), i.prototype.addBack = function() { var t = this.game.add.image(0, 0, "tutorial", "Tutor_Board0000", this); this._width = t.width, this._height = t.height }, i.prototype.addTitle = function(t) { var e = { font: "50px GrilledCheeseBTNToasted", fill: "#ffffff", align: "center" }, i = new Phaser.Text(this.game, 50, 20, t, e); this.add(i), i.x = .5 * (this._width - i.getLocalBounds().width), i.y = 20 }, i.prototype.addImage = function(t) { var e = this.game.add.image(0, 100, "tutorial", t, this); e.x = .5 * (this._width - e.width) }, i.prototype.addDescription = function(e) { var i = { font: "32px GrilledCheeseBTNToasted", fill: "#ffffff", align: "center" }, a = new Phaser.Text(this.game, 50, 20, e, i); this.add(a), a.lineSpacing = -5, a.wordWrapWidth = .8 * this._width, a.wordWrap = !0, a.x = 10 + .5 * (this._width - a.wordWrapWidth), a.y = 255, "ru" === t.Main.language && (a.lineSpacing = -10) }, i.prototype.addCloseButton = function() { var e = new t.SimpleButton(this.game, .5 * this._width, this._height, "tutorial", "Close_Button0000"); e.callback.addOnce(this.hide, this), this.add(e) }, i.prototype.hide = function() { var e = this; this.game.add.tween(this).to({ y: t.Config.GAME_HEIGHT + 30 }, 600, Phaser.Easing.Back.In, !0).onComplete.addOnce(function() { e._closedSignal.dispatch(), e.destroy() }, this) }, i.prototype.getWidth = function() { return this._width }, i.prototype.getHeight = function() { return this._height }, i.prototype.destroy = function() { this.visible = !1, this._closedSignal.dispose(), this._closedSignal = null, e.prototype.destroy.call(this, !0) }, Object.defineProperty(i.prototype, "closedSignal", { get: function() { return this._closedSignal }, enumerable: !0, configurable: !0 }), i.OCTOPUS = "octopus", i.JELLY = "jellyfish", i.CRAB = "crab", i.NEEDLEFISH = "needlefish", i.MANTA_RAY = "manta_ray", i.HAPPY_AREA = "happy_area", i } (Phaser.Group); t.TutorBoard = e } (game || (game = {})); var game; ! function(t) { var e = function() { function e() {} return e.getBoard = function(t, i, a) { var n = e.BOARDS_BY_LEVELS[a]; return n ? e.createBoard(t, i, n) : null }, e.createBoard = function(i, a, n) { var s = t.Main.texts[n]; if (!s) return null; var o = e.getImageKeyById(n); return new t.TutorBoard(i, a, s.title, o, s.description) }, e.getImageKeyById = function(e) { switch (e) { case t.TutorBoard.OCTOPUS: return "Tutor_Octopus0000"; case t.TutorBoard.CRAB: return "Tutor_Crab0000"; case t.TutorBoard.MANTA_RAY: return "Tutor_MantaRay0000"; case t.TutorBoard.NEEDLEFISH: return "Tutor_NeedleFish0000"; case t.TutorBoard.JELLY: return "Tutor_JellyFish0000"; case t.TutorBoard.HAPPY_AREA: return "Tutor_HappyArea0000"; default: return "Tutor_Octopus0000" } }, e.BOARDS_BY_LEVELS = { 1 : t.TutorBoard.OCTOPUS, 5 : t.TutorBoard.CRAB, 11 : t.TutorBoard.MANTA_RAY, 19 : t.TutorBoard.NEEDLEFISH, 31 : t.TutorBoard.HAPPY_AREA, 40 : t.TutorBoard.JELLY }, e } (); t.TutorBoardFactory = e } (game || (game = {})); var game; ! function(t) { var e; ! function(t) { t[t.ACTIVE = 0] = "ACTIVE", t[t.PAUSED = 1] = "PAUSED", t[t.RESTART = 2] = "RESTART" } (e || (e = {})); var i = function(e) { function i() { e.apply(this, arguments) } return __extends(i, e), i.prototype.init = function(e) { this.debugRenderFlag = !1, this.state = 1, this._settings = new t.LevelSettings(e) }, i.prototype.preload = function() { if (t.Main.development) { var e = this._settings.levelNumber.toString(), i = "assets/levels/Level_" + e + ".json"; this.load.json("level_" + e, i) } }, i.prototype.create = function() { this.game.state.onShutDownCallback = this.destroy, this.state = 1, this.addLayers(), t.Main.development && this.addFPSMeter(), this.parse(), this.afterParsing(), this.initKeyCallbacks(), this._settings.levelNumber > 1 && this.showAds(), this.state = 0 }, i.prototype.showAds = function() {}, i.prototype.pauseGame = function() { t.Main.wasPaused = !0, t.Main.wasMuted = this.game.sound.mute, this.game.sound.mute = !0, this.game.tweens.pauseAll() }, i.prototype.resumeGame = function() { t.Main.wasPaused && (t.Main.wasPaused = !1, this.game.sound.mute = t.Main.wasMuted, this.game.tweens.resumeAll()) }, i.prototype.addLayers = function() { this.game.add.image( - 33, 0, "level_graphics", "Level_BG20000"), this.addGrid(), this.addGUI() }, i.prototype.addGrid = function() { this.grid = new t.Grid(this.game), this.grid.levelCompleteSignal.add(this.onLevelComplete, this) }, i.prototype.addGUI = function() { this.gui = new t.LevelGUI(this.game, this._settings) }, i.prototype.addFPSMeter = function() { this.fpsMeter = new utils.FPSMeter(this.game, 0, t.Config.GAME_HEIGHT - 22) }, i.prototype.parse = function() { var e; if (t.Main.development) e = this.game.cache.getJSON("level_" + this._settings.levelNumber.toString()); else { var i = "Level_" + this._settings.levelNumber, a = this.game.cache.getJSON("levelConfigs"); e = a[i] } t.Main.parser.parse(this, e) }, i.prototype.afterParsing = function() { this.grid.init(), this.grid.position.set(.5 * (t.Config.GAME_WIDTH - this.grid.bounds.width) - this.grid.bounds.x, .5 * (t.Config.GAME_HEIGHT - this.grid.bounds.height) - this.grid.bounds.y), this.grid.position.x = Math.round(this.grid.position.x), this.grid.position.y = Math.round(this.grid.position.y); var e = this.grid.getStarsAvailable(); this.gui.initCompleteBoard(e), this.initTutorial() }, i.prototype.initTutorial = function() { this.initTutorHands(), this.initTutorBoards() }, i.prototype.initTutorHands = function() { 1 === this._settings.levelNumber ? this.addMovingTutorHand() : 5 === this._settings.levelNumber && this.addSimpleTutorHand() }, i.prototype.addMovingTutorHand = function() { var e = this, i = new t.MovingTutorHand(this.game, 350, 125, new Phaser.Point(185, 210)); this.grid.add(i), this.grid.creatureDragSignal = new Phaser.Signal, this.grid.creatureDragSignal.addOnce(function() { i.hideAndDestroy(), e.grid.creatureDragSignal.dispose(), e.grid.creatureDragSignal = null }) }, i.prototype.addSimpleTutorHand = function() { var e = this, i = new t.TutorHand(this.game, 108, 160); this.grid.add(i), this.grid.crabRotateSignal = new Phaser.Signal, this.grid.crabRotateSignal.addOnce(function() { i.hideAndDestroy(), e.grid.crabRotateSignal.dispose(), e.grid.crabRotateSignal = null }) }, i.prototype.initTutorBoards = function() { var e = this, i = t.TutorBoardFactory.getBoard(this.game, this.world, this._settings.levelNumber); if (i) { i.position.set(.5 * (t.Config.GAME_WIDTH - i.getWidth()), -i.getHeight()); var a = .5 * (t.Config.GAME_HEIGHT - i.getHeight()); this.game.add.tween(i).to({ y: a }, 600, Phaser.Easing.Back.Out, !0, 150), this.grid.visible = !1, this.grid.alpha = 0, i.closedSignal.addOnce(function() { e.grid.visible = !0, e.game.add.tween(e.grid).to({ alpha: 1 }, 200, Phaser.Easing.Linear.None, !0) }, this) } }, i.prototype.initKeyCallbacks = function() { var e = this; this.game.input.keyboard.addKey(Phaser.Keyboard.ESC).onDown.add(this.gotoChooseLevelMenu, this), t.Main.development && (this.game.input.keyboard.addKey(Phaser.Keyboard.S).onDown.add(function() { e.fpsMeter.visible = !e.fpsMeter.visible }), this.game.input.keyboard.addKey(Phaser.Keyboard.D).onDown.add(this.toggleDebugRender, this), this.game.input.keyboard.addKey(Phaser.Keyboard.LEFT).onDown.add(this.gotoPrevLevel, this), this.game.input.keyboard.addKey(Phaser.Keyboard.RIGHT).onDown.add(this.gotoNextLevel, this)) }, i.prototype.gotoPrevLevel = function() { var e = this._settings.levelNumber, i = 1 === e ? t.Config.LEVELS_NUM: e - 1; this.gotoLevel(i) }, i.prototype.gotoNextLevel = function() { var e = this._settings.levelNumber, i = e >= t.Config.LEVELS_NUM ? 1 : e + 1; this.gotoLevel(i) }, i.prototype.gotoLevel = function(t) { this.game.changeState("Level", t) }, i.prototype.restart = function() { this.gui.onRestart(), this.grid.onRestart() }, i.prototype.toggleDebugRender = function() { this.debugRenderFlag = !this.debugRenderFlag }, i.prototype.gotoChooseLevelMenu = function() { this.game.changeState("LevelsMenu") }, i.prototype.onLevelComplete = function(t) { this.game.sound.usingWebAudio && this.game.sound.play("onLevelComplete", .66); try { this.saveLevelResult(t) } catch(e) {} 1 === this._settings.levelNumber ? this.gotoNextLevel() : (this.grid.visible = !1, this.gui.onLevelComplete(t)) }, i.prototype.saveLevelResult = function(e) { e.levelNumber = this._settings.levelNumber; var i = this._settings.levelNumber.toString(); t.Main.storage.saveValue(i, e); // updateShare(e.levelNumber); // Play68.setRankingScoreDesc(e.levelNumber) }, i.prototype.render = function() { this.debugRenderFlag && this.grid.render() }, i.prototype.destroy = function() { this.game.state.onShutDownCallback = null, this.removeKeyCallbacks(), this._settings = null }, i.prototype.removeKeyCallbacks = function() { this.game.input.keyboard.removeKey(Phaser.Keyboard.R), this.game.input.keyboard.removeKey(Phaser.Keyboard.P), this.game.input.keyboard.removeKey(Phaser.Keyboard.ESC), this.game.input.keyboard.removeKey(Phaser.Keyboard.D) }, Object.defineProperty(i.prototype, "settings", { get: function() { return this._settings }, enumerable: !0, configurable: !0 }), i } (Phaser.State); t.Level = i } (game || (game = {})); var game; ! function(t) { var e = function() { function t(t) { this.game = t, this.initCallbacks() } return t.prototype.initCallbacks = function() { this.callbacks = {}, this.callbacks.HexCell = this.addGridCell, this.callbacks.Octopus = this.addCreature, this.callbacks.Jellyfish = this.addCreature, this.callbacks.Crab = this.addCreature, this.callbacks.Needlefish = this.addCreature, this.callbacks.ElectricRay = this.addCreature, this.callbacks.Stone = this.addGridObject, this.callbacks.HappyArea = this.addGridObject, this.callbacks.Star = this.addGridObject }, t.prototype.parse = function(t, e) { this.newLevel = t, this.levelConfig = e, this.parseObjects(), this.cleanup() }, t.prototype.cleanup = function() { this.newLevel = null, this.levelConfig = null }, t.prototype.parseObjects = function() { var t = this; this.levelConfig.forEach(function(e) { t.addGameObject(e) }) }, t.prototype.addGameObject = function(t) { var e = t.type, i = this.getCallback(e); i ? i.call(this, t) : this.addImage(t) }, t.prototype.getCallback = function(t) { for (var e in this.callbacks) if (t.indexOf(e) > -1) return this.callbacks[e]; return null }, t.prototype.addCreature = function(t) { this.newLevel.grid.addCreature(t) }, t.prototype.addGridCell = function(t) { var e = Math.round(t.x), i = Math.round(t.y), a = new game.HexCell(this.game, e, i); this.newLevel.grid.addCell(a) }, t.prototype.addGridObject = function(t) { this.newLevel.grid.addGridObject(t) }, t.prototype.addImage = function() {}, t } (); t.LevelParser = e } (game || (game = {})); var utils; ! function(t) { var e = function() { function t() { this._enabled = !0, this.init() } return t.prototype.init = function() { try { this.localStorage = window.localStorage, this.localStorage.setItem("testKey", "testData"), this.localStorage.removeItem("testKey") } catch(t) { this._enabled = !1 } }, t.prototype.saveValue = function(t, e) { if (this._enabled) { var i = JSON.stringify(e); window.localStorage.setItem(t,i) } }, t.prototype.getValue = function(t) { return window.localStorage.getItem(t) }, t.prototype.remove = function(t) { this._enabled && window.localStorage.removeItem(t) }, t.prototype.clear = function() { this._enabled && this.localStorage.clear() }, Object.defineProperty(t.prototype, "enabled", { get: function() { return this._enabled }, enumerable: !0, configurable: !0 }), t } (); t.LocalStorageWrapper = e } (utils || (utils = {})), window.addEventListener("load", onLoad, !1); var game; ! function(t) { var e = function(e) { function i() { e.call(this, t.Config.GAME_WIDTH, t.Config.GAME_HEIGHT, Phaser.CANVAS, "gameContainer"), i.parser = new t.LevelParser(this), i.storage = new utils.LocalStorageWrapper, this.setupLanguage(), this.state.add("Boot", t.Boot, !1), this.state.add("SplashScreen", t.SplashScreen, !1), this.state.add("Preloader", t.Preloader, !1), this.state.add("MainMenu", t.MainMenu, !1), this.state.add("LevelsMenu", t.LevelsMenu, !1), this.state.add("Level", t.Level, !1), this.state.start("Boot") } return __extends(i, e), i.prototype.setupLanguage = function() { i.language = "cn" }, i.prototype.changeState = function(t, e) { this.stateTransitionPlugin || (this.stateTransitionPlugin = this.plugins.plugins[0]), this.stateTransitionPlugin.changeState(t, e) }, i.wasPaused = !1, i.wasMuted = !1, i.development = !1, i.language = "cn", i } (Phaser.Game); t.Main = e } (game || (game = {}));