game.min.js 99 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722
  1. function onLoad() {
  2. new game.Main
  3. }
  4. var game; !
  5. function(t) {
  6. var e = function() {
  7. function t() {}
  8. return t.GAME_WIDTH = 640,
  9. t.GAME_HEIGHT = 832,
  10. t.HALF_GAME_WIDTH = .5 * t.GAME_WIDTH,
  11. t.HALF_GAME_HEIGHT = .5 * t.GAME_HEIGHT,
  12. t.LEVELS_NUM = 60,
  13. t
  14. } ();
  15. t.Config = e
  16. } (game || (game = {}));
  17. var __extends = this.__extends ||
  18. function(t, e) {
  19. function i() {
  20. this.constructor = t
  21. }
  22. for (var a in e) e.hasOwnProperty(a) && (t[a] = e[a]);
  23. i.prototype = e.prototype,
  24. t.prototype = new i
  25. },
  26. game; !
  27. function(t) {
  28. var e = function(e) {
  29. function i() {
  30. e.apply(this, arguments)
  31. }
  32. return __extends(i, e),
  33. i.prototype.init = function() {
  34. this.game.device.android && !this.game.device.chrome && (this.game.canvas.parentElement.style.overflow = "visible");
  35. var t = {
  36. font: "10px GrilledCheeseBTNToasted"
  37. },
  38. e = this.add.text(0, 0, "0", t);
  39. e.destroy()
  40. },
  41. i.prototype.preload = function() {
  42. this.load.image("rotate", "assets/graphics/rotate-phone.png"),
  43. this.load.image("LoadingBar_Outer", "assets/graphics/LoadingBar_Outer.png"),
  44. this.load.image("LoadingBar_Inner", "assets/graphics/LoadingBar_Inner.png")
  45. },
  46. i.prototype.create = function() {
  47. var e = this.game.scale;
  48. e.scaleMode = Phaser.ScaleManager.SHOW_ALL,
  49. e.minWidth = .25 * t.Config.GAME_WIDTH,
  50. e.minHeight = .25 * t.Config.GAME_HEIGHT,
  51. e.aspectRatio = t.Config.GAME_WIDTH / t.Config.GAME_HEIGHT,
  52. e.pageAlignHorizontally = !0,
  53. e.pageAlignVertically = !0,
  54. this.game.device.desktop || e.forceOrientation(!1, !0),
  55. e.enterIncorrectOrientation.add(this.onEnterIncorrectOrientation, this),
  56. e.leaveIncorrectOrientation.add(this.onLeaveIncorrectOrientation, this),
  57. e.setScreenSize(!0),
  58. this.input.maxPointers = 1,
  59. this.stage.disableVisibilityChange = !0,
  60. this.stage.backgroundColor = 8179412,
  61. this.game.state.start("Preloader", !0, !1)
  62. },
  63. i.prototype.onEnterIncorrectOrientation = function() {
  64. document.getElementById("orientation").style.display = "block",
  65. document.body.style.marginBottom = "0px"
  66. },
  67. i.prototype.onLeaveIncorrectOrientation = function() {
  68. document.getElementById("orientation").style.display = "none",
  69. document.body.style.marginBottom = "100px",
  70. this.game.device.android && !this.game.device.chrome && this.game.scale.setScreenSize(!0)
  71. },
  72. i
  73. } (Phaser.State);
  74. t.Boot = e
  75. } (game || (game = {}));
  76. var game; !
  77. function(t) {
  78. var e = function(t) {
  79. function e() {
  80. t.apply(this, arguments)
  81. }
  82. return __extends(e, t),
  83. e.prototype.create = function() {},
  84. e.prototype.addSplash = function() {},
  85. e.prototype.gotoMainMenu = function() {
  86. this.game.state.start("MainMenu", !0, !1, !0)
  87. },
  88. e
  89. } (Phaser.State);
  90. t.SplashScreen = e
  91. } (game || (game = {}));
  92. var game; !
  93. function(t) {
  94. var e = function(e) {
  95. function i(i, a) {
  96. e.call(this, i, a),
  97. this.overlayDuration = 300;
  98. var n = i.add.bitmapData(t.Config.GAME_WIDTH, t.Config.GAME_HEIGHT, "overlay", !0);
  99. n.context.fillStyle = "rgba(0, 0, 0, 1)",
  100. n.context.fillRect(0, 0, t.Config.GAME_WIDTH, t.Config.GAME_HEIGHT),
  101. this.overlay = new Phaser.Image(i, 0, 0, n),
  102. this.overlay.visible = !1,
  103. this.game.stage.addChild(this.overlay)
  104. }
  105. return __extends(i, e),
  106. i.prototype.changeState = function(t, e) {
  107. this.showOverlay(t, e)
  108. },
  109. i.prototype.showOverlay = function(t, e) {
  110. var i = this;
  111. this.game.input.disabled = !0,
  112. this.overlayTween && this.overlayTween.isRunning && this.overlayTween.stop(),
  113. this.overlay.visible = !0,
  114. this.overlay.alpha = 0,
  115. this.overlayTween = this.game.add.tween(this.overlay).to({
  116. alpha: 1
  117. },
  118. this.overlayDuration, Phaser.Easing.Cubic.Out, !0),
  119. this.overlayTween.onComplete.addOnce(function() {
  120. i.doChangeState(t, e)
  121. },
  122. this)
  123. },
  124. i.prototype.doChangeState = function(t, e) {
  125. var i = this;
  126. this.game.state.start(t, !0, !1, e),
  127. setTimeout(function() {
  128. i.hideOverlay()
  129. },
  130. 100),
  131. setTimeout(function() {
  132. i.overlay.visible && (i.overlay.visible = !1)
  133. },
  134. 100 + this.overlayDuration)
  135. },
  136. i.prototype.hideOverlay = function() {
  137. this.game.input.disabled = !1,
  138. this.overlayTween && this.overlayTween.isRunning && this.overlayTween.stop(),
  139. this.overlayTween = this.game.add.tween(this.overlay).to({
  140. alpha: 0
  141. },
  142. this.overlayDuration, Phaser.Easing.Cubic.Out, !0)
  143. },
  144. i
  145. } (Phaser.Plugin);
  146. t.StateTransition = e
  147. } (game || (game = {}));
  148. var game; !
  149. function(t) {
  150. var e = function(e) {
  151. function i() {
  152. e.apply(this, arguments)
  153. }
  154. return __extends(i, e),
  155. i.prototype.init = function() {
  156. this.addLoadingText()
  157. },
  158. i.prototype.addLoadingText = function() {
  159. var e = {
  160. font: "45px GrilledCheeseBTNToasted",
  161. fill: "#FFFFFF",
  162. align: "center"
  163. },
  164. i = this.game.add.text(0, 0, "Loading...", e);
  165. i.anchor.set(.5, .5),
  166. i.position.set(t.Config.HALF_GAME_WIDTH, t.Config.HALF_GAME_HEIGHT + 100),
  167. i.setShadow(2, 2, "#249BC8")
  168. },
  169. i.prototype.preload = function() {
  170. this.addPreloadBar(),
  171. this.loadAssets()
  172. },
  173. i.prototype.addPreloadBar = function() {
  174. if (t.Main.development === !1) {
  175. var e = this.game.add.sprite(0, 0, "LoadingBar_Inner");
  176. e.x = t.Config.HALF_GAME_WIDTH - .5 * e.width - .5,
  177. e.y = t.Config.HALF_GAME_HEIGHT - .5 * e.height - 1.5;
  178. var i = this.add.image(0, 0, "LoadingBar_Outer");
  179. i.anchor.set(.5, .5),
  180. i.x = t.Config.HALF_GAME_WIDTH - .5,
  181. i.y = t.Config.HALF_GAME_HEIGHT,
  182. this.load.setPreloadSprite(e)
  183. }
  184. },
  185. i.prototype.loadAssets = function() {
  186. this.load.audio("main_loop", ["assets/audio/MainLoop.ogg", "assets/audio/MainLoop.m4a"], !0),
  187. 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)),
  188. // this.load.image("splash_screen", "assets/graphics/Splash_Image_play68.png"),
  189. this.load.atlasJSONHash("gui", "assets/graphics/gui.png", "assets/graphics/gui.json"),
  190. this.load.atlasJSONHash("level_graphics", "assets/graphics/level_graphics.png", "assets/graphics/level_graphics.json"),
  191. this.load.atlasJSONHash("manta_ray", "assets/graphics/manta_ray.png", "assets/graphics/manta_ray.json"),
  192. this.load.atlasJSONHash("level_complete", "assets/graphics/level_complete.png", "assets/graphics/level_complete.json"),
  193. this.load.atlasJSONHash("tutor_hand", "assets/graphics/tutorial_hand.png", "assets/graphics/tutorial_hand.json"),
  194. this.load.atlasJSONHash("tutorial", "assets/graphics/tutorial.png", "assets/graphics/tutorial.json"),
  195. this.load.atlasJSONHash("yellow_fish", "assets/graphics/yellow_fish.png", "assets/graphics/yellow_fish.json"),
  196. this.load.atlasJSONHash("pink_fish", "assets/graphics/pink_fish.png", "assets/graphics/pink_fish.json"),
  197. this.load.json("texts", "assets/texts.json"),
  198. t.Main.development ? this.load.json("startLevel", "assets/levels/StartLevel.json") : this.load.json("levelConfigs", "assets/levels/Levels.json")
  199. },
  200. i.prototype.create = function() {
  201. this.initLanguage(),
  202. this.prepareTextures(),
  203. this.game.plugins.add(t.StateTransition),
  204. this.game.cache.removeImage("LoadingBar_Outer"),
  205. this.game.cache.removeImage("LoadingBar_Inner"),
  206. t.Main.development && this.cache.getJSON("startLevel").level,
  207. this.game.state.start("MainMenu", !0, !1, !0)
  208. },
  209. i.prototype.initLanguage = function() {
  210. var e = this.game.cache.getJSON("texts");
  211. t.Main.texts = e[t.Main.language]
  212. },
  213. i.prototype.prepareTextures = function() {},
  214. i
  215. } (Phaser.State);
  216. t.Preloader = e
  217. } (game || (game = {}));
  218. var game; !
  219. function(t) {
  220. var e = function(t) {
  221. function e(e, i, a, n, s) {
  222. var o = this;
  223. t.call(this, e, i, a, n, s),
  224. this._callback = new Phaser.Signal,
  225. this.anchor.set(.5, .5),
  226. this.inputEnabled = !0,
  227. this.game.device.desktop && (this.input.useHandCursor = !0),
  228. this.inputEnabled && (this.events.onInputDown.add(function() {
  229. o.game.device.webAudio && o.game.sound.play("tap"),
  230. o.game.add.tween(o.scale).to({
  231. x: .9,
  232. y: .9
  233. },
  234. 200, Phaser.Easing.Cubic.Out, !0)
  235. }), this.events.onInputUp.add(function() {
  236. o.game.add.tween(o.scale).to({
  237. x: 1,
  238. y: 1
  239. },
  240. 100, Phaser.Easing.Cubic.Out, !0).onComplete.addOnce(o._callback.dispatch, o)
  241. }))
  242. }
  243. return __extends(e, t),
  244. e.prototype.destroy = function() {
  245. t.prototype.destroy.call(this),
  246. this._callback.dispose()
  247. },
  248. Object.defineProperty(e.prototype, "callback", {
  249. get: function() {
  250. return this._callback
  251. },
  252. enumerable: !0,
  253. configurable: !0
  254. }),
  255. e
  256. } (Phaser.Image);
  257. t.SimpleButton = e
  258. } (game || (game = {}));
  259. var game; !
  260. function(t) {
  261. var e = function(t) {
  262. function e(e, i, a, n, s) {
  263. t.call(this, e, i, a, "gui", n),
  264. this.textureKey1 = n,
  265. this.textureKey2 = s,
  266. this.activeTextureKey = this.textureKey1,
  267. this._state = 1,
  268. this.events.onInputUp.add(this.switchTextures, this, 2)
  269. }
  270. return __extends(e, t),
  271. e.prototype.switchTextures = function() {
  272. this.activeTextureKey = this.activeTextureKey === this.textureKey1 ? this.textureKey2: this.textureKey1,
  273. this.loadTexture("gui", this.activeTextureKey),
  274. this._state = this.activeTextureKey === this.textureKey1 ? 1 : 2
  275. },
  276. Object.defineProperty(e.prototype, "state", {
  277. get: function() {
  278. return this._state
  279. },
  280. enumerable: !0,
  281. configurable: !0
  282. }),
  283. e
  284. } (game.SimpleButton);
  285. t.ToggleButton = e
  286. } (game || (game = {}));
  287. var game; !
  288. function(t) {
  289. var e = function(e) {
  290. function i() {
  291. e.apply(this, arguments),
  292. this.fromPreloader = !1
  293. }
  294. return __extends(i, e),
  295. i.prototype.init = function(t) {
  296. this.fromPreloader = t
  297. },
  298. i.prototype.create = function() {
  299. this.initImages(),
  300. this.addCreatures(),
  301. this.initButtons(),
  302. this.initLogo(),
  303. this.initCredits(),
  304. this.initAnimation(),
  305. 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))
  306. },
  307. i.prototype.onFocusLost = function() {
  308. this.game.tweens.pauseAll(),
  309. t.Main.wasMuted = this.game.sound.mute,
  310. this.game.sound.mute = !0
  311. },
  312. i.prototype.onFocus = function() {
  313. this.game.tweens.resumeAll(),
  314. t.Main.wasMuted === !1 && (this.game.sound.mute = !1)
  315. },
  316. i.prototype.initImages = function() {
  317. this.game.add.image( - 32, 0, "gui", "BG_20000"),
  318. this.title = this.add.image(0, 0, "gui", "GameTitle0000"),
  319. this.title.anchor.set(.5, .5),
  320. this.title.x = t.Config.HALF_GAME_WIDTH - .5,
  321. this.title.y = 150
  322. },
  323. i.prototype.addCreatures = function() {
  324. this.needlefish = this.game.add.image(t.Config.HALF_GAME_WIDTH + 15, 550, "gui", "Needlefish0000"),
  325. this.needlefish.angle = 120,
  326. this.octopus = this.game.add.image(t.Config.HALF_GAME_WIDTH + 190, 760, "gui", "Octopus0000"),
  327. this.jelly = this.game.add.image(t.Config.HALF_GAME_WIDTH - 145, 740, "gui", "Jelly0000"),
  328. [this.needlefish, this.octopus, this.jelly].forEach(function(t) {
  329. t.anchor.set(.5, .5)
  330. })
  331. },
  332. i.prototype.initButtons = function() {
  333. var e = this,
  334. i = 60;
  335. this.soundButton = new t.ToggleButton(this.game, t.Config.GAME_WIDTH - i, i, "Music_On_Button0000", "Music_Off_Button0000"),
  336. this.soundButton.callback.add(function() {
  337. e.game.sound.mute = !e.game.sound.mute
  338. }),
  339. this.game.sound.mute && this.soundButton.switchTextures(),
  340. this.playButton = new t.SimpleButton(this.game, t.Config.HALF_GAME_WIDTH, 330, "gui", "Play_Button0000"),
  341. this.playButton.callback.addOnce(function() {
  342. e.game.changeState("LevelsMenu")
  343. },
  344. this),
  345. this.creditsButton = new t.SimpleButton(this.game, this.playButton.x + 130, this.playButton.y, "gui", "Credits_Button0000"),
  346. this.creditsButton.callback.add(this.toggleCredits, this),
  347. this.moreGamesButton = new t.SimpleButton(this.game, this.playButton.x - 130, this.playButton.y, "gui", "MoreGames_Button0000"),
  348. this.moreGamesButton.callback.add(this.gotoDeveloperWebsite, this),
  349. this.buttons = [this.playButton, this.soundButton, this.moreGamesButton, this.creditsButton],
  350. this.buttons.forEach(function(t) {
  351. e.world.add(t)
  352. })
  353. },
  354. i.prototype.gotoDeveloperWebsite = function() {
  355. // Play68.goHome()
  356. },
  357. i.prototype.initLogo = function() {},
  358. i.prototype.initCredits = function() {
  359. this.credits = this.game.add.image(0, 0, "gui", "CreditsBoard0000"),
  360. this.credits.position.set(Math.round(.5 * (t.Config.GAME_WIDTH - this.credits.width)), Math.round(.5 * (t.Config.GAME_HEIGHT - this.credits.height))),
  361. this.credits.visible = !1
  362. },
  363. i.prototype.toggleCredits = function() {
  364. this.credits.visible ? this.hideCredits() : this.showCredits()
  365. },
  366. i.prototype.hideCredits = function() {
  367. var t = this;
  368. this.game.add.tween(this.credits).to({
  369. y: this.credits.y + 200,
  370. alpha: 0
  371. },
  372. 500, Phaser.Easing.Back.In, !0).onComplete.addOnce(function() {
  373. t.playButton.input.enabled = !0,
  374. t.creditsButton.input.enabled = !0,
  375. t.credits.visible = !1
  376. },
  377. this)
  378. },
  379. i.prototype.showCredits = function() {
  380. var e = this;
  381. this.credits.visible = !0,
  382. this.credits.alpha = 0,
  383. this.credits.y = Math.round(.5 * (t.Config.GAME_HEIGHT - this.credits.height)) + 200,
  384. this.game.add.tween(this.credits).to({
  385. y: this.credits.y - 200,
  386. alpha: 1
  387. },
  388. 500, Phaser.Easing.Back.Out, !0),
  389. this.playButton.input.enabled = !1,
  390. this.creditsButton.input.enabled = !1,
  391. this.game.input.onTap.addOnce(function() {
  392. e.hideCredits()
  393. },
  394. this)
  395. },
  396. i.prototype.startMusic = function() {
  397. this.game.sound.play("main_loop", .33, !1),
  398. this.soundButton.switchTextures(),
  399. this.soundButton.input.enabled = !0
  400. },
  401. i.prototype.initAnimation = function() {
  402. var t = this;
  403. this.title.y -= 280,
  404. this.game.add.tween(this.title).to({
  405. y: this.title.y + 280
  406. },
  407. 600, Phaser.Easing.Back.Out, !0, 300);
  408. var e = 800;
  409. this.needlefish.y += 500,
  410. this.octopus.x += 400,
  411. this.jelly.x -= 400,
  412. this.game.add.tween(this.needlefish).to({
  413. y: this.needlefish.y - 500,
  414. angle: 354
  415. },
  416. 700, Phaser.Easing.Back.Out, !0, e),
  417. this.game.add.tween(this.octopus).to({
  418. x: this.octopus.x - 400
  419. },
  420. 600, Phaser.Easing.Back.Out, !0, e + 300),
  421. this.game.add.tween(this.jelly).to({
  422. x: this.jelly.x + 400
  423. },
  424. 600, Phaser.Easing.Back.Out, !0, e + 300);
  425. var i = 1600;
  426. this.buttons.forEach(function(e) {
  427. e.scale.set(0, 0),
  428. t.game.add.tween(e.scale).to({
  429. x: 1,
  430. y: 1
  431. },
  432. 300, Phaser.Easing.Back.Out, !0, i),
  433. i += 200
  434. })
  435. },
  436. i.prototype.destroy = function() {
  437. this.buttons = null
  438. },
  439. i
  440. } (Phaser.State);
  441. t.MainMenu = e
  442. } (game || (game = {}));
  443. var game; !
  444. function(t) {
  445. var e = function(t) {
  446. function e(e, i, a, n, s) {
  447. var o = this;
  448. void 0 === s && (s = !1),
  449. t.call(this, e, i, a, "gui", "Button_Clear0000"),
  450. this.inputEnabled = !s,
  451. this.locked = s,
  452. this._levelNumber = n,
  453. this.anchor.set(.5, .5),
  454. this.createGraphics(),
  455. this.inputEnabled && (this.game.device.desktop && (this.input.useHandCursor = !0), this.events.onInputDown.add(function() {
  456. o.game.sound.play("tap", .75),
  457. o.game.add.tween(o.scale).to({
  458. x: .9,
  459. y: .9
  460. },
  461. 200, Phaser.Easing.Cubic.Out, !0)
  462. }), this.events.onInputUp.add(function() {
  463. o.game.add.tween(o.scale).to({
  464. x: 1,
  465. y: 1
  466. },
  467. 200, Phaser.Easing.Cubic.Out, !0)
  468. }))
  469. }
  470. return __extends(e, t),
  471. e.prototype.createGraphics = function() {
  472. this.locked ? this.createLockedGraphics() : this.createUnlockedGraphics()
  473. },
  474. e.prototype.createLockedGraphics = function() {
  475. this.loadTexture("gui", "Button_Lock0000")
  476. },
  477. e.prototype.createUnlockedGraphics = function() {
  478. var t = -2;
  479. this.game.device.firefox && (t = 8);
  480. var e = {
  481. font: "42px GrilledCheeseBTNToasted",
  482. fill: "#218DB7",
  483. align: "center"
  484. },
  485. i = this.game.add.text(0, 0, this._levelNumber.toString(), e);
  486. i.anchor.set(.5, .5);
  487. var a = this.game.add.renderTexture(this.width, this.height);
  488. a.renderXY(this, .5 * this.width, .5 * this.height),
  489. a.renderXY(i, Math.floor(.5 * this.width) - 2, Math.floor(.5 * this.height) + t),
  490. this.setTexture(a),
  491. i.destroy()
  492. },
  493. Object.defineProperty(e.prototype, "levelNumber", {
  494. get: function() {
  495. return this._levelNumber
  496. },
  497. enumerable: !0,
  498. configurable: !0
  499. }),
  500. e
  501. } (Phaser.Image);
  502. t.LevelIcon = e
  503. } (game || (game = {}));
  504. var game; !
  505. function(t) {
  506. var e = function(t) {
  507. function e(e, i, a, n) {
  508. t.call(this, e, i),
  509. this._width = 0;
  510. for (var s = 0,
  511. o = 30,
  512. r = 0; a > r; r++) {
  513. var h = e.add.image(s, 0, "gui", "Star_NO0000", this);
  514. h.anchor.set(.5, .5),
  515. s += o,
  516. this._width += o
  517. }
  518. s = 0;
  519. for (var r = 0; n > r; r++) {
  520. var u = e.add.image(s, 0, "gui", "Star_YES0000", this);
  521. u.anchor.set(.5, .5),
  522. s += o
  523. }
  524. }
  525. return __extends(e, t),
  526. e.prototype.getWidth = function() {
  527. return this._width
  528. },
  529. e
  530. } (Phaser.SpriteBatch);
  531. t.LevelIconStars = e
  532. } (game || (game = {}));
  533. var game; !
  534. function(t) {
  535. var e = function() {
  536. function t() {}
  537. return t
  538. } ();
  539. t.LevelResult = e
  540. } (game || (game = {}));
  541. var game; !
  542. function(t) {
  543. var e = function(e) {
  544. function i(t, i) {
  545. e.call(this, t, i),
  546. this.distanceBetweenPages = 560,
  547. this.isTweening = !1,
  548. this._iconClicked = new Phaser.Signal,
  549. this.initIconSets(),
  550. this.calculateWidth(),
  551. this.currentPage = 0,
  552. this.pages[this.currentPage].visible = !0
  553. }
  554. return __extends(i, e),
  555. i.prototype.initIconSets = function() {
  556. this.pages = [];
  557. for (var t = 1,
  558. e = 20,
  559. i = 0,
  560. a = 0; 3 > a; a++) {
  561. var n = t,
  562. s = n + e - 1,
  563. o = this.createIconSet(n, s);
  564. o.visible = !1,
  565. o.x = i,
  566. i += this.distanceBetweenPages,
  567. t += e,
  568. this.pages[a] = o
  569. }
  570. },
  571. i.prototype.createIconSet = function(e, i) {
  572. for (var a = this.game.add.group(this), n = 120, s = 144, o = 0, r = 0, h = e; i >= h; h++) {
  573. var u = h,
  574. l = this.levelIsLocked(u),
  575. d = new t.LevelIcon(this.game, o, r, u, l);
  576. l === !1 && d.events.onInputUp.addOnce(this.dispatchIconClicked, this);
  577. var c = this.getLevelResult(u);
  578. if (c) {
  579. var g = new t.LevelIconStars(this.game, a, c.starsAvailable, c.starsEarned),
  580. p = o - .5 * g.getWidth() + 13;
  581. g.position.set(p, r + 62)
  582. }
  583. a.add(d),
  584. o += n,
  585. h % 4 === 0 && (o = 0, r += s)
  586. }
  587. return a
  588. },
  589. i.prototype.levelIsLocked = function(e) {
  590. if (1 === e) return ! 1;
  591. var i = e - 1,
  592. a = i.toString(),
  593. n = t.Main.storage.getValue(a);
  594. return null === n
  595. },
  596. i.prototype.getLevelResult = function(e) {
  597. var i = e.toString(),
  598. a = t.Main.storage.getValue(i);
  599. return a && a.length > 0 ? JSON.parse(a) : null
  600. },
  601. i.prototype.dispatchIconClicked = function(t) {
  602. this.game.time.events.add(200, this._iconClicked.dispatch, this, t.levelNumber)
  603. },
  604. i.prototype.calculateWidth = function() {
  605. var t = 0,
  606. e = this.pages[0].getTop().x;
  607. this._width = e - t
  608. },
  609. i.prototype.showPage = function(t) {
  610. if (!this.isTweening) {
  611. var e;
  612. 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) {
  613. this.isTweening = !0;
  614. var i = "next_page" === t ? -this.distanceBetweenPages: this.distanceBetweenPages;
  615. this.currentPage = e,
  616. this.pages.forEach(function(t) {
  617. t.visible = !0
  618. }),
  619. this.game.add.tween(this).to({
  620. x: this.x + i
  621. },
  622. 600, Phaser.Easing.Cubic.InOut, !0).onComplete.addOnce(this.onTweenComplete, this)
  623. }
  624. }
  625. },
  626. i.prototype.onTweenComplete = function() {
  627. this.isTweening = !1;
  628. for (var t = 0; t < this.pages.length; t++) t !== this.currentPage && (this.pages[t].visible = !1)
  629. },
  630. i.prototype.getWidth = function() {
  631. return this._width
  632. },
  633. i.prototype.isFirstPage = function() {
  634. return 0 === this.currentPage
  635. },
  636. i.prototype.isLastPage = function() {
  637. return this.currentPage === this.pages.length - 1
  638. },
  639. i.prototype.destroy = function() {
  640. e.prototype.destroy.call(this, !0),
  641. this._iconClicked.dispose(),
  642. this._iconClicked = null,
  643. this.pages = null
  644. },
  645. Object.defineProperty(i.prototype, "iconClicked", {
  646. get: function() {
  647. return this._iconClicked
  648. },
  649. enumerable: !0,
  650. configurable: !0
  651. }),
  652. i
  653. } (Phaser.Group);
  654. t.LevelIcons = e
  655. } (game || (game = {}));
  656. var utils; !
  657. function(t) {
  658. var e = function() {
  659. function e() {}
  660. return e.createArrayWithNumbers = function(t, e, i) {
  661. arguments.length <= 1 && (e = t || 0, t = 0),
  662. i = arguments[2] || 1;
  663. for (var a = Math.max(Math.ceil((e - t) / i), 0), n = 0, s = new Array(a); a > n;) s[n++] = t,
  664. t += i;
  665. return s
  666. },
  667. e.getRandomItem = function(e) {
  668. var i = t.MathUtil.integerInRange(0, e.length - 1);
  669. return e[i]
  670. },
  671. e
  672. } ();
  673. t.ArrayUtil = e
  674. } (utils || (utils = {}));
  675. var utils; !
  676. function(t) {
  677. var e = function() {
  678. function t() {}
  679. return t.distanceSquared = function(t, e, i, a) {
  680. var n = i - t,
  681. s = a - e;
  682. return n * n + s * s
  683. },
  684. t.distance = function(e, i, a, n) {
  685. var s = t.distanceSquared(e, i, a, n);
  686. return Math.sqrt(s)
  687. },
  688. t.realInRange = function(t, e) {
  689. return Math.random() * (e - t) + t
  690. },
  691. t.integerInRange = function(e, i) {
  692. return Math.round(t.realInRange(e, i))
  693. },
  694. t.DEG_TO_RAD = .017453292519943295,
  695. t.RAD_TO_DEG = 57.29577951308232,
  696. t
  697. } ();
  698. t.MathUtil = e
  699. } (utils || (utils = {}));
  700. var game; !
  701. function(t) {
  702. var e = function(e) {
  703. function i(t, i, a, n) {
  704. e.call(this, t, i, a, n),
  705. this.anchor.set(.5, .5);
  706. var s = t.rnd.realInRange(1, 2);
  707. this.scale.set(s, s),
  708. this.target = new Phaser.Point,
  709. this.velocity = new Phaser.Point,
  710. this.setTarget(),
  711. this.addAnimation("main", 0, 19),
  712. this.play("main")
  713. }
  714. return __extends(i, e),
  715. i.prototype.addAnimation = function(t, e, i) {
  716. var a = utils.ArrayUtil.createArrayWithNumbers(e, i + 1);
  717. this.animations.add(t, a, 30, !0)
  718. },
  719. i.prototype.setTarget = function() {
  720. this.target.x = this.x < t.Config.HALF_GAME_WIDTH ? t.Config.GAME_WIDTH + 100 : -100,
  721. this.target.y = this.game.rnd.integerInRange(60, t.Config.GAME_HEIGHT - 60),
  722. this.maxSpeed = this.game.rnd.realInRange(2, 3),
  723. this.velocity = this.target.clone().subtract(this.x, this.y).normalize().multiply(this.maxSpeed, this.maxSpeed),
  724. this.scale.x = this.velocity.x > 0 ? -1 * Math.abs(this.scale.x) : Math.abs(this.scale.x)
  725. },
  726. i.prototype.update = function() {
  727. var t = utils.MathUtil.distanceSquared(this.x, this.y, this.target.x, this.target.y);
  728. t < this.maxSpeed * this.maxSpeed && this.setTarget(),
  729. this.x += this.velocity.x,
  730. this.y += this.velocity.y
  731. },
  732. i.prototype.destroy = function() {
  733. e.prototype.destroy.call(this, !0),
  734. this.target = null,
  735. this.velocity = null
  736. },
  737. i
  738. } (Phaser.Sprite);
  739. t.Fish = e
  740. } (game || (game = {}));
  741. var game; !
  742. function(t) {
  743. var e = function(t) {
  744. function e(e, i, a) {
  745. var n = this;
  746. t.call(this, e, 0, 0, i, a),
  747. this.hidden = !1,
  748. this.anchor.set(.5, .5),
  749. this.inputEnabled = !0,
  750. this.events.onInputDown.add(function() {
  751. n.game.device.webAudio && n.game.sound.play("tap"),
  752. n.game.add.tween(n.scale).to({
  753. x: .9,
  754. y: .9
  755. },
  756. 200, Phaser.Easing.Cubic.Out, !0)
  757. }),
  758. this.events.onInputUp.add(function() {
  759. n.game.add.tween(n.scale).to({
  760. x: 1,
  761. y: 1
  762. },
  763. 200, Phaser.Easing.Cubic.Out, !0)
  764. },
  765. this, 1)
  766. }
  767. return __extends(e, t),
  768. e.prototype.show = function() {
  769. this.hidden && (this.hidden = !1, this.input.enabled = !0, this.game.add.tween(this).to({
  770. alpha: 1
  771. },
  772. 100, Phaser.Easing.Linear.None, !0))
  773. },
  774. e.prototype.hide = function(t) {
  775. void 0 === t && (t = !1),
  776. this.hidden === !1 && (this.hidden = !0, this.input.enabled = !1, t ? this.alpha = 0 : this.game.add.tween(this).to({
  777. alpha: 0
  778. },
  779. 100, Phaser.Easing.Linear.None, !0))
  780. },
  781. e
  782. } (Phaser.Image);
  783. t.ArrowButton = e
  784. } (game || (game = {}));
  785. var game; !
  786. function(t) {
  787. var e = function(e) {
  788. function i() {
  789. e.call(this)
  790. }
  791. return __extends(i, e),
  792. i.prototype.create = function() {
  793. this.game.add.image( - 32, 0, "gui", "BG_20000"),
  794. this.addFishes(),
  795. this.initLevelIcons(),
  796. this.initNavigationArrows(),
  797. this.initButtons(),
  798. t.Main.development && (this.addFPSMeter(), this.game.input.keyboard.addKey(Phaser.Keyboard.C).onDown.add(this.clearSavedData, this))
  799. },
  800. i.prototype.clearSavedData = function() {
  801. var e = window.confirm("Do you want to clear all saved data?");
  802. e && (t.Main.storage.clear(), this.game.state.restart(!0, !1))
  803. },
  804. i.prototype.addFishes = function() {
  805. var e = this,
  806. i = new t.Fish(this.game, this.game.rnd.integerInRange(0, t.Config.GAME_WIDTH), 100, "yellow_fish"),
  807. a = new t.Fish(this.game, this.game.rnd.integerInRange(0, t.Config.GAME_WIDTH), 300, "yellow_fish"),
  808. n = new t.Fish(this.game, this.game.rnd.integerInRange(0, t.Config.GAME_WIDTH), 600, "pink_fish"); [i, a, n].forEach(function(t) {
  809. e.world.add(t)
  810. })
  811. },
  812. i.prototype.initLevelIcons = function() {
  813. this.levelIcons = new t.LevelIcons(this.game, this.world),
  814. this.levelIcons.iconClicked.addOnce(this.onLevelIconClicked, this),
  815. this.levelIcons.x = .5 * (t.Config.GAME_WIDTH - this.levelIcons.getWidth()) + 2,
  816. this.levelIcons.y = 155
  817. },
  818. i.prototype.onLevelIconClicked = function(t) {
  819. this.changeState("Level", t)
  820. },
  821. i.prototype.initNavigationArrows = function() {
  822. var e = this,
  823. i = t.Config.HALF_GAME_HEIGHT + 27;
  824. this.leftArrow = new t.ArrowButton(this.game, "gui", "Button_L0000"),
  825. this.leftArrow.events.onInputUp.add(function() {
  826. e.changeLevelIconsPage("prev_page")
  827. },
  828. this, 2),
  829. this.leftArrow.x = 41,
  830. this.leftArrow.y = i,
  831. this.leftArrow.hide(!0),
  832. this.world.add(this.leftArrow),
  833. this.rightArrow = new t.ArrowButton(this.game, "gui", "Button_R0000"),
  834. this.rightArrow.events.onInputUp.add(function() {
  835. e.changeLevelIconsPage("next_page")
  836. },
  837. this, 2),
  838. this.rightArrow.x = t.Config.GAME_WIDTH - 38,
  839. this.rightArrow.y = i,
  840. this.world.add(this.rightArrow)
  841. },
  842. i.prototype.changeLevelIconsPage = function(t) {
  843. this.levelIcons.showPage(t),
  844. this.levelIcons.isFirstPage() ? this.leftArrow.hide() : this.levelIcons.isLastPage() ? this.rightArrow.hide() : (this.leftArrow.show(), this.rightArrow.show())
  845. },
  846. i.prototype.initButtons = function() {
  847. var e = this,
  848. i = 60;
  849. this.backButton = new t.SimpleButton(this.game, i, i, "gui", "Home_Button0000"),
  850. this.backButton.callback.addOnce(function() {
  851. e.changeState("MainMenu")
  852. },
  853. this),
  854. this.world.add(this.backButton),
  855. this.soundButton = new t.ToggleButton(this.game, t.Config.GAME_WIDTH - i + .5, i, "Music_On_Button0000", "Music_Off_Button0000"),
  856. this.soundButton.callback.add(function() {
  857. e.game.sound.mute = !e.game.sound.mute
  858. }),
  859. this.game.sound.mute && this.soundButton.switchTextures(),
  860. this.world.add(this.soundButton)
  861. },
  862. i.prototype.changeState = function(t, e) {
  863. this.game.changeState(t, e)
  864. },
  865. i.prototype.addFPSMeter = function() {
  866. new utils.FPSMeter(this.game, 0, t.Config.GAME_HEIGHT - 22)
  867. },
  868. i
  869. } (Phaser.State);
  870. t.LevelsMenu = e
  871. } (game || (game = {}));
  872. var game; !
  873. function(t) {
  874. var e = function() {
  875. function t(t) {
  876. this._ballsToSpawn = 20,
  877. this._baseSpeed = 20,
  878. this._levelNumber = t
  879. }
  880. return Object.defineProperty(t.prototype, "levelNumber", {
  881. get: function() {
  882. return this._levelNumber
  883. },
  884. enumerable: !0,
  885. configurable: !0
  886. }),
  887. Object.defineProperty(t.prototype, "ballsToSpawn", {
  888. get: function() {
  889. return this._ballsToSpawn
  890. },
  891. enumerable: !0,
  892. configurable: !0
  893. }),
  894. Object.defineProperty(t.prototype, "baseSpeed", {
  895. get: function() {
  896. return this._baseSpeed
  897. },
  898. enumerable: !0,
  899. configurable: !0
  900. }),
  901. t
  902. } ();
  903. t.LevelSettings = e
  904. } (game || (game = {}));
  905. var utils; !
  906. function(t) {
  907. var e = function(t) {
  908. function e(e, i, a) {
  909. void 0 === i && (i = 0),
  910. void 0 === a && (a = 0),
  911. t.call(this, e, e.world, "FPS Meter"),
  912. this.x = i,
  913. this.y = a,
  914. this.initBackground(),
  915. this.initText(),
  916. this.game.time.advancedTiming = !0,
  917. this.loopEvent = this.game.time.events.loop(500, this.updateText, this)
  918. }
  919. return __extends(e, t),
  920. e.prototype.initBackground = function() {
  921. var t = 80;
  922. this.bg = new Phaser.Graphics(this.game, 0, 0),
  923. this.bg.beginFill(0, 1),
  924. this.bg.drawRect(0, 0, t, 22),
  925. this.bg.endFill(),
  926. this.add(this.bg)
  927. },
  928. e.prototype.initText = function() {
  929. var t = {
  930. font: "18px Consolas",
  931. fill: "#FFFFFF",
  932. align: "center"
  933. };
  934. this.statsText = this.game.add.text(5, 0, "0 fps", t, this)
  935. },
  936. e.prototype.updateText = function() {
  937. var t = "FPS: " + this.game.time.fps;
  938. this.statsText.setText(t)
  939. },
  940. e.prototype.destroy = function() {
  941. this.game.time.events.remove(this.loopEvent),
  942. this.loopEvent = null,
  943. this.game.time.advancedTiming = !1,
  944. t.prototype.destroy.call(this)
  945. },
  946. e
  947. } (Phaser.Group);
  948. t.FPSMeter = e
  949. } (utils || (utils = {}));
  950. var game; !
  951. function(t) {
  952. var e = function(t) {
  953. function e(e, i, a, n) {
  954. t.call(this, e, i, a, "debug_gui", n),
  955. this.inputEnabled = !0,
  956. this.input.useHandCursor = !0
  957. }
  958. return __extends(e, t),
  959. e
  960. } (Phaser.Image);
  961. t.DebugButton = e
  962. } (game || (game = {}));
  963. var game; !
  964. function(t) {
  965. var e = function(t) {
  966. function e(e, i) {
  967. t.call(this, e, i, "SandTilesLabel"),
  968. this.initBack(),
  969. this.initText()
  970. }
  971. return __extends(e, t),
  972. e.prototype.initBack = function() {
  973. var t = new Phaser.Image(this.game, 0, 0, "gui", "SandTiles_Label0000");
  974. this.add(t)
  975. },
  976. e.prototype.initText = function() {
  977. var t = {
  978. font: "42px TF2 Build",
  979. fill: "#FDF490",
  980. align: "center"
  981. };
  982. this.text = new Phaser.Text(this.game, 55, 6, "0", t),
  983. this.add(this.text)
  984. },
  985. e.prototype.updateText = function(t) {
  986. this.text.setText(t.toString())
  987. },
  988. e
  989. } (Phaser.SpriteBatch);
  990. t.SandTilesLabel = e
  991. } (game || (game = {}));
  992. var game; !
  993. function(t) {
  994. var e = function(e) {
  995. function i(t, i, a, n) {
  996. e.call(this, t, i, "Level Complete Board"),
  997. this.levelNumber = a,
  998. this.starsNum = n,
  999. this.boardGroup = this.game.add.group(this),
  1000. this.addBoard(),
  1001. this.addLabel(),
  1002. this.addStars(),
  1003. this.addButtons()
  1004. }
  1005. return __extends(i, e),
  1006. i.prototype.addBoard = function() {
  1007. var t = this.game.add.image(0, 0, "level_complete", "LevelComplete_Board0000", this.boardGroup);
  1008. this._width = t.width
  1009. },
  1010. i.prototype.addLabel = function() {
  1011. var e = t.Main.texts.level_complete,
  1012. i = {
  1013. font: "45px GrilledCheeseBTNToasted",
  1014. fill: "#249BC8",
  1015. align: "center"
  1016. },
  1017. a = new Phaser.Text(this.game, 50, 20, e, i);
  1018. a.anchor.set(.5, .5),
  1019. a.x = .5 * this._width,
  1020. a.y = 60,
  1021. this.boardGroup.add(a)
  1022. },
  1023. i.prototype.addStars = function() {
  1024. var t = this.game.add.group(this.boardGroup, "stars");
  1025. this.stars = [];
  1026. for (var e = 0,
  1027. i = 100,
  1028. a = 0,
  1029. n = 0; n < this.starsNum; n++) {
  1030. var s = this.game.add.image(e, 0, "level_complete", "NoStar0000", t);
  1031. s.anchor.set(.5, .5);
  1032. var o = this.game.add.image(e - 2, -1, "level_complete", "Star0000", t);
  1033. o.anchor.set(.5, .5),
  1034. o.visible = !1,
  1035. this.stars.push(o),
  1036. e += i,
  1037. a += i
  1038. }
  1039. a -= i,
  1040. t.x = .5 * (this._width - a),
  1041. t.y = 146
  1042. },
  1043. i.prototype.addButtons = function() {
  1044. var t = this,
  1045. e = this.game.add.group(this),
  1046. i = 116,
  1047. a = new game.SimpleButton(this.game, 0, 0, "level_complete", "Home_Button0000");
  1048. a.callback.addOnce(function() {
  1049. t.game.changeState("LevelsMenu")
  1050. },
  1051. this);
  1052. var n = new game.SimpleButton(this.game, i, 0, "level_complete", "Restart_Button0000");
  1053. n.callback.add(function() {
  1054. var e = t.game.state.getCurrentState();
  1055. e.restart()
  1056. },
  1057. this);
  1058. var s = new game.SimpleButton(this.game, 2 * i, 0, "level_complete", "NextLevel_Button0000");
  1059. s.callback.addOnce(function() {
  1060. t.levelNumber === game.Config.LEVELS_NUM ? t.game.changeState("LevelsMenu") : t.game.changeState("Level", t.levelNumber + 1)
  1061. },
  1062. this),
  1063. this.buttons = [a, n, s],
  1064. this.buttons.forEach(function(t) {
  1065. e.add(t)
  1066. }),
  1067. e.position.set(118, 300)
  1068. },
  1069. i.prototype.show = function(t) {
  1070. this.showStars(t),
  1071. this.startAnimation()
  1072. },
  1073. i.prototype.showStars = function(t) {
  1074. this.stars.forEach(function(t) {
  1075. t.visible = !1
  1076. });
  1077. for (var e = 0; e < t.starsEarned; e++) this.stars[e].visible = !0
  1078. },
  1079. i.prototype.startAnimation = function() {
  1080. var t = this;
  1081. this.visible = !0,
  1082. this.boardGroup.y -= 200,
  1083. this.boardGroup.alpha = 0,
  1084. this.game.add.tween(this.boardGroup).to({
  1085. alpha: 1
  1086. },
  1087. 200, Phaser.Easing.Linear.None, !0),
  1088. this.game.add.tween(this.boardGroup).to({
  1089. y: this.boardGroup.y + 200
  1090. },
  1091. 500, Phaser.Easing.Back.Out, !0);
  1092. var e = 600,
  1093. i = 800;
  1094. this.stars.forEach(function(a) {
  1095. a.visible && (a.scale.set(3, 3), a.alpha = 0, t.game.add.tween(a).to({
  1096. alpha: 1
  1097. },
  1098. .5 * i, Phaser.Easing.Cubic.Out, !0, e), t.game.add.tween(a.scale).to({
  1099. x: 1,
  1100. y: 1
  1101. },
  1102. i, Phaser.Easing.Bounce.Out, !0, e).onStart.addOnce(function() {
  1103. t.game.sound.usingWebAudio && t.game.sound.play("star")
  1104. }), e += 500)
  1105. });
  1106. var a = 200;
  1107. this.buttons.forEach(function(e) {
  1108. e.scale.set(0, 0),
  1109. e.visible = !1,
  1110. e.y += 200,
  1111. t.game.add.tween(e).to({
  1112. y: e.y - 200
  1113. },
  1114. 500, Phaser.Easing.Back.Out, !0, a),
  1115. t.game.add.tween(e.scale).to({
  1116. x: 1,
  1117. y: 1
  1118. },
  1119. 500, Phaser.Easing.Back.Out, !0, a).onStart.addOnce(function() {
  1120. e.visible = !0
  1121. },
  1122. t),
  1123. a += 100
  1124. })
  1125. },
  1126. i.prototype.hide = function() {
  1127. var t = this;
  1128. this.game.add.tween(this).to({
  1129. alpha: 0
  1130. },
  1131. 200, Phaser.Easing.Cubic.Out, !0).onComplete.addOnce(function() {
  1132. t.visible = !1,
  1133. t.alpha = 1
  1134. },
  1135. this)
  1136. },
  1137. i.prototype.getWidth = function() {
  1138. return this._width
  1139. },
  1140. i.prototype.destroy = function() {
  1141. e.prototype.destroy.call(this, !0),
  1142. this.buttons = null,
  1143. this.stars = null
  1144. },
  1145. i
  1146. } (Phaser.Group);
  1147. t.LevelCompleteBoard = e
  1148. } (game || (game = {}));
  1149. var game; !
  1150. function(t) {
  1151. var e = function(e) {
  1152. function i(t, i) {
  1153. e.call(this, t, t.world, "gui"),
  1154. this.levelSettings = i,
  1155. this.initLevelLabel(),
  1156. this.initButtons()
  1157. }
  1158. return __extends(i, e),
  1159. i.prototype.initLevelLabel = function() {
  1160. var t = "Level " + this.levelSettings.levelNumber,
  1161. e = {
  1162. font: "45px GrilledCheeseBTNToasted",
  1163. fill: "#249BC8",
  1164. align: "center"
  1165. };
  1166. this.label = new Phaser.Text(this.game, 50, 20, t, e),
  1167. this.add(this.label),
  1168. this.label.x = .5 * (game.Config.GAME_WIDTH - this.label.getLocalBounds().width),
  1169. this.label.y = 20
  1170. },
  1171. i.prototype.initButtons = function() {
  1172. var t = this,
  1173. e = 55,
  1174. i = new game.ToggleButton(this.game, 505, e, "Music_On_Button0000", "Music_Off_Button0000");
  1175. i.callback.add(function() {
  1176. t.game.sound.mute = !t.game.sound.mute
  1177. }),
  1178. this.game.sound.mute && i.switchTextures();
  1179. var a = new game.SimpleButton(this.game, 590, e, "gui", "Home_Button0000");
  1180. a.callback.addOnce(function() {
  1181. t.game.changeState("LevelsMenu")
  1182. }),
  1183. this.buttons = [a, i],
  1184. this.buttons.forEach(function(e) {
  1185. t.add(e)
  1186. })
  1187. },
  1188. i.prototype.gotoNextLevel = function() {
  1189. 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)
  1190. },
  1191. i.prototype.gotoPrevLevel = function() {
  1192. 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)
  1193. },
  1194. i.prototype.initCompleteBoard = function(t) {
  1195. this.completeBoard = new game.LevelCompleteBoard(this.game, this, this.levelSettings.levelNumber, t),
  1196. this.completeBoard.position.set(.5 * (game.Config.GAME_WIDTH - this.completeBoard.getWidth()), 200),
  1197. this.completeBoard.visible = !1
  1198. },
  1199. i.prototype.onLevelComplete = function(t) {
  1200. this.buttons.forEach(function(t) {
  1201. t.visible = !1
  1202. }),
  1203. this.completeBoard.show(t)
  1204. },
  1205. i.prototype.onRestart = function() {
  1206. this.buttons.forEach(function(t) {
  1207. t.visible = !0
  1208. }),
  1209. this.completeBoard.hide()
  1210. },
  1211. i.prototype.destroy = function() {
  1212. e.prototype.destroy.call(this, !0),
  1213. this.buttons = null
  1214. },
  1215. i
  1216. } (Phaser.Group);
  1217. t.LevelGUI = e
  1218. } (game || (game = {}));
  1219. var game; !
  1220. function(t) {
  1221. var e = function(t) {
  1222. function e(e, i, a) {
  1223. t.call(this, e, i, a, "level_graphics", "HexCell0000"),
  1224. this.anchor.set(.5, .5)
  1225. }
  1226. return __extends(e, t),
  1227. e.RADIUS = 55,
  1228. e.RADIUS_SQUARED = e.RADIUS * e.RADIUS,
  1229. e
  1230. } (Phaser.Image);
  1231. t.HexCell = e
  1232. } (game || (game = {}));
  1233. var game; !
  1234. function(t) {
  1235. var e = function() {
  1236. function t(t, e) {
  1237. this.numericValue = t,
  1238. this.stringValue = e.toUpperCase()
  1239. }
  1240. return t.getDelta = function(t, e) {
  1241. if (t === e) return 0;
  1242. var i = 6,
  1243. a = 3,
  1244. n = Math.abs(t.numericValue - e.numericValue);
  1245. return n > a && (n = i - n),
  1246. n
  1247. },
  1248. t.getDirectionByAngle = function(e) {
  1249. switch (e) {
  1250. case 0:
  1251. return t.TOP;
  1252. case 60:
  1253. return t.RIGHT_TOP;
  1254. case 120:
  1255. return t.RIGHT_BOTTOM;
  1256. case 180:
  1257. return t.BOTTOM;
  1258. case 240:
  1259. return t.LEFT_BOTTOM;
  1260. case 300:
  1261. return t.LEFT_TOP;
  1262. default:
  1263. return null
  1264. }
  1265. },
  1266. t.getAngleByDirection = function(e) {
  1267. switch (e) {
  1268. case t.TOP:
  1269. return 0;
  1270. case t.RIGHT_TOP:
  1271. return 60;
  1272. case t.RIGHT_BOTTOM:
  1273. return 120;
  1274. case t.BOTTOM:
  1275. return 180;
  1276. case t.LEFT_BOTTOM:
  1277. return 240;
  1278. case t.LEFT_TOP:
  1279. return 300;
  1280. default:
  1281. return null
  1282. }
  1283. },
  1284. t.prototype.toString = function() {
  1285. return "[Direction: " + this.stringValue + "]"
  1286. },
  1287. t.TOP = new t(1, "top"),
  1288. t.RIGHT_TOP = new t(2, "right_top"),
  1289. t.RIGHT_BOTTOM = new t(3, "right_bottom"),
  1290. t.BOTTOM = new t(4, "bottom"),
  1291. t.LEFT_BOTTOM = new t(5, "left_bottom"),
  1292. t.LEFT_TOP = new t(6, "left_top"),
  1293. t
  1294. } ();
  1295. t.HandDirection = e
  1296. } (game || (game = {}));
  1297. var game; !
  1298. function(t) { !
  1299. function(t) {
  1300. t[t.Octopus = 0] = "Octopus",
  1301. t[t.Crab = 1] = "Crab",
  1302. t[t.Jellyfish = 2] = "Jellyfish",
  1303. t[t.Needlefish = 3] = "Needlefish",
  1304. t[t.ElectricRay = 4] = "ElectricRay"
  1305. } (t.CreatureType || (t.CreatureType = {})),
  1306. t.CreatureType
  1307. } (game || (game = {}));
  1308. var game; !
  1309. function(t) {
  1310. var e = function(t) {
  1311. function e(e, i) {
  1312. this.happyTexture = i + "_HappyFace0000",
  1313. this.sadTexture = i + "_SadFace0000",
  1314. this.isHappy = !1,
  1315. t.call(this, e, 0, 0, "level_graphics", this.sadTexture),
  1316. this.anchor.set(.5, .5)
  1317. }
  1318. return __extends(e, t),
  1319. e.prototype.setHappiness = function(t) {
  1320. t !== this.isHappy && (this.isHappy = t, this.game.add.tween(this.scale).to({
  1321. x: 0,
  1322. y: 0
  1323. },
  1324. 150, Phaser.Easing.Back.In, !0).onComplete.addOnce(this.changeTexture, this))
  1325. },
  1326. e.prototype.changeTexture = function() {
  1327. this.isHappy ? this.loadTexture("level_graphics", this.happyTexture) : this.loadTexture("level_graphics", this.sadTexture),
  1328. this.game.add.tween(this.scale).to({
  1329. x: 1,
  1330. y: 1
  1331. },
  1332. 150, Phaser.Easing.Back.Out, !0)
  1333. },
  1334. e
  1335. } (Phaser.Image);
  1336. t.Face = e
  1337. } (game || (game = {}));
  1338. var game; !
  1339. function(t) {
  1340. var e = function(e) {
  1341. function i(t, i, a) {
  1342. e.call(this, t, i),
  1343. this.isHappy = !1,
  1344. this.onHappyArea = !1,
  1345. this.isRayAround = !1,
  1346. this.hasHands = !1,
  1347. this._type = a,
  1348. this.addBody(),
  1349. this.addFace()
  1350. }
  1351. return __extends(i, e),
  1352. i.prototype.addBody = function() {
  1353. var e = t.CreatureType[this._type] + "_Body0000";
  1354. this.body = this.game.add.image(0, 0, "level_graphics", e, this),
  1355. this.body.anchor.set(.5, .5)
  1356. },
  1357. i.prototype.addFace = function() {
  1358. var e = t.CreatureType[this._type];
  1359. this.face = new game.Face(this.game, e),
  1360. this.add(this.face)
  1361. },
  1362. i.prototype.onDragComplete = function() {},
  1363. i.prototype.updateHappiness = function() {},
  1364. i.prototype.returnToLastCell = function() {
  1365. var t = Phaser.Math.distance(this.position.x, this.position.y, this.cell.x, this.cell.y),
  1366. e = Math.min(200, 1.5 * t);
  1367. this.game.add.tween(this.position).to({
  1368. x: this.cell.x,
  1369. y: this.cell.y
  1370. },
  1371. e, Phaser.Easing.Cubic.Out, !0)
  1372. },
  1373. Object.defineProperty(i.prototype, "type", {
  1374. get: function() {
  1375. return this._type
  1376. },
  1377. enumerable: !0,
  1378. configurable: !0
  1379. }),
  1380. i.CONTACT_RADIUS = 2 * t.HexCell.RADIUS,
  1381. i.CONTACT_RADIUS_SQUARED = i.CONTACT_RADIUS * i.CONTACT_RADIUS,
  1382. i.BODY_RADIUS = 48,
  1383. i.BODY_RADIUS_SQUARED = i.BODY_RADIUS * i.BODY_RADIUS,
  1384. i
  1385. } (Phaser.SpriteBatch);
  1386. t.BaseCreature = e
  1387. } (game || (game = {}));
  1388. var game; !
  1389. function(t) {
  1390. var e = function(e) {
  1391. function i(i, a, n) {
  1392. e.call(this, i, 0, 0, "level_graphics", a),
  1393. this.free = !0,
  1394. this.anchor.set(.5, 1),
  1395. this.angle = n,
  1396. this.currentDirection = t.HandDirection.getDirectionByAngle(n)
  1397. }
  1398. return __extends(i, e),
  1399. i.prototype.connect = function(e, i) {
  1400. this.free && (this.free = !1, this.connectedHand = e, this.currentDirection = t.HandDirection.getDirectionByAngle(i), this.rotateTo(i))
  1401. },
  1402. i.prototype.rotateTo = function(t) {
  1403. this.tween && this.tween.stop();
  1404. var e = 360,
  1405. i = (t - this.angle) % e;
  1406. i !== i % (e / 2) && (i = 0 > i ? i + e: i - e);
  1407. var a = 4 * Math.abs(i);
  1408. this.tween = this.game.add.tween(this).to({
  1409. angle: this.angle + i
  1410. },
  1411. a, Phaser.Easing.Cubic.Out, !0)
  1412. },
  1413. i.prototype.disconnect = function() {
  1414. this.free === !1 && (this.free = !0, this.connectedHand.disconnect(), this.connectedHand = null, this.angle = t.HandDirection.getAngleByDirection(this.currentDirection), this.tween && this.tween.stop())
  1415. },
  1416. i.prototype.destroy = function() {
  1417. this.connectedHand = null
  1418. },
  1419. i
  1420. } (Phaser.Image);
  1421. t.Hand = e
  1422. } (game || (game = {}));
  1423. var game; !
  1424. function(t) {
  1425. var e = function(t) {
  1426. function e(e, i, a, n) {
  1427. t.call(this, e, i, a),
  1428. this.hasHands = !0,
  1429. this.addHands(n)
  1430. }
  1431. return __extends(e, t),
  1432. e.prototype.addHands = function() {},
  1433. e.prototype.addHand = function(t) {
  1434. this.addAt(t, 0),
  1435. this.hands.push(t)
  1436. },
  1437. e.prototype.getFreeHands = function() {
  1438. var t = [];
  1439. return this.hands.forEach(function(e) {
  1440. e.free && t.push(e)
  1441. }),
  1442. t
  1443. },
  1444. e.prototype.getFreeHand = function(t) {
  1445. if (this.isDirectionTaken(t)) return null;
  1446. var e = 6,
  1447. i = null;
  1448. return this.hands.forEach(function(a) {
  1449. if (a.free) {
  1450. var n = game.HandDirection.getDelta(a.currentDirection, t);
  1451. e > n && (i = a, e = n)
  1452. }
  1453. }),
  1454. i
  1455. },
  1456. e.prototype.isDirectionTaken = function(t) {
  1457. for (var e = 0; e < this.hands.length; e++) {
  1458. var i = this.hands[e];
  1459. if (i.free === !1 && i.currentDirection === t) return ! 0
  1460. }
  1461. return ! 1
  1462. },
  1463. e.prototype.onDragComplete = function() {
  1464. t.prototype.onDragComplete.call(this),
  1465. this.disconnectAllHands()
  1466. },
  1467. e.prototype.disconnectAllHands = function() {
  1468. this.hands.forEach(function(t) {
  1469. t.disconnect()
  1470. })
  1471. },
  1472. e.prototype.hasFreeHands = function() {
  1473. return this.hands.some(function(t) {
  1474. return t.free
  1475. })
  1476. },
  1477. e.prototype.updateHappiness = function() {
  1478. var t = this.isHappy;
  1479. this.isHappy = this.onHappyArea ? !0 : this.isRayAround ? !1 : this.hasFreeHands() === !1,
  1480. this.face.setHappiness(this.isHappy),
  1481. this.isHappy && t === !1 && this.shake()
  1482. },
  1483. e.prototype.shake = function() {
  1484. this.bodyTween && this.bodyTween.isRunning && (this.bodyTween.stop(), this.body.angle = 0),
  1485. this.bodyTween = this.game.add.tween(this.body).to({
  1486. angle: 15
  1487. },
  1488. 100, Phaser.Easing.Cubic.Out, !0, 0, 5, !0)
  1489. },
  1490. e.prototype.destroy = function() {
  1491. t.prototype.destroy.call(this, !0, !1),
  1492. this.hands = null
  1493. },
  1494. e
  1495. } (t.BaseCreature);
  1496. t.CreatureWithHands = e
  1497. } (game || (game = {}));
  1498. var game; !
  1499. function(t) {
  1500. var e = function(e) {
  1501. function i(t, i, a, n) {
  1502. e.call(this, t, i, a, n)
  1503. }
  1504. return __extends(i, e),
  1505. i.prototype.addHands = function(e) {
  1506. this.hands = [];
  1507. for (var i = this.getHandAngles(e), a = 0; e > a; a++) {
  1508. var n = i[a],
  1509. s = t.CreatureType[this.type] + "_Hand0000",
  1510. o = new t.Hand(this.game, s, n);
  1511. this.addHand(o)
  1512. }
  1513. },
  1514. i.prototype.getHandAngles = function(t) {
  1515. switch (t) {
  1516. case 1:
  1517. return [180];
  1518. case 2:
  1519. return [120, 240];
  1520. case 3:
  1521. return [120, 180, 240];
  1522. case 4:
  1523. return [300, 60, 120, 240];
  1524. case 5:
  1525. return [300, 60, 120, 180, 240];
  1526. case 6:
  1527. return [300, 0, 60, 120, 180, 240];
  1528. default:
  1529. return null
  1530. }
  1531. },
  1532. i
  1533. } (t.CreatureWithHands);
  1534. t.Octopus = e
  1535. } (game || (game = {}));
  1536. var game; !
  1537. function(t) {
  1538. var e = function(t) {
  1539. function e(e, i) {
  1540. t.call(this, e, i, 3),
  1541. this.areCreaturesAround = !0
  1542. }
  1543. return __extends(e, t),
  1544. e.prototype.updateHappiness = function() {
  1545. this.isHappy = this.onHappyArea ? !0 : this.areCreaturesAround === !1,
  1546. this.face.setHappiness(this.isHappy)
  1547. },
  1548. e
  1549. } (t.BaseCreature);
  1550. t.Needlefish = e
  1551. } (game || (game = {}));
  1552. var game; !
  1553. function(t) {
  1554. var e = function(e) {
  1555. function i(t, i, a) {
  1556. e.call(this, t, i, a),
  1557. this.initialAngle = a,
  1558. this.currentAngle = a
  1559. }
  1560. return __extends(i, e),
  1561. i.prototype.connect = function(t) {
  1562. this.free && (this.free = !1, this.connectedHand = t)
  1563. },
  1564. i.prototype.disconnect = function() {
  1565. this.free === !1 && (this.free = !0, this.connectedHand.disconnect(), this.connectedHand = null)
  1566. },
  1567. i.prototype.setRotation = function(e) {
  1568. this.currentAngle = (e + this.initialAngle + 360) % 360,
  1569. this.currentDirection = t.HandDirection.getDirectionByAngle(this.currentAngle)
  1570. },
  1571. i
  1572. } (t.Hand);
  1573. t.CrabHand = e
  1574. } (game || (game = {}));
  1575. var game; !
  1576. function(t) {
  1577. var e = function(e) {
  1578. function i(t, i, a) {
  1579. e.call(this, t, i, 1, 2),
  1580. this._rotatedSignal = new Phaser.Signal,
  1581. this.rotation = Phaser.Math.degToRad(a),
  1582. this.currentRotation = this.rotation,
  1583. this.updateHands(),
  1584. this.body.x -= 1,
  1585. this.body.y += 3
  1586. }
  1587. return __extends(i, e),
  1588. i.prototype.addFace = function() {
  1589. e.prototype.addFace.call(this),
  1590. this.face.x -= 1,
  1591. this.face.y -= 16
  1592. },
  1593. i.prototype.addHands = function() {
  1594. this.hands = [];
  1595. var e = new t.CrabHand(this.game, "Crab_Hand0000", 300),
  1596. i = new t.CrabHand(this.game, "Crab_Hand0000", 60);
  1597. this.addHand(e),
  1598. this.addHand(i)
  1599. },
  1600. i.prototype.getFreeHand = function(t) {
  1601. for (var e = 0; e < this.hands.length; e++) {
  1602. var i = this.hands[e];
  1603. if (i.free && i.currentDirection === t) return i
  1604. }
  1605. return null
  1606. },
  1607. i.prototype.rotate = function() {
  1608. this.currentRotation += Phaser.Math.degToRad(60),
  1609. this.game.add.tween(this).to({
  1610. rotation: this.currentRotation
  1611. },
  1612. 100, Phaser.Easing.Linear.None, !0),
  1613. this.updateHands(),
  1614. this._rotatedSignal.dispatch(this)
  1615. },
  1616. i.prototype.updateHands = function() {
  1617. var t = Phaser.Math.radToDeg(this.currentRotation);
  1618. t = Math.round(t),
  1619. this.hands.forEach(function(e) {
  1620. e.setRotation(t),
  1621. e.disconnect()
  1622. })
  1623. },
  1624. i.prototype.destroy = function() {
  1625. e.prototype.destroy.call(this),
  1626. this._rotatedSignal.dispose(),
  1627. this._rotatedSignal = null
  1628. },
  1629. Object.defineProperty(i.prototype, "rotatedSignal", {
  1630. get: function() {
  1631. return this._rotatedSignal
  1632. },
  1633. enumerable: !0,
  1634. configurable: !0
  1635. }),
  1636. i
  1637. } (t.CreatureWithHands);
  1638. t.Crab = e
  1639. } (game || (game = {}));
  1640. var game; !
  1641. function(t) {
  1642. var e = function(t) {
  1643. function e(e, i, a) {
  1644. t.call(this, e, i, 2, a)
  1645. }
  1646. return __extends(e, t),
  1647. e.prototype.addFace = function() {
  1648. t.prototype.addFace.call(this),
  1649. this.face.y -= 3
  1650. },
  1651. e
  1652. } (t.Octopus);
  1653. t.Jelly = e
  1654. } (game || (game = {}));
  1655. var game; !
  1656. function(t) {
  1657. var e = function(t) {
  1658. function e(e, i, a) {
  1659. t.call(this, e, i, a),
  1660. this.isHappy = !0
  1661. }
  1662. return __extends(e, t),
  1663. e.prototype.addFace = function() {},
  1664. e.prototype.addBody = function() {
  1665. this.body = this.game.add.sprite(0, 0, "manta_ray", "", this),
  1666. this.body.anchor.set(.5, .45),
  1667. this.body.animations.add("main", null, 30, !0),
  1668. this.body.animations.play("main")
  1669. },
  1670. e
  1671. } (t.BaseCreature);
  1672. t.ElectricRay = e
  1673. } (game || (game = {}));
  1674. var game; !
  1675. function(t) {
  1676. var e = function() {
  1677. function e() {}
  1678. return e.create = function(i, a, n) {
  1679. var s = n.hands,
  1680. o = n.type.split("_")[0],
  1681. r = e.TYPES[o];
  1682. switch (r) {
  1683. case 0:
  1684. return new t.Octopus(i, a, r, s);
  1685. case 2:
  1686. return new t.Jelly(i, a, s);
  1687. case 1:
  1688. return new t.Crab(i, a, n.rotation);
  1689. case 3:
  1690. return new t.Needlefish(i, a);
  1691. case 4:
  1692. return new t.ElectricRay(i, a, 4);
  1693. default:
  1694. return null
  1695. }
  1696. },
  1697. e.TYPES = {
  1698. Octopus: 0,
  1699. Jellyfish: 2,
  1700. Crab: 1,
  1701. Needlefish: 3,
  1702. ElectricRay: 4
  1703. },
  1704. e
  1705. } ();
  1706. t.CreatureFactory = e
  1707. } (game || (game = {}));
  1708. var game; !
  1709. function(t) { !
  1710. function(t) {
  1711. t[t.Stone = 0] = "Stone",
  1712. t[t.Happy = 1] = "Happy",
  1713. t[t.Star = 2] = "Star"
  1714. } (t.ObjectType || (t.ObjectType = {})),
  1715. t.ObjectType
  1716. } (game || (game = {}));
  1717. var game; !
  1718. function(t) {
  1719. var e = function(t) {
  1720. function e(e, i, a) {
  1721. t.call(this, e, 0, 0, "level_graphics", i),
  1722. this._type = a,
  1723. this.anchor.set(.5, .5)
  1724. }
  1725. return __extends(e, t),
  1726. Object.defineProperty(e.prototype, "type", {
  1727. get: function() {
  1728. return this._type
  1729. },
  1730. enumerable: !0,
  1731. configurable: !0
  1732. }),
  1733. e
  1734. } (Phaser.Image);
  1735. t.GridObject = e
  1736. } (game || (game = {}));
  1737. var game; !
  1738. function(t) {
  1739. var e = function(t) {
  1740. function e(e, i) {
  1741. t.call(this, e, i, 0)
  1742. }
  1743. return __extends(e, t),
  1744. e
  1745. } (t.GridObject);
  1746. t.Stone = e
  1747. } (game || (game = {}));
  1748. var game; !
  1749. function(t) {
  1750. var e = function(t) {
  1751. function e(e, i) {
  1752. t.call(this, e, i, 1),
  1753. this.game.add.tween(this).to({
  1754. angle: 360
  1755. },
  1756. 5e3, Phaser.Easing.Linear.None, !0, 0, 1e4)
  1757. }
  1758. return __extends(e, t),
  1759. e
  1760. } (t.GridObject);
  1761. t.HappyArea = e
  1762. } (game || (game = {}));
  1763. var game; !
  1764. function(t) {
  1765. var e = function(t) {
  1766. function e(e) {
  1767. t.call(this, e, "Star0000", 2),
  1768. this._isTaken = !1,
  1769. this.freeTexture = "Star0000",
  1770. this.takenTexture = "Star_Taken0000",
  1771. this.anchor.set(.48, .5),
  1772. this.startFreeTween()
  1773. }
  1774. return __extends(e, t),
  1775. e.prototype.startFreeTween = function() { (this.angleTween || this.scaleTween) && (this.angleTween.stop(), this.scaleTween.stop());
  1776. var t = 800;
  1777. this.angle = -15,
  1778. this.angleTween = this.game.add.tween(this).to({
  1779. angle: 15
  1780. },
  1781. t, Phaser.Easing.Cubic.Out, !0, 0, 1e4, !0),
  1782. this.scaleTween = this.game.add.tween(this.scale).to({
  1783. x: 1.1,
  1784. y: 1.1
  1785. },
  1786. .5 * t, Phaser.Easing.Cubic.Out, !0, 0, 1e4, !0)
  1787. },
  1788. e.prototype.onTaken = function() {
  1789. 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))
  1790. },
  1791. e.prototype.onFree = function() {
  1792. this._isTaken && (this._isTaken = !1, this.loadTexture("level_graphics", this.freeTexture), this.startFreeTween())
  1793. },
  1794. Object.defineProperty(e.prototype, "isTaken", {
  1795. get: function() {
  1796. return this._isTaken
  1797. },
  1798. enumerable: !0,
  1799. configurable: !0
  1800. }),
  1801. e
  1802. } (t.GridObject);
  1803. t.Star = e
  1804. } (game || (game = {}));
  1805. var game; !
  1806. function(t) {
  1807. var e = function(e) {
  1808. function i(t) {
  1809. e.call(this, t, t.world, "grid"),
  1810. this.startDragPosition = new Phaser.Point,
  1811. this.cells = [],
  1812. this.creatures = [],
  1813. this.stars = [],
  1814. this.stones = [],
  1815. this.happyAreas = [],
  1816. this._levelCompleteSignal = new Phaser.Signal,
  1817. this.bottomLayer = this.game.add.group(this, "cells_rocks"),
  1818. this.topLayer = this.game.add.group(this, "creatures_objects"),
  1819. this.initInput()
  1820. }
  1821. return __extends(i, e),
  1822. i.prototype.initInput = function() {
  1823. this.game.input.onDown.add(this.onDown, this),
  1824. this.game.input.onUp.add(this.onUp, this)
  1825. },
  1826. i.prototype.disableInput = function() {
  1827. this.game.input.onDown.remove(this.onDown, this),
  1828. this.game.input.onUp.remove(this.onUp, this)
  1829. },
  1830. i.prototype.addCell = function(t) {
  1831. this.bottomLayer.add(t),
  1832. this.cells.push(t)
  1833. },
  1834. i.prototype.addCreature = function(t) {
  1835. var e = this.getCellUnderPoint(t.x, t.y),
  1836. i = game.CreatureFactory.create(this.game, this.topLayer, t);
  1837. i.position.set(e.x, e.y),
  1838. i.cell = e,
  1839. this.creatures.push(i),
  1840. 1 === i.type && i.rotatedSignal.add(this.onCrabRotate, this)
  1841. },
  1842. i.prototype.onCrabRotate = function() {
  1843. this.updateCreatures(),
  1844. this.checkLevelComplete(),
  1845. this.crabRotateSignal && this.crabRotateSignal.dispatch()
  1846. },
  1847. i.prototype.addGridObject = function(e) {
  1848. var i, a = e.type,
  1849. n = a + "0000";
  1850. 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) {
  1851. 0 === i.type ? this.bottomLayer.add(i) : this.topLayer.addAt(i, 0);
  1852. var s = this.getCellUnderPoint(e.x, e.y);
  1853. 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)
  1854. }
  1855. },
  1856. i.prototype.onDown = function(t) {
  1857. var e = this.getCreatureUnderPoint(t.worldX - this.x, t.worldY - this.y);
  1858. 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))
  1859. },
  1860. i.prototype.getCreatureUnderPoint = function(e, i) {
  1861. for (var a = 0; a < this.creatures.length; a++) {
  1862. var n = this.creatures[a],
  1863. s = utils.MathUtil.distanceSquared(n.position.x, n.position.y, e, i);
  1864. if (s < t.BaseCreature.BODY_RADIUS_SQUARED) return n
  1865. }
  1866. return null
  1867. },
  1868. i.prototype.onUp = function() {
  1869. if (this.selectedCrab && (this.selectedCrab.rotate(), this.selectedCrab = null), this.draggedCreature) {
  1870. this.game.sound.usingWebAudio && this.game.sound.play("on_up", .5);
  1871. var t = this.getCellUnderPoint(this.draggedCreature.position.x, this.draggedCreature.position.y),
  1872. 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({
  1873. x: t.x,
  1874. y: t.y
  1875. },
  1876. 150, Phaser.Easing.Cubic.Out, !0), this.draggedCreature.cell = t, this.draggedCreature.onDragComplete()), this.updateCreatures(), this.updateStars(), this.checkLevelComplete()),
  1877. this.cellHighlight.visible = !1,
  1878. this.game.add.tween(this.draggedCreature.scale).to({
  1879. x: 1,
  1880. y: 1
  1881. },
  1882. 150, Phaser.Easing.Cubic.In, !0),
  1883. this.draggedCreature = null
  1884. }
  1885. },
  1886. i.prototype.swapCreatures = function(t, e) {
  1887. var i = t.cell,
  1888. a = e.cell;
  1889. t.cell = null,
  1890. e.cell = null,
  1891. this.game.add.tween(t.position).to({
  1892. x: a.x,
  1893. y: a.y
  1894. },
  1895. 150, Phaser.Easing.Cubic.Out, !0),
  1896. t.cell = a,
  1897. t.onDragComplete(),
  1898. this.game.add.tween(e.position).to({
  1899. x: i.x,
  1900. y: i.y
  1901. },
  1902. 150, Phaser.Easing.Cubic.Out, !0),
  1903. e.cell = i,
  1904. e.onDragComplete()
  1905. },
  1906. i.prototype.cellIsEmpty = function(t) {
  1907. var e = this.creatures.some(function(e) {
  1908. return e.cell === t
  1909. }),
  1910. i = this.stones.some(function(e) {
  1911. return e.cell === t
  1912. });
  1913. return e === !1 && i === !1
  1914. },
  1915. i.prototype.updateCreatures = function() {
  1916. var t = this;
  1917. this.creatures.forEach(function(e) {
  1918. e.onHappyArea = null !== t.getHappyAreaInCell(e.cell),
  1919. e.isRayAround = t.getNeighbourCreatures(e).some(function(t) {
  1920. return 4 === t.type
  1921. });
  1922. var i = t.getNeighbourCreatures(e);
  1923. if (3 === e.type) {
  1924. var a = e;
  1925. a.areCreaturesAround = i.length > 0
  1926. } else e.hasHands && t.connectCreaturesAround(e, i);
  1927. e.updateHappiness()
  1928. })
  1929. },
  1930. i.prototype.getRockInCell = function(t) {
  1931. for (var e = 0; e < this.stones.length; e++) {
  1932. var i = this.stones[e];
  1933. if (i.cell === t) return i
  1934. }
  1935. return null
  1936. },
  1937. i.prototype.getHappyAreaInCell = function(t) {
  1938. for (var e = 0; e < this.happyAreas.length; e++) {
  1939. var i = this.happyAreas[e];
  1940. if (i.cell === t) return i
  1941. }
  1942. return null
  1943. },
  1944. i.prototype.getCreatureInCell = function(t) {
  1945. for (var e = 0; e < this.creatures.length; e++) {
  1946. var i = this.creatures[e];
  1947. if (i.cell === t) return i
  1948. }
  1949. return null
  1950. },
  1951. i.prototype.getCellUnderPoint = function(e, i) {
  1952. for (var a = 0; a < this.cells.length; a++) {
  1953. var n = this.cells[a],
  1954. s = utils.MathUtil.distanceSquared(e, i, n.x, n.y);
  1955. if (s < t.HexCell.RADIUS_SQUARED) return n
  1956. }
  1957. return null
  1958. },
  1959. i.prototype.connectCreaturesAround = function(t, e) {
  1960. var i = this;
  1961. 0 !== e.length && e.forEach(2 === t.type ?
  1962. function(e) {
  1963. if (2 === e.type) {
  1964. var a = e;
  1965. a.hasFreeHands() && i.connectHands(t, a)
  1966. }
  1967. }: function(e) {
  1968. if (1 === e.type || 0 === e.type) {
  1969. var a = e;
  1970. a.hasFreeHands() && i.connectHands(t, a)
  1971. }
  1972. })
  1973. },
  1974. i.prototype.getNeighbourCreatures = function(t) {
  1975. for (var e = t.cell.x,
  1976. i = t.cell.y,
  1977. a = [], n = 0; n < this.creatures.length; n++) {
  1978. var s = this.creatures[n];
  1979. if (s !== t) {
  1980. var o = utils.MathUtil.distanceSquared(s.cell.x, s.cell.y, e, i);
  1981. o < game.BaseCreature.CONTACT_RADIUS_SQUARED && a.push(s)
  1982. }
  1983. }
  1984. return a
  1985. },
  1986. i.prototype.connectHands = function(t, e) {
  1987. var i = this.getAngleBetweenCells(t.cell, e.cell),
  1988. a = (i + 180) % 360,
  1989. n = game.HandDirection.getDirectionByAngle(i),
  1990. s = game.HandDirection.getDirectionByAngle(a),
  1991. o = t.getFreeHand(n),
  1992. r = e.getFreeHand(s);
  1993. o && r && (o.connect(r, i), r.connect(o, a))
  1994. },
  1995. i.prototype.getAngleBetweenCells = function(t, e) {
  1996. var i = t.x - e.x,
  1997. a = t.y - e.y,
  1998. n = Math.atan2(a, i) * utils.MathUtil.RAD_TO_DEG - 90;
  1999. return n = (n + 720) % 360,
  2000. n = Phaser.Math.snapTo(n, 10, 0)
  2001. },
  2002. i.prototype.checkLevelComplete = function() {
  2003. this.allCreaturesHappy() && this.game.time.events.add(1e3, this.finalCheckLevelComplete, this)
  2004. },
  2005. i.prototype.finalCheckLevelComplete = function() {
  2006. if (this.allCreaturesHappy()) {
  2007. if (this.draggedCreature) {
  2008. var t = this.draggedCreature.cell;
  2009. this.game.add.tween(this.draggedCreature.position).to({
  2010. x: t.x,
  2011. y: t.y
  2012. },
  2013. 150, Phaser.Easing.Cubic.Out, !0),
  2014. this.draggedCreature.cell = t,
  2015. this.draggedCreature.onDragComplete(),
  2016. this.draggedCreature = null
  2017. }
  2018. this.disableInput(),
  2019. this.onLevelComplete()
  2020. }
  2021. },
  2022. i.prototype.allCreaturesHappy = function() {
  2023. return this.creatures.every(function(t) {
  2024. return t.isHappy
  2025. })
  2026. },
  2027. i.prototype.onLevelComplete = function() {
  2028. var e = new t.LevelResult;
  2029. e.starsAvailable = this.stars.length,
  2030. e.starsEarned = this.getStarsEarnedNum(),
  2031. e.starsAvailable > 3 && (e.starsAvailable = 3),
  2032. this._levelCompleteSignal.dispatch(e)
  2033. },
  2034. i.prototype.getStarsAvailable = function() {
  2035. return this.stars.length
  2036. },
  2037. i.prototype.getStarsEarnedNum = function() {
  2038. var t = 0;
  2039. return this.stars.forEach(function(e) {
  2040. e.isTaken && t++
  2041. }),
  2042. t
  2043. },
  2044. i.prototype.init = function() {
  2045. this.bottomLayer.cacheAsBitmap = !0,
  2046. this.initBounds(),
  2047. this.addCellHighlight(),
  2048. this.sortCreatures(),
  2049. this.updateCreatures(),
  2050. this.updateStars()
  2051. },
  2052. i.prototype.initBounds = function() {
  2053. var t = 1e3,
  2054. e = 0,
  2055. i = 1e3,
  2056. a = 0;
  2057. this.cells.forEach(function(n) {
  2058. n.x < t && (t = n.x),
  2059. n.x > e && (e = n.x),
  2060. n.y < i && (i = n.y),
  2061. n.y > a && (a = n.y)
  2062. }),
  2063. this.bounds = new Phaser.Rectangle(t, i, e - t, a - i)
  2064. },
  2065. i.prototype.addCellHighlight = function() {
  2066. this.cellHighlight = this.game.add.image(0, 0, "level_graphics", "HexCell_Highlight0000", this),
  2067. this.cellHighlight.anchor.set(.5, .5),
  2068. this.cellHighlight.visible = !1,
  2069. this.bringToTop(this.topLayer)
  2070. },
  2071. i.prototype.sortCreatures = function() {
  2072. var t = this.creatures.filter(function(t) {
  2073. return 1 === t.type
  2074. }),
  2075. e = this.creatures.filter(function(t) {
  2076. return 0 === t.type
  2077. });
  2078. e.sort(function(t, e) {
  2079. return e.getFreeHands().length - t.getFreeHands().length
  2080. });
  2081. var i = this.creatures.filter(function(t) {
  2082. return 2 === t.type
  2083. });
  2084. i.sort(function(t, e) {
  2085. return e.getFreeHands().length - t.getFreeHands().length
  2086. });
  2087. var a = this.creatures.filter(function(t) {
  2088. return 3 === t.type || 4 === t.type
  2089. });
  2090. this.creatures = [].concat(t, e, i, a)
  2091. },
  2092. i.prototype.update = function() {
  2093. if (this.selectedCrab) {
  2094. var t = this.game.input.activePointer,
  2095. e = Phaser.Math.distance(t.x, t.y, this.startDragPosition.x, this.startDragPosition.y);
  2096. e > 20 && (this.startDragCreature(this.selectedCrab), this.selectedCrab = null)
  2097. }
  2098. if (this.draggedCreature) {
  2099. var i = this.game.input.activePointer.worldX - this.x,
  2100. a = this.game.input.activePointer.worldY - this.y;
  2101. this.draggedCreature.position.set(i, a);
  2102. var n = this.getCellUnderPoint(i, a);
  2103. n ? (this.cellHighlight.visible = !0, this.cellHighlight.x = n.x, this.cellHighlight.y = n.y) : this.cellHighlight.visible = !1
  2104. }
  2105. },
  2106. i.prototype.startDragCreature = function(t) {
  2107. this.draggedCreature = t,
  2108. this.topLayer.bringToTop(t),
  2109. this.game.add.tween(this.draggedCreature.scale).to({
  2110. x: 1.25,
  2111. y: 1.25
  2112. },
  2113. 150, Phaser.Easing.Cubic.Out, !0),
  2114. this.creatureDragSignal && this.creatureDragSignal.dispatch()
  2115. },
  2116. i.prototype.updateStars = function() {
  2117. var t = this;
  2118. this.stars.forEach(function(e) {
  2119. var i = t.getCreatureInCell(e.cell);
  2120. i ? e.onTaken() : e.onFree()
  2121. })
  2122. },
  2123. i.prototype.render = function() {
  2124. this.renderCells()
  2125. },
  2126. i.prototype.renderCreatures = function() {
  2127. var e = this,
  2128. i = new Phaser.Circle(0, 0, t.BaseCreature.CONTACT_RADIUS);
  2129. this.creatures.forEach(function(a) {
  2130. i.radius = t.BaseCreature.CONTACT_RADIUS,
  2131. i.x = a.position.x + e.x,
  2132. i.y = a.position.y + e.y,
  2133. e.game.debug.geom(i, "red", !1),
  2134. i.radius = t.BaseCreature.BODY_RADIUS,
  2135. i.x = a.position.x + e.x,
  2136. i.y = a.position.y + e.y,
  2137. e.game.debug.geom(i, "blue", !0)
  2138. })
  2139. },
  2140. i.prototype.renderCells = function() {
  2141. var e = this,
  2142. i = new Phaser.Circle(0, 0, 10);
  2143. this.cells.forEach(function(a) {
  2144. i.radius = t.HexCell.RADIUS,
  2145. i.x = a.x + e.x,
  2146. i.y = a.y + e.y,
  2147. e.game.debug.geom(i, "red", !1)
  2148. })
  2149. },
  2150. i.prototype.onRestart = function() {
  2151. this.visible = !0,
  2152. this.initInput()
  2153. },
  2154. i.prototype.destroy = function(t, i) {
  2155. void 0 === t && (t = !0),
  2156. void 0 === i && (i = !1),
  2157. e.prototype.destroy.call(this, t, i),
  2158. this.bounds = null,
  2159. this._levelCompleteSignal.dispose(),
  2160. this._levelCompleteSignal = null,
  2161. this.stars = null,
  2162. this.creatures = null,
  2163. this.happyAreas = null,
  2164. this.stones = null,
  2165. this.cells = null,
  2166. this.selectedCrab = null,
  2167. this.draggedCreature = null,
  2168. this.startDragPosition = null
  2169. },
  2170. Object.defineProperty(i.prototype, "levelCompleteSignal", {
  2171. get: function() {
  2172. return this._levelCompleteSignal
  2173. },
  2174. enumerable: !0,
  2175. configurable: !0
  2176. }),
  2177. i
  2178. } (Phaser.Group);
  2179. t.Grid = e
  2180. } (game || (game = {}));
  2181. var game; !
  2182. function(t) {
  2183. var e = function(t) {
  2184. function e(e, i, a, n) {
  2185. t.call(this, e, i, a, "tutor_hand"),
  2186. this.start = new Phaser.Point(i, a),
  2187. this.destination = n,
  2188. this.show(),
  2189. this.initAnimation(),
  2190. this.initTweens()
  2191. }
  2192. return __extends(e, t),
  2193. e.prototype.show = function() {
  2194. this.alpha = 0,
  2195. this.game.add.tween(this).to({
  2196. alpha: 1
  2197. },
  2198. 500, Phaser.Easing.Cubic.Out, !0, 1e3)
  2199. },
  2200. e.prototype.initAnimation = function() {
  2201. this.animations.add("main", utils.ArrayUtil.createArrayWithNumbers(5, 20), 30, !1)
  2202. },
  2203. e.prototype.initTweens = function() {
  2204. this.repeatEvent = this.game.time.events.repeat(1700, Number.MAX_VALUE, this.startTween, this)
  2205. },
  2206. e.prototype.startTween = function() {
  2207. this.x = this.start.x,
  2208. this.y = this.start.y,
  2209. this.animations.play("main", 30, !1, !1),
  2210. this.game.add.tween(this).to({
  2211. x: this.destination.x,
  2212. y: this.destination.y
  2213. },
  2214. 800, Phaser.Easing.Cubic.Out, !0, 600)
  2215. },
  2216. e.prototype.hideAndDestroy = function() {
  2217. this.game.time.events.remove(this.repeatEvent),
  2218. this.repeatEvent = null,
  2219. this.start = null,
  2220. this.destination = null,
  2221. this.visible = !1
  2222. },
  2223. e
  2224. } (Phaser.Sprite);
  2225. t.MovingTutorHand = e
  2226. } (game || (game = {}));
  2227. var game; !
  2228. function(t) {
  2229. var e = function(t) {
  2230. function e(e, i, a) {
  2231. t.call(this, e, i, a, "tutor_hand"),
  2232. this.initAnimation()
  2233. }
  2234. return __extends(e, t),
  2235. e.prototype.initAnimation = function() {
  2236. this.animations.add("main", null),
  2237. this.play("main", 30, !0)
  2238. },
  2239. e.prototype.hideAndDestroy = function() {
  2240. this.animations.stop(),
  2241. this.game.add.tween(this).to({
  2242. alpha: 0
  2243. },
  2244. 300, Phaser.Easing.Linear.None, !0).onComplete.addOnce(this.destroy, this)
  2245. },
  2246. e
  2247. } (Phaser.Sprite);
  2248. t.TutorHand = e
  2249. } (game || (game = {}));
  2250. var game; !
  2251. function(t) {
  2252. var e = function(e) {
  2253. function i(t, i, a, n, s) {
  2254. e.call(this, t, i),
  2255. this._closedSignal = new Phaser.Signal,
  2256. this.addBack(),
  2257. this.addTitle(a),
  2258. this.addImage(n),
  2259. this.addDescription(s),
  2260. this.addCloseButton()
  2261. }
  2262. return __extends(i, e),
  2263. i.prototype.addBack = function() {
  2264. var t = this.game.add.image(0, 0, "tutorial", "Tutor_Board0000", this);
  2265. this._width = t.width,
  2266. this._height = t.height
  2267. },
  2268. i.prototype.addTitle = function(t) {
  2269. var e = {
  2270. font: "50px GrilledCheeseBTNToasted",
  2271. fill: "#ffffff",
  2272. align: "center"
  2273. },
  2274. i = new Phaser.Text(this.game, 50, 20, t, e);
  2275. this.add(i),
  2276. i.x = .5 * (this._width - i.getLocalBounds().width),
  2277. i.y = 20
  2278. },
  2279. i.prototype.addImage = function(t) {
  2280. var e = this.game.add.image(0, 100, "tutorial", t, this);
  2281. e.x = .5 * (this._width - e.width)
  2282. },
  2283. i.prototype.addDescription = function(e) {
  2284. var i = {
  2285. font: "32px GrilledCheeseBTNToasted",
  2286. fill: "#ffffff",
  2287. align: "center"
  2288. },
  2289. a = new Phaser.Text(this.game, 50, 20, e, i);
  2290. this.add(a),
  2291. a.lineSpacing = -5,
  2292. a.wordWrapWidth = .8 * this._width,
  2293. a.wordWrap = !0,
  2294. a.x = 10 + .5 * (this._width - a.wordWrapWidth),
  2295. a.y = 255,
  2296. "ru" === t.Main.language && (a.lineSpacing = -10)
  2297. },
  2298. i.prototype.addCloseButton = function() {
  2299. var e = new t.SimpleButton(this.game, .5 * this._width, this._height, "tutorial", "Close_Button0000");
  2300. e.callback.addOnce(this.hide, this),
  2301. this.add(e)
  2302. },
  2303. i.prototype.hide = function() {
  2304. var e = this;
  2305. this.game.add.tween(this).to({
  2306. y: t.Config.GAME_HEIGHT + 30
  2307. },
  2308. 600, Phaser.Easing.Back.In, !0).onComplete.addOnce(function() {
  2309. e._closedSignal.dispatch(),
  2310. e.destroy()
  2311. },
  2312. this)
  2313. },
  2314. i.prototype.getWidth = function() {
  2315. return this._width
  2316. },
  2317. i.prototype.getHeight = function() {
  2318. return this._height
  2319. },
  2320. i.prototype.destroy = function() {
  2321. this.visible = !1,
  2322. this._closedSignal.dispose(),
  2323. this._closedSignal = null,
  2324. e.prototype.destroy.call(this, !0)
  2325. },
  2326. Object.defineProperty(i.prototype, "closedSignal", {
  2327. get: function() {
  2328. return this._closedSignal
  2329. },
  2330. enumerable: !0,
  2331. configurable: !0
  2332. }),
  2333. i.OCTOPUS = "octopus",
  2334. i.JELLY = "jellyfish",
  2335. i.CRAB = "crab",
  2336. i.NEEDLEFISH = "needlefish",
  2337. i.MANTA_RAY = "manta_ray",
  2338. i.HAPPY_AREA = "happy_area",
  2339. i
  2340. } (Phaser.Group);
  2341. t.TutorBoard = e
  2342. } (game || (game = {}));
  2343. var game; !
  2344. function(t) {
  2345. var e = function() {
  2346. function e() {}
  2347. return e.getBoard = function(t, i, a) {
  2348. var n = e.BOARDS_BY_LEVELS[a];
  2349. return n ? e.createBoard(t, i, n) : null
  2350. },
  2351. e.createBoard = function(i, a, n) {
  2352. var s = t.Main.texts[n];
  2353. if (!s) return null;
  2354. var o = e.getImageKeyById(n);
  2355. return new t.TutorBoard(i, a, s.title, o, s.description)
  2356. },
  2357. e.getImageKeyById = function(e) {
  2358. switch (e) {
  2359. case t.TutorBoard.OCTOPUS:
  2360. return "Tutor_Octopus0000";
  2361. case t.TutorBoard.CRAB:
  2362. return "Tutor_Crab0000";
  2363. case t.TutorBoard.MANTA_RAY:
  2364. return "Tutor_MantaRay0000";
  2365. case t.TutorBoard.NEEDLEFISH:
  2366. return "Tutor_NeedleFish0000";
  2367. case t.TutorBoard.JELLY:
  2368. return "Tutor_JellyFish0000";
  2369. case t.TutorBoard.HAPPY_AREA:
  2370. return "Tutor_HappyArea0000";
  2371. default:
  2372. return "Tutor_Octopus0000"
  2373. }
  2374. },
  2375. e.BOARDS_BY_LEVELS = {
  2376. 1 : t.TutorBoard.OCTOPUS,
  2377. 5 : t.TutorBoard.CRAB,
  2378. 11 : t.TutorBoard.MANTA_RAY,
  2379. 19 : t.TutorBoard.NEEDLEFISH,
  2380. 31 : t.TutorBoard.HAPPY_AREA,
  2381. 40 : t.TutorBoard.JELLY
  2382. },
  2383. e
  2384. } ();
  2385. t.TutorBoardFactory = e
  2386. } (game || (game = {}));
  2387. var game; !
  2388. function(t) {
  2389. var e; !
  2390. function(t) {
  2391. t[t.ACTIVE = 0] = "ACTIVE",
  2392. t[t.PAUSED = 1] = "PAUSED",
  2393. t[t.RESTART = 2] = "RESTART"
  2394. } (e || (e = {}));
  2395. var i = function(e) {
  2396. function i() {
  2397. e.apply(this, arguments)
  2398. }
  2399. return __extends(i, e),
  2400. i.prototype.init = function(e) {
  2401. this.debugRenderFlag = !1,
  2402. this.state = 1,
  2403. this._settings = new t.LevelSettings(e)
  2404. },
  2405. i.prototype.preload = function() {
  2406. if (t.Main.development) {
  2407. var e = this._settings.levelNumber.toString(),
  2408. i = "assets/levels/Level_" + e + ".json";
  2409. this.load.json("level_" + e, i)
  2410. }
  2411. },
  2412. i.prototype.create = function() {
  2413. this.game.state.onShutDownCallback = this.destroy,
  2414. this.state = 1,
  2415. this.addLayers(),
  2416. t.Main.development && this.addFPSMeter(),
  2417. this.parse(),
  2418. this.afterParsing(),
  2419. this.initKeyCallbacks(),
  2420. this._settings.levelNumber > 1 && this.showAds(),
  2421. this.state = 0
  2422. },
  2423. i.prototype.showAds = function() {},
  2424. i.prototype.pauseGame = function() {
  2425. t.Main.wasPaused = !0,
  2426. t.Main.wasMuted = this.game.sound.mute,
  2427. this.game.sound.mute = !0,
  2428. this.game.tweens.pauseAll()
  2429. },
  2430. i.prototype.resumeGame = function() {
  2431. t.Main.wasPaused && (t.Main.wasPaused = !1, this.game.sound.mute = t.Main.wasMuted, this.game.tweens.resumeAll())
  2432. },
  2433. i.prototype.addLayers = function() {
  2434. this.game.add.image( - 33, 0, "level_graphics", "Level_BG20000"),
  2435. this.addGrid(),
  2436. this.addGUI()
  2437. },
  2438. i.prototype.addGrid = function() {
  2439. this.grid = new t.Grid(this.game),
  2440. this.grid.levelCompleteSignal.add(this.onLevelComplete, this)
  2441. },
  2442. i.prototype.addGUI = function() {
  2443. this.gui = new t.LevelGUI(this.game, this._settings)
  2444. },
  2445. i.prototype.addFPSMeter = function() {
  2446. this.fpsMeter = new utils.FPSMeter(this.game, 0, t.Config.GAME_HEIGHT - 22)
  2447. },
  2448. i.prototype.parse = function() {
  2449. var e;
  2450. if (t.Main.development) e = this.game.cache.getJSON("level_" + this._settings.levelNumber.toString());
  2451. else {
  2452. var i = "Level_" + this._settings.levelNumber,
  2453. a = this.game.cache.getJSON("levelConfigs");
  2454. e = a[i]
  2455. }
  2456. t.Main.parser.parse(this, e)
  2457. },
  2458. i.prototype.afterParsing = function() {
  2459. this.grid.init(),
  2460. 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),
  2461. this.grid.position.x = Math.round(this.grid.position.x),
  2462. this.grid.position.y = Math.round(this.grid.position.y);
  2463. var e = this.grid.getStarsAvailable();
  2464. this.gui.initCompleteBoard(e),
  2465. this.initTutorial()
  2466. },
  2467. i.prototype.initTutorial = function() {
  2468. this.initTutorHands(),
  2469. this.initTutorBoards()
  2470. },
  2471. i.prototype.initTutorHands = function() {
  2472. 1 === this._settings.levelNumber ? this.addMovingTutorHand() : 5 === this._settings.levelNumber && this.addSimpleTutorHand()
  2473. },
  2474. i.prototype.addMovingTutorHand = function() {
  2475. var e = this,
  2476. i = new t.MovingTutorHand(this.game, 350, 125, new Phaser.Point(185, 210));
  2477. this.grid.add(i),
  2478. this.grid.creatureDragSignal = new Phaser.Signal,
  2479. this.grid.creatureDragSignal.addOnce(function() {
  2480. i.hideAndDestroy(),
  2481. e.grid.creatureDragSignal.dispose(),
  2482. e.grid.creatureDragSignal = null
  2483. })
  2484. },
  2485. i.prototype.addSimpleTutorHand = function() {
  2486. var e = this,
  2487. i = new t.TutorHand(this.game, 108, 160);
  2488. this.grid.add(i),
  2489. this.grid.crabRotateSignal = new Phaser.Signal,
  2490. this.grid.crabRotateSignal.addOnce(function() {
  2491. i.hideAndDestroy(),
  2492. e.grid.crabRotateSignal.dispose(),
  2493. e.grid.crabRotateSignal = null
  2494. })
  2495. },
  2496. i.prototype.initTutorBoards = function() {
  2497. var e = this,
  2498. i = t.TutorBoardFactory.getBoard(this.game, this.world, this._settings.levelNumber);
  2499. if (i) {
  2500. i.position.set(.5 * (t.Config.GAME_WIDTH - i.getWidth()), -i.getHeight());
  2501. var a = .5 * (t.Config.GAME_HEIGHT - i.getHeight());
  2502. this.game.add.tween(i).to({
  2503. y: a
  2504. },
  2505. 600, Phaser.Easing.Back.Out, !0, 150),
  2506. this.grid.visible = !1,
  2507. this.grid.alpha = 0,
  2508. i.closedSignal.addOnce(function() {
  2509. e.grid.visible = !0,
  2510. e.game.add.tween(e.grid).to({
  2511. alpha: 1
  2512. },
  2513. 200, Phaser.Easing.Linear.None, !0)
  2514. },
  2515. this)
  2516. }
  2517. },
  2518. i.prototype.initKeyCallbacks = function() {
  2519. var e = this;
  2520. this.game.input.keyboard.addKey(Phaser.Keyboard.ESC).onDown.add(this.gotoChooseLevelMenu, this),
  2521. t.Main.development && (this.game.input.keyboard.addKey(Phaser.Keyboard.S).onDown.add(function() {
  2522. e.fpsMeter.visible = !e.fpsMeter.visible
  2523. }), 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))
  2524. },
  2525. i.prototype.gotoPrevLevel = function() {
  2526. var e = this._settings.levelNumber,
  2527. i = 1 === e ? t.Config.LEVELS_NUM: e - 1;
  2528. this.gotoLevel(i)
  2529. },
  2530. i.prototype.gotoNextLevel = function() {
  2531. var e = this._settings.levelNumber,
  2532. i = e >= t.Config.LEVELS_NUM ? 1 : e + 1;
  2533. this.gotoLevel(i)
  2534. },
  2535. i.prototype.gotoLevel = function(t) {
  2536. this.game.changeState("Level", t)
  2537. },
  2538. i.prototype.restart = function() {
  2539. this.gui.onRestart(),
  2540. this.grid.onRestart()
  2541. },
  2542. i.prototype.toggleDebugRender = function() {
  2543. this.debugRenderFlag = !this.debugRenderFlag
  2544. },
  2545. i.prototype.gotoChooseLevelMenu = function() {
  2546. this.game.changeState("LevelsMenu")
  2547. },
  2548. i.prototype.onLevelComplete = function(t) {
  2549. this.game.sound.usingWebAudio && this.game.sound.play("onLevelComplete", .66);
  2550. try {
  2551. this.saveLevelResult(t)
  2552. } catch(e) {}
  2553. 1 === this._settings.levelNumber ? this.gotoNextLevel() : (this.grid.visible = !1, this.gui.onLevelComplete(t))
  2554. },
  2555. i.prototype.saveLevelResult = function(e) {
  2556. e.levelNumber = this._settings.levelNumber;
  2557. var i = this._settings.levelNumber.toString();
  2558. t.Main.storage.saveValue(i, e);
  2559. // updateShare(e.levelNumber);
  2560. // Play68.setRankingScoreDesc(e.levelNumber)
  2561. },
  2562. i.prototype.render = function() {
  2563. this.debugRenderFlag && this.grid.render()
  2564. },
  2565. i.prototype.destroy = function() {
  2566. this.game.state.onShutDownCallback = null,
  2567. this.removeKeyCallbacks(),
  2568. this._settings = null
  2569. },
  2570. i.prototype.removeKeyCallbacks = function() {
  2571. this.game.input.keyboard.removeKey(Phaser.Keyboard.R),
  2572. this.game.input.keyboard.removeKey(Phaser.Keyboard.P),
  2573. this.game.input.keyboard.removeKey(Phaser.Keyboard.ESC),
  2574. this.game.input.keyboard.removeKey(Phaser.Keyboard.D)
  2575. },
  2576. Object.defineProperty(i.prototype, "settings", {
  2577. get: function() {
  2578. return this._settings
  2579. },
  2580. enumerable: !0,
  2581. configurable: !0
  2582. }),
  2583. i
  2584. } (Phaser.State);
  2585. t.Level = i
  2586. } (game || (game = {}));
  2587. var game; !
  2588. function(t) {
  2589. var e = function() {
  2590. function t(t) {
  2591. this.game = t,
  2592. this.initCallbacks()
  2593. }
  2594. return t.prototype.initCallbacks = function() {
  2595. this.callbacks = {},
  2596. this.callbacks.HexCell = this.addGridCell,
  2597. this.callbacks.Octopus = this.addCreature,
  2598. this.callbacks.Jellyfish = this.addCreature,
  2599. this.callbacks.Crab = this.addCreature,
  2600. this.callbacks.Needlefish = this.addCreature,
  2601. this.callbacks.ElectricRay = this.addCreature,
  2602. this.callbacks.Stone = this.addGridObject,
  2603. this.callbacks.HappyArea = this.addGridObject,
  2604. this.callbacks.Star = this.addGridObject
  2605. },
  2606. t.prototype.parse = function(t, e) {
  2607. this.newLevel = t,
  2608. this.levelConfig = e,
  2609. this.parseObjects(),
  2610. this.cleanup()
  2611. },
  2612. t.prototype.cleanup = function() {
  2613. this.newLevel = null,
  2614. this.levelConfig = null
  2615. },
  2616. t.prototype.parseObjects = function() {
  2617. var t = this;
  2618. this.levelConfig.forEach(function(e) {
  2619. t.addGameObject(e)
  2620. })
  2621. },
  2622. t.prototype.addGameObject = function(t) {
  2623. var e = t.type,
  2624. i = this.getCallback(e);
  2625. i ? i.call(this, t) : this.addImage(t)
  2626. },
  2627. t.prototype.getCallback = function(t) {
  2628. for (var e in this.callbacks) if (t.indexOf(e) > -1) return this.callbacks[e];
  2629. return null
  2630. },
  2631. t.prototype.addCreature = function(t) {
  2632. this.newLevel.grid.addCreature(t)
  2633. },
  2634. t.prototype.addGridCell = function(t) {
  2635. var e = Math.round(t.x),
  2636. i = Math.round(t.y),
  2637. a = new game.HexCell(this.game, e, i);
  2638. this.newLevel.grid.addCell(a)
  2639. },
  2640. t.prototype.addGridObject = function(t) {
  2641. this.newLevel.grid.addGridObject(t)
  2642. },
  2643. t.prototype.addImage = function() {},
  2644. t
  2645. } ();
  2646. t.LevelParser = e
  2647. } (game || (game = {}));
  2648. var utils; !
  2649. function(t) {
  2650. var e = function() {
  2651. function t() {
  2652. this._enabled = !0,
  2653. this.init()
  2654. }
  2655. return t.prototype.init = function() {
  2656. try {
  2657. this.localStorage = window.localStorage,
  2658. this.localStorage.setItem("testKey", "testData"),
  2659. this.localStorage.removeItem("testKey")
  2660. } catch(t) {
  2661. this._enabled = !1
  2662. }
  2663. },
  2664. t.prototype.saveValue = function(t, e) {
  2665. if (this._enabled) {
  2666. var i = JSON.stringify(e);
  2667. window.localStorage.setItem(t,i)
  2668. }
  2669. },
  2670. t.prototype.getValue = function(t) {
  2671. return window.localStorage.getItem(t)
  2672. },
  2673. t.prototype.remove = function(t) {
  2674. this._enabled && window.localStorage.removeItem(t)
  2675. },
  2676. t.prototype.clear = function() {
  2677. this._enabled && this.localStorage.clear()
  2678. },
  2679. Object.defineProperty(t.prototype, "enabled", {
  2680. get: function() {
  2681. return this._enabled
  2682. },
  2683. enumerable: !0,
  2684. configurable: !0
  2685. }),
  2686. t
  2687. } ();
  2688. t.LocalStorageWrapper = e
  2689. } (utils || (utils = {})),
  2690. window.addEventListener("load", onLoad, !1);
  2691. var game; !
  2692. function(t) {
  2693. var e = function(e) {
  2694. function i() {
  2695. e.call(this, t.Config.GAME_WIDTH, t.Config.GAME_HEIGHT, Phaser.CANVAS, "gameContainer"),
  2696. i.parser = new t.LevelParser(this),
  2697. i.storage = new utils.LocalStorageWrapper,
  2698. this.setupLanguage(),
  2699. this.state.add("Boot", t.Boot, !1),
  2700. this.state.add("SplashScreen", t.SplashScreen, !1),
  2701. this.state.add("Preloader", t.Preloader, !1),
  2702. this.state.add("MainMenu", t.MainMenu, !1),
  2703. this.state.add("LevelsMenu", t.LevelsMenu, !1),
  2704. this.state.add("Level", t.Level, !1),
  2705. this.state.start("Boot")
  2706. }
  2707. return __extends(i, e),
  2708. i.prototype.setupLanguage = function() {
  2709. i.language = "cn"
  2710. },
  2711. i.prototype.changeState = function(t, e) {
  2712. this.stateTransitionPlugin || (this.stateTransitionPlugin = this.plugins.plugins[0]),
  2713. this.stateTransitionPlugin.changeState(t, e)
  2714. },
  2715. i.wasPaused = !1,
  2716. i.wasMuted = !1,
  2717. i.development = !1,
  2718. i.language = "cn",
  2719. i
  2720. } (Phaser.Game);
  2721. t.Main = e
  2722. } (game || (game = {}));