main.min.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. var Config = {
  2. allTime: 3e4,
  3. liveTimeStart: 3e3,
  4. liveTimeEnd: 1e3,
  5. num: 3,
  6. meiziLen: 13,
  7. interval: 200
  8. },
  9. Res = ["mblogpic/53906b453e48eb290e34/120.jpg", "mblogpic/7a22839181b07a690ecc/120.jpg", "mblogpic/7e90dde8ac83ffd16b58/120.jpg", "mblogpic/f13da5af094ec552f0bc/120.jpg", "mblogpic/97bf0271a41eb311249a/120.jpg", "mblogpic/52bef08d35e6d8f36e7c/120.jpg", "mblogpic/62a31b4cf34795cc5e2c/120.jpg", "mblogpic/9960d7a52d32ba39d3fa/120.jpg", "mblogpic/55dc25c83d4eb9d23ba0/120.jpg", "mblogpic/36f94de5be883f5a6692/120.jpg", "mblogpic/f13da5af094ec552f0bc/120.jpg", "mblogpic/d2a78fdd1659381753a4/460.jpg", "mblogpic/830f59fcde1e5279f01a/460.jpg", "mblogpic/f8aa2f3ca6d4a2bb1622/460.jpg", "mblogpic/59a79dc060d981fe15b0/460.jpg", "mblogpic/d41a598521a46d91ffaa/80.jpg", "mblogpic/54b4a15b4ec611d6337e/460.jpg"],
  10. timeoutData = [{
  11. max: 30,
  12. desc: "肥皂诚可贵,基友价更高!若为妹纸故,二者皆可抛~!这位壮士只亲到 #score# 位妹纸,还需努力啊~"
  13. },
  14. {
  15. max: 50,
  16. desc: "眼前的妹纸是我的心头爱,想要亲她就要点的快~这位壮士本次亲到 #score# 位妹纸,再来一次!可以亲更多的妹纸呢~!"
  17. },
  18. {
  19. max: 90,
  20. desc: "这位壮士眼疾手快亲到了 #score# 位美女,完美闪避出现的宅男~不亏是真·汉纸·无双!"
  21. },
  22. {
  23. max: 30,
  24. desc: "这位壮士完美闪避如花,亲到 #score# 个美女!你行?来试试?"
  25. },
  26. {
  27. max: 1e6,
  28. desc: "这位壮士真直男!爱美女!不畏基友和肥皂的诱惑,居然亲到了 #score# 位妹纸!真是叹为观止~!"
  29. }],
  30. suicideData = [{
  31. max: 0,
  32. desc: "恭喜您亲到了女神如花,他已决定为你生儿育女,和美丽的妹子 say goodbye吧~"
  33. },
  34. {
  35. max: 20,
  36. desc: "人固有一死,或死于老眼昏花错点如花,或死于手速太快误点宅男!马上再来一次,不亲到妹纸不罢休~"
  37. },
  38. {
  39. max: 40,
  40. desc: "此人死于手太快,错把如花当美女~你来亲亲美女试试?"
  41. },
  42. {
  43. max: 60,
  44. desc: "恭喜您亲到了女神如花,他已决定为你生儿育女,和美丽的妹子 say goodbye吧~"
  45. },
  46. {
  47. max: 80,
  48. desc: "壮士断腕,你勇于牺牲自己拯救妹子的精神已感动如花,真英雄,不畏基!"
  49. },
  50. {
  51. max: 1e5,
  52. desc: "虽然你亲到了大波的美女,但还是没能逃过宅男【王大锤】的荼毒……菊花残,满地伤……你的影子已……"
  53. }],
  54. rankData = [{
  55. max: 30,
  56. name: "色中菜鸟"
  57. },
  58. {
  59. max: 50,
  60. name: "色中好手"
  61. },
  62. {
  63. max: 70,
  64. name: "色中饿狼"
  65. },
  66. {
  67. max: 90,
  68. name: "色中领袖"
  69. },
  70. {
  71. max: 1e5,
  72. name: "色中翘楚"
  73. }],
  74. beatData = [{
  75. max: 3,
  76. percent: 0
  77. },
  78. {
  79. max: 5,
  80. percent: 8
  81. },
  82. {
  83. max: 10,
  84. percent: 20
  85. },
  86. {
  87. max: 15,
  88. percent: 40
  89. },
  90. {
  91. max: 30,
  92. percent: 70
  93. },
  94. {
  95. max: 40,
  96. percent: 85
  97. },
  98. {
  99. max: 50,
  100. percent: 98.5
  101. },
  102. {
  103. max: 60,
  104. percent: 99.2
  105. },
  106. {
  107. max: 70,
  108. percent: 99.4
  109. },
  110. {
  111. max: 80,
  112. percent: 99.6
  113. },
  114. {
  115. max: 90,
  116. percent: 99.8
  117. },
  118. {
  119. max: 1e5,
  120. percent: 100
  121. }]; !
  122. function(a) {
  123. var b,
  124. c = $("#layout"),
  125. d = $("#box"),
  126. e = ($(".page"), $("#box .hole")),
  127. f = $("#box .meizi"),
  128. g = ($("#box .kiss"), $(".count_down")),
  129. h = $(".score span"),
  130. i = [],
  131. j = [],
  132. k = 0,
  133. m = {
  134. init: function() {
  135. this.inited || (this.initEvent()),
  136. this.inited = !0
  137. },
  138. load: function() {
  139. function a() {
  140. c++,
  141. b == c && (m.init(), d.switchPage("index"))
  142. }
  143. for (var b = Res.length, c = 0, d = this, e = 0; b > e; e++) {
  144. var f = new Image;
  145. f.onload = a,
  146. f.src = Res[e]
  147. }
  148. },
  149. renderUI: function() {
  150. var b,
  151. c,
  152. g,
  153. h,
  154. i = a.innerWidth - 20,
  155. j = a.innerHeight - 50;
  156. j / i > 1.2 ? (b = Math.min(i, 500), g = (b - 12) / 3, h = 1.2 * g, c = 3 * h + 12) : (c = Math.min(j, 500), b = c / 1.2, g = (b - 12) / 3, h = 1.2 * g),
  157. d.width(b).height(c),
  158. e.width(g).height(h),
  159. f.width(g).height(h)
  160. },
  161. initEvent: function() {
  162. var a = "ontouchstart" in document.documentElement ? "touchend": "click";
  163. d.on(a, ".hole>div", _.bind(this.checkTap, this)),
  164. c.on(a, ".js_start_game", _.bind(this.start, this)),
  165. c.on(a, ".js_pause_game", _.bind(this.pause, this)),
  166. c.on(a, ".js_game_again", _.bind(this.again, this)),
  167. c.on(a, ".js_game_continue", _.bind(this.resume, this))
  168. },
  169. start: function() {
  170. this.reset(),
  171. console.log(">> start"),
  172. h.text(0),
  173. g.text(Config.allTime / 1e3),
  174. this.switchPage("game"),
  175. this.renderUI(),
  176. i = this.initThree(),
  177. console.log(i);
  178. for (var a = 0; 9 > a; a++) i[a] > 0 ? this.addMeizi(a) : j.push(!1);
  179. this.tick()
  180. },
  181. initThree: function() {
  182. for (var a = [], b = 0, c = 9; c > b; b++) a.push(3 > b ? Config.liveTimeStart: 0);
  183. return _.shuffle(a)
  184. },
  185. tick: function(b) {
  186. function c(b) {
  187. return e = e || b,
  188. b = Date.now(),
  189. f = b - e,
  190. f >= k && (d(f), e = b),
  191. l._gameover ? void(h && a.cancelAnimationFrame(h)) : l._pause ? void(h && a.cancelAnimationFrame(h)) : void(h = a.requestAnimationFrame(c))
  192. }
  193. function d(a) {
  194. var b = Date.now();
  195. if (l.time = b - m, l.time >= Config.allTime) return void l.gameOver("timeout");
  196. l.time < 6e3 && g.addClass("danger");
  197. for (var c = 0; 9 > c; c++) {
  198. var d = i[c] - a;
  199. d > 0 ? i[c] = d: j[c] && (l.removeMeizi(c), l.addMeizi())
  200. }
  201. g.text(Math.round((Config.allTime - l.time) / 1e3))
  202. }
  203. var e,
  204. f,
  205. h,
  206. k = Config.interval,
  207. l = this,
  208. m = Date.now();
  209. console.log("startTime", m),
  210. "resume" == b && (m -= l.time);
  211. var e = Date.now();
  212. h = a.requestAnimationFrame(c)
  213. },
  214. resume: function() {
  215. console.log(">> resume"),
  216. this._pause = !1,
  217. this.switchPage("game"),
  218. this.tick("resume")
  219. },
  220. pause: function() {
  221. console.log(">> pause"),
  222. this._pause = !0,
  223. this.switchPage("game_pause")
  224. },
  225. checkTap: function(a) {
  226. if (!this._gameover) {
  227. var b = this,
  228. c = $(a.currentTarget),
  229. d = c.data(),
  230. e = d.id,
  231. f = d.value;
  232. j[e] && (k = f, f ? (this.kiss(e,
  233. function() {
  234. b.removeMeizi(e)
  235. }), this.addMeizi(), this.setScore()) : this.gameOver("suicide"))
  236. }
  237. },
  238. setScore: function() {
  239. this.score += 1,
  240. h.text(this.score)
  241. },
  242. again: function() {
  243. console.log(">> again"),
  244. this.start(),
  245. this.switchPage("game")
  246. },
  247. gameOver: function(a) {
  248. console.log(">> gameover");
  249. var b = this;
  250. this._gameover = !0,
  251. b.switchPage("gameover"); {
  252. var c,
  253. d,
  254. e,
  255. g = this.score,
  256. h = this.filterText(g, beatData).percent;
  257. g > 0 ? "我一分钟亲了" + b.score + "个美女!肯定比你多,不信你试试?": shareDataX.tTitle
  258. }
  259. "timeout" == a ? (c = this.filterText(g, timeoutData), d = c.desc.replace(/#score#/, g), e = "恭喜你将她领回家~") : (c = this.filterText(g, suicideData), d = c.desc, e = "恭喜你将他领回家~");
  260. var i = $("#tpl_gameover").html(),
  261. j = _.template(i, {
  262. score: this.score,
  263. desc: d,
  264. img: Res[k],
  265. name: this.filterText(g, rankData).name,
  266. doMore: "再多亲" + this.random(4, 2) + "个就能多击败" + this.random(5, 2) + "%的玩家,加油哦~",
  267. congratulation: e,
  268. percent: h
  269. });
  270. $("#gameover").html(j),
  271. f.removeClass();
  272. dp_submitScore(g);
  273. },
  274. filterText: function(a, b) {
  275. var c = _.filter(b,
  276. function(b) {
  277. return a <= b.max
  278. });
  279. return c[0]
  280. },
  281. reset: function() {
  282. i = [],
  283. j = [],
  284. this.time = Config.allTime,
  285. this.score = 0,
  286. this._gameover = null,
  287. this._pause = !1,
  288. b = Date.now()
  289. },
  290. switchPage: function(a) {
  291. a && ($(".page").addClass("hide"), $("#" + a).addClass("show").removeClass("hide"))
  292. },
  293. random: function(a, b) {
  294. return Math.floor(Math.random() * (a - b + 1)) + b
  295. },
  296. randomSurplusOnly: function() {
  297. function a() {
  298. var c = 8,
  299. d = 0,
  300. e = Math.floor(Math.random() * (c - d + 1)) + d;
  301. return b[e] ? a() : e
  302. }
  303. var b = _.clone(j);
  304. return a()
  305. },
  306. removeMeizi: function(a) {
  307. i[a] = 0,
  308. j[a] = !1,
  309. $(f[a]).removeClass()
  310. },
  311. addMeizi: function(a) {
  312. var a = _.isUndefined(a) ? this.randomSurplusOnly() : a,
  313. b = this.random(Config.meiziLen - 1, 0);
  314. j[a] = !0,
  315. i[a] = this.getliveTime(),
  316. $(f[a]).addClass("meizi_" + b).addClass("meizi").data("value", b)
  317. },
  318. initShareEvent: function() {
  319. },
  320. kiss: function(a, b) {
  321. var c = $(f[a]),
  322. d = '<img src="mblogpic/54b4a15b4ec611d6337e/460.jpg" />';
  323. c.html(d),
  324. c.find("img").fadeOut(300, b)
  325. },
  326. getliveTime: function() {
  327. var a = (Config.liveTimeStart - Config.liveTimeEnd) / Config.allTime;
  328. return Config.liveTimeStart - this.time * a
  329. }
  330. };
  331. m.load()
  332. } (window);