game.min.js 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379
  1. function onLoad() {
  2. new game.Main
  3. }
  4. var game;
  5. ! function(a) {
  6. var b = function() {
  7. function a() {}
  8. return a.TITLE = "Water Game", a.GAME_WIDTH = 640, a.GAME_HEIGHT = 832, a.HALF_GAME_WIDTH = 320, a.HALF_GAME_HEIGHT = 416, a.LEVELS_NUM = 28, a
  9. }();
  10. a.Config = b
  11. }(game || (game = {}));
  12. var __extends = this.__extends || function(a, b) {
  13. function c() {
  14. this.constructor = a
  15. }
  16. for (var d in b) b.hasOwnProperty(d) && (a[d] = b[d]);
  17. c.prototype = b.prototype, a.prototype = new c
  18. },
  19. game;
  20. ! function(a) {
  21. var b = function(a) {
  22. function b() {
  23. a.apply(this, arguments)
  24. }
  25. return __extends(b, a), b.prototype.init = function() {
  26. this.game.device.android && !this.game.device.chrome && (this.game.canvas.parentElement.style.overflow = "visible");
  27. var a = {
  28. font: "46px TF2 Build"
  29. },
  30. b = this.add.text(0, 0, "0", a);
  31. b.destroy()
  32. }, b.prototype.preload = function() {
  33. this.load.image("rotate", "assets/graphics/rotate-phone.png"), this.load.image("LoadingBar_Outer", "assets/graphics/LoadingBar_Outer.png"), this.load.image("LoadingBar_Inner", "assets/graphics/LoadingBar_Inner.png")
  34. }, b.prototype.create = function() {
  35. var a = this.game.scale;
  36. a.scaleMode = Phaser.ScaleManager.SHOW_ALL, a.minWidth = 160, a.minHeight = 208, a.sourceAspectRatio = this.game.scale.minWidth / this.game.scale.minHeight, a.pageAlignHorizontally = !0, a.pageAlignVertically = !0, this.game.device.desktop || a.forceOrientation(!1, !0), a.enterIncorrectOrientation.add(this.onEnterIncorrectOrientation, this), a.leaveIncorrectOrientation.add(this.onLeaveIncorrectOrientation, this), a.setScreenSize(!0), this.input.maxPointers = 1, this.stage.disableVisibilityChange = !0, this.stage.backgroundColor = 11320911, this.game.state.start("Preloader", !0, !1)
  37. }, b.prototype.onEnterIncorrectOrientation = function() {
  38. document.getElementById("orientation").style.display = "block", document.body.style.marginBottom = "0px"
  39. }, b.prototype.onLeaveIncorrectOrientation = function() {
  40. document.getElementById("orientation").style.display = "none", document.body.style.marginBottom = "100px", this.game.device.android && !this.game.device.chrome && this.game.scale.setScreenSize(!0)
  41. }, b
  42. }(Phaser.State);
  43. a.Boot = b
  44. }(game || (game = {}));
  45. var game;
  46. ! function(a) {
  47. ! function(a) {
  48. a[a.COMMON = 0] = "COMMON", a[a.SAND = 1] = "SAND", a[a.WATER = 2] = "WATER"
  49. }(a.TileType || (a.TileType = {}));
  50. var b = (a.TileType, function(a) {
  51. function b(b, c, d, e) {
  52. a.call(this, b, c, d, "levelGraphics", e), this.tileType = 0, this.setAnchorByFrameName(e), this.updateRowAndColumn()
  53. }
  54. return __extends(b, a), b.prototype.setAnchorByFrameName = function(a) {
  55. var b = game.CommonTile.ANCHORS[a];
  56. b ? this.anchor.set(b.x, b.y) : this.anchor.set(.5, .5)
  57. }, b.prototype.updateRowAndColumn = function() {
  58. this._row = Math.floor(this.y / b.SIZE), this._column = Math.floor(this.x / b.SIZE)
  59. }, Object.defineProperty(b.prototype, "row", {
  60. get: function() {
  61. return this._row
  62. },
  63. enumerable: !0,
  64. configurable: !0
  65. }), Object.defineProperty(b.prototype, "column", {
  66. get: function() {
  67. return this._column
  68. },
  69. enumerable: !0,
  70. configurable: !0
  71. }), b.SIZE = 70, b.ANCHORS = {
  72. GroundTile_10000: new Phaser.Point(.5, .44),
  73. GroundTile_20000: new Phaser.Point(.5, .4),
  74. GroundTile_30000: new Phaser.Point(.5, .46),
  75. SandTile0000: new Phaser.Point(.5, .4),
  76. WaterTile0000: new Phaser.Point(.5, .37)
  77. }, b
  78. }(Phaser.Image));
  79. a.CommonTile = b
  80. }(game || (game = {}));
  81. var game;
  82. ! function(a) {
  83. var b = function(b) {
  84. function c() {
  85. b.apply(this, arguments)
  86. }
  87. return __extends(c, b), c.prototype.preload = function() {
  88. if (a.Main.development === !1) {
  89. var b = this.add.image(0, 0, "LoadingBar_Outer");
  90. b.anchor.set(.5, .5), b.x = a.Config.HALF_GAME_WIDTH - .5, b.y = a.Config.HALF_GAME_HEIGHT;
  91. var c = this.game.add.sprite(0, 0, "LoadingBar_Inner");
  92. c.x = a.Config.HALF_GAME_WIDTH - .5 * c.width - .5, c.y = a.Config.HALF_GAME_HEIGHT - .5 * c.height - 1.5, this.load.setPreloadSprite(c)
  93. }
  94. this.game.device.webAudio && (this.load.audio("sand_block", ["assets/audio/SandTile.wav"], !0), this.load.audio("valve", ["assets/audio/valve.wav"], !0), this.load.audio("tap", ["assets/audio/TapSound.wav"], !0), this.load.audio("water", ["assets/audio/WaterSound.wav"], !0), this.load.audio("levelComplete", ["assets/audio/LevelCompleteSound.wav"], !0)), this.load.audio("main_loop", ["assets/audio/MainLoop.ogg", "assets/audio/MainLoop.m4a"], !0), this.load.atlasJSONHash("valve", "assets/graphics/valve.png", "assets/graphics/valve.json"), this.load.atlasJSONHash("flower", "assets/graphics/flower.png", "assets/graphics/flower.json"), this.load.atlasJSONHash("gnome", "assets/graphics/gnome.png", "assets/graphics/gnome.json"), this.load.atlasJSONHash("tutorial_hand", "assets/graphics/tutorial_hand.png", "assets/graphics/tutorial_hand.json"), this.load.atlasJSONHash("levelGraphics", "assets/graphics/levelGraphics.png", "assets/graphics/levelGraphics.json"), this.load.atlasJSONHash("gui", "assets/graphics/gui.png", "assets/graphics/gui.json"), this.load.image("lr_logo", "assets/graphics/LR_logo.png"), a.Main.development ? this.load.json("startLevel", "assets/levels/StartLevel.json") : this.load.json("levelConfigs", "assets/levels/Levels.json")
  95. }, c.prototype.create = function() {
  96. if (this.prepareTextures(), this.game.cache.removeImage("LoadingBar_Outer"), this.game.cache.removeImage("LoadingBar_Inner"), a.Main.development) {
  97. this.cache.getJSON("startLevel").level
  98. }
  99. this.game.state.start("MainMenu", !0, !1, !0)
  100. }, c.prototype.prepareTextures = function() {
  101. this.prepareBackground(), this.prepareTopRow(), this.prepareLockLevelIcon()
  102. }, c.prototype.prepareBackground = function() {
  103. for (var b = new Phaser.Image(this.game, 0, 0, "levelGraphics", "BgTile_Light0000"), c = new Phaser.Image(this.game, 0, 0, "levelGraphics", "BgTile_Dark0000"), d = Math.ceil(a.Config.GAME_HEIGHT / a.CommonTile.SIZE) + 1, e = Math.ceil(a.Config.GAME_WIDTH / a.CommonTile.SIZE) + 1, f = new Phaser.RenderTexture(this.game, a.Config.GAME_WIDTH, a.Config.GAME_HEIGHT), g = 5, h = -a.CommonTile.SIZE + 4, i = 0; d > i; i++) {
  104. for (var j = 0; e / 2 > j; j++) f.renderXY(b, g, h), g += 2 * a.CommonTile.SIZE;
  105. g = i % 2 == 0 ? 5 : 5 + a.CommonTile.SIZE, h += a.CommonTile.SIZE
  106. }
  107. g = 5 + 2 * a.CommonTile.SIZE, h = -a.CommonTile.SIZE + 4;
  108. for (var i = 0; d > i; i++) {
  109. for (var j = 0; e / 2 > j; j++) f.renderXY(c, g - 5, h - 6), g += 2 * a.CommonTile.SIZE;
  110. g = i % 2 == 0 ? 5 + a.CommonTile.SIZE : 5, h += a.CommonTile.SIZE
  111. }
  112. this.cache.addRenderTexture("levelBackground", f), b.destroy(), c.destroy()
  113. }, c.prototype.prepareTopRow = function() {
  114. for (var b = new Phaser.Image(this.game, 0, 0, "levelGraphics", "GroundTile_20000"), c = 0, d = 0, e = new Phaser.RenderTexture(this.game, a.Config.GAME_WIDTH, b.height), f = 0; 11 > f; f++) e.renderXY(b, c, d), c += a.CommonTile.SIZE;
  115. b.destroy(), this.cache.addRenderTexture("topRow", e)
  116. }, c.prototype.prepareLockLevelIcon = function() {
  117. var a = new Phaser.Image(this.game, 0, 0, "gui", "Button_Base0000"),
  118. b = new Phaser.Image(this.game, 0, 0, "gui", "LevelIcon_Lock0000"),
  119. c = new Phaser.RenderTexture(this.game, a.width, a.height);
  120. c.renderXY(a, 0, 0), c.renderXY(b, .5 * (a.width - b.width) + 1, .5 * (a.height - b.height) - 3, !1), this.cache.addRenderTexture("lockedLevelIcon", c), a.destroy(), b.destroy()
  121. }, c
  122. }(Phaser.State);
  123. a.Preloader = b
  124. }(game || (game = {}));
  125. var game;
  126. ! function(a) {
  127. var b = function(a) {
  128. function b(b, c, d, e) {
  129. var f = this;
  130. a.call(this, b, c, d, "gui", e), this._callback = new Phaser.Signal, this.anchor.set(.5, .5), this.inputEnabled = !0, this.game.device.desktop && (this.input.useHandCursor = !0), this.inputEnabled && (this.events.onInputDown.add(function() {
  131. f.game.device.webAudio && f.game.sound.play("tap"), f.tint *= .995, f.game.add.tween(f.scale).to({
  132. x: .9,
  133. y: .9
  134. }, 200, Phaser.Easing.Cubic.Out, !0)
  135. }), this.events.onInputUp.add(function() {
  136. f.tint = 16777215, f.scale.set(1, 1)
  137. }, this, 1), this.events.onInputDown.add(function() {
  138. f.game.time.events.add(300, f._callback.dispatch, f, [f])
  139. }, this, 2))
  140. }
  141. return __extends(b, a), b.prototype.destroy = function() {
  142. a.prototype.destroy.call(this), this._callback.dispose()
  143. }, Object.defineProperty(b.prototype, "callback", {
  144. get: function() {
  145. return this._callback
  146. },
  147. enumerable: !0,
  148. configurable: !0
  149. }), b
  150. }(Phaser.Image);
  151. a.SimpleButton = b
  152. }(game || (game = {}));
  153. var game;
  154. ! function(a) {
  155. var b = function(a) {
  156. function b(b, c, d, e, f) {
  157. a.call(this, b, c, d, e), this.textureKey1 = e, this.textureKey2 = f, this.activeTextureKey = this.textureKey1, this._state = 1, this.events.onInputUp.add(this.switchTextures, this, 0)
  158. }
  159. return __extends(b, a), b.prototype.switchTextures = function() {
  160. this.activeTextureKey = this.activeTextureKey === this.textureKey1 ? this.textureKey2 : this.textureKey1, this.loadTexture("gui", this.activeTextureKey), this._state = this.activeTextureKey === this.textureKey1 ? 1 : 2
  161. }, Object.defineProperty(b.prototype, "state", {
  162. get: function() {
  163. return this._state
  164. },
  165. enumerable: !0,
  166. configurable: !0
  167. }), b
  168. }(game.SimpleButton);
  169. a.ToggleButton = b
  170. }(game || (game = {}));
  171. var game;
  172. ! function(a) {
  173. var b = function(b) {
  174. function c() {
  175. b.apply(this, arguments), this.fromPreloader = !1
  176. }
  177. return __extends(c, b), c.prototype.init = function(a) {
  178. this.fromPreloader = a
  179. }, c.prototype.create = function() {
  180. this.initImages(), this.initButtons(), this.initCredits(), this.initAnimation(), this.fromPreloader && (this.soundButton.input.enabled = !1, this.soundButton.switchTextures(), this.game.input.onTap.addOnce(this.startMusic, this), this.stage.disableVisibilityChange = !1, this.game.onBlur.add(this.onFocusLost, this), this.game.onFocus.add(this.onFocus, this))
  181. }, c.prototype.onFocusLost = function() {
  182. this.game.tweens.pauseAll(), a.Main.wasMuted = this.game.sound.mute, this.game.sound.mute = !0
  183. }, c.prototype.onFocus = function() {
  184. this.game.tweens.resumeAll(), a.Main.wasMuted === !1 && (this.game.sound.mute = !1)
  185. }, c.prototype.initImages = function() {
  186. this.add.image(-16, -75, "gui", "LevelsMenu_Background0000"), this.add.image(-1, a.Config.GAME_HEIGHT - 388, "gui", "MainMenu_Back0000"), this.title = this.add.image(0, 0, "gui", "GameTitle0000"), this.title.anchor.set(.5, .5), this.title.x = a.Config.HALF_GAME_WIDTH - .5, this.title.y = 150
  187. }, c.prototype.initButtons = function() {
  188. var b = this,
  189. c = 60;
  190. this.soundButton = new a.ToggleButton(this.game, a.Config.GAME_WIDTH - c, c, "Music_ON_Button0000", "Music_OFF_Button0000"), this.soundButton.callback.add(function() {
  191. b.game.sound.mute = !b.game.sound.mute
  192. }), this.game.sound.mute && this.soundButton.switchTextures(), this.playButton = new a.SimpleButton(this.game, a.Config.HALF_GAME_WIDTH, 350, "MainMenu_PlayButton0000"), this.playButton.callback.addOnce(function() {
  193. b.game.state.start("LevelsMenu")
  194. }, this), this.creditsButton = new a.SimpleButton(this.game, a.Config.GAME_WIDTH - c, a.Config.GAME_HEIGHT - c, "Credits_Button0000"), this.creditsButton.callback.add(this.toggleCredits, this), this.buttons = [this.playButton, this.soundButton, this.creditsButton], this.buttons.forEach(function(a) {
  195. b.world.add(a)
  196. })
  197. }, c.prototype.addLogo = function() {
  198. var b = this.game.add.image(45, a.Config.GAME_HEIGHT - 110, "lr_logo");
  199. b.inputEnabled = !0, b.input.useHandCursor = !0, b.events.onInputDown.add(this.gotoDevWebsite, this)
  200. }, c.prototype.gotoDevWebsite = function() {
  201. window.open("http://liquidrainbow.net", "_blank")
  202. }, c.prototype.initCredits = function() {
  203. this.credits = this.game.add.image(0, 0, "gui", "CreditsBoard0000"), this.credits.position.set(Math.round(.5 * (a.Config.GAME_WIDTH - this.credits.width)), Math.round(.5 * (a.Config.GAME_HEIGHT - this.credits.height))), this.credits.visible = !1
  204. }, c.prototype.toggleCredits = function() {
  205. this.credits.visible ? this.hideCredits() : this.showCredits()
  206. }, c.prototype.hideCredits = function() {
  207. var a = this;
  208. this.game.add.tween(this.credits).to({
  209. y: this.credits.y + 200,
  210. alpha: 0
  211. }, 500, Phaser.Easing.Back.In, !0).onComplete.addOnce(function() {
  212. a.playButton.input.enabled = !0, a.creditsButton.input.enabled = !0, a.credits.visible = !1
  213. }, this)
  214. }, c.prototype.showCredits = function() {
  215. var b = this;
  216. this.credits.visible = !0, this.credits.alpha = 0, this.credits.y = Math.round(.5 * (a.Config.GAME_HEIGHT - this.credits.height)) + 200, this.game.add.tween(this.credits).to({
  217. y: this.credits.y - 200,
  218. alpha: 1
  219. }, 500, Phaser.Easing.Back.Out, !0), this.playButton.input.enabled = !1, this.creditsButton.input.enabled = !1, this.game.input.onTap.addOnce(function() {
  220. b.hideCredits()
  221. }, this)
  222. }, c.prototype.startMusic = function() {
  223. this.game.sound.play("main_loop", .33, !0), this.soundButton.switchTextures(), this.soundButton.input.enabled = !0
  224. }, c.prototype.initAnimation = function() {
  225. var a = this;
  226. this.title.y -= 280, this.game.add.tween(this.title).to({
  227. y: this.title.y + 280
  228. }, 600, Phaser.Easing.Back.Out, !0, 300);
  229. var b = 800;
  230. this.buttons.forEach(function(c) {
  231. c.scale.set(0, 0), a.game.add.tween(c.scale).to({
  232. x: 1,
  233. y: 1
  234. }, 300, Phaser.Easing.Back.Out, !0, b), b += 200
  235. })
  236. }, c.prototype.destroy = function() {
  237. this.buttons = null
  238. }, c
  239. }(Phaser.State);
  240. a.MainMenu = b
  241. }(game || (game = {}));
  242. var game;
  243. ! function(a) {
  244. var b = function(a) {
  245. function b(b, c, d, e, f) {
  246. var g = this;
  247. void 0 === f && (f = !1), a.call(this, b, c, d, "gui", "Button_Base0000"), this.inputEnabled = !f, this.locked = f, this._levelNumber = e, this.anchor.set(.5, .5), this.createGraphics(), this.inputEnabled && (this.game.device.desktop && (this.input.useHandCursor = !0), this.events.onInputDown.add(function() {
  248. g.game.sound.play("tap", .75), g.tint *= .995, g.game.add.tween(g.scale).to({
  249. x: .9,
  250. y: .9
  251. }, 200, Phaser.Easing.Cubic.Out, !0)
  252. }), this.events.onInputUp.add(function() {
  253. g.tint = 16777215, g.game.add.tween(g.scale).to({
  254. x: 1,
  255. y: 1
  256. }, 200, Phaser.Easing.Cubic.Out, !0)
  257. }))
  258. }
  259. return __extends(b, a), b.prototype.createGraphics = function() {
  260. this.locked ? this.createLockedGraphics() : this.createUnlockedGraphics()
  261. }, b.prototype.createLockedGraphics = function() {
  262. var a = "lockedLevelIcon",
  263. b = this.game.cache.getTexture(a);
  264. this.setTexture(b.texture)
  265. }, b.prototype.createUnlockedGraphics = function() {
  266. var a = {
  267. font: "48px TF2 Build",
  268. fill: "#A07B08",
  269. align: "center"
  270. },
  271. b = this.game.add.text(0, 0, this._levelNumber.toString(), a);
  272. b.anchor.set(.5, .5);
  273. var c = this.game.add.renderTexture(this.width, this.height);
  274. c.renderXY(this, .5 * this.width, .5 * this.height), c.renderXY(b, Math.floor(.5 * this.width), Math.floor(.5 * this.height) - 1), this.setTexture(c), b.destroy()
  275. }, Object.defineProperty(b.prototype, "levelNumber", {
  276. get: function() {
  277. return this._levelNumber
  278. },
  279. enumerable: !0,
  280. configurable: !0
  281. }), b
  282. }(Phaser.Image);
  283. a.LevelIcon = b
  284. }(game || (game = {}));
  285. var game;
  286. ! function(a) {
  287. var b = function(b) {
  288. function c() {
  289. b.call(this)
  290. }
  291. return __extends(c, b), c.prototype.create = function() {
  292. this.game.add.image(-16, 0, "gui", "LevelsMenu_Background0000"), this.initLevelIcons(), this.initButtons(), this.initAnimations()
  293. }, c.prototype.initLevelIcons = function() {
  294. this.levelIconsGroup = this.game.add.group(this.game.world, "LevelIcons Container"), this.levelIconsGroup.x = 85, this.levelIconsGroup.y = 150;
  295. for (var b = 118, c = 118, d = 59, e = 0, f = 1; f <= a.Config.LEVELS_NUM; f++) {
  296. var g = f,
  297. h = this.levelIsLocked(g),
  298. i = new a.LevelIcon(this.game, d - .5, e, g, h);
  299. h === !1 && i.events.onInputUp.add(this.onLevelIconInputUp, this, 2), this.levelIconsGroup.add(i), d += b, 4 === f && (d = 0, e += c), f > 4 && (f - 4) % 5 === 0 && (d = 0, e += c), 24 === f && (d = 59)
  300. }
  301. }, c.prototype.levelIsLocked = function(a) {
  302. if (1 === a) return !1;
  303. var b = a - 1;
  304. return !("true" === window.localStorage.getItem(b.toString()))
  305. }, c.prototype.onLevelIconInputUp = function(a) {
  306. var b = this;
  307. this.game.time.events.add(200, function() {
  308. var c = a.levelNumber;
  309. b.game.state.start("Level", !0, !1, c)
  310. }, this)
  311. }, c.prototype.initButtons = function() {
  312. var b = this,
  313. c = 60;
  314. this.backButton = new a.SimpleButton(this.game, c, c, "Back_Button0000"), this.backButton.callback.addOnce(function() {
  315. b.game.state.start("MainMenu")
  316. }, this), this.world.add(this.backButton), this.soundButton = new a.ToggleButton(this.game, a.Config.GAME_WIDTH - c, c, "Music_ON_Button0000", "Music_OFF_Button0000"), this.soundButton.callback.add(function() {
  317. b.game.sound.mute = !b.game.sound.mute
  318. }), this.game.sound.mute && this.soundButton.switchTextures(), this.world.add(this.soundButton)
  319. }, c.prototype.initAnimations = function() {
  320. this.levelIconsGroup.alpha = 0, this.levelIconsGroup.y += 200, this.game.add.tween(this.levelIconsGroup).to({
  321. y: this.levelIconsGroup.y - 200,
  322. alpha: 1
  323. }, 600, Phaser.Easing.Back.Out, !0, 300), this.backButton.x -= 300, this.game.add.tween(this.backButton).to({
  324. x: this.backButton.x + 300
  325. }, 300, Phaser.Easing.Back.Out, !0, 700), this.soundButton.x += 300, this.game.add.tween(this.soundButton).to({
  326. x: this.soundButton.x - 300
  327. }, 300, Phaser.Easing.Back.Out, !0, 700)
  328. }, c
  329. }(Phaser.State);
  330. a.LevelsMenu = b
  331. }(game || (game = {}));
  332. var game;
  333. ! function(a) {
  334. var b = function(a) {
  335. function b(b, c, d) {
  336. a.call(this, b, c, d, "SandTile0000"), this.tileType = 1, this.canBeDestroyed = !0
  337. }
  338. return __extends(b, a), b.prototype.startDestroyTween = function() {
  339. if (this.canBeDestroyed) {
  340. this.canBeDestroyed = !1;
  341. var a = 394,
  342. b = -18,
  343. c = Phaser.Math.distance(this.x, this.y, a, b),
  344. d = Math.max(500, 1.1 * c);
  345. this.game.add.tween(this).to({
  346. y: -15,
  347. x: 394
  348. }, d, Phaser.Easing.Cubic.Out, !0), this.game.add.tween(this.scale).to({
  349. x: 0,
  350. y: 0
  351. }, 300, Phaser.Easing.Cubic.Out, !0, d - 150).onComplete.addOnce(this.destroy, this)
  352. }
  353. }, b
  354. }(game.CommonTile);
  355. a.SandTile = b
  356. }(game || (game = {}));
  357. var game;
  358. ! function(a) {
  359. var b = function(a) {
  360. function b(b, c, d) {
  361. a.call(this, b, c, d, "WaterTile0000"), this.tileType = 2, this._onWaterArriveComplete = new Phaser.Signal
  362. }
  363. return __extends(b, a), b.prototype.startAddAnimation = function(a) {
  364. var b = this,
  365. c = 400;
  366. this.scale.set(.5, .5), this.alpha = 0, this.addTween = this.game.add.tween(this.scale).to({
  367. x: 1,
  368. y: 1
  369. }, .66 * c, Phaser.Easing.Cubic.Out, !0, a), this.addTween.onStart.addOnce(function() {
  370. b.alpha = 1
  371. }), this.addTween.onComplete.addOnce(this._onWaterArriveComplete.dispatch, this)
  372. }, b.prototype.startRemoveAnimation = function() {
  373. this.addTween && this.addTween.isRunning && this.addTween.stop(), this.removeTween = this.game.add.tween(this).to({
  374. y: this.y - 8,
  375. alpha: 0
  376. }, 300, Phaser.Easing.Linear.None, !0), this.removeTween.onComplete.addOnce(this.destroy, this)
  377. }, b.prototype.destroy = function(b) {
  378. void 0 === b && (b = !0), this.addTween && this.game.tweens.remove(this.addTween), this.removeTween && this.game.tweens.remove(this.removeTween), a.prototype.destroy.call(this, b), this._onWaterArriveComplete.dispose(), this._onWaterArriveComplete = null
  379. }, Object.defineProperty(b.prototype, "onWaterArriveComplete", {
  380. get: function() {
  381. return this._onWaterArriveComplete
  382. },
  383. enumerable: !0,
  384. configurable: !0
  385. }), b
  386. }(game.CommonTile);
  387. a.WaterTile = b
  388. }(game || (game = {}));
  389. var game;
  390. ! function(a) {
  391. ! function(a) {
  392. a[a.FLOWER = 0] = "FLOWER", a[a.PIPE = 1] = "PIPE", a[a.GNOME = 2] = "GNOME", a[a.VALVE = 3] = "VALVE"
  393. }(a.GameObjectType || (a.GameObjectType = {}));
  394. a.GameObjectType
  395. }(game || (game = {}));
  396. var game;
  397. ! function(a) {
  398. var b = function(a) {
  399. function b(b, c, d, e) {
  400. a.call(this, b, c, d, "levelGraphics", e), this.initialY = this.y, this.anchor.set(.5, .5);
  401. var f = this.game.rnd.integerInRange(2500, 4e3);
  402. this.shakeEvent = this.game.time.events.loop(f, this.shake, this)
  403. }
  404. return __extends(b, a), b.prototype.shake = function() {
  405. var a = this;
  406. this.visible !== !1 && this.game.add.tween(this).to({
  407. y: this.y + 5
  408. }, 150, Phaser.Easing.Linear.None, !0, 0, 3, !0).onComplete.addOnce(function() {
  409. a.y = a.initialY
  410. }, this)
  411. }, b.prototype.show = function() {
  412. this.y = this.initialY, this.alpha = 0, this.visible = !0, this.game.add.tween(this).to({
  413. alpha: 1
  414. }, 300, Phaser.Easing.Linear.None, !0)
  415. }, b.prototype.hide = function() {
  416. var a = this;
  417. this.game.add.tween(this).to({
  418. alpha: 0
  419. }, 300, Phaser.Easing.Linear.None, !0).onComplete.addOnce(function() {
  420. a.visible = !1
  421. }, this)
  422. }, b.prototype.clearShakeEvent = function() {
  423. this.shakeEvent && (this.game.time.events.remove(this.shakeEvent), this.shakeEvent = null)
  424. }, b.prototype.destroy = function() {
  425. this.clearShakeEvent(), a.prototype.destroy.call(this)
  426. }, b
  427. }(Phaser.Image);
  428. a.BubbleTalk = b
  429. }(game || (game = {}));
  430. var utils;
  431. ! function(a) {
  432. var b = function() {
  433. function a() {}
  434. return a.range = function(a, b, c) {
  435. arguments.length <= 1 && (b = a || 0, a = 0), c = arguments[2] || 1;
  436. for (var d = Math.max(Math.ceil((b - a) / c), 0), e = 0, f = new Array(d); d > e;) f[e++] = a, a += c;
  437. return f
  438. }, a
  439. }();
  440. a.ArrayUtil = b
  441. }(utils || (utils = {}));
  442. var game;
  443. ! function(a) {
  444. var b = function(a) {
  445. function b(b, c, d) {
  446. a.call(this, b, c, d, "flower"), this._objectType = 0, this._hasWater = !1, this.anchor.set(.45, 1), this.setRowAndColumn(), this.initAnimations()
  447. }
  448. return __extends(b, a), b.prototype.setRowAndColumn = function() {
  449. this._row = Math.floor(this.y / game.CommonTile.SIZE), this._column = Math.floor(this.x / game.CommonTile.SIZE)
  450. }, b.prototype.initAnimations = function() {
  451. this.addAnimation("water", 0, 55), this.addAnimation("no_water", 56, 57), this.animations.play("no_water")
  452. }, b.prototype.addAnimation = function(a, b, c) {
  453. var d = utils.ArrayUtil.range(b, c + 1);
  454. this.animations.add(a, d, 30, !0)
  455. }, b.prototype.updateWater = function(a, b) {
  456. this._hasWater !== a && (this._hasWater = a, this.clearWaterDelayedEvent(), b > 0 ? this.delayedWaterEvent = this._hasWater ? this.game.time.events.add(b, this.onWaterArrive, this) : this.game.time.events.add(200, this.onWaterLeft, this) : this._hasWater ? this.onWaterArrive() : this.onWaterLeft())
  457. }, b.prototype.clearWaterDelayedEvent = function() {
  458. this.delayedWaterEvent && (this.game.time.events.remove(this.delayedWaterEvent), this.delayedWaterEvent = null)
  459. }, b.prototype.onWaterArrive = function() {
  460. this.scale.set(.33, .33), this.alpha = .5, this.game.add.tween(this.scale).to({
  461. x: 1,
  462. y: 1
  463. }, 500, Phaser.Easing.Back.Out, !0), this.game.add.tween(this).to({
  464. alpha: 1
  465. }, 250, Phaser.Easing.Linear.None, !0), this.animations.play("water"), this._bubbleTalk && this._bubbleTalk.hide()
  466. }, b.prototype.onWaterLeft = function() {
  467. this.alpha = .5, this.game.add.tween(this).to({
  468. alpha: 1
  469. }, 250, Phaser.Easing.Linear.None, !0), this.animations.play("no_water"), this._bubbleTalk && this._bubbleTalk.show()
  470. }, b.prototype.destroy = function() {
  471. a.prototype.destroy.call(this), this._bubbleTalk = null
  472. }, Object.defineProperty(b.prototype, "row", {
  473. get: function() {
  474. return this._row
  475. },
  476. enumerable: !0,
  477. configurable: !0
  478. }), Object.defineProperty(b.prototype, "column", {
  479. get: function() {
  480. return this._column
  481. },
  482. enumerable: !0,
  483. configurable: !0
  484. }), Object.defineProperty(b.prototype, "objectType", {
  485. get: function() {
  486. return this._objectType
  487. },
  488. enumerable: !0,
  489. configurable: !0
  490. }), Object.defineProperty(b.prototype, "hasWater", {
  491. get: function() {
  492. return this._hasWater
  493. },
  494. enumerable: !0,
  495. configurable: !0
  496. }), Object.defineProperty(b.prototype, "bubbleTalk", {
  497. set: function(a) {
  498. this._bubbleTalk = a
  499. },
  500. enumerable: !0,
  501. configurable: !0
  502. }), b
  503. }(Phaser.Sprite);
  504. a.Flower = b
  505. }(game || (game = {}));
  506. var game;
  507. ! function(a) {
  508. var b = function(a) {
  509. function b(b, c, d) {
  510. a.call(this, b, c, d, "valve"), this._objectType = 3, this.canPump = !0, this._pumpSignal = new Phaser.Signal, this.anchor.set(.5, .5), this.initInput(), this.initAnimations(), this.setRowAndColumn()
  511. }
  512. return __extends(b, a), b.prototype.setRowAndColumn = function() {
  513. this._row = Math.floor(this.y / game.CommonTile.SIZE), this._column = Math.floor(this.x / game.CommonTile.SIZE)
  514. }, b.prototype.initInput = function() {
  515. this.inputEnabled = !0, this.input.useHandCursor = !0, this.events.onInputDown.add(this.onTap, this)
  516. }, b.prototype.onTap = function() {
  517. this.canPump && (this.canPump = !1, this.animations.play("main", 60, !1), this._pumpSignal.dispatch(this))
  518. }, b.prototype.initAnimations = function() {
  519. this.animations.add("main", null, 60), this.events.onAnimationComplete.add(this.onAnimationComplete, this)
  520. }, b.prototype.onAnimationComplete = function() {
  521. this.animations.frame = 0, this.canPump = !0
  522. }, b.prototype.destroy = function() {
  523. a.prototype.destroy.call(this), this._pumpSignal.dispose(), this._pumpSignal = null
  524. }, Object.defineProperty(b.prototype, "row", {
  525. get: function() {
  526. return this._row
  527. },
  528. enumerable: !0,
  529. configurable: !0
  530. }), Object.defineProperty(b.prototype, "column", {
  531. get: function() {
  532. return this._column
  533. },
  534. enumerable: !0,
  535. configurable: !0
  536. }), Object.defineProperty(b.prototype, "objectType", {
  537. get: function() {
  538. return this._objectType
  539. },
  540. enumerable: !0,
  541. configurable: !0
  542. }), Object.defineProperty(b.prototype, "pumpSignal", {
  543. get: function() {
  544. return this._pumpSignal
  545. },
  546. enumerable: !0,
  547. configurable: !0
  548. }), b
  549. }(Phaser.Sprite);
  550. a.Valve = b
  551. }(game || (game = {}));
  552. var game;
  553. ! function(a) {
  554. var b = function(a) {
  555. function b(b, c, d) {
  556. a.call(this, b, c, d, "gnome"), this._objectType = 2, this._hasWater = !1, this.anchor.set(.5, .4), this.setRowAndColumn(), this.initAnimations()
  557. }
  558. return __extends(b, a), b.prototype.setRowAndColumn = function() {
  559. this._row = Math.floor(this.y / game.CommonTile.SIZE), this._column = Math.floor(this.x / game.CommonTile.SIZE)
  560. }, b.prototype.initAnimations = function() {
  561. this.addAnimation("stay_in_water", 0, 0), this.addAnimation("wave_in_water", 1, 25), this.addAnimation("stay", 26, 26), this.addAnimation("shake", 27, 38), this.events.onAnimationComplete.add(this.onAnimationComplete, this), this.animations.play("stay")
  562. }, b.prototype.onAnimationComplete = function(a, b) {
  563. "wave_in_water" === b.name ? this.animations.play("stay_in_water") : "shake" === b.name && this.animations.play("stay")
  564. }, b.prototype.addAnimation = function(a, b, c, d) {
  565. void 0 === d && (d = 30);
  566. var e = utils.ArrayUtil.range(b, c + 1);
  567. return this.animations.add(a, e, d, !0, !0)
  568. }, b.prototype.updateWater = function(a, b) {
  569. this._hasWater !== a && (this._hasWater = a, this.clearWaterDelayedEvent(), b > 0 ? this.delayedWaterEvent = this._hasWater ? this.game.time.events.add(b, this.onWaterArrive, this) : this.game.time.events.add(200, this.onWaterLeft, this) : this._hasWater ? this.onWaterArrive() : this.onWaterLeft())
  570. }, b.prototype.onWaterArrive = function() {
  571. var a = this;
  572. this.clearRepeatAnimationEvent(), this.animations.play("stay_in_water"), this.repeatAnimEvent = this.game.time.events.loop(5e3, function() {
  573. a.animations.play("wave_in_water", 30, !1)
  574. }, this), this._bubbleTalk.show()
  575. }, b.prototype.onWaterLeft = function() {
  576. var a = this;
  577. this.clearRepeatAnimationEvent(), this.animations.play("stay"), this.repeatAnimEvent = this.game.time.events.loop(3e3, function() {
  578. a.animations.play("shake", 30, !1)
  579. }, this), this._bubbleTalk.hide()
  580. }, b.prototype.clearWaterDelayedEvent = function() {
  581. this.delayedWaterEvent && (this.game.time.events.remove(this.delayedWaterEvent), this.delayedWaterEvent = null)
  582. }, b.prototype.clearRepeatAnimationEvent = function() {
  583. this.repeatAnimEvent && (this.game.time.events.remove(this.repeatAnimEvent), this.repeatAnimEvent = null)
  584. }, b.prototype.destroy = function() {
  585. a.prototype.destroy.call(this)
  586. }, Object.defineProperty(b.prototype, "row", {
  587. get: function() {
  588. return this._row
  589. },
  590. enumerable: !0,
  591. configurable: !0
  592. }), Object.defineProperty(b.prototype, "column", {
  593. get: function() {
  594. return this._column
  595. },
  596. enumerable: !0,
  597. configurable: !0
  598. }), Object.defineProperty(b.prototype, "objectType", {
  599. get: function() {
  600. return this._objectType
  601. },
  602. enumerable: !0,
  603. configurable: !0
  604. }), Object.defineProperty(b.prototype, "hasWater", {
  605. get: function() {
  606. return this._hasWater
  607. },
  608. enumerable: !0,
  609. configurable: !0
  610. }), Object.defineProperty(b.prototype, "bubbleTalk", {
  611. set: function(a) {
  612. this._bubbleTalk = a
  613. },
  614. enumerable: !0,
  615. configurable: !0
  616. }), b
  617. }(Phaser.Sprite);
  618. a.Gnome = b
  619. }(game || (game = {}));
  620. var game;
  621. ! function(a) {
  622. var b = function(a) {
  623. function b(b, c, d, e, f, g) {
  624. a.call(this, b, c, d, "levelGraphics", e), this._objectType = 1, this._hasWater = !1, this._pipeName = f, this._linkedPipeName = g, this.anchor.set(.5, .5), this._waterSignal = new Phaser.Signal, this.setRowAndColumn()
  625. }
  626. return __extends(b, a), b.prototype.setRowAndColumn = function() {
  627. this._row = Math.floor(this.y / game.CommonTile.SIZE), this._column = Math.floor(this.x / game.CommonTile.SIZE)
  628. }, b.prototype.dispatchWater = function() {
  629. this._linkedPipe.hasWater && this._hasWater === !1 && this.game.time.events.add(300, this.dispatchWaterAfterDelay, this)
  630. }, b.prototype.dispatchWaterAfterDelay = function() {
  631. this._linkedPipe.hasWater && this._hasWater === !1 && (this._waterSignal.dispatch(this), this.game.add.tween(this.scale).to({
  632. x: 1.2,
  633. y: .8
  634. }, 100, Phaser.Easing.Linear.None, !0).to({
  635. x: 1,
  636. y: 1.25
  637. }, 200, Phaser.Easing.Back.Out).to({
  638. x: 1,
  639. y: 1
  640. }, 100, Phaser.Easing.Linear.None))
  641. }, b.prototype.updateWater = function(a, b) {
  642. !this._hasWater && a ? (this._hasWater = !0, this.clearWaterDelayedEvent(), this.delayedWaterEvent = this.game.time.events.add(b, this.onWaterArrive, this)) : a || (this._hasWater = !1)
  643. }, b.prototype.onWaterArrive = function() {
  644. this._linkedPipe.dispatchWater()
  645. }, b.prototype.clearWaterDelayedEvent = function() {
  646. this.delayedWaterEvent && (this.game.time.events.remove(this.delayedWaterEvent), this.delayedWaterEvent = null)
  647. }, b.prototype.destroy = function() {
  648. a.prototype.destroy.call(this), this._linkedPipe = null
  649. }, Object.defineProperty(b.prototype, "row", {
  650. get: function() {
  651. return this._row
  652. },
  653. enumerable: !0,
  654. configurable: !0
  655. }), Object.defineProperty(b.prototype, "column", {
  656. get: function() {
  657. return this._column
  658. },
  659. enumerable: !0,
  660. configurable: !0
  661. }), Object.defineProperty(b.prototype, "objectType", {
  662. get: function() {
  663. return this._objectType
  664. },
  665. enumerable: !0,
  666. configurable: !0
  667. }), Object.defineProperty(b.prototype, "waterSignal", {
  668. get: function() {
  669. return this._waterSignal
  670. },
  671. enumerable: !0,
  672. configurable: !0
  673. }), Object.defineProperty(b.prototype, "pipeName", {
  674. get: function() {
  675. return this._pipeName
  676. },
  677. enumerable: !0,
  678. configurable: !0
  679. }), Object.defineProperty(b.prototype, "linkedPipeName", {
  680. get: function() {
  681. return this._linkedPipeName
  682. },
  683. enumerable: !0,
  684. configurable: !0
  685. }), Object.defineProperty(b.prototype, "linkedPipe", {
  686. set: function(a) {
  687. this._linkedPipe = a
  688. },
  689. enumerable: !0,
  690. configurable: !0
  691. }), Object.defineProperty(b.prototype, "hasWater", {
  692. get: function() {
  693. return this._hasWater
  694. },
  695. enumerable: !0,
  696. configurable: !0
  697. }), b
  698. }(Phaser.Image);
  699. a.Pipe = b
  700. }(game || (game = {}));
  701. var game;
  702. ! function(a) {
  703. var b = function() {
  704. function a(a) {
  705. this.grid = a, this.stack = []
  706. }
  707. return a.prototype.fillWithWater = function(a, b) {
  708. this.stack.length = 0, this.stack.push(a, b);
  709. for (var c = []; this.stack.length > 0;) {
  710. var d = this.stack.pop(),
  711. e = this.stack.pop();
  712. c.push(this.grid.addWaterTile(d, e)), d - 1 >= 0 && this.grid.tileIsEmpty(d - 1, e) && this.notInStack(e, d - 1) && this.stack.push(e, d - 1), e + 1 < this.grid.columns && this.grid.tileIsEmpty(d, e + 1) && this.notInStack(e + 1, d) && this.stack.push(e + 1, d), d + 1 < this.grid.rows && this.grid.tileIsEmpty(d + 1, e) && this.notInStack(e, d + 1) && this.stack.push(e, d + 1), e - 1 >= 0 && this.grid.tileIsEmpty(d, e - 1) && this.notInStack(e - 1, d) && this.stack.push(e - 1, d)
  713. }
  714. for (var f = 0; f < c.length; f++) {
  715. var g = c[f],
  716. h = utils.MathUtil.distance(a, b, g.column, g.row),
  717. i = 150 * h;
  718. g.startAddAnimation(i)
  719. }
  720. }, a.prototype.notInStack = function(a, b) {
  721. for (var c = 0; c < this.stack.length; c += 2)
  722. if (this.stack[c] == a && this.stack[c + 1] == b) return !1;
  723. return !0
  724. }, a.prototype.destroy = function() {
  725. this.stack.length = 0, this.stack = null, this.grid = null
  726. }, a
  727. }();
  728. a.WaterStrategy = b
  729. }(game || (game = {}));
  730. var game;
  731. ! function(a) {
  732. var b = function(b) {
  733. function c(c) {
  734. b.call(this, c, c.world, "grid"), this._rows = 11, this._columns = 9, this.sandTilesMoves = 0, this.tiles = [], this.pipes = [], this.gnomes = [], this.flowers = [], this.floodFillStrategy = new a.WaterStrategy(this), this._levelCompleteSignal = new Phaser.Signal, this._sandTilesChanged = new Phaser.Signal, this._valveUsed = new Phaser.Signal, this.tilesLayer = this.game.add.spriteBatch(this, "tiles"), this.valvesLayer = this.game.add.group(this, "valves"), this.objectsLayer = this.game.add.spriteBatch(this, "objects_1"), this.game.input.onDown.add(this.onTap, this)
  735. }
  736. return __extends(c, b), c.prototype.addTutorialSprite = function(a) {
  737. this.objectsLayer.add(a)
  738. }, c.prototype.addTile = function(a) {
  739. this.tilesLayer.add(a), this.addToTilesArray(a)
  740. }, c.prototype.addObject = function(a) {
  741. var b = this;
  742. switch (a.objectType) {
  743. case 2:
  744. this.gnomes.push(a);
  745. break;
  746. case 0:
  747. this.flowers.push(a);
  748. break;
  749. case 3:
  750. a.pumpSignal.add(this.transferWater, this);
  751. break;
  752. case 1:
  753. this.pipes.push(a), a.waterSignal.add(function(a) {
  754. b.floodFillAt(a.row, a.column)
  755. }, this)
  756. }
  757. 3 === a.objectType ? this.valvesLayer.add(a) : this.objectsLayer.add(a)
  758. }, c.prototype.transferWater = function(a) {
  759. var b = this;
  760. this.game.device.webAudio && this.game.sound.play("valve"), this._valveUsed.dispatch();
  761. for (var c = this.getNeighbours(a.row, a.column), d = [], e = [], f = 0; f < c.length; f++) {
  762. var g = c[f];
  763. if (void 0 === g) {
  764. var h = new Phaser.Point;
  765. 0 == f ? (h.x = a.column, h.y = a.row - 1) : 1 == f ? (h.x = a.column + 1, h.y = a.row) : 2 == f ? (h.x = a.column, h.y = a.row + 1) : (h.x = a.column - 1, h.y = a.row), e.push(h)
  766. } else g && 2 === g.tileType && d.push(g)
  767. }
  768. e.length > 0 && d.length > 0 && (d.forEach(function(a) {
  769. b.removeWaterFrom(a.row, a.column)
  770. }), e.forEach(function(a) {
  771. b.floodFillAt(a.y, a.x)
  772. }))
  773. }, c.prototype.removeWaterFrom = function(a, b) {
  774. var c = this.getTileAt(a, b);
  775. c && 2 === c.tileType && (c.startRemoveAnimation(), this.removeFromTilesArray(c), this.removeWaterFrom(a - 1, b), this.removeWaterFrom(a, b + 1), this.removeWaterFrom(a + 1, b), this.removeWaterFrom(a, b - 1))
  776. }, c.prototype.onTap = function(a) {
  777. var b = a.x - this.x,
  778. c = a.y - this.y;
  779. if (this.inBounds(a.x, a.y)) {
  780. var d = this.getTileUnderPoint(b, c);
  781. if (d && 1 === d.tileType) {
  782. var e = d;
  783. e.startDestroyTween(), this.onSandTileRemove(e), this.sandTilesMoves++, this._sandTilesChanged.dispatch(this.sandTilesMoves, "removed"), this.game.device.webAudio && this.game.sound.play("sand_block")
  784. } else if (!d && !this.isObjectUnderPoint(b, c) && this.canAddSandTile()) {
  785. var e = this.addSandTile(b, c);
  786. e.scale.setTo(.75, .75), this.game.add.tween(e.scale).to({
  787. x: 1,
  788. y: 1
  789. }, 150, Phaser.Easing.Cubic.Out, !0), this.sortTiles(), this.sandTilesMoves--, this._sandTilesChanged.dispatch(this.sandTilesMoves, "added"), this.game.device.webAudio && this.game.sound.play("sand_block")
  790. }
  791. }
  792. }, c.prototype.inBounds = function(a, b) {
  793. return this.bounds.contains(a, b)
  794. }, c.prototype.isObjectUnderPoint = function(a, b) {
  795. for (var c = Math.floor(b / game.CommonTile.SIZE), d = Math.floor(a / game.CommonTile.SIZE), e = 0; e < this.gnomes.length; e++) {
  796. var f = this.gnomes[e];
  797. if (f.row === c && f.column === d) return !0
  798. }
  799. for (var e = 0; e < this.pipes.length; e++) {
  800. var g = this.pipes[e];
  801. if (g.row === c && g.column === d) return !0
  802. }
  803. return !1
  804. }, c.prototype.canAddSandTile = function() {
  805. return this.sandTilesMoves > 0
  806. }, c.prototype.addSandTile = function(a, b) {
  807. var c = new game.SandTile(this.game, a, b);
  808. return this.addTile(c), this.alignTile(c), c
  809. }, c.prototype.alignTile = function(a) {
  810. a.x = a.column * game.CommonTile.SIZE + .5 * game.CommonTile.SIZE, a.y = a.row * game.CommonTile.SIZE + .5 * game.CommonTile.SIZE
  811. }, c.prototype.init = function() {
  812. this.bounds = new Phaser.Rectangle(this.x, this.y, this._columns * game.CommonTile.SIZE, this._rows * game.CommonTile.SIZE), this.linkPipes(), this.addBubbleTalks(), this.updateWaterDependants(!1), this.sortTiles()
  813. }, c.prototype.addBubbleTalks = function() {
  814. var a = this;
  815. this.flowers.forEach(function(b) {
  816. var c = new game.BubbleTalk(a.game, b.x - 26, b.y - 80, "WaterBubble0000");
  817. c.show(), a.objectsLayer.add(c), b.bubbleTalk = c
  818. }), this.gnomes.forEach(function(b) {
  819. var c = new game.BubbleTalk(a.game, b.x - 26, b.y - 40, "SadBubble0000");
  820. c.visible = !1, a.objectsLayer.add(c), b.bubbleTalk = c
  821. })
  822. }, c.prototype.linkPipes = function() {
  823. var a = this;
  824. this.pipes.forEach(function(b) {
  825. var c = a.getPipeByName(b.linkedPipeName);
  826. c && (b.linkedPipe = c)
  827. })
  828. }, c.prototype.getPipeByName = function(a) {
  829. for (var b = 0; b < this.pipes.length; b++) {
  830. var c = this.pipes[b];
  831. if (c.pipeName === a) return c
  832. }
  833. return null
  834. }, c.prototype.onSandTileRemove = function(a) {
  835. this.removeFromTilesArray(a), this.thereIsWaterAround(a.row, a.column) && this.floodFillAt(a.row, a.column)
  836. }, c.prototype.floodFillAt = function(a, b) {
  837. this.tileIsEmpty(a, b) && (this.game.device.webAudio && this.game.sound.play("water"), this.floodFillStrategy.fillWithWater(b, a), this.updateWaterDependants(!0, a, b), this.sortTiles())
  838. }, c.prototype.addWaterTile = function(a, b) {
  839. var c = b * game.CommonTile.SIZE + .5 * game.CommonTile.SIZE,
  840. d = a * game.CommonTile.SIZE + .5 * game.CommonTile.SIZE,
  841. e = new game.WaterTile(this.game, c, d);
  842. return this.addTile(e), e
  843. }, c.prototype.updateWaterDependants = function(a, b, c) {
  844. var d = this;
  845. void 0 === b && (b = 0), void 0 === c && (c = 0);
  846. var e = 0;
  847. this.flowers.forEach(function(f) {
  848. var g = d.thereIsWaterAround(f.row, f.column),
  849. h = a ? d.calculateDelay(b, c, f) : e;
  850. f.updateWater(g, h)
  851. }), this.gnomes.forEach(function(f) {
  852. var g = d.getTileAt(f.row, f.column),
  853. h = Boolean(g && 2 === g.tileType),
  854. i = a ? d.calculateDelay(b, c, f) : e;
  855. f.updateWater(h, i)
  856. }), this.pipes.forEach(function(f) {
  857. var g = d.getTileAt(f.row, f.column),
  858. h = Boolean(g && 2 === g.tileType),
  859. i = a ? d.calculateDelay(b, c, f) : e;
  860. f.updateWater(h, i)
  861. }), this.checkLevelComplete()
  862. }, c.prototype.calculateDelay = function(a, b, c) {
  863. var d = Phaser.Math.distance(b, a, c.column, c.row);
  864. return 150 * d
  865. }, c.prototype.checkLevelComplete = function() {
  866. this.allWaterDependantsHappy() && this.game.time.events.add(1500, this.doubleCheckLevelComplete, this)
  867. }, c.prototype.doubleCheckLevelComplete = function() {
  868. this.allWaterDependantsHappy() && (this.exists = !1, this.game.input.onDown.remove(this.onTap, this), this.valvesLayer.forEach(function(a) {
  869. a.inputEnabled = !1
  870. }, this, !0), this._levelCompleteSignal.dispatch())
  871. }, c.prototype.allWaterDependantsHappy = function() {
  872. var a = this.flowers.every(function(a) {
  873. return a.hasWater
  874. }),
  875. b = this.gnomes.every(function(a) {
  876. return a.hasWater === !1
  877. });
  878. return a && b
  879. }, c.prototype.thereIsWaterAround = function(a, b) {
  880. var c = this.getNeighbours(a, b),
  881. d = c.some(function(a) {
  882. return Boolean(a && 2 === a.tileType)
  883. });
  884. return d
  885. }, c.prototype.getNeighbours = function(a, b) {
  886. var c = a > 0 ? this.getTileAt(a - 1, b) : null,
  887. d = b < this._columns - 1 ? this.getTileAt(a, b + 1) : null,
  888. e = a < this._rows - 1 ? this.getTileAt(a + 1, b) : null,
  889. f = b > 0 ? this.getTileAt(a, b - 1) : null;
  890. return [c, d, e, f]
  891. }, c.prototype.getTileUnderPoint = function(a, b) {
  892. var c = Math.floor(b / game.CommonTile.SIZE),
  893. d = Math.floor(a / game.CommonTile.SIZE);
  894. return this.getTileAt(c, d)
  895. }, c.prototype.getTileAt = function(a, b) {
  896. if (0 > a || a > this._rows - 1 || 0 > b || b > this._columns - 1) return null;
  897. var c = this._columns,
  898. d = a * c + b;
  899. return this.tiles[d]
  900. }, c.prototype.getRandomCell = function() {
  901. var a = this.game.rnd.integerInRange(0, this.tiles.length - 1),
  902. b = this.tiles[a];
  903. return b
  904. }, c.prototype.tileIsEmpty = function(a, b) {
  905. var c = this.getTileAt(a, b);
  906. return void 0 === c
  907. }, c.prototype.addToTilesArray = function(a) {
  908. var b = this._columns,
  909. c = a.row * b + a.column;
  910. void 0 === this.tiles[c] && (this.tiles[c] = a)
  911. }, c.prototype.removeFromTilesArray = function(a) {
  912. var b = this.tiles.indexOf(a);
  913. b > -1 && delete this.tiles[b]
  914. }, c.prototype.sortTiles = function() {
  915. this.tilesLayer.sort("y")
  916. }, c.prototype.render = function() {
  917. this.renderLines()
  918. }, c.prototype.renderLines = function() {
  919. for (var a = game.CommonTile.SIZE, b = 0, c = game.CommonTile.SIZE, d = game.Config.GAME_HEIGHT, e = new Phaser.Line(a, b, c, d), f = 0; f < this._columns; f++) this.game.debug.geom(e, "0xffffff"), a = c = a + game.CommonTile.SIZE, e.setTo(a, b, c, d);
  920. a = 0, c = game.Config.GAME_WIDTH, b = 0, d = 0;
  921. for (var f = 0; f < this._rows; f++) b = d = b + game.CommonTile.SIZE, e.setTo(a, b, c, d), this.game.debug.geom(e, "0xffffff")
  922. }, c.prototype.destroy = function(a, c) {
  923. void 0 === a && (a = !0), void 0 === c && (c = !1), b.prototype.destroy.call(this, a, c), this.tiles = null, this.flowers = null, this.gnomes = null, this.bounds = null, this.pipes = null, this._sandTilesChanged.dispose(), this._sandTilesChanged = null, this._valveUsed.dispose(), this._valveUsed = null, this._levelCompleteSignal.dispose(), this._levelCompleteSignal = null, this.floodFillStrategy.destroy(), this.floodFillStrategy = null
  924. }, Object.defineProperty(c.prototype, "rows", {
  925. get: function() {
  926. return this._rows
  927. },
  928. enumerable: !0,
  929. configurable: !0
  930. }), Object.defineProperty(c.prototype, "columns", {
  931. get: function() {
  932. return this._columns
  933. },
  934. enumerable: !0,
  935. configurable: !0
  936. }), Object.defineProperty(c.prototype, "levelCompleteSignal", {
  937. get: function() {
  938. return this._levelCompleteSignal
  939. },
  940. enumerable: !0,
  941. configurable: !0
  942. }), Object.defineProperty(c.prototype, "sandTilesChanged", {
  943. get: function() {
  944. return this._sandTilesChanged
  945. },
  946. enumerable: !0,
  947. configurable: !0
  948. }), Object.defineProperty(c.prototype, "valveUsed", {
  949. get: function() {
  950. return this._valveUsed
  951. },
  952. enumerable: !0,
  953. configurable: !0
  954. }), c
  955. }(Phaser.Group);
  956. a.Grid = b
  957. }(game || (game = {}));
  958. var game;
  959. ! function(a) {
  960. var b = function() {
  961. function a(a) {
  962. this._levelNumber = a
  963. }
  964. return Object.defineProperty(a.prototype, "levelNumber", {
  965. get: function() {
  966. return this._levelNumber
  967. },
  968. enumerable: !0,
  969. configurable: !0
  970. }), a
  971. }();
  972. a.LevelSettings = b
  973. }(game || (game = {}));
  974. var utils;
  975. ! function(a) {
  976. var b = function() {
  977. function a() {}
  978. return a.distanceSquared = function(a, b, c, d) {
  979. var e = c - a,
  980. f = d - b;
  981. return e * e + f * f
  982. }, a.distance = function(b, c, d, e) {
  983. var f = a.distanceSquared(b, c, d, e);
  984. return Math.sqrt(f)
  985. }, a.DEG_TO_RAD = .017453292519943295, a.RAD_TO_DEG = 57.29577951308232, a
  986. }();
  987. a.MathUtil = b
  988. }(utils || (utils = {}));
  989. var utils;
  990. ! function(a) {
  991. var b = function(a) {
  992. function b(b, c, d) {
  993. void 0 === c && (c = 0), void 0 === d && (d = 0), a.call(this, b, b.world, "FPS Meter"), this.x = c, this.y = d, this.initBackground(), this.initText(), b.time.advancedTiming ? this.loopEvent = this.game.time.events.loop(500, this.updateText, this) : this.statsText.setText("error")
  994. }
  995. return __extends(b, a), b.prototype.initBackground = function() {
  996. var a = 80;
  997. this.bg = new Phaser.Graphics(this.game, 0, 0), this.bg.beginFill(0, 1), this.bg.drawRect(0, 0, a, 22), this.bg.endFill(), this.add(this.bg)
  998. }, b.prototype.initText = function() {
  999. var a = {
  1000. font: "18px Consolas",
  1001. fill: "#FFFFFF",
  1002. align: "center"
  1003. };
  1004. this.statsText = this.game.add.text(5, 0, "0 fps", a, this)
  1005. }, b.prototype.updateText = function() {
  1006. var a = "FPS: " + this.game.time.fps;
  1007. this.statsText.setText(a)
  1008. }, b.prototype.destroy = function() {
  1009. this.game.time.events.remove(this.loopEvent), this.loopEvent = null, a.prototype.destroy.call(this)
  1010. }, b
  1011. }(Phaser.Group);
  1012. a.FPSMeter = b
  1013. }(utils || (utils = {}));
  1014. var game;
  1015. ! function(a) {
  1016. var b = function() {
  1017. function a(a) {
  1018. this._levelNumber = a
  1019. }
  1020. return a.prototype.doReset = function() {
  1021. this.sheepsArrived = 0, this.allSheepsArrived = !1, this.startTime = 0
  1022. }, a.prototype.saveForReset = function() {}, Object.defineProperty(a.prototype, "levelNumber", {
  1023. get: function() {
  1024. return this._levelNumber
  1025. },
  1026. enumerable: !0,
  1027. configurable: !0
  1028. }), a
  1029. }();
  1030. a.LevelResult = b
  1031. }(game || (game = {}));
  1032. var game;
  1033. ! function(a) {
  1034. var b = function(a) {
  1035. function b(b, c, d, e) {
  1036. a.call(this, b, c, d, "debug_gui", e), this.inputEnabled = !0, this.input.useHandCursor = !0, this.anchor.set(.5, .5)
  1037. }
  1038. return __extends(b, a), b
  1039. }(Phaser.Image);
  1040. a.DebugButton = b
  1041. }(game || (game = {}));
  1042. var game;
  1043. ! function(a) {
  1044. var b = function(a) {
  1045. function b(b, c) {
  1046. a.call(this, b, c, "SandTilesLabel"), this.initBack(), this.initText()
  1047. }
  1048. return __extends(b, a), b.prototype.initBack = function() {
  1049. var a = new Phaser.Image(this.game, 0, 0, "gui", "SandTiles_Label0000");
  1050. this.add(a)
  1051. }, b.prototype.initText = function() {
  1052. var a = {
  1053. font: "42px TF2 Build",
  1054. fill: "#FDF490",
  1055. align: "center"
  1056. };
  1057. this.text = new Phaser.Text(this.game, 55, 6, "0", a), this.add(this.text)
  1058. }, b.prototype.updateText = function(a) {
  1059. this.text.setText(a.toString())
  1060. }, b
  1061. }(Phaser.SpriteBatch);
  1062. a.SandTilesLabel = b
  1063. }(game || (game = {}));
  1064. var game;
  1065. ! function(a) {
  1066. var b = function(a) {
  1067. function b(b, c, d) {
  1068. a.call(this, b, c, "Level Complete Board"), this.levelNumber = d, this.addBack(), this.addButtons(), this.board = this.game.add.image(-10, 250, "gui", "LevelCompleteBoard0000", this)
  1069. }
  1070. return __extends(b, a), b.prototype.addBack = function() {
  1071. var a = this.game.add.graphics(0, 0, this);
  1072. a.beginFill(0, .5), a.drawRect(0, 0, game.Config.GAME_WIDTH, game.Config.GAME_HEIGHT), a.endFill()
  1073. }, b.prototype.addButtons = function() {
  1074. var a = this,
  1075. b = 550,
  1076. c = 120,
  1077. d = new game.SimpleButton(this.game, game.Config.HALF_GAME_WIDTH, b, "Restart_Button0000");
  1078. d.callback.addOnce(function() {
  1079. a.game.state.start("Level", !0, !1, a.levelNumber)
  1080. }, this);
  1081. var e = new game.SimpleButton(this.game, d.x - c, b, "Menu_Button0000");
  1082. e.callback.addOnce(function() {
  1083. a.game.state.start("LevelsMenu")
  1084. }, this);
  1085. var f = new game.SimpleButton(this.game, d.x + c + .25, b, "Play_Button0000");
  1086. f.callback.addOnce(function() {
  1087. a.levelNumber === game.Config.LEVELS_NUM ? a.game.state.start("LevelsMenu") : a.game.state.start("Level", !0, !1, a.levelNumber + 1)
  1088. }, this), this.buttons = [e, d, f], this.buttons.forEach(function(b) {
  1089. a.add(b)
  1090. })
  1091. }, b.prototype.show = function() {
  1092. var a = this;
  1093. this.visible = !0, this.board.y -= 200, this.board.alpha = 0;
  1094. var b = 500;
  1095. this.game.add.tween(this.board).to({
  1096. alpha: 1
  1097. }, 200, Phaser.Easing.Linear.None, !0), this.game.add.tween(this.board).to({
  1098. y: this.board.y + 200
  1099. }, b, Phaser.Easing.Back.Out, !0);
  1100. var c = b;
  1101. this.buttons.forEach(function(d) {
  1102. d.y -= 200, d.visible = !1, a.game.add.tween(d).to({
  1103. y: d.y + 200
  1104. }, b, Phaser.Easing.Back.Out, !0, c).onStart.addOnce(function() {
  1105. d.visible = !0
  1106. }, a), c += 100
  1107. })
  1108. }, b
  1109. }(Phaser.Group);
  1110. a.LevelCompleteBoard = b
  1111. }(game || (game = {}));
  1112. var game;
  1113. ! function(a) {
  1114. var b = function(a) {
  1115. function b(b, c) {
  1116. a.call(this, b, b.world, "gui"), this.levelSettings = c, this.initSandTilesLabel(), this.initButtons(), this.initLevelCompleteBoard()
  1117. }
  1118. return __extends(b, a), b.prototype.initSandTilesLabel = function() {
  1119. this._sandTilesLabel = new game.SandTilesLabel(this.game, this), this._sandTilesLabel.position.set(375, 14)
  1120. }, b.prototype.initButtons = function() {
  1121. var a = this,
  1122. b = 45,
  1123. c = new game.SimpleButton(this.game, 505, b, "Restart_Button0000");
  1124. c.callback.addOnce(function() {
  1125. a.game.state.start("Level", !0, !1, a.levelSettings.levelNumber)
  1126. }, this);
  1127. var d = new game.SimpleButton(this.game, 590, b, "Menu_Button0000");
  1128. d.callback.addOnce(function() {
  1129. a.game.state.start("LevelsMenu")
  1130. }), this.buttons = [c, d], this.buttons.forEach(function(b) {
  1131. a.add(b)
  1132. })
  1133. }, b.prototype.initLevelCompleteBoard = function() {
  1134. this.levelCompleteBoard = new game.LevelCompleteBoard(this.game, this, this.levelSettings.levelNumber), this.levelCompleteBoard.visible = !1
  1135. }, b.prototype.onLevelComplete = function() {
  1136. this._sandTilesLabel.position.set(0, -300), this._sandTilesLabel.exists = !1, this.buttons.forEach(function(a) {
  1137. a.visible = !1
  1138. }), this.levelCompleteBoard.show()
  1139. }, Object.defineProperty(b.prototype, "sandTilesLabel", {
  1140. get: function() {
  1141. return this._sandTilesLabel
  1142. },
  1143. enumerable: !0,
  1144. configurable: !0
  1145. }), b
  1146. }(Phaser.Group);
  1147. a.LevelGUI = b
  1148. }(game || (game = {}));
  1149. var game;
  1150. ! function(a) {
  1151. var b;
  1152. ! function(a) {
  1153. a[a.ACTIVE = 0] = "ACTIVE", a[a.PAUSED = 1] = "PAUSED", a[a.RESTART = 2] = "RESTART"
  1154. }(b || (b = {}));
  1155. var c = function(b) {
  1156. function c() {
  1157. b.apply(this, arguments)
  1158. }
  1159. return __extends(c, b), c.prototype.init = function(b) {
  1160. this.debugRenderFlag = !1, this.state = 1, this.tutorHands = [], this._settings = new a.LevelSettings(b), this.result = new a.LevelResult(b)
  1161. }, c.prototype.preload = function() {
  1162. if (a.Main.development) {
  1163. var b = this._settings.levelNumber.toString(),
  1164. c = "assets/levels/Level_" + b + ".json";
  1165. this.load.json("level_" + b, c)
  1166. }
  1167. }, c.prototype.create = function() {
  1168. this.game.state.onShutDownCallback = this.destroy, this.state = 1, this.addLayers(), this.parse(), this.initKeyCallbacks(), a.Main.development && this.addFPSMeter(), this.grid.init(), 5 === this._settings.levelNumber && (this.tutorHands[1].visible = !1, this.tutorHands[2].visible = !1), this.state = 0
  1169. }, c.prototype.addLayers = function() {
  1170. this.addBackground(), this.addTopRow(), this.addGrid(), this.addSideGrass(), this.addGui()
  1171. }, c.prototype.addBackground = function() {
  1172. var a = "levelBackground",
  1173. b = this.cache.getTexture(a),
  1174. c = this.game.add.image(0, 0, a);
  1175. c.setTexture(b.texture)
  1176. }, c.prototype.addTopRow = function() {
  1177. var a = "topRow",
  1178. b = this.cache.getTexture(a),
  1179. c = this.game.add.image(4, -16, a);
  1180. c.setTexture(b.texture)
  1181. }, c.prototype.addSideGrass = function() {
  1182. var b = 26,
  1183. c = new Phaser.Image(this.game, -b, a.Config.HALF_GAME_HEIGHT, "levelGraphics", "EdgeGrass0000");
  1184. c.anchor.set(.5, .5), c.angle = -90, this.world.add(c);
  1185. var d = new Phaser.Image(this.game, a.Config.GAME_WIDTH + b, a.Config.HALF_GAME_HEIGHT, "levelGraphics", "EdgeGrass0000");
  1186. d.anchor.set(.5, .5), d.angle = 90, this.world.add(d)
  1187. }, c.prototype.addGrid = function() {
  1188. this.grid = new a.Grid(this.game), this.grid.x = 5, this.grid.y = 55, this.grid.levelCompleteSignal.addOnce(this.levelComplete, this), this.grid.sandTilesChanged.add(this.onSandTilesChanged, this), 3 === this._settings.levelNumber && this.grid.valveUsed.addOnce(this.hideTutorHands, this)
  1189. }, c.prototype.onSandTilesChanged = function(a, b) {
  1190. this.gui.sandTilesLabel.updateText(a), 1 === this._settings.levelNumber && "removed" === b ? this.hideTutorHands() : 5 === this._settings.levelNumber && ("removed" === b ? (this.tutorHands[0].visible = !1, this.tutorHands[1].visible = !0, this.tutorHands[2].visible = !0) : this.hideTutorHands())
  1191. }, c.prototype.hideTutorHands = function() {
  1192. this.tutorHands.forEach(function(a) {
  1193. a.exists && a.hideAndDestroy()
  1194. })
  1195. }, c.prototype.addGui = function() {
  1196. this.gui = new a.LevelGUI(this.game, this._settings)
  1197. }, c.prototype.addFPSMeter = function() {
  1198. this.time.advancedTiming = !0, this.fpsMeter = new utils.FPSMeter(this.game, 0, 0)
  1199. }, c.prototype.parse = function() {
  1200. var b;
  1201. if (a.Main.development) b = this.game.cache.getJSON("level_" + this._settings.levelNumber.toString());
  1202. else {
  1203. var c = "Level_" + this._settings.levelNumber,
  1204. d = this.game.cache.getJSON("levelConfigs");
  1205. b = d[c]
  1206. }
  1207. a.Main.parser.parse(this, b)
  1208. }, c.prototype.initKeyCallbacks = function() {
  1209. var b = this;
  1210. this.game.input.keyboard.addKey(Phaser.Keyboard.R).onDown.add(this.restart, this), this.game.input.keyboard.addKey(Phaser.Keyboard.P).onDown.add(this.togglePause, this), this.game.input.keyboard.addKey(Phaser.Keyboard.ESC).onDown.add(this.gotoChooseLevelMenu, this), a.Main.development && (this.game.input.keyboard.addKey(Phaser.Keyboard.S).onDown.add(function() {
  1211. b.fpsMeter.visible = !b.fpsMeter.visible
  1212. }), 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))
  1213. }, c.prototype.gotoPrevLevel = function() {
  1214. var b = this._settings.levelNumber,
  1215. c = 1 === b ? a.Config.LEVELS_NUM : b - 1;
  1216. this.gotoLevel(c)
  1217. }, c.prototype.gotoNextLevel = function() {
  1218. var b = this._settings.levelNumber,
  1219. c = b >= a.Config.LEVELS_NUM ? 1 : b + 1;
  1220. this.gotoLevel(c)
  1221. }, c.prototype.gotoLevel = function(a) {
  1222. this.game.state.start("Level", !0, !1, a)
  1223. }, c.prototype.restart = function() {
  1224. this.state = 2
  1225. }, c.prototype.toggleDebugRender = function() {
  1226. this.debugRenderFlag = !this.debugRenderFlag
  1227. }, c.prototype.gotoChooseLevelMenu = function() {
  1228. this.game.state.start("LevelsMenu", !0, !1)
  1229. }, c.prototype.togglePause = function() {
  1230. this.game.paused = !this.game.paused, this.game.paused ? this.onPause() : this.onResume()
  1231. }, c.prototype.onPause = function() {
  1232. this.state = 1
  1233. }, c.prototype.onResume = function() {
  1234. this.state = 1
  1235. }, c.prototype.update = function() {
  1236. switch (this.state) {
  1237. case 0:
  1238. this.doUpdate();
  1239. break;
  1240. case 2:
  1241. this.doRestart(), this.state = 0
  1242. }
  1243. }, c.prototype.doRestart = function() {
  1244. this.gotoLevel(this._settings.levelNumber)
  1245. }, c.prototype.doUpdate = function() {}, c.prototype.levelComplete = function() {
  1246. this.game.device.webAudio && this.game.sound.play("levelComplete"), this.saveLevelResult(), this.gui.onLevelComplete()
  1247. }, c.prototype.saveLevelResult = function() {
  1248. window.localStorage.setItem(this.settings.levelNumber.toString(), "true");
  1249. // updateShare(this.settings.levelNumber);
  1250. // Play68.setRankingScoreDesc(this.settings.levelNumber);
  1251. }, c.prototype.render = function() {
  1252. this.debugRenderFlag && this.debugRender()
  1253. }, c.prototype.debugRender = function() {
  1254. this.grid.render()
  1255. }, c.prototype.destroy = function() {
  1256. this.game.state.onShutDownCallback = null, this.removeKeyCallbacks(), this._settings = null, this.result = null, this.tutorHands = null
  1257. }, c.prototype.removeKeyCallbacks = function() {
  1258. this.game.input.keyboard.removeKey(Phaser.Keyboard.R), this.game.input.keyboard.removeKey(Phaser.Keyboard.P), this.game.input.keyboard.removeKey(Phaser.Keyboard.ESC), this.game.input.keyboard.removeKey(Phaser.Keyboard.D)
  1259. }, Object.defineProperty(c.prototype, "settings", {
  1260. get: function() {
  1261. return this._settings
  1262. },
  1263. enumerable: !0,
  1264. configurable: !0
  1265. }), c
  1266. }(Phaser.State);
  1267. a.Level = c
  1268. }(game || (game = {}));
  1269. var game;
  1270. ! function(a) {
  1271. var b = function(a) {
  1272. function b(b, c, d) {
  1273. a.call(this, b, c, d, "tutorial_hand"), this.initAnimation()
  1274. }
  1275. return __extends(b, a), b.prototype.initAnimation = function() {
  1276. this.animations.add("main", null), this.play("main", 30, !0)
  1277. }, b.prototype.hideAndDestroy = function() {
  1278. this.animations.stop(), this.game.add.tween(this).to({
  1279. alpha: 0
  1280. }, 300, Phaser.Easing.Linear.None, !0).onComplete.addOnce(this.destroy, this)
  1281. }, b
  1282. }(Phaser.Sprite);
  1283. a.TutorHand = b
  1284. }(game || (game = {}));
  1285. var game;
  1286. ! function(a) {
  1287. var b = function() {
  1288. function a(a) {
  1289. this.game = a, this.initCallbacks()
  1290. }
  1291. return a.prototype.initCallbacks = function() {
  1292. this.callbacks = {}, this.callbacks.SandTile = this.addSandTile, this.callbacks.WaterTile = this.addWaterTile, this.callbacks.Tile = this.addTile, this.callbacks.Flower = this.addFlower, this.callbacks.Valve = this.addValve, this.callbacks.Gnome = this.addGnome, this.callbacks.Pipe = this.addPipe, this.callbacks.Tutorial_Hand = this.addTutorialHand
  1293. }, a.prototype.parse = function(a, b) {
  1294. this.newLevel = a, this.levelConfig = b, this.parseObjects(), this.cleanup()
  1295. }, a.prototype.cleanup = function() {
  1296. this.newLevel = null, this.levelConfig = null
  1297. }, a.prototype.parseObjects = function() {
  1298. var a = this,
  1299. b = this.levelConfig;
  1300. b.forEach(function(b) {
  1301. a.addGameObject(b)
  1302. })
  1303. }, a.prototype.addGameObject = function(a) {
  1304. var b = a.type,
  1305. c = this.getCallback(b),
  1306. d = c ? c.call(this, a) : this.addImage(a);
  1307. d && d.body && (d.body = null)
  1308. }, a.prototype.getCallback = function(a) {
  1309. for (var b in this.callbacks)
  1310. if (a.indexOf(b) > -1) return this.callbacks[b];
  1311. return null
  1312. }, a.prototype.addFlower = function(a) {
  1313. var b = a.x,
  1314. c = a.y + 35,
  1315. d = new game.Flower(this.game, b, c);
  1316. return this.newLevel.grid.addObject(d), d
  1317. }, a.prototype.addGnome = function(a) {
  1318. var b = a.x,
  1319. c = a.y,
  1320. d = new game.Gnome(this.game, b, c);
  1321. return this.newLevel.grid.addObject(d), d
  1322. }, a.prototype.addValve = function(a) {
  1323. var b = Math.round(a.x),
  1324. c = Math.round(a.y) + .5 + 5,
  1325. d = new game.Valve(this.game, b, c);
  1326. return this.newLevel.grid.addObject(d), d
  1327. }, a.prototype.addPipe = function(a) {
  1328. var b = a.pipeName,
  1329. c = a.linkedPipe,
  1330. d = a.type + "0000",
  1331. e = new game.Pipe(this.game, a.x, a.y + 6, d, b, c);
  1332. return this.newLevel.grid.addObject(e), e
  1333. }, a.prototype.addTile = function(a) {
  1334. var b = a.x,
  1335. c = a.y,
  1336. d = a.type + "0000";
  1337. if (null !== this.game.cache.getFrameByName("levelGraphics", d)) {
  1338. var e = new game.CommonTile(this.game, b, c, d);
  1339. return this.newLevel.grid.addTile(e), e
  1340. }
  1341. return null
  1342. }, a.prototype.addSandTile = function(a) {
  1343. var b = a.x,
  1344. c = a.y,
  1345. d = new game.SandTile(this.game, b, c);
  1346. return this.newLevel.grid.addTile(d), d
  1347. }, a.prototype.addWaterTile = function(a) {
  1348. var b = a.x,
  1349. c = a.y,
  1350. d = new game.WaterTile(this.game, b, c);
  1351. return this.newLevel.grid.addTile(d), d
  1352. }, a.prototype.addTutorialHand = function(a) {
  1353. var b = new game.TutorHand(this.game, a.x, a.y);
  1354. b.x -= 40, b.y -= 65, this.newLevel.grid.addTutorialSprite(b), this.newLevel.tutorHands.push(b)
  1355. }, a.prototype.addImage = function(a) {
  1356. var b = a.x,
  1357. c = a.y,
  1358. d = a.type + "0000";
  1359. if (null !== this.game.cache.getFrameByName("levelGraphics", d)) {
  1360. var e = new Phaser.Image(this.game, b, c, "levelGraphics_1", d);
  1361. return e.anchor.set(.5, .5), e.scale.set(a.scaleX, a.scaleY), this.newLevel.world.add(e), e
  1362. }
  1363. return null
  1364. }, a
  1365. }();
  1366. a.LevelParser = b
  1367. }(game || (game = {})), window.addEventListener("load", onLoad, !1);
  1368. var game;
  1369. ! function(a) {
  1370. var b = function(b) {
  1371. function c() {
  1372. b.call(this, a.Config.GAME_WIDTH, a.Config.GAME_HEIGHT, Phaser.CANVAS, "gameContainer"), c.parser = new a.LevelParser(this), this.initStates(), this.state.start("Boot")
  1373. }
  1374. return __extends(c, b), c.prototype.initStates = function() {
  1375. this.state.add("Boot", a.Boot, !1), this.state.add("Preloader", a.Preloader, !1), this.state.add("MainMenu", a.MainMenu, !1), this.state.add("LevelsMenu", a.LevelsMenu, !1), this.state.add("Level", a.Level, !1)
  1376. }, c.development = !1, c.wasMuted = !1, c
  1377. }(Phaser.Game);
  1378. a.Main = b
  1379. }(game || (game = {}));