main.min.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. var _config = {
  2. color: {
  3. allTime: 60,
  4. addTime: 0,
  5. lvMap: [2, 3, 4, 5, 5, 6, 6, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9]
  6. },
  7. pic: {
  8. isOpen: !1,
  9. allTime: 5,
  10. addTime: 0,
  11. lvMap: [2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8]
  12. }
  13. },
  14. shareData = {
  15. imgUrl: "http://game.ikongzhong.cn/games/semo/logo.jpg",
  16. timeLineLink: "http://game.ikongzhong.cn/games/semo/index.html",
  17. tTitle: "看你有多色?",
  18. tContent: "找出所有色块中颜色不同的一块。分享朋友圈,找到身边的色魔"
  19. };
  20. !
  21. function() {
  22. var a = $("#box"),
  23. b = {
  24. lv: $("#room .lv em"),
  25. time: $("#room .time"),
  26. start: $("#dialog .btn-restart"),
  27. back: $("#dialog .btn-back"),
  28. share: $("#dialog .btn-share"),
  29. pause: $("#room .btn-pause"),
  30. resume: $("#dialog .btn-resume"),
  31. dialog: $("#dialog"),
  32. d_content: $("#dialog .content"),
  33. d_pause: $("#dialog .pause"),
  34. d_gameover: $("#dialog .gameover")
  35. },
  36. c = {
  37. init: function(a, b, c) {
  38. this.type = a, this.api = API[a], this.config = _config[a], this.reset(), this.parent = c, this.el = b, this.renderUI(), this.inited || this.initEvent(), this.inited = !0, this.start()
  39. },
  40. renderUI: function() {
  41. var b = 90 == window.orientation || -90 == window.orientation,
  42. c = b ? window.innerHeight : window.innerWidth;
  43. c -= 20, c = Math.min(c, 500), a.width(c).height(c), this.el.show()
  44. },
  45. initEvent: function() {
  46. var d = "ontouchstart" in document.documentElement ? "touchend" : "click",
  47. e = this;
  48. $(window).resize(function() {
  49. c.renderUI()
  50. }), a.on(d, "span", function() {
  51. var a = $(this).data("type");
  52. "a" == a && e.nextLv.call(e)
  53. }), b.pause.on(d, _.bind(this.pause, this)), b.resume.on(d, _.bind(this.resume, this)), b.start.on(d, _.bind(this.start, this)), b.back.on(d, _.bind(this.back, this)), b.share.on(d, _.bind(this.share, this))
  54. },
  55. start: function() {
  56. this.time > 5 && b.time.removeClass("danger"), b.dialog.hide(), this._pause = !1, this.lv = "undefined" != typeof this.lv ? this.lv + 1 : 0, this.lvMap = this.config.lvMap[this.lv] || _.last(this.config.lvMap), this.renderMap(), this.renderInfo(), this.timer || (this.timer = setInterval(_.bind(this.tick, this), 1e3))
  57. },
  58. share: function() {},
  59. resume: function() {
  60. b.dialog.hide(), this._pause = !1
  61. },
  62. pause: function() {
  63. this._pause = !0, b.d_content.hide(), b.d_pause.show(), b.dialog.show()
  64. },
  65. tick: function() {
  66. return this._pause ? void 0 : (this.time--, this.time < 6 && b.time.addClass("danger"), this.time < 0 ? void this.gameOver() : void b.time.text(parseInt(this.time)))
  67. },
  68. renderMap: function() {
  69. if (!this._pause) {
  70. var b = this.lvMap * this.lvMap,
  71. c = "",
  72. d = "lv" + this.lvMap;
  73. _(b).times(function() {
  74. c += "<span></span>"
  75. }), a.attr("class", d).html(c), this.api.render(this.lvMap, this.lv)
  76. }
  77. },
  78. renderInfo: function() {
  79. b.lv.text(this.lv + 1)
  80. },
  81. gameOver: function() {
  82. try {
  83. WeixinJSBridge.call("showOptionMenu")
  84. } catch (c) {}
  85. var d = this.api.getGameOverText(this.lv);
  86. this.lastLv = this.lv, this.lastGameTxt = d.txt, this.lastGamePercent = d.percent, b.d_content.hide(), b.d_gameover.show().find("h3").text(this.lastGameTxt), a.find("span").fadeOut(1500, function() {
  87. b.dialog.show()
  88. }), this._pause = !0, this.reset()
  89. },
  90. reset: function() {
  91. this.time = this.config.allTime, this.lv = -1
  92. },
  93. nextLv: function() {
  94. this.time += this.config.addTime, b.time.text(parseInt(this.time)), this._pause || this.start()
  95. },
  96. back: function() {
  97. this._pause = !0, this.el.hide(), b.dialog.hide(), this.parent.render()
  98. }
  99. };
  100. window.Game = c
  101. }(), function(a) {
  102. var b = {
  103. index: $("#index"),
  104. room: $("#room"),
  105. loading: $("#loading"),
  106. dialog: $("#dialog"),
  107. play: $(".play-btn"),
  108. btn_boyaa: $(".btn-boyaa"),
  109. banner: $(".banner"),
  110. boyaa_logo: $(".boyaa-logo")
  111. },
  112. c = window.navigator.userAgent.toLowerCase(),
  113. d = {
  114. init: function() {
  115. this.initEvent(), this.loading(), /android/i.test(c) ? (b.banner.show()) : /iphone|ipad|ipod/i.test(c) && ( b.banner.show())
  116. },
  117. loading: function() {
  118. function a() {
  119. e++, e == c && d.render()
  120. }
  121. if (_config.pic.isOpen) for (var b = ["assets/img/1.png", "assets/img/2.png", "assets/img/3.png", "assets/img/4.png", "assets/img/5.png", "assets/img/6.png", "assets/img/7.png", "assets/img/8.png", "assets/img/9.png", "assets/img/10.png", "assets/img/11.png", "assets/img/12.png", "assets/img/13.png", "assets/img/14.png", "assets/img/15.png", "assets/img/16.png", "assets/img/17.png", "assets/img/18.png"], c = b.length, e = 0, f = 0; c > f; f++) {
  122. var g = new Image;
  123. g.onload = a, g.src = b[f]
  124. } else d.render();
  125. var backurl = "http://www.lieqicun.com/nav/top.php?id=215";
  126. document.addEventListener("WeixinJSBridgeReady", function() {
  127. WeixinJSBridge && (WeixinJSBridge.on("menu:share:appmessage", function() {
  128. var a = Game.lastLv > 0 ? "我闯过" + (Game.lastLv + 1) + "关,击败" + Game.lastGamePercent + "%的人!我是【" + Game.lastGameTxt + "】!不服来战!" : shareData.tTitle;
  129. WeixinJSBridge.invoke("sendAppMessage", {
  130. img_url: shareData.imgUrl,
  131. link: shareData.timeLineLink,
  132. desc: shareData.tContent,
  133. title: a
  134. }, function(res) {
  135. document.location.href = backurl;
  136. setTimeout(function(){document.location.href = 'http://www.lieqicun.com/nav/top.php?id=167';},1000);
  137. })
  138. }), WeixinJSBridge.on("menu:share:timeline", function() {
  139. var a = Game.lastLv > 0 ? "我闯过" + (Game.lastLv + 1) + "关,击败" + Game.lastGamePercent + "%的人!我是【" + Game.lastGameTxt + "】!不服来战!" : shareData.tTitle;
  140. WeixinJSBridge.invoke("shareTimeline", {
  141. img_url: shareData.imgUrl,
  142. img_width: "640",
  143. img_height: "640",
  144. link: shareData.timeLineLink,
  145. desc: shareData.tContent,
  146. title: a
  147. }, function(res) {
  148. document.location.href = backurl;
  149. setTimeout(function(){document.location.href = 'http://www.lieqicun.com/nav/top.php?id=167';},1000);
  150. })
  151. }))
  152. }, !1)
  153. },
  154. render: function() {
  155. b.loading.hide(), b.index.show()
  156. },
  157. initEvent: function() {
  158. var a = "ontouchstart" in document.documentElement ? "touchstart" : "click",
  159. c = this;
  160. b.play.on(a, function() {
  161. var a = $(this).data("type") || "color";
  162. b.index.hide(), Game.init(a, b.room, c)
  163. }), b.btn_boyaa.on(a, function() {
  164. }), b.boyaa_logo.on(a, function() {
  165. }), b.banner.on(a, function() {
  166. })
  167. }
  168. };
  169. d.init(), a.API = {}
  170. }(window), function() {
  171. var a = $("#box"),
  172. b = "span",
  173. c = $("#help p"),
  174. d = $("#help_color"),
  175. e = {
  176. lvT: ["瞎子", "色盲", "色郎", "色狼", "色鬼", "色魔", "超级色魔", "变态色魔", "孤独求色"],
  177. render: function(e, f) {
  178. this.lv = f, c.hide(), d.show();
  179. var g = _config.color.lvMap[f] || _.last(_config.color.lvMap);
  180. this.d = 15 * Math.max(9 - g, 1), this.d = f > 20 ? 10 : this.d, this.d = f > 40 ? 8 : this.d, this.d = f > 50 ? 5 : this.d;
  181. var h = Math.floor(Math.random() * e * e),
  182. i = this.getColor(255 - this.d),
  183. j = this.getLvColor(i[0]);
  184. a.find(b).css("background-color", i[1]).data("type", "b"), a.find(b).eq(h).css("background-color", j[1]).data("type", "a")
  185. },
  186. getColor: function(a) {
  187. var b = [Math.round(Math.random() * a), Math.round(Math.random() * a), Math.round(Math.random() * a)],
  188. c = "rgb(" + b.join(",") + ")";
  189. return [b, c]
  190. },
  191. getLvColor: function(a) {
  192. var b = this.d,
  193. c = _.map(a, function(a) {
  194. return a + b
  195. }),
  196. d = "rgb(" + c.join(",") + ")";
  197. return [c, d]
  198. },
  199. getGameOverText: function(a) {
  200. var b = 15 > a ? 0 : Math.ceil((a - 15) / 5),
  201. c = this.lvT[b] || _.last(this.lvT),
  202. d = c + "lv" + (a + 1),
  203. e = 2 * a;
  204. return e = e > 90 ? 90 + .15 * a : e, e = Math.min(e, 100), {
  205. txt: d,
  206. percent: e
  207. }
  208. }
  209. };
  210. API.color = e
  211. }();