game.min.js 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  1. var LevelButton = function(t, e, s, a, i, h) {
  2. Phaser.Button.call(this, game, t, e, null, i, h), this.lvl_number = a, this.anchor.setTo(.5, .5), this.locked = !1, this.onInputDown.add(function() {
  3. game.add.tween(this.scale).to({
  4. x: 1.3,
  5. y: 1.3
  6. }, 200, Phaser.Easing.Sinusoidal.InOut, !0, 0, 0, !0)
  7. }, this), this.miniature = new Phaser.Image(game, 0, 0, null), this.miniature.anchor.setTo(.5, .6), this.miniature.renderable = !1, this.addChild(this.miniature), this.stars = new Phaser.Image(game, 0, 8, null), this.stars.anchor.setTo(.5, 0), this.stars.renderable = !1, this.addChild(this.stars)
  8. };
  9. LevelButton.prototype = Object.create(Phaser.Button.prototype), LevelButton.prototype.goToLevel = function() {
  10. if (!this.locked) {
  11. game.current_lvl = this.lvl_number;
  12. var t = game.add.tween(game.state.getCurrentState().fade_gfx).to({
  13. alpha: 1
  14. }, 300, Phaser.Easing.Sinusoidal.InOut, !0);
  15. game.lastRoom = "Category", t.onComplete.add(function() {
  16. game.state.start("Play")
  17. })
  18. }
  19. }, LevelButton.prototype.refresh = function() {
  20. SaveLoad.unlocked_levels[game.current_category] < this.lvl_number ? (this.loadTexture("ssheet", "lvl_button_locked"), this.stars.renderable = !1, this.miniature.renderable = !1, this.locked = !0) : (this.loadTexture("ssheet", "lvl_highlight"), this.miniature.loadTexture("lvlmini", game.current_category.toString() + "_" + this.lvl_number.toString()), this.miniature.renderable = !0, this.stars.renderable = !0, this.stars.loadTexture("ssheet", "lvl_star_" + SaveLoad.level[game.current_category][this.lvl_number].toString()), this.locked = !1)
  21. }, LevelButton.prototype.constructor = LevelButton, Preload = function() {}, Preload.prototype = {
  22. preload: function() {
  23. this.cm_logo = game.add.image(210, 150, "circusmoth"), this.cm_logo.anchor.setTo(.5, .5), this.preload_bg = game.add.image(57, 250, "loading_bar_0"), this.preload_bar = game.add.image(57, 250, "loading_bar_1"), this.loading = game.add.image(210, 330, "loading"), this.loading.anchor.setTo(.5, .5), game.add.tween(this.loading.scale).to({
  24. x: 1.2,
  25. y: 1.2
  26. }, 1e3, Phaser.Easing.Sinusoidal.InOut, !0, 0, -1, !0), this.load.setPreloadSprite(this.preload_bar), game.load.bitmapFont("font_label", "assets/images/font_label.png", "assets/images/font_label.fnt", null, 0), game.load.bitmapFont("font_digits", "assets/images/font-digits.png", "assets/images/font-digits.fnt", null, 4), game.load.atlasJSONHash("ssheet","assets/images/spritesheet.png", "assets/images/spritesheet.json"), game.load.atlasJSONHash("lvlmini", "assets/images/lvlmini.png", "assets/images/lvlmini.json"), game.load.image("line_dbg", "assets/images/line_dbg.png"), game.load.audio("music_sfx", "assets/sounds/music.mp3"), game.load.audio("chainsaw_sfx", "assets/sounds/chainsaw_1s.mp3"), game.load.audio("chainsaw_alt_sfx", "assets/sounds/chainsaw_1s_alt.mp3"), game.load.audio("click_sfx", "assets/sounds/click.mp3"), game.load.audio("transition_sfx", "assets/sounds/transition.mp3"), game.load.audio("whoosh_sfx", "assets/sounds/whoosh.mp3"), game.load.audio("label_pop_sfx", "assets/sounds/label_pop.mp3"), game.load.audio("win_sfx", "assets/sounds/win.mp3"), game.load.audio("lose_sfx", "assets/sounds/lose.mp3")
  27. },
  28. create: function() {
  29. this.game.stage.backgroundColor = "#FFFFFF", game.sfx = {}, game.sfx.music = game.add.audio("music_sfx", 1, !0), game.sfx.click = game.add.audio("click_sfx"), this.cm_logo.visible = !1, this.preload_bg.visible = !1, this.preload_bar.visible = !1, this.loading.visible = !1, game.sfx.chainsaw_index = 0, game.sfx.chainsaw = game.add.audio("chainsaw_sfx"), game.sfx.chainsaw_alt = game.add.audio("chainsaw_alt_sfx"), game.sfx.transition = game.add.audio("transition_sfx"), game.sfx.whoosh = game.add.audio("whoosh_sfx"), game.sfx.label_pop = game.add.audio("label_pop_sfx"), game.sfx.win = game.add.audio("win_sfx"), game.sfx.lose = game.add.audio("lose_sfx"), this.state.start("MainMenu")
  30. }
  31. };
  32. var Slice = function(t, e) {
  33. this.point_0 = t, this.point_1 = e, this.f0t1 = !1, this.f1t0 = !1
  34. };
  35. Slice.prototype.checkLine = function(t) {
  36. return this.point_0.i == t ? (this.f0t1 = !0, [this.point_0, this.point_1]) : this.point_1.i == t ? (this.f1t0 = !0, [this.point_1, this.point_0]) : null
  37. };
  38. var Shape = function(t) {
  39. Phaser.Polygon.call(this, t), this.to_kill = !1, this.dead = !1, this.slices = [], this.new_shapes = [], this.centroid = Phaser.Point.centroid(this.points)
  40. };
  41. Shape.prototype = Object.create(Phaser.Polygon.prototype), Shape.prototype.constructor = Shape, Shape.prototype.update = function() {}, Shape.prototype.prepareSlices = function(t) {
  42. for (var e = [], s = 0; s < this.points.length; s++) {
  43. var a, i = this.points[s];
  44. a = s == this.points.length - 1 ? this.points[0] : this.points[s + 1];
  45. var h = Phaser.Line.intersectsPoints(t.start, t.end, i, a, !0);
  46. null != h && (h.i = s, e.push(h))
  47. }
  48. e.sort(function(e, s) {
  49. var a = Phaser.Point.distance(t.start, e),
  50. i = Phaser.Point.distance(t.start, s);
  51. return a - i
  52. }), e.length > 0 && (this.contains(t.start.x, t.start.y) && e.splice(0, 1), this.contains(t.end.x, t.end.y) && e.splice(e.length - 1, 1));
  53. for (var o = [], s = 0; s < e.length; s += 2) o.push(new Slice(e[s], e[s + 1]));
  54. this.slices = o
  55. }, Shape.prototype.makeNewPolygon = function(t, e) {
  56. for (var s = [t, e], a = t.i, i = e.i; i++, i == this.points.length && (i = 0), s.push(this.points[i]), i != a;) {
  57. var h = this.checkSliceLine(i);
  58. null != h && (i = h[1].i, s.push(h[0]), s.push(h[1]))
  59. }
  60. this.new_shapes.push(s)
  61. }, Shape.prototype.checkSliceLine = function(t) {
  62. for (var e = 0; e < this.slices.length; e++) {
  63. var s = this.slices[e].checkLine(t);
  64. if (null != s) return s
  65. }
  66. return null
  67. }, Shape.prototype.slice = function(t) {
  68. if (this.prepareSlices(t), 0 != this.slices.length) {
  69. this.to_kill = !0;
  70. for (var e = 0; e < this.slices.length; e++) {
  71. var s = this.slices[e];
  72. s.f0t1 || (this.makeNewPolygon(s.point_0, s.point_1), s.f0t1 = !0), s.f1t0 || (s.f1t0 = !0, this.makeNewPolygon(s.point_1, s.point_0))
  73. }
  74. Phaser.Point.centroid(this.points, this.centroid)
  75. }
  76. };
  77. var Logo = function(t) {
  78. Phaser.Group.call(this, game, 0, 0), this.logo_0 = game.add.image(60, t, "ssheet", "logo_0"), this.logo_1 = game.add.image(117, t + 20, "ssheet", "logo_1"), this.logo_2 = game.add.image(172, t, "ssheet", "logo_2"), this.logo_3 = game.add.image(267, t + 5, "ssheet", "logo_3"), this.logo_4 = game.add.image(325, t, "ssheet", "logo_4"), this.logo_5 = game.add.image(382, t, "ssheet", "logo_5"), this.logo_0.anchor.setTo(.5, .5), this.logo_1.anchor.setTo(.5, .5), this.logo_2.anchor.setTo(.5, .5), this.logo_3.anchor.setTo(.5, .5), this.logo_4.anchor.setTo(.5, .5), this.logo_5.anchor.setTo(.5, .5), game.add.tween(this.logo_0).from({
  79. y: -100
  80. }, 1200, Phaser.Easing.Elastic.Out, !0, 1020), game.add.tween(this.logo_1).from({
  81. y: -100
  82. }, 1420, Phaser.Easing.Elastic.Out, !0, 1060), game.add.tween(this.logo_2).from({
  83. y: -100
  84. }, 1200, Phaser.Easing.Elastic.Out, !0, 1050), game.add.tween(this.logo_3).from({
  85. y: -100
  86. }, 1410, Phaser.Easing.Elastic.Out, !0, 1120), game.add.tween(this.logo_4).from({
  87. y: -100
  88. }, 1200, Phaser.Easing.Elastic.Out, !0, 1080), game.add.tween(this.logo_5).from({
  89. y: -100
  90. }, 1410, Phaser.Easing.Elastic.Out, !0, 1050), this.add(this.logo_0), this.add(this.logo_1), this.add(this.logo_2), this.add(this.logo_3), this.add(this.logo_4), this.add(this.logo_5), game.time.events.add(5 * Phaser.Timer.SECOND, this.init_bounce, this)
  91. };
  92. Logo.prototype = Object.create(Phaser.Group.prototype), Logo.prototype.constructor = Logo, Logo.prototype.init_bounce = function() {
  93. game.time.events.loop(6 * Phaser.Timer.SECOND, this.bounce, this)
  94. }, Logo.prototype.bounce = function() {
  95. game.add.tween(this.logo_0).to({
  96. y: this.logo_0.y - 30
  97. }, 200, Phaser.Easing.Sinusoidal.InOut, !0, 0, 0, !0), game.add.tween(this.logo_1).to({
  98. y: this.logo_0.y - 30
  99. }, 200, Phaser.Easing.Sinusoidal.InOut, !0, 100, 0, !0), game.add.tween(this.logo_2).to({
  100. y: this.logo_0.y - 30
  101. }, 200, Phaser.Easing.Sinusoidal.Out, !0, 200, 0, !0), game.add.tween(this.logo_3).to({
  102. y: this.logo_0.y - 30
  103. }, 200, Phaser.Easing.Sinusoidal.Out, !0, 300, 0, !0), game.add.tween(this.logo_4).to({
  104. y: this.logo_0.y - 30
  105. }, 200, Phaser.Easing.Sinusoidal.InOut, !0, 400, 0, !0), game.add.tween(this.logo_5).to({
  106. y: this.logo_0.y - 30
  107. }, 200, Phaser.Easing.Sinusoidal.InOut, !0, 500, 0, !0)
  108. };
  109. var Background = function(t) {
  110. Phaser.Sprite.call(this, game, 0, 0), this.fixedToCamera = !0, this.offset = t || 0, this.y_margin = game.height - 525, this.sky = this.game.add.image(0, 0, "ssheet", "bg"), this.sky.fixedToCamera = !0, this.sky.scale.y = (this.y_margin + 251) / 251, this.cloud = this.game.add.image(100, 50, "ssheet", "cloud_0"), this.cloud.fixedToCamera = !0, this.cloud.xx = 400, this.cloud2 = this.game.add.image(500, 70, "ssheet", "cloud_0"), this.cloud2.xx = 1e3, this.cloud2.fixedToCamera = !0, this.cloud3 = this.game.add.image(1e3, 60, "ssheet", "cloud_0"), this.cloud3.xx = 1600, this.cloud3.fixedToCamera = !0, this.grass_2 = this.game.add.tileSprite(0, this.y_margin + 200, game.width, 160, "ssheet", "bg_grass_2"), this.grass_2.fixedToCamera = !0, this.grass_2.tilePosition.set(-500, 0), this.grass_1 = this.game.add.tileSprite(0, this.y_margin + 240, game.width, 187, "ssheet", "bg_grass_1"), this.grass_1.fixedToCamera = !0, this.grass_1.tilePosition.set(-250, 0), this.grass_0 = this.game.add.tileSprite(0, this.y_margin + 310, game.width, 220, "ssheet", "bg_grass_0"), this.grass_0.fixedToCamera = !0
  111. };
  112. Background.prototype = Object.create(Phaser.Sprite.prototype), Background.prototype.update = function() {
  113. this.grass_2.tilePosition.set((this.game.camera.x + this.offset) * -.2, 0), this.grass_1.tilePosition.set((this.game.camera.x + this.offset) * -.5, 0), this.grass_0.tilePosition.set((this.game.camera.x + this.offset) * -.8, 0), this.cloud.cameraOffset.x = this.cloud.xx - .2 * this.game.camera.x, this.cloud.xx -= .2, this.cloud2.cameraOffset.x = this.cloud2.xx - .2 * this.game.camera.x, this.cloud2.xx -= .2, this.cloud3.cameraOffset.x = this.cloud2.xx - .2 * this.game.camera.x, this.cloud3.xx -= .2, this.cloud.xx < -200 && (this.cloud.xx = 1500), this.cloud2.xx < -200 && (this.cloud2.xx = 1500), this.cloud3.xx < -200 && (this.cloud3.xx = 1500)
  114. }, Background.prototype.destroyBg = function() {
  115. this.sky.destroy(), this.grass_2.destroy(), this.grass_1.destroy(), this.grass_0.destroy(), this.destroy()
  116. }, Background.prototype.rescale = function() {
  117. this.y_margin = game.height - 525, this.sky.scale.y = (this.y_margin + 251) / 251, this.grass_2.cameraOffset.y = this.y_margin + 200, this.grass_1.cameraOffset.y = this.y_margin + 240, this.grass_0.cameraOffset.y = this.y_margin + 310
  118. };
  119. var Tutorial = function() {
  120. Phaser.Group.call(this, game), this.y = 150, this.bg = game.add.image(-100, 125, "ssheet", "tut_bg"), this.bg.anchor.setTo(0, .5), this.addChild(this.bg), this.game.add.tween(this).from({
  121. x: -750
  122. }, 1500, Phaser.Easing.Elastic.InOut, !0, 0), game.time.events.add(300, function() {
  123. SaveLoad.SFX && game.sfx.whoosh.play()
  124. }, this), this.current_page = 0, this.page_1 = game.add.group(), this.addChild(this.page_1), this.title = game.add.image(210, 20, "ssheet", "tut_title"), this.title.anchor.setTo(.5, 0), this.page_1.addChild(this.title), this.shape_w = game.add.image(210, 125, "ssheet", "tut_shape_w"), this.shape_w.anchor.setTo(.5, .5), this.page_1.addChild(this.shape_w), this.shape_bottom = game.add.image(210, 125, "ssheet", "tut_shape_bottom"), this.shape_bottom.anchor.setTo(.5, .5), this.shape_bottom.visible = !1, this.page_1.addChild(this.shape_bottom), this.shape_top = game.add.image(210, 125, "ssheet", "tut_shape_top"), this.shape_top.anchor.setTo(.5, .5), this.shape_top.visible = !1, this.page_1.addChild(this.shape_top), this.slice = game.add.image(100, 160, "ssheet", "tut_slice"), this.slice.anchor.setTo(0, .5), this.slice.width = 0, this.slice.rotation = -.12435499454676144, this.page_1.addChild(this.slice), this.click_dot = game.add.image(100, 160, "ssheet", "tut_click_dot"), this.click_dot.scale.setTo(1.2, 1.2), this.click_dot.alpha = 0, this.click_dot.anchor.setTo(.5, .5), this.page_1.addChild(this.click_dot), this.hand = game.add.image(100, 160, "ssheet", "tut_hand"), this.page_1.addChild(this.hand), this.page_2 = game.add.image(210, 20, "ssheet", "tut_page2"), this.page_2.alpha = 0, this.page_2.anchor.setTo(.5, 0), this.addChild(this.page_2), game.time.events.add(2e3, function() {
  125. this.resetAnimation()
  126. }, this), console.log("TUTORIAL"), console.log(this)
  127. };
  128. Tutorial.prototype = Object.create(Phaser.Group.prototype), Tutorial.prototype.constructor = Tutorial, Tutorial.prototype.update = function() {
  129. this.y = .28 * game.height
  130. }, Tutorial.prototype.resetAnimation = function() {
  131. this.shape_top.visible = !1, this.shape_top.y = 125, this.shape_bottom.y = 125, this.shape_bottom.visible = !1, this.shape_w.visible = !0, this.hand.x = 100, this.hand.y = 160, this.slice.width = 0, game.add.tween(this.hand).to({
  132. x: 300,
  133. y: 135
  134. }, 2e3, Phaser.Easing.Sinusoidal.InOut, !0, 0), game.add.tween(this.click_dot.scale).to({
  135. x: .5,
  136. y: .5
  137. }, 200, Phaser.Easing.Sinusoidal.InOut, !0, 0), game.add.tween(this.click_dot).to({
  138. alpha: .5
  139. }, 200, Phaser.Easing.Sinusoidal.InOut, !0, 0), game.add.tween(this.click_dot).to({
  140. x: 300,
  141. y: 135
  142. }, 2e3, Phaser.Easing.Sinusoidal.InOut, !0, 0), SaveLoad.SFX && game.sfx.click.play(), game.add.tween(this.slice).to({
  143. width: 202
  144. }, 2e3, Phaser.Easing.Sinusoidal.InOut, !0, 0), game.add.tween(this.slice).to({
  145. alpha: 0
  146. }, 200, Phaser.Easing.Sinusoidal.InOut, !0, 2500), game.time.events.add(2500, function() {
  147. SaveLoad.SFX && game.sfx.label_pop.play(), this.shape_top.visible = !0, this.shape_bottom.visible = !0, this.shape_w.visible = !1, game.add.tween(this.click_dot.scale).to({
  148. x: 1.2,
  149. y: 1.2
  150. }, 200, Phaser.Easing.Sinusoidal.InOut, !0, 0), game.add.tween(this.click_dot).to({
  151. alpha: 0
  152. }, 200, Phaser.Easing.Sinusoidal.InOut, !0, 0)
  153. }, this), game.add.tween(this.shape_bottom).to({
  154. y: 140
  155. }, 200, Phaser.Easing.Sinusoidal.InOut, !0, 2500), game.add.tween(this.shape_top).to({
  156. y: 110
  157. }, 200, Phaser.Easing.Sinusoidal.InOut, !0, 2500), game.add.tween(this.page_2).to({
  158. alpha: 1
  159. }, 500, Phaser.Easing.Sinusoidal.InOut, !0, 4500), game.add.tween(this.page_1).to({
  160. alpha: 0
  161. }, 500, Phaser.Easing.Sinusoidal.InOut, !0, 4200), game.add.tween(this).to({
  162. x: 750
  163. }, 1500, Phaser.Easing.Elastic.InOut, !0, 8500), game.time.events.add(8800, function() {
  164. SaveLoad.SFX && game.sfx.whoosh.play()
  165. }, this)
  166. };
  167. var CategoryButton = function(t, e, s, a, i, h) {
  168. function o() {
  169. this.unlocked && (SaveLoad.SFX && game.sfx.click.play(), game.add.tween(this.scale).to({
  170. x: 1.3,
  171. y: 1.3
  172. }, 200, Phaser.Easing.Sinusoidal.InOut, !0, 0, 0, !0), game.current_category = this.category, game.add.tween(game.camera).to({
  173. x: 840
  174. }, 1e3, Phaser.Easing.Sinusoidal.InOut, !0))
  175. }
  176. Phaser.Button.call(this, game, t, e, ""), this.onInputDown.add(o, this, 1), this.anchor.setTo(.5, .5), this.category = s, this.fill = new Phaser.Image(game, 0, 0, null), this.fill.anchor.setTo(.5, .5), this.addChild(this.fill), this.unlocked = !1, SaveLoad.all_stars < a ? (this.fill.loadTexture("ssheet", i), this.reqStar = new Phaser.BitmapText(game, -115, 20, "font_digits", a.toString(), 25), this.reqStar.anchor.setTo(1, 0), this.underline = new Phaser.Image(game, .5 * (this.reqStar.width + 47 + 153) - 165, 15, "ssheet", "to_unlock"), this.star_ico = new Phaser.Image(game, this.underline.x + 28, 17, "ssheet", "small_star"), this.star_ico.anchor.setTo(1, 0), this.reqStar.x = this.star_ico.x - 38, this.addChild(this.underline), this.addChild(this.reqStar), this.addChild(this.star_ico)) : (this.unlocked = !0, this.fill.loadTexture("ssheet", h), maxStars = 54, this.stars = new Phaser.BitmapText(game, 18, 20, "font_digits", SaveLoad.star[s] + "/" + maxStars, 25), this.stars.anchor.setTo(1, 0), this.stars.x = this.stars.width - .5 * (this.stars.width + 47) + 5, this.star_ico = new Phaser.Image(game, this.stars.x - 5, 17, "ssheet", "small_star"), this.addChild(this.stars), this.addChild(this.star_ico))
  177. };
  178. CategoryButton.prototype = Object.create(Phaser.Button.prototype), CategoryButton.prototype.constructor = CategoryButton;
  179. var TurnDevice = function() {
  180. Phaser.Group.call(this, game), this.fixedToCamera = !0, this.bg = game.add.graphics(0, 0), this.bg.beginFill("#000000", 1), this.bg.drawRect(0, 0, 420, 1500), this.bg.endFill(), this.add(this.bg), this.please_turn = game.add.image(210, .5 * game.height, "ssheet", "turn_device"), this.please_turn.anchor.setTo(.5, .5), this.please_turn.scale.setTo(2, 2), this.add(this.please_turn)
  181. };
  182. TurnDevice.prototype = Object.create(Phaser.Group.prototype), TurnDevice.prototype.constructor = TurnDevice, TurnDevice.prototype.show = function() {
  183. this.visible = !0, this.please_turn.y = .5 * game.height
  184. }, TurnDevice.prototype.hide = function() {
  185. this.visible = !1
  186. }, TurnDevice.prototype.test = function() {
  187. game.scale.isLandscape ? this.hide() : this.hide()
  188. }, MainMenu = function() {}, MainMenu.prototype = {
  189. create: function() {
  190. game.sfx.music.isPlaying || game.sfx.music.play(), SaveLoad.SFX || game.sfx.music.stop(), game.world.setBounds(0, 0, 4 * game.width, game.height), this.bg = new Background, game.add.existing(this.bg), this.sun_flare = game.add.image(210, 140, "ssheet", "sun"), this.sun_flare.anchor.setTo(.5, .5), game.add.tween(this.sun_flare).to({
  191. angle: 359
  192. }, 15e3, Phaser.Easing.Linear.InOut, !0, 0, -1), this.logo = new Logo(140), game.add.existing(this.logo), this.chainsaw = game.add.image(210, .8 * game.height, "ssheet", "chainsaw_play"), this.chainsaw.anchor.setTo(.5, .5), this.play_button = game.add.button(210, .8 * game.height, null, this.play_button_click, this), this.play_button.loadTexture("ssheet", "play"), this.play_button.anchor.setTo(.5, .5), this.play_button.onInputDown.add(function() {
  193. SaveLoad.SFX && game.sfx.click.play(), game.add.tween(this.play_button.scale).to({
  194. x: 1.3,
  195. y: 1.3
  196. }, 200, Phaser.Easing.Sinusoidal.InOut, !0, 0, 0, !0)
  197. }, this), this.page_1 = game.add.group(), this.page_1.add(this.play_button), this.categories = game.add.group(), this.categories.y = .19 * game.height, this.categories.add(new CategoryButton(630, -25, 0, 0, "very_easy_0", "very_easy_1")), this.categories.add(new CategoryButton(630, 75, 1, 30, "easy_0", "easy_1")), this.categories.add(new CategoryButton(630, 175, 2, 60, "medium_0", "medium_1")), this.categories.add(new CategoryButton(630, 275, 3, 90, "hard_0", "hard_1")), this.categories.forEach(function(t) {
  198. t.onInputDown.add(this.refresh_buttons, this, -1)
  199. }, this), this.page_1.add(this.categories), this.UI_buttons = game.add.group(), this.UI_buttons.y = .92 * game.height, this.back_button = game.add.button(470, 0, null, this.back_button_click, this), this.back_button.anchor.setTo(.5, .5), this.back_button.onInputDown.add(function() {
  200. SaveLoad.SFX && game.sfx.click.play(), game.add.tween(this.back_button.scale).to({
  201. x: -1.3,
  202. y: 1.3
  203. }, 200, Phaser.Easing.Sinusoidal.InOut, !0, 0, 0, !0)
  204. }, this), this.back_button.loadTexture("ssheet", "arrow_button"), this.back_button.scale.x = -1, this.UI_buttons.add(this.back_button), this.lvl_buttons = game.add.group(), this.lvl_row = [], this.lvl_row[0] = game.add.group(), this.lvl_row[1] = game.add.group(), this.lvl_row[2] = game.add.group(), this.lvl_row[0].y = .17 * game.height, this.lvl_row[1].y = .41 * game.height, this.lvl_row[2].y = .64 * game.height, this.lvl_buttons.add(this.lvl_row[0]), this.lvl_buttons.add(this.lvl_row[1]), this.lvl_buttons.add(this.lvl_row[2]);
  205. for (var t = 0; 9 > t; t++) this.lvl_row[Math.floor(t / 3)].add(new LevelButton(930 + t % 3 * 120, 0, game.current_category, t, this.goToLevel));
  206. for (var t = 9; 18 > t; t++) this.lvl_row[Math.floor((t - 9) / 3)].add(new LevelButton(1260 + (90 + t % 3 * 120), 0, game.current_category, t, this.goToLevel));
  207. this.back_to_cat = game.add.button(890, 0, null, function() {
  208. SaveLoad.SFX && game.sfx.click.play(), game.add.tween(this.back_to_cat.scale).to({
  209. x: -1.3,
  210. y: 1.3
  211. }, 200, Phaser.Easing.Sinusoidal.InOut, !0, 0, 0, !0), game.add.tween(game.camera).to({
  212. x: 420
  213. }, 1e3, Phaser.Easing.Sinusoidal.InOut, !0)
  214. }, this), this.back_to_cat.scale.x = -1, this.back_to_cat.loadTexture("ssheet", "arrow_button"), this.back_to_cat.anchor.setTo(.5, .5), this.UI_buttons.add(this.back_to_cat), this.next_lvl = game.add.button(1210, 0, null, function() {
  215. SaveLoad.SFX && game.sfx.click.play(), game.add.tween(this.next_lvl.scale).to({
  216. x: 1.3,
  217. y: 1.3
  218. }, 200, Phaser.Easing.Sinusoidal.InOut, !0, 0, 0, !0), game.add.tween(game.camera).to({
  219. x: 1260
  220. }, 1e3, Phaser.Easing.Sinusoidal.InOut, !0)
  221. }, this), this.next_lvl.loadTexture("ssheet", "arrow_button"), this.next_lvl.anchor.setTo(.5, .5), this.UI_buttons.add(this.next_lvl), this.prev_lvl = game.add.button(1310, 0, null, function() {
  222. SaveLoad.SFX && game.sfx.click.play(), game.add.tween(this.prev_lvl.scale).to({
  223. x: -1.3,
  224. y: 1.3
  225. }, 200, Phaser.Easing.Sinusoidal.InOut, !0, 0, 0, !0), game.add.tween(game.camera).to({
  226. x: 840
  227. }, 1e3, Phaser.Easing.Sinusoidal.InOut, !0)
  228. }, this), this.prev_lvl.scale.x = -1, this.prev_lvl.loadTexture("ssheet", "arrow_button"), this.prev_lvl.anchor.setTo(.5, .5), this.UI_buttons.add(this.prev_lvl), this.refresh_buttons(), this.tb_music = game.add.button(0, 0, null, this.tb_music_click, this), this.tb_music.anchor.setTo(0, 0), this.tb_music.fixedToCamera = !0, this.tb_music.loadTexture("ssheet", "music_button"), SaveLoad.SFX || (this.tb_music.alpha = .5), this.fade_gfx = game.add.graphics(0, 0), this.fade_gfx.beginFill(16777215, 1), this.fade_gfx.drawRect(0, 0, game.width, game.height), this.fade_gfx.endFill(), this.fade_gfx.fixedToCamera = !0, "Play" == game.lastRoom && (game.current_lvl < 10 && (game.camera.x = 840), game.current_lvl > 9 && (game.camera.x = 1260)), game.add.tween(this.fade_gfx).to({
  229. alpha: 0
  230. }, 300, Phaser.Easing.Sinusoidal.Out, !0), game.camera.x < 100 && game.time.events.add(500, function() {
  231. SaveLoad.SFX && game.sfx.whoosh.play()
  232. }, this), this.scale.onSizeChange.add(this.resize_layout, this), game.device.desktop || (this.turndevice = new TurnDevice, game.add.existing(this.turndevice), this.turndevice.test())
  233. },
  234. update: function() {},
  235. resize_layout: function() {
  236. this.categories.y = .19 * game.height, this.bg.rescale(), this.lvl_row[0].y = .17 * game.height, this.lvl_row[1].y = .41 * game.height, this.lvl_row[2].y = .64 * game.height, this.play_button.y = .8 * game.height, this.chainsaw.y = this.play_button.y, this.UI_buttons.y = .92 * game.height, game.device.desktop || this.turndevice.test()
  237. },
  238. tb_info_click: function() {},
  239. tb_music_click: function() {
  240. SaveLoad.SFX ? (game.add.tween(this.tb_music).to({
  241. alpha: .5
  242. }, 300, Phaser.Easing.Sinusoidal.InOut, !0), game.sfx.music.stop(), SaveLoad.SFX = !1, SaveLoad.saveSFX()) : (game.add.tween(this.tb_music).to({
  243. alpha: 1
  244. }, 300, Phaser.Easing.Sinusoidal.InOut, !0), SaveLoad.SFX = !0, SaveLoad.saveSFX(), game.sfx.music.play("", 0, 1, !0))
  245. },
  246. play_button_click: function() {
  247. game.add.tween(game.camera).to({
  248. x: 420
  249. }, 1e3, Phaser.Easing.Sinusoidal.InOut, !0)
  250. },
  251. back_button_click: function() {
  252. game.add.tween(game.camera).to({
  253. x: 0
  254. }, 1e3, Phaser.Easing.Sinusoidal.InOut, !0)
  255. },
  256. refresh_buttons: function() {
  257. this.lvl_row.forEach(function(t) {
  258. t.forEach(function(t) {
  259. t.refresh()
  260. })
  261. })
  262. },
  263. goToLevel: function() {
  264. if (!this.locked) {
  265. SaveLoad.SFX && (game.sfx.transition.play(), game.sfx.click.play()), game.current_lvl = this.lvl_number;
  266. var t = game.add.tween(game.state.getCurrentState().fade_gfx).to({
  267. alpha: 1
  268. }, 300, Phaser.Easing.Sinusoidal.InOut, !0);
  269. game.lastRoom = "Category", t.onComplete.add(function() {
  270. game.state.start("Play")
  271. })
  272. }
  273. },
  274. shutdown: function() {
  275. this.bg.destroyBg(), this.tb_music.destroy(), this.page_1.destroy(), this.back_button.destroy()
  276. }
  277. }, Boot = function() {}, Boot.prototype = {
  278. preload: function() {
  279. this.load.image("circusmoth", "assets/images/circusmoth.png"), this.load.image("loading", "assets/images/loading.png"), this.load.image("loading_bar_0", "assets/images/loading_bar_0.png"), this.load.image("loading_bar_1", "assets/images/loading_bar_1.png"), game.time.advancedTiming = !0
  280. },
  281. create: function() {
  282. this.game.stage.backgroundColor = "#000000", game.current_category = 0, game.current_lvl = 0, game.lastRoom = null, this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL, this.scale.pageAlignHorizontally = !0, this.scale.setScreenSize(!0), this.game.scale.setResizeCallback(scaleGameSizeUpdate, this.game), game.main_menu_screen = 0, game.time.events.add(1e3, function() {
  283. SaveLoad.loadSave(), this.state.start("Preload")
  284. }, this)
  285. }
  286. };
  287. var scaleGameSizeUpdate = function() {
  288. var t = window.innerHeight / window.innerWidth;
  289. 420 * t > 525 ? this.scale.setGameSize(420, Math.floor(420 * t)) : this.scale.setGameSize(420, 525)
  290. };
  291. SaveLoad = {}, SaveLoad.loadSave = function() {
  292. this.unlocked_levels = [], this.star = [0, 0, 0, 0], this.unlocked_levels[0] = 0, this.unlocked_levels[1] = 0, this.unlocked_levels[2] = 0, this.unlocked_levels[3] = 0, this.all_stars = 0;
  293. try {
  294. this.level = window.localStorage.getItem("cutit_level")
  295. } catch (t) {
  296. console.log("CAN'T ACCESS localStorage"), this.level = null
  297. }
  298. if (null == this.level) {
  299. this.level = [
  300. [],
  301. [],
  302. [],
  303. []
  304. ];
  305. for (var e = 0; 4 > e; e++)
  306. for (var s = 0; 18 > s; s++) this.level[e][s] = 0
  307. } else {
  308. if (this.level = JSON.parse(this.level), !Array.isArray(this.level))
  309. for (var e = 0; 4 > e; e++)
  310. for (var s = 0; 18 > s; s++) this.level[e][s] = 0;
  311. for (var e = 0; 4 > e; e++)
  312. for (var s = 0; 18 > s; s++) this.level[e][s] > 0 && (this.unlocked_levels[e]++, this.star[e] += this.level[e][s]);
  313. this.all_stars = this.star[0] + this.star[1] + this.star[2] + this.star[3]
  314. }
  315. try {
  316. this.SFX = window.localStorage.getItem("SFX")
  317. } catch (t) {
  318. console.log("CAN'T ACCESS localStorage"), this.SFX = null
  319. }
  320. this.SFX = null == this.SFX ? !0 : "true" == this.SFX ? !0 : !1
  321. }, SaveLoad.saveSFX = function() {
  322. try {
  323. window.localStorage.setItem("SFX", this.SFX)
  324. } catch (t) {
  325. console.log("CAN'T ACCESS localStorage")
  326. }
  327. }, SaveLoad.savePassLevel = function(t, e, s) {
  328. if (this.level[t][e] < s) {
  329. this.all_stars += s - this.level[t][e], this.star[t] += s - this.level[t][e], 0 == this.level[t][e] && this.unlocked_levels[t]++, this.level[t][e] = s;
  330. try {
  331. window.localStorage.setItem("cutit_level", JSON.stringify(this.level))
  332. } catch (a) {
  333. console.log("CAN'T ACCESS localStorage")
  334. }
  335. return !0
  336. }
  337. return !1
  338. }, Level = [
  339. [
  340. [
  341. [2, 4],
  342. [128, 164, 128, 324, 288, 324, 288, 164]
  343. ],
  344. [
  345. [2, 6],
  346. [112, 148, 112, 340, 176, 340, 176, 148],
  347. [240, 148, 240, 340, 304, 340, 304, 148]
  348. ],
  349. [
  350. [3, 4],
  351. [64, 356, 352, 356, 208, 132]
  352. ],
  353. [
  354. [2, 4],
  355. [112, 148, 112, 276, 176, 276, 176, 340, 304, 340, 304, 212, 240, 212, 240, 148]
  356. ],
  357. [
  358. [2, 3],
  359. [80, 212, 80, 340, 144, 340, 144, 276, 272, 276, 272, 212, 336, 212, 336, 148, 208, 148, 208, 212]
  360. ],
  361. [
  362. [3, 4],
  363. [96, 148, 96, 212, 224, 212, 224, 276, 160, 276, 160, 340, 288, 340, 352, 276, 288, 276, 288, 212, 224, 148]
  364. ],
  365. [
  366. [3, 6],
  367. [72, 156, 128, 212, 184, 212, 184, 268, 128, 268, 72, 324, 352, 324, 296, 268, 240, 268, 240, 212, 296, 212, 352, 156]
  368. ],
  369. [
  370. [2, 3],
  371. [184, 156, 72, 268, 128, 268, 184, 324, 296, 324, 352, 268, 296, 268, 296, 212, 240, 212]
  372. ],
  373. [
  374. [3, 4],
  375. [144, 180, 80, 244, 80, 308, 144, 308, 144, 244, 272, 244, 272, 308, 336, 308, 336, 244, 272, 180]
  376. ],
  377. [
  378. [2, 3],
  379. [144, 324, 312, 324, 144, 156]
  380. ],
  381. [
  382. [2, 4],
  383. [176, 172, 104, 316, 248, 316, 320, 172]
  384. ],
  385. [
  386. [5, 6],
  387. [96, 220, 96, 316, 336, 316, 336, 220, 288, 220, 288, 268, 240, 268, 240, 172, 192, 172, 192, 268, 144, 268, 144, 220]
  388. ],
  389. [
  390. [3, 6],
  391. [128, 164, 128, 324, 288, 324, 288, 164]
  392. ],
  393. [
  394. [1, 3],
  395. [64, 172, 64, 284, 120, 340, 288, 340, 344, 284, 344, 172, 232, 172, 232, 284, 176, 284, 176, 172]
  396. ],
  397. [
  398. [2, 3],
  399. [184, 148, 120, 212, 120, 276, 184, 340, 248, 340, 312, 276, 312, 212, 248, 148, 248, 212, 184, 212]
  400. ],
  401. [
  402. [3, 6],
  403. [136, 148, 184, 196, 88, 196, 136, 244, 136, 292, 232, 292, 232, 340, 328, 340, 328, 244, 232, 148]
  404. ],
  405. [
  406. [2, 3],
  407. [72, 332, 352, 332, 352, 276, 296, 276, 296, 220, 240, 220, 240, 164, 184, 164, 128, 220, 128, 276]
  408. ],
  409. [
  410. [3, 5],
  411. [104, 212, 104, 324, 328, 324, 272, 268, 272, 156, 160, 156, 160, 212, 216, 212, 216, 268, 160, 268, 160, 212]
  412. ]
  413. ],
  414. [
  415. [
  416. [3, 4],
  417. [80, 148, 80, 340, 336, 340, 336, 148, 272, 212, 208, 148, 144, 212]
  418. ],
  419. [
  420. [2, 4],
  421. [112, 140, 112, 220, 152, 220, 152, 260, 112, 260, 112, 340, 312, 340, 312, 260, 272, 260, 272, 220, 312, 220, 312, 140, 232, 140, 232, 260, 192, 260, 192, 140]
  422. ],
  423. [
  424. [2, 3],
  425. [88, 148, 88, 276, 152, 276, 152, 340, 280, 340, 280, 212, 344, 212, 344, 148]
  426. ],
  427. [
  428. [2, 3],
  429. [88, 212, 88, 340, 216, 340, 152, 276, 280, 276, 344, 212, 344, 148, 280, 148, 280, 212]
  430. ],
  431. [
  432. [3, 4],
  433. [192, 148, 192, 196, 144, 196, 144, 244, 192, 244, 192, 340, 288, 340, 288, 292, 240, 292, 240, 148]
  434. ],
  435. [
  436. [3, 6],
  437. [136, 300, 176, 340, 256, 340, 296, 300, 256, 300, 256, 180, 216, 180, 216, 140, 176, 140, 176, 260, 216, 260, 216, 300]
  438. ],
  439. [
  440. [4, 5],
  441. [272, 140, 152, 140, 152, 340, 272, 340, 272, 300, 192, 300, 192, 260, 232, 260, 232, 220, 192, 220, 192, 180, 272, 180]
  442. ],
  443. [
  444. [3, 4],
  445. [104, 156, 104, 268, 160, 324, 216, 324, 216, 268, 272, 324, 328, 324, 328, 156, 272, 156, 272, 268, 216, 212, 160, 268, 160, 156]
  446. ],
  447. [
  448. [2, 4],
  449. [64, 156, 64, 252, 112, 300, 304, 300, 304, 348, 352, 348, 352, 252, 304, 252, 208, 156, 160, 156, 160, 204, 112, 204]
  450. ],
  451. [
  452. [2, 4],
  453. [160, 132, 216, 188, 216, 244, 160, 244, 104, 188, 104, 300, 160, 300, 160, 356, 216, 300, 272, 356, 272, 300, 328, 300, 328, 244, 272, 244, 272, 132]
  454. ],
  455. [
  456. [2, 4],
  457. [152, 188, 152, 244, 96, 244, 152, 300, 152, 356, 208, 356, 208, 244, 264, 244, 320, 300, 320, 244, 264, 188, 264, 132, 208, 188]
  458. ],
  459. [
  460. [2, 4],
  461. [96, 244, 96, 292, 240, 292, 240, 340, 288, 340, 288, 292, 336, 292, 336, 148, 288, 196, 240, 148, 192, 148, 192, 196, 144, 196, 144, 244]
  462. ],
  463. [
  464. [3, 4],
  465. [152, 132, 152, 244, 96, 244, 96, 300, 152, 300, 152, 356, 208, 356, 208, 300, 264, 244, 208, 244, 208, 188, 264, 188, 320, 244, 320, 132]
  466. ],
  467. [
  468. [3, 4],
  469. [160, 148, 160, 180, 128, 180, 128, 212, 160, 212, 160, 244, 128, 244, 128, 340, 160, 340, 192, 308, 160, 308, 160, 276, 192, 276, 192, 212, 224, 212, 224, 244, 256, 244, 256, 276, 288, 276, 320, 244, 288, 244, 288, 212, 256, 212, 256, 180, 192, 180, 192, 148]
  470. ],
  471. [
  472. [2, 4],
  473. [264, 148, 216, 148, 168, 196, 120, 196, 120, 292, 168, 292, 168, 340, 216, 292, 264, 340, 312, 340, 264, 292, 312, 244, 264, 196]
  474. ],
  475. [
  476. [2, 4],
  477. [280, 148, 160, 148, 120, 188, 120, 228, 160, 268, 120, 308, 160, 308, 200, 348, 200, 308, 280, 308, 320, 268, 320, 228, 280, 268, 200, 268, 160, 228, 200, 188, 240, 188, 280, 228, 320, 188, 280, 188]
  478. ],
  479. [
  480. [2, 3],
  481. [208, 196, 112, 292, 112, 340, 160, 292, 208, 292, 256, 340, 256, 292, 304, 292, 304, 148, 256, 196]
  482. ],
  483. [
  484. [2, 3],
  485. [72, 236, 112, 236, 112, 316, 352, 316, 352, 236, 312, 276, 312, 236, 272, 236, 272, 276, 232, 236, 192, 236, 152, 196, 112, 156, 72, 196]
  486. ]
  487. ],
  488. [
  489. [
  490. [3, 4],
  491. [64, 228, 64, 324, 96, 356, 320, 356, 352, 324, 352, 228, 320, 228, 320, 164, 288, 164, 288, 228, 256, 228, 256, 132, 224, 132, 224, 228, 192, 228, 192, 164, 160, 164, 160, 228, 128, 228, 128, 132, 96, 132, 96, 228]
  492. ],
  493. [
  494. [3, 6],
  495. [128, 132, 64, 196, 128, 356, 160, 260, 192, 324, 224, 324, 256, 260, 288, 356, 352, 196, 288, 132]
  496. ],
  497. [
  498. [2, 4],
  499. [64, 132, 64, 228, 96, 228, 96, 292, 160, 292, 160, 356, 256, 356, 256, 292, 352, 292, 352, 196, 288, 196, 288, 132, 192, 132, 192, 196, 160, 196, 160, 132]
  500. ],
  501. [
  502. [3, 6],
  503. [64, 260, 96, 260, 96, 164, 160, 164, 160, 228, 192, 228, 192, 196, 224, 196, 224, 132, 288, 132, 288, 196, 320, 196, 320, 228, 352, 228, 352, 356, 64, 356]
  504. ],
  505. [
  506. [4, 5],
  507. [192, 132, 64, 196, 64, 292, 160, 356, 224, 292, 320, 292, 352, 196, 320, 132, 288, 132, 288, 196, 224, 196, 224, 260, 160, 260, 160, 196, 192, 196, 192, 164, 224, 164, 224, 132]
  508. ],
  509. [
  510. [2, 3],
  511. [64, 292, 128, 292, 128, 324, 160, 356, 256, 356, 288, 324, 288, 292, 352, 292, 288, 196, 256, 228, 224, 132, 192, 132, 160, 228, 128, 196]
  512. ],
  513. [
  514. [2, 3],
  515. [64, 260, 160, 260, 160, 356, 256, 356, 256, 260, 352, 260, 352, 132, 64, 132]
  516. ],
  517. [
  518. [3, 5],
  519. [64, 260, 64, 356, 352, 356, 352, 132, 288, 228, 256, 164, 224, 196, 192, 164, 160, 196, 128, 132, 96, 196, 96, 260, 64, 228]
  520. ],
  521. [
  522. [3, 4],
  523. [64, 260, 192, 356, 224, 292, 288, 356, 352, 292, 352, 196, 288, 164, 256, 196, 224, 132, 128, 132, 160, 196, 96, 164]
  524. ],
  525. [
  526. [3, 6],
  527. [128, 132, 64, 196, 64, 292, 128, 356, 288, 356, 352, 292, 352, 196, 288, 132]
  528. ],
  529. [
  530. [4, 5],
  531. [352, 196, 256, 132, 160, 132, 64, 196, 64, 292, 160, 356, 288, 356, 352, 292, 224, 260]
  532. ],
  533. [
  534. [3, 4],
  535. [64, 356, 352, 356, 352, 260, 288, 292, 256, 132, 160, 228, 128, 132, 96, 292, 64, 260]
  536. ],
  537. [
  538. [3, 4],
  539. [320, 132, 192, 132, 256, 196, 160, 196, 128, 132, 64, 196, 96, 260, 128, 228, 160, 292, 96, 292, 160, 356, 224, 292, 288, 356, 352, 292, 288, 260, 352, 196]
  540. ],
  541. [
  542. [4, 5],
  543. [192, 132, 128, 228, 64, 260, 96, 356, 192, 356, 192, 324, 224, 324, 224, 356, 320, 356, 352, 260, 288, 228]
  544. ],
  545. [
  546. [2, 4],
  547. [64, 292, 64, 356, 352, 356, 352, 292, 320, 324, 256, 324, 256, 260, 320, 228, 352, 196, 320, 164, 256, 132, 160, 132, 96, 164, 64, 196, 96, 228, 160, 260, 160, 324, 96, 324]
  548. ],
  549. [
  550. [3, 4],
  551. [64, 132, 64, 356, 192, 356, 192, 292, 256, 356, 320, 356, 192, 228, 256, 228, 352, 292, 352, 164, 288, 132]
  552. ],
  553. [
  554. [3, 6],
  555. [160, 132, 64, 228, 64, 292, 160, 356, 288, 356, 352, 260, 320, 164, 256, 132]
  556. ],
  557. [
  558. [4, 5],
  559. [192, 132, 64, 132, 64, 292, 192, 292, 192, 356, 256, 356, 288, 324, 320, 356, 352, 356, 352, 228, 320, 228, 320, 292, 288, 260, 256, 292, 224, 292, 224, 228, 192, 228, 192, 260, 96, 260, 96, 228, 160, 228, 160, 196, 96, 196, 96, 164, 192, 164]
  560. ]
  561. ],
  562. [
  563. [
  564. [2, 4],
  565. [64, 260, 352, 356, 256, 132]
  566. ],
  567. [
  568. [2, 3],
  569. [64, 196, 128, 356, 224, 228, 256, 356, 352, 196, 256, 132, 160, 196, 128, 164]
  570. ],
  571. [
  572. [2, 4],
  573. [64, 228, 128, 324, 256, 324, 288, 356, 320, 356, 352, 260, 288, 164, 192, 196, 128, 164]
  574. ],
  575. [
  576. [5, 6],
  577. [96, 132, 64, 164, 96, 196, 96, 292, 64, 324, 96, 356, 128, 324, 128, 228, 160, 228, 160, 260, 192, 292, 224, 292, 256, 260, 256, 228, 288, 228, 288, 324, 320, 356, 352, 324, 320, 292, 320, 196, 352, 164, 320, 132, 288, 164, 256, 164, 224, 196, 192, 196, 160, 164, 128, 164]
  578. ],
  579. [
  580. [3, 5],
  581. [64, 356, 352, 356, 256, 132, 160, 132]
  582. ],
  583. [
  584. [4, 5],
  585. [96, 292, 192, 324, 224, 228, 288, 324, 288, 356, 352, 356, 320, 132, 160, 132, 160, 196, 64, 196]
  586. ],
  587. [
  588. [2, 4],
  589. [64, 228, 64, 260, 96, 292, 128, 292, 128, 324, 160, 324, 192, 324, 192, 356, 288, 356, 352, 324, 352, 196, 288, 196, 288, 260, 224, 260, 224, 164, 256, 164, 224, 132, 128, 132, 96, 164]
  590. ],
  591. [
  592. [3, 6],
  593. [64, 196, 64, 260, 128, 324, 192, 324, 224, 292, 288, 356, 352, 356, 352, 260, 288, 228, 288, 164, 192, 132, 128, 132]
  594. ],
  595. [
  596. [2, 4],
  597. [64, 356, 352, 356, 320, 324, 320, 292, 288, 292, 288, 196, 320, 196, 320, 164, 288, 132, 224, 132, 192, 164, 192, 196, 224, 196, 224, 260, 192, 292, 160, 260, 128, 260, 128, 292, 96, 324, 64, 292]
  598. ],
  599. [
  600. [2, 6],
  601. [64, 132, 160, 356, 192, 196, 160, 164, 128, 132],
  602. [256, 132, 224, 228, 320, 356, 352, 228]
  603. ],
  604. [
  605. [2, 4],
  606. [128, 132, 160, 228, 64, 260, 160, 292, 160, 356, 224, 292, 320, 356, 288, 292, 352, 196, 256, 228, 288, 132, 224, 196]
  607. ],
  608. [
  609. [3, 6],
  610. [96, 132, 64, 260, 256, 356, 352, 260, 288, 228, 288, 132, 224, 164, 160, 164]
  611. ],
  612. [
  613. [3, 5],
  614. [64, 356, 352, 356, 256, 228, 352, 164, 224, 164, 256, 132, 160, 132, 192, 164, 64, 164, 160, 228]
  615. ],
  616. [
  617. [4, 6],
  618. [192, 132, 160, 228, 96, 132, 64, 260, 128, 356, 192, 324, 256, 324, 352, 260, 320, 164, 256, 228, 256, 132]
  619. ],
  620. [
  621. [3, 4],
  622. [320, 196, 128, 132, 64, 196, 128, 324, 192, 324, 160, 228, 288, 324, 352, 356, 352, 260, 256, 228]
  623. ],
  624. [
  625. [3, 4],
  626. [64, 228, 64, 292, 192, 356, 192, 260, 320, 324, 320, 228, 352, 260, 352, 132, 256, 164, 256, 196, 192, 164, 128, 196, 128, 228, 96, 196]
  627. ],
  628. [
  629. [3, 6],
  630. [128, 132, 64, 196, 64, 260, 128, 292, 128, 324, 160, 324, 160, 356, 288, 356, 288, 324, 320, 292, 352, 260, 352, 164, 320, 132]
  631. ],
  632. [
  633. [3, 5],
  634. [96, 132, 64, 260, 192, 324, 192, 356, 288, 324, 352, 196, 256, 164, 192, 196, 192, 132]
  635. ]
  636. ]
  637. ], Play = function() {}, Play.prototype = {
  638. create: function() {
  639. this.bg = new Background, game.add.existing(this.bg), this.sun_flare = game.add.image(350, 40, "ssheet", "sun"), this.sun_flare.scale.setTo(1.5, 1.5), this.sun_flare.anchor.setTo(.5, .5), game.add.tween(this.sun_flare).to({
  640. angle: 359.9
  641. }, 3e4, Phaser.Easing.Linear.InOut, !0, 0, -1), this.prime_shape = [], this.shapes = [];
  642. for (var t = 1; t < Level[game.current_category][game.current_lvl].length; t++) this.shapes[this.shapes.length] = new Shape(Level[game.current_category][game.current_lvl][t]), this.prime_shape[this.shapes.length - 1] = new Shape(Level[game.current_category][game.current_lvl][t]);
  643. this.wood = game.add.group(), this.wood.x = 210, this.wood_texture = game.add.image(0, 0, "ssheet", "wood_bg"), this.wood_texture.anchor.setTo(.5, 0), this.wood_shape = game.add.graphics(0, 0), this.shapes.forEach(function(t) {
  644. this.wood_shape.beginFill(16711731, 1), this.wood_shape.drawPolygon(t.points), this.wood_shape.endFill()
  645. }, this), this.wood_shape.x = -210, this.wood_texture.mask = this.wood_shape, this.graphics = game.add.graphics(0, 0), this.bitmapka = game.add.bitmapData(game.width, game.height), bitmap_test = this.bitmapka, this.bitmapka_img = this.bitmapka.addToWorld(), this.bitmapka_img.anchor.setTo(.5, 0), this.wood.add(this.wood_texture), this.wood.add(this.wood_shape), this.wood.add(this.bitmapka_img), this.drawAllShapes(), this.cuts_left = Level[game.current_category][game.current_lvl][0][0], this.cuts_start = Level[game.current_category][game.current_lvl][0][0], this.shapes_goal = Level[game.current_category][game.current_lvl][0][1], this.cut_line = game.add.tileSprite(0, 0, 0, 32, "ssheet", "cut_line_hl_line"), this.cut_line.line = game.add.tileSprite(0, 0, 0, 3, "ssheet", "cut_line"), this.cut_line.addChild(this.cut_line.line), this.cut_line.line.anchor.setTo(0, .5), this.cut_line.end1 = game.add.image(0, 0, "ssheet", "cut_line_hl_end"), this.cut_line.end1.anchor.setTo(.5, .5), this.cut_line.addChild(this.cut_line.end1), this.cut_line.end2 = game.add.image(0, 0, "ssheet", "cut_line_hl_end"), this.cut_line.end2.anchor.setTo(.5, .5), this.cut_line.addChild(this.cut_line.end2), this.cut_line.anchor.setTo(0, .5), this.cut_line.visible = !1, this.cut_line.update = function() {
  646. this.visible && (this.rotation = game.math.angleBetween(this.x, this.y, game.input.x, game.input.y), this.width = game.math.distance(this.x, this.y, game.input.x, game.input.y), this.line.width = this.width, this.end2.angle = 180, this.end2.x = this.width)
  647. }, this.input.onDown.add(this.startCut, this), this.input.onUp.add(this.endCut, this), this.cuts_txt_label = game.add.image(130, 10, "ssheet", "cuts_ico"), this.cuts_txt = game.add.bitmapText(220, 20, "font_digits", "x" + this.cuts_left.toString(), 25), this.shapes_txt_label = game.add.image(280, 10, "ssheet", "pieces_ico"), this.shapes_txt = game.add.bitmapText(405, 20, "font_digits", this.shapes.length + "/" + this.shapes_goal, 25), this.shapes_txt.anchor.setTo(1, 0), this.slice_line_line = game.add.image(0, 0, "ssheet", "slice_line"), this.slice_line_line.anchor.setTo(0, .5), this.slice_line_line.alpha = 0, this.slice_line = game.add.image(0, 0, "ssheet", "cut_chinesaw"), this.slice_line.anchor.setTo(.16, .5), this.slice_line.visible = !1, this.labels = game.add.group(), this.labels.x = -210, this.wood.add(this.labels), this.result = game.add.group(), this.result.x = -420, this.result.y = .58 * game.height, this.low_buttons = game.add.group(), this.low_buttons.y = .92 * game.height, this.restart = game.add.button(210, 0, null, this.restart_level, this), this.restart.loadTexture("ssheet", "restart_button"), this.restart.anchor.setTo(.5, .5), this.restart.onInputDown.add(function() {
  648. SaveLoad.SFX && game.sfx.click.play(), game.add.tween(this.restart.scale).to({
  649. x: 1.3,
  650. y: 1.3
  651. }, 200, Phaser.Easing.Sinusoidal.InOut, !0, 0, 0, !0)
  652. }, this), this.low_buttons.add(this.restart), this.back_to_cat = game.add.button(60, 0, null, this.tb_exit_click, this), this.back_to_cat.loadTexture("ssheet", "menu_button"), this.back_to_cat.anchor.setTo(.5, .5), this.back_to_cat.onInputDown.add(function() {
  653. SaveLoad.SFX && game.sfx.click.play(), game.add.tween(this.back_to_cat.scale).to({
  654. x: 1.3,
  655. y: 1.3
  656. }, 200, Phaser.Easing.Sinusoidal.InOut, !0, 0, 0, !0)
  657. }, this), this.low_buttons.add(this.back_to_cat), this.next_button = null, SaveLoad.unlocked_levels[game.current_category] >= game.current_lvl + 1 && game.current_lvl != Level[game.current_category].length - 1 && (this.next_button = game.add.button(360, 0, null, this.next_level, this), this.next_button.loadTexture("ssheet", "arrow_button"), this.next_button.anchor.setTo(.5, .5), this.next_button.onInputDown.add(function() {
  658. SaveLoad.SFX && game.sfx.click.play(), game.add.tween(this.next_button.scale).to({
  659. x: 1.3,
  660. y: 1.3
  661. }, 200, Phaser.Easing.Sinusoidal.InOut, !0, 0, 0, !0)
  662. }, this), this.low_buttons.add(this.next_button)), this.tb_music = game.add.button(80, 0, null, this.tb_music_click, this), this.tb_music.anchor.setTo(.5, 0), SaveLoad.SFX || (this.tb_music.alpha = .5), this.cut_offset = .4 * (game.height - 525), this.wood.y = this.cut_offset, this.tb_music = game.add.button(0, 0, null, this.tb_music_click, this), this.tb_music.anchor.setTo(0, 0), this.tb_music.fixedToCamera = !0, this.tb_music.loadTexture("ssheet", "music_button"), SaveLoad.SFX || (this.tb_music.alpha = .5), 0 == SaveLoad.all_stars ? (this.tutorial = new Tutorial(0, 150), game.add.existing(this.tutorial), this.tutorial_lock = !0, game.time.events.add(1e4, function() {
  663. this.tutorial_lock = !1
  664. }, this)) : this.tutorial_lock = !1, this.info_text = game.add.image(210, 250, null), this.info_text.anchor.setTo(.5, .5), this.fade_gfx = game.add.graphics(0, 0), this.fade_gfx.fixedToCamera = !0, this.fade_gfx.beginFill(16777215, 1), this.fade_gfx.drawRect(0, 0, game.width, game.height), this.fade_gfx.endFill(), game.add.tween(this.fade_gfx).to({
  665. alpha: 0
  666. }, 300, Phaser.Easing.Sinusoidal.Out, !0), this.scale.onSizeChange.add(this.resize_layout, this), this.staremitter = game.add.emitter(0, 0, 50), this.staremitter.width = 29, this.staremitter.height = 29, this.staremitter.makeParticles("ssheet", "star_particle"), this.staremitter.gravity = 300, this.staremitter.setXSpeed(-400, 400), this.staremitter.setYSpeed(-500, 100), this.staremitter.setAlpha(1, 0, 1500), game.device.desktop || (this.turndevice = new TurnDevice, game.add.existing(this.turndevice), this.turndevice.test())
  667. },
  668. update: function() {
  669. this.slice_line.visible && (this.slice_line_line.width = game.math.distance(this.slice_line.x, this.slice_line.y, this.slice_line_line.x, this.slice_line_line.y) + 15, this.prime_contains(this.slice_line.x, this.slice_line.y - this.cut_offset))
  670. },
  671. tb_music_click: function() {
  672. SaveLoad.SFX ? (game.add.tween(this.tb_music).to({
  673. alpha: .5
  674. }, 300, Phaser.Easing.Sinusoidal.InOut, !0), game.sfx.music.stop(), SaveLoad.SFX = !1, SaveLoad.saveSFX()) : (game.add.tween(this.tb_music).to({
  675. alpha: 1
  676. }, 300, Phaser.Easing.Sinusoidal.InOut, !0), SaveLoad.SFX = !0, SaveLoad.saveSFX(), game.sfx.music.play("", 0, 1, !0))
  677. },
  678. prime_contains: function(t, e) {
  679. for (var s = 0; s < this.prime_shape.length; s++)
  680. if (this.prime_shape[s].contains(t, e)) return !0;
  681. return !1
  682. },
  683. resize_layout: function() {
  684. this.cut_offset = .4 * (game.height - 520), 0 == this.result.x ? (this.wood.y = this.cut_offset, this.labels.y = this.cut_offset) : (this.wood.y = this.cut_offset, this.labels.y = this.cut_offset), this.fade_gfx.clear(), this.fade_gfx.beginFill(16777215, 1), this.fade_gfx.drawRect(0, 0, game.width, game.height), this.fade_gfx.endFill(), this.low_buttons.y = .91 * game.height, this.result.y = .58 * game.height, this.bg.rescale(), game.device.desktop || this.turndevice.test()
  685. },
  686. tb_exit_click: function() {
  687. var t = this;
  688. t.really_tb_exit_click()
  689. },
  690. really_tb_exit_click: function() {
  691. game.lastRoom = "Play";
  692. var t = game.add.tween(this.fade_gfx).to({
  693. alpha: 1
  694. }, 300, Phaser.Easing.Sinusoidal.In, !0);
  695. SaveLoad.SFX && game.sfx.transition.play(), t.onComplete.add(function() {
  696. this.state.start("MainMenu")
  697. }, this)
  698. },
  699. startCut: function() {
  700. game.input.y < 70 || game.input.y > .84 * game.height || 0 != this.cuts_left && (this.slice_line.visible || this.shapes.length != this.shapes_goal && (this.tutorial_lock || (SaveLoad.SFX && game.sfx.click.play(), this.cut_line.width = 0, this.cut_line.x = this.input.x, this.cut_line.y = this.input.y, this.cut_line.visible = !0)))
  701. },
  702. endCut: function() {
  703. this.cut_line.visible && (this.cut_line.visible = !1, this.cut_line.end_x = game.input.x, this.cut_line.end_y = game.input.y, this.cut_line.width > 20 && this.cut(new Phaser.Line(this.cut_line.x, this.cut_line.y - this.cut_offset, this.input.x, this.input.y - this.cut_offset)), this.cut_line.width = 0)
  704. },
  705. cut: function(t) {
  706. for (var e = 0; e < this.shapes.length; e++) this.shapes[e].slice(t);
  707. this.makeNewShapes(), this.shapes_txt.setText(this.shapes.length + "/" + this.shapes_goal)
  708. },
  709. endProcedure: function() {
  710. var t = this;
  711. t.reallyEndProcedure()
  712. },
  713. reallyEndProcedure: function() {
  714. /*window.famobi.levelUp(), */this.makeLabels(), game.add.tween(this.wood).to({
  715. y: this.wood.y - 10
  716. }, 500, Phaser.Easing.Sinusoidal.InOut, !0), game.add.tween(this.wood.scale).to({
  717. x: .8,
  718. y: .8
  719. }, 500, Phaser.Easing.Sinusoidal.InOut, !0), SaveLoad.SFX && game.sfx.whoosh.play(), this.result_score = new Phaser.Image(game, 84 + 100 / this.shapes_goal * 6, 0, null), this.result_score.anchor.setTo(.5, 0), this.result_bar = new Phaser.Image(game, 210, 0, "ssheet", "result_bar"), this.result_bar.anchor.setTo(.5, 0), this.result.add(this.result_score), this.result.add(this.result_bar), this.result_star = [];
  720. for (var t = 0; 3 > t; t++) this.result_star[t] = game.add.image(110 + 100 * t, 80, "ssheet", "result_star_0"), this.result_star[t].highlight = new Phaser.Image(game, 0, 0, "ssheet", "result_star_2"), this.result_star[t].anchor.setTo(.5, .5), this.result_star[t].highlight.alpha = 0, this.result_star[t].highlight.anchor.setTo(.5, .5), this.result_star[t].addChild(this.result_star[t].highlight), this.result.add(this.result_star[t]);
  721. game.add.tween(this.result).to({
  722. x: 0
  723. }, 500, Phaser.Easing.Sinusoidal.InOut, !0);
  724. for (var t = 0; t < this.labels.length; t++) game.time.events.add(Phaser.Timer.SECOND + 300 * t, this.revelLabel, this, t);
  725. game.time.events.add(Phaser.Timer.SECOND + 300 * (2 + this.labels.length), this.revealStars, this)
  726. },
  727. revelLabel: function(t) {
  728. var e = this.labels.getChildAt(t);
  729. game.add.tween(e).to({
  730. alpha: 1
  731. }, 300, Phaser.Easing.Sinusoidal.InOut, !0), game.add.tween(e.scale).to({
  732. x: 2,
  733. y: 2
  734. }, 300, Phaser.Easing.Sinusoidal.InOut, !0, 0, 0, !0), this.resultAddDot(e.percent), SaveLoad.SFX && game.sfx.label_pop.play()
  735. },
  736. revealStars: function() {
  737. // window.famobi.levelUp();
  738. console.log('levelUp');
  739. for (var t = this.countResult(), e = 0; t > e; e++) game.add.tween(this.result_star[e].highlight).to({
  740. alpha: 1
  741. }, 500, Phaser.Easing.Sinusoidal.InOut, !0, 0, 0, !0);
  742. 0 == t && (game.add.tween(this.result_star[0]).to({
  743. y: 65
  744. }, 300, Phaser.Easing.Sinusoidal.InOut, !0, 0, 0, !0), game.add.tween(this.result_star[1]).to({
  745. y: 65
  746. }, 300, Phaser.Easing.Sinusoidal.InOut, !0, 100, 0, !0), game.add.tween(this.result_star[2]).to({
  747. y: 65
  748. }, 300, Phaser.Easing.Sinusoidal.InOut, !0, 200, 0, !0)), SaveLoad.savePassLevel(game.current_category, game.current_lvl, t), game.time.events.add(250, function() {
  749. SaveLoad.SFX && (t > 0 ? game.sfx.win.play() : game.sfx.lose.play());
  750. for (var e = 0; t > e; e++) this.result_star[e].loadTexture("ssheet", "result_star_1"), this.staremitter.emitX = this.result_star[e].x, this.staremitter.emitY = this.result.y + this.result_star[e].y, this.staremitter.explode(1500, 15), game.add.tween(this.result_star[e]).to({
  751. angle: 359
  752. }, 3e3, Phaser.Easing.Sinusoidal.InOut, !0, 0, -1, !0)
  753. }, this), t > 0 && void 0 == this.next_button && game.current_lvl != Level[game.current_category].length - 1 && (this.next_button = game.add.button(360, 0, null, function() {
  754. this.next_level(), SaveLoad.SFX && game.sfx.click.play()
  755. }, this), this.next_button.loadTexture("ssheet", "arrow_button"), this.next_button.anchor.setTo(.5, .5), this.low_buttons.add(this.next_button), game.add.tween(this.next_button).from({
  756. alpha: 0
  757. }, 500, Phaser.Easing.Sinusoidal.InOut, !0), game.add.tween(this.next_button.scale).to({
  758. x: 1.2,
  759. y: 1.2
  760. }, 500, Phaser.Easing.Sinusoidal.InOut, !0, 0, -1, !0));
  761. // updateShare(SaveLoad.all_stars);
  762. // Play68.setRankingScoreDesc(SaveLoad.all_stars,Play68.rankingShowType.RANKING_SHOW_NO);
  763. },
  764. countResult: function() {
  765. var t = 100 / this.shapes_goal,
  766. e = 0;
  767. this.labels.forEach(function() {
  768. e = Math.max(e, Math.abs(arguments[0].percent - t))
  769. }, this);
  770. var s = 100 / this.shapes_goal;
  771. return .1 * s > e ? 3 : .2 * s > e ? 2 : .3 * s > e ? 1 : 0
  772. },
  773. resultAddDot: function(t) {
  774. var e = new Phaser.Image(game, 35 + 3.5 * t, 5, "ssheet", "result_point");
  775. game.add.tween(e.scale).to({
  776. x: 2,
  777. y: 2
  778. }, 300, Phaser.Easing.Sinusoidal.InOut, !0, 0, 0, !0), e.anchor.setTo(.5, .4), this.result.add(e)
  779. },
  780. cleanShapes: function() {
  781. for (var t = 0; t < this.shapes.length; t++)(this.shapes[t].to_kill || Math.abs(this.shapes[t].area) < 25) && (this.shapes.splice(t, 1), t = -1)
  782. },
  783. drawAllShapes: function() {
  784. this.bitmapka.clear();
  785. for (var t = 0; t < this.shapes.length; t++) this.drawShapeBitmap(this.shapes[t].points)
  786. },
  787. makeNewShapes: function() {
  788. for (var t = !1, e = 0; e < this.shapes.length; e++)
  789. if (this.shapes[e].new_shapes.length > 0)
  790. for (var s = 0; s < this.shapes[e].new_shapes.length; s++) t = !0, this.shapes[this.shapes.length] = new Shape(this.shapes[e].new_shapes[s]);
  791. if (this.cleanShapes(), t) {
  792. this.cuts_left -= 1, this.cuts_txt.setText("x" + this.cuts_left.toString()), this.slice_line.x = this.cut_line.x, this.slice_line.y = this.cut_line.y, this.slice_line.scale.x = 1.5, this.slice_line.scale.y = 1.5, this.slice_line.alpha = 1, this.slice_line.rotation = this.cut_line.rotation + game.math.degToRad(90), this.slice_line.visible = !0, this.slice_line_line.x = this.cut_line.x, this.slice_line_line.y = this.cut_line.y, this.slice_line_line.alpha = 1, this.slice_line_line.rotation = this.cut_line.rotation, this.slice_line_line.width = 0, SaveLoad.SFX && (game.sfx.chainsaw_index % 2 == 0 ? game.sfx.chainsaw.play() : game.sfx.chainsaw_alt.play(), game.sfx.chainsaw_index++);
  793. var a = game.add.tween(this.slice_line).to({
  794. x: this.cut_line.end_x,
  795. y: this.cut_line.end_y
  796. }, 800, Phaser.Easing.Sinusoidal.InOut).to({
  797. alpha: 0
  798. }, 300, Phaser.Easing.Linear.InOut).start();
  799. a.onComplete.add(function() {
  800. this.slice_line.visible = !1, this.drawAllShapes()
  801. }, this), game.add.tween(this.slice_line_line).to({
  802. alpha: 0
  803. }, 300, Phaser.Easing.Sinusoidal.InOut, !0, 1100), this.shapes.length > this.shapes_goal ? this.wrongShapeNumber() : this.shapes.length == this.shapes_goal ? a.onComplete.add(function() {
  804. game.time.events.add(500, this.endProcedure, this)
  805. }, this) : 0 == this.cuts_left && this.wrongShapeNumber()
  806. }
  807. },
  808. wrongShapeNumber: function() {
  809. game.time.events.add(1e3, function() {
  810. SaveLoad.SFX && game.sfx.lose.play()
  811. }, this), this.shapes.length > this.shapes_goal ? this.info_text.loadTexture("ssheet", "too_many") : this.info_text.loadTexture("ssheet", "not_enough"), game.add.tween(this.info_text).from({
  812. alpha: 0
  813. }, 500, Phaser.Easing.Sinusoidal.InOut, !0, 700), game.add.tween(this.info_text.scale).to({
  814. x: 1.2,
  815. y: 1.2
  816. }, 1e3, Phaser.Easing.Sinusoidal.InOut, !0, 700, -1, !0), game.add.tween(this.restart.scale).to({
  817. x: 1.15,
  818. y: 1.15
  819. }, 1e3, Phaser.Easing.Sinusoidal.InOut, !0, 700, -1, !0), game.add.tween(this.shapes_txt.scale).to({
  820. x: 1.3,
  821. y: 1.3
  822. }, 1e3, Phaser.Easing.Sinusoidal.InOut, !0, 700, -1, !0)
  823. },
  824. drawShapeGraphics: function(t) {
  825. var e = t.length;
  826. this.graphics.lineStyle(6, 0, 1), this.graphics.beginFill(16724736, 0), this.graphics.moveTo(t[0].x, t[0].y);
  827. for (var s = 0; e > s; s++) p_1 = t[s], p_2 = t[(s + 1) % e], this.graphics.lineTo(p_2.x, p_2.y + this.cut_offset);
  828. this.graphics.endFill()
  829. },
  830. drawShapeBitmap: function(t) {
  831. for (var e = t.length, s = 0; e > s; s++) p_1 = t[s], p_2 = t[(s + 1) % e], this.bitmapka.textureLine(new Phaser.Line(p_1.x, p_1.y, p_2.x, p_2.y), "line_dbg")
  832. },
  833. totalArea: function() {
  834. for (var t = 0, e = 0; e < this.shapes.length; e++) t += Math.abs(this.shapes[e].area);
  835. return t
  836. },
  837. makeLabels: function() {
  838. for (var t = this.totalArea(), e = 0; e < this.shapes.length; e++) {
  839. var s = Math.abs(this.shapes[e].area) / t * 100,
  840. a = new Phaser.Image(game, this.shapes[e].centroid.x, this.shapes[e].centroid.y, "ssheet", "result_label");
  841. a.percent = s;
  842. var i = game.add.bitmapText(0, 0, "font_label", parseFloat(Math.round(100 * s) / 100).toFixed(2) + "%", 20);
  843. i.anchor.setTo(.5, .5), a.anchor.setTo(.5, .5), a.addChild(i), a.alpha = 0, this.labels.add(a)
  844. }
  845. },
  846. shutdown: function() {
  847. this.bg.destroy(), this.tb_music.destroy(), this.shapes = null, this.bitmapka_img.destroy(), this.bitmapka = null, this.cut_line.destroy(), this.slice_line.destroy(), this.labels.destroy(), this.result.destroy(), this.restart.destroy(), this.fade_gfx.destroy()
  848. },
  849. restart_level: function() {
  850. var t = this;
  851. t.really_restart_level()
  852. },
  853. really_restart_level: function() {
  854. game.lastRoom = "Play";
  855. var t = game.add.tween(this.fade_gfx).to({
  856. alpha: 1
  857. }, 300, Phaser.Easing.Sinusoidal.In, !0);
  858. t.onComplete.add(function() {
  859. this.state.start("Play")
  860. }, this)
  861. },
  862. next_level: function() {
  863. var t = this;
  864. t.really_next_level()
  865. },
  866. really_next_level: function() {
  867. game.lastRoom = "Play";
  868. var t = game.add.tween(this.fade_gfx).to({
  869. alpha: 1
  870. }, 300, Phaser.Easing.Sinusoidal.In, !0);
  871. game.current_lvl++, t.onComplete.add(function() {
  872. this.state.start("Play")
  873. }, this)
  874. }
  875. };