game(1).js 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780
  1. function att(e) {
  2. new Jok.JokEngine("gameCanvas");
  3. (new Jok.JokG).jokEngine.initState(new PreloadState)
  4. }
  5. function init() {
  6. att(0);
  7. }
  8. var Jok = Jok || {};
  9. Jok.JokState = function() {
  10. createjs.Container.call(this);
  11. this.name = ""
  12. };
  13. Jok.JokState.prototype = Object.create(createjs.Container.prototype);
  14. Jok.JokState.prototype.constructor = Jok.JokState;
  15. Jok.JokState.prototype.dispose = function() {};
  16. Jok.JokState.prototype.create = function() {};
  17. Jok.JokState.prototype.update = function() {};
  18. SplashScreenZibbo = function() {
  19. Jok.JokState.call(this)
  20. };
  21. SplashScreenZibbo.prototype = Object.create(Jok.JokState.prototype);
  22. SplashScreenZibbo.prototype.constructor = SplashScreenZibbo;
  23. SplashScreenZibbo.prototype.create = function() {
  24. console.log("SplashScreenZibbo.create");
  25. var e = new createjs.Container;
  26. this.addChild(e);
  27. this.shape = new createjs.Shape;
  28. this.shape.x = -(new Jok.JokG).width / 2;
  29. this.shape.y = -(new Jok.JokG).height / 2;
  30. this.shape.graphics.beginFill("rgba(255,255,255,1)").rect(0, 0, (new Jok.JokG).width, (new Jok.JokG).height);
  31. e.addChild(this.shape);
  32. var t = new createjs.Bitmap((new Jok.JokG).queue.getResult("zibboLogoBig"));
  33. t.x = -t.getBounds().width / 2;
  34. t.y = -t.getBounds().height / 2;
  35. e.addChild(t);
  36. console.log("bmp.x = " + t.x);
  37. this.timeBegin = createjs.Ticker.getTime();
  38. this.transScreen = true;
  39. e.on("click", createjs.proxy(ZibboUtils.logoAction, this));
  40. e.cursor = "pointer";
  41. if ((new Jok.JokG).showZibbo) {
  42. console.log("new Jok.JokG().showZibbo = " + (new Jok.JokG).showZibbo)
  43. }
  44. };
  45. SplashScreenZibbo.prototype.openUrl = function() {
  46. ZibboUtils.logoAction()
  47. };
  48. SplashScreenZibbo.prototype.update = function() {
  49. if (createjs.Ticker.getTime() - this.timeBegin > 500 && this.transScreen) {
  50. this.transScreen = false;
  51. (new Jok.JokG).jokEngine.transitionScreen(new MainMenu, null, null)
  52. }
  53. };
  54. ZibboUtils = function() {};
  55. ZibboUtils.prototype.constructor = ZibboUtils;
  56. ZibboUtils.walkAction = function() {
  57. ZibboUtils.buttonAction("walkthrough")
  58. };
  59. ZibboUtils.moreAction = function() {
  60. ZibboUtils.buttonAction("more_games")
  61. };
  62. ZibboUtils.logoAction = function() {
  63. ZibboUtils.buttonAction("logo")
  64. };
  65. ZibboUtils.buttonAction = function(e) {};
  66. ZibboUtils.openUrl = function(e) {
  67. e = e || "http://play68.com";
  68. var t = window.open(e, "_blank");
  69. t.focus()
  70. };
  71. MyButtonBase = function(e, t, n, r) {
  72. createjs.Container.call(this);
  73. this.actionFunc = e;
  74. this._actionDefault = null;
  75. this.x = t.x;
  76. this.y = t.y;
  77. this._scaleBegin = n;
  78. this.scaleX = this._scaleBegin.x;
  79. this.scaleY = this._scaleBegin.y;
  80. if (r)
  81. if (r.length > 0) {
  82. this.sprDown = new createjs.Sprite(Jok.JokG().animLoader.spriteSheet, r);
  83. this.sprDown.stop();
  84. this.addChild(this.sprDown)
  85. }
  86. this.onWork();
  87. this.TIME_ANIM = 300;
  88. this.SCALE_ANIM = 1.11;
  89. this.tweenSize = null;
  90. this.eventScaleBegin = createjs.proxy(this.scaleBegin, this);
  91. this.eventScaleEnd = createjs.proxy(this.scaleEnd, this)
  92. };
  93. MyButtonBase.prototype = Object.create(createjs.Container.prototype);
  94. MyButtonBase.prototype.constructor = MyButtonBase;
  95. MyButtonBase.prototype.addBmpTTT = function(e, t, n, r) {
  96. console.log("bmp = " + e);
  97. console.log("MyButtonBase.prototype.addBmpTTT width = " + n);
  98. if (n);
  99. else if (e.getBounds()) {
  100. n = e.getBounds().width;
  101. r = e.getBounds().height
  102. } else {
  103. n = 202;
  104. r = 50
  105. } if (t) {
  106. e.x = -n / 2;
  107. e.y = -r / 2
  108. }
  109. var i = new createjs.Shape((new createjs.Graphics).beginFill("#000000").drawRect(e.x, e.y, n, r));
  110. this.hitArea = i;
  111. this.addChild(e);
  112. console.log("this.addChild(bmp);")
  113. };
  114. MyButtonBase.prototype.initUp = function(e) {
  115. this.sprUp = new createjs.Sprite(Jok.JokG().animLoader.spriteSheet, e);
  116. this.sprUp.stop();
  117. this.addChild(this.sprUp)
  118. };
  119. MyButtonBase.prototype.action = function(e) {
  120. if (this.tweenSize == null) {
  121. (new MusicManager).playMouse();
  122. if (this.actionFunc != null) this.actionFunc();
  123. this.tweenSize = createjs.Tween.get(this).to({
  124. scaleX: this._scaleBegin.x * this.SCALE_ANIM,
  125. scaleY: this._scaleBegin.y * this.SCALE_ANIM
  126. }, this.TIME_ANIM, createjs.Ease.quartInOut).call(this.eventScaleBegin)
  127. }
  128. };
  129. MyButtonBase.prototype.scaleBegin = function(e) {
  130. this.tweenSize = createjs.Tween.get(this).to({
  131. scaleX: this._scaleBegin.x,
  132. scaleY: this._scaleBegin.y
  133. }, this.TIME_ANIM, createjs.Ease.quartInOut).call(this.eventScaleEnd)
  134. };
  135. MyButtonBase.prototype.scaleEnd = function(e) {
  136. this.tweenSize = null
  137. };
  138. MyButtonBase.prototype.onSetAction = function(e) {
  139. this.offWork();
  140. this._actionDefault = e;
  141. this.onWork()
  142. };
  143. MyButtonBase.prototype.onWork = function() {
  144. if (!this.hasEventListener("click"))
  145. if (this._actionDefault != null) this.on("click", this._actionDefault);
  146. else this.eventAction = this.on("click", createjs.proxy(this.action, this));
  147. this.cursor = "pointer"
  148. };
  149. MyButtonBase.prototype.offWork = function() {
  150. console.log("MyButtonBase.prototype.offWork");
  151. if (this.hasEventListener("click")) this.off("click", this.eventAction);
  152. this.cursor = "arrow"
  153. };
  154. FieldContainer = function(e, t) {
  155. createjs.Container.call(this);
  156. this.gameManager = t;
  157. this.field = e;
  158. this.fieldsSteps = [];
  159. this.addSaveStep();
  160. this.x = -this.gameManager.FIELD_WIDTH / 2 * this.gameManager.CELL_SIZE + this.gameManager.CELL_SIZE;
  161. this.y = -207;
  162. this.BLUE_ID = 1;
  163. this.ORANGE_ID = 2;
  164. this.BLACK_ID = 3;
  165. this.PURPLE_ID = 4;
  166. this._moveClipsNames = {};
  167. this._moveClipsNames["" + this.BLUE_ID] = "tile_a_";
  168. this._moveClipsNames["" + this.ORANGE_ID] = "tile_c_";
  169. this._moveClipsNames["" + this.BLACK_ID] = "tile_black_";
  170. this._moveClipsNames["" + this.PURPLE_ID] = "tile_b_";
  171. this.figures = [];
  172. this._moveComplete = true;
  173. this._numMove = 0;
  174. this.findFigures();
  175. this.drawBlackCells();
  176. this.initMouse()
  177. };
  178. FieldContainer.prototype = Object.create(createjs.Container.prototype);
  179. FieldContainer.prototype.constructor = FieldContainer;
  180. FieldContainer.prototype.initMouse = function() {
  181. this.stage = (new Jok.JokG).stage;
  182. this._mouseDown = false;
  183. this._step = false;
  184. this._oldPos = new createjs.Point(this.stage.mouseX, this.stage.mouseY);
  185. this.onMouse();
  186. this.MOUSE_X_Y_DIFF_MIN = 5;
  187. this.MOUSE_PATH_MIN = 3
  188. };
  189. FieldContainer.prototype.offMouse = function() {
  190. this.stage.off("stagemousemove", this.eventMove);
  191. this.stage.off("stagemousedown", this.eventMouseDown);
  192. this.stage.off("stagemouseup", this.eventMouseUp)
  193. };
  194. FieldContainer.prototype.onMouse = function() {
  195. this.eventMove = this.stage.on("stagemousemove", createjs.proxy(this.cccMouseMove, this));
  196. this.eventMouseDown = this.stage.on("stagemousedown", createjs.proxy(this.cccMouseDown, this));
  197. this.eventMouseUp = this.stage.on("stagemouseup", createjs.proxy(this.cccMouseUp, this))
  198. };
  199. FieldContainer.prototype.cccMouseMove = function(e) {
  200. if (this._mouseDown && this._step && this._moveComplete) {
  201. var t = this.stage.mouseX;
  202. var n = this.stage.mouseY;
  203. var r = Math.abs(t - this._oldPos.x);
  204. var i = Math.abs(n - this._oldPos.y);
  205. if (Math.abs(r - i) < this.MOUSE_X_Y_DIFF_MIN || r < this.MOUSE_PATH_MIN && i < this.MOUSE_PATH_MIN) {
  206. this._oldPos.x = t;
  207. this._oldPos.y = n;
  208. return
  209. }
  210. this._step = false;
  211. this._numMove = 0;
  212. this._moveComplete = false;
  213. if (r > i)
  214. if (t > this._oldPos.x) this.step(1, 0);
  215. else this.step(-1, 0);
  216. else if (n > this._oldPos.y) this.step(0, 1);
  217. else this.step(0, -1);
  218. this._oldPos.x = t;
  219. this._oldPos.y = n
  220. }
  221. };
  222. FieldContainer.prototype.cccMouseDown = function(e) {
  223. this._mouseDown = true;
  224. this._step = true;
  225. this._oldPos.x = this.stage.mouseX;
  226. this._oldPos.y = this.stage.mouseY
  227. };
  228. FieldContainer.prototype.cccMouseUp = function(e) {
  229. this._mouseDown = false
  230. };
  231. FieldContainer.prototype.findFigures = function() {
  232. var e = new FigureBlocks(this.field, this.gameManager, this);
  233. var t = 0;
  234. var n = 0;
  235. for (t = 0; t < this.gameManager.FIELD_WIDTH; t++)
  236. for (n = 0; n < this.gameManager.FIELD_HEIGHT; n++)
  237. if (!this.cellOnFigere(t, n))
  238. if (e.findAllCells(t, n)) {
  239. this.figures.push(e);
  240. this.addChild(e);
  241. var e = new FigureBlocks(this.field, this.gameManager, this)
  242. }
  243. };
  244. FieldContainer.prototype.cellOnFigere = function(e, t) {
  245. for (var n = 0; n < this.figures.length; n++)
  246. if (this.figures[n].isCellFigure(e, t)) return true;
  247. return false
  248. };
  249. FieldContainer.prototype.drawBlackCells = function() {
  250. this.drawOne(this.BLACK_ID)
  251. };
  252. FieldContainer.prototype.testDrawFiled = function() {
  253. this.removeAllChildren();
  254. this.drawOne(this.BLACK_ID);
  255. this.drawOne(this.BLUE_ID);
  256. this.drawOne(this.ORANGE_ID);
  257. this.drawOne(this.PURPLE_ID)
  258. };
  259. FieldContainer.prototype.drawOne = function(e) {
  260. var t = -1;
  261. var n = -1;
  262. var r = new createjs.Container;
  263. this.addChild(r);
  264. for (t = -1; t < this.gameManager.FIELD_WIDTH; t++)
  265. for (n = -1; n < this.gameManager.FIELD_HEIGHT; n++) {
  266. var i = this.getSprTile(t, n, e);
  267. if (i != null) {
  268. i.x = this.gameManager.CELL_SIZE * t;
  269. i.y = this.gameManager.CELL_SIZE * n;
  270. r.addChild(i)
  271. }
  272. }
  273. };
  274. FieldContainer.prototype.getSprTile = function(e, t, n) {
  275. var r = this.getTileId(e, t);
  276. var i = this.getTileId(e + 1, t);
  277. var s = this.getTileId(e + 1, t + 1);
  278. var o = this.getTileId(e, t + 1);
  279. if (r != n) r = 0;
  280. else r = 1; if (i != n) i = 0;
  281. else i = 1; if (s != n) s = 0;
  282. else s = 1; if (o != n) o = 0;
  283. else o = 1; if (r == 0 && i == 0 && s == 0 && o == 0) return null;
  284. var u = new createjs.Sprite(Jok.JokG().animLoader.spriteSheet, this._moveClipsNames["" + n] + r + "_" + i + "_" + s + "_" + o);
  285. u.stop();
  286. return u
  287. };
  288. FieldContainer.prototype.getTileId = function(e, t) {
  289. if (e <= -1 || t <= -1 || e >= this.gameManager.FIELD_WIDTH || t >= this.gameManager.FIELD_HEIGHT) return 0;
  290. return this.field[e][t]
  291. };
  292. FieldContainer.prototype.getFigureByCell = function(e, t) {
  293. for (var n = 0; n < this.figures.length; n++)
  294. if (this.figures[n].isCellFigure(e, t)) return this.figures[n];
  295. console.log("OMFG figures = NULL )) cellX = " + e + " cellY = " + t);
  296. return null
  297. };
  298. FieldContainer.prototype.step = function(e, t) {
  299. for (var n = 0; n < this.figures.length; n++) this.figures[n].step(e, t);
  300. var r = false;
  301. while (true) {
  302. r = false;
  303. for (var n = 0; n < this.figures.length; n++)
  304. if (this.figures[n].postStep()) r = true;
  305. if (!r) break
  306. }
  307. for (var n = 0; n < this.figures.length; n++) this.figures[n].preGo();
  308. var i = false;
  309. for (n = 0; n < this.figures.length; n++)
  310. if (this.figures[n].go(e, t)) i = true;
  311. if (i) {
  312. (new MusicManager).playStep();
  313. this.gameManager.gui.starBar.addStep();
  314. this.addSaveStep()
  315. }
  316. };
  317. FieldContainer.prototype.checkFigureConnection = function() {
  318. var e = false;
  319. for (var t = 0; t < this.figures.length; t++)
  320. for (var n = t + 1; n < this.figures.length; n++)
  321. if (this.figures[t].connectToFigure(this.figures[n])) e = true;
  322. if (e) {
  323. for (var t = 0; t < this.figures.length; t++)
  324. if (this.figures[t].connecting) {
  325. this.removeChild(this.figures[t]);
  326. this.figures.splice(t, 1);
  327. t--
  328. }
  329. this.findFigures();
  330. if (!this.checkWin())(new MusicManager).playConnect()
  331. }
  332. };
  333. FieldContainer.prototype.checkWin = function() {
  334. var e = {};
  335. e["" + this.BLUE_ID] = 0;
  336. e["" + this.ORANGE_ID] = 0;
  337. e["" + this.BLACK_ID] = 0;
  338. e["" + this.PURPLE_ID] = 0;
  339. for (var t = 0; t < this.figures.length; t++) e["" + this.figures[t].cellId]++;
  340. for (var t in e)
  341. if (e[t] > 1) return false;
  342. this.gameManager.setGameOver();
  343. console.log("WIN!!!");
  344. // updateShare(this.gameManager.levelId + 1);
  345. // Play68.setRankingScoreDesc(this.gameManager.levelId + 1, Play68.rankingShowType.RANKING_SHOW_NO);
  346. return true
  347. };
  348. FieldContainer.prototype.moveComplete = function() {
  349. this._numMove++;
  350. if (this._numMove == this.figures.length) {
  351. this._moveComplete = true;
  352. this.checkFigureConnection()
  353. }
  354. };
  355. FieldContainer.prototype.addSaveStep = function() {
  356. var e = [];
  357. for (var t = 0; t < this.field.length; t++) e.push(this.field[t].slice(0));
  358. this.fieldsSteps.push(e);
  359. this.traceSteps()
  360. };
  361. FieldContainer.prototype.deleteStep = function() {
  362. if (this.gameManager.gui.starBar.stepNow > 0) {
  363. var e = this.fieldsSteps[this.gameManager.gui.starBar.stepNow - 1];
  364. for (var t = 0; t < e.length; t++)
  365. for (var n = 0; n < e[t].length; n++) this.field[t][n] = e[t][n];
  366. this.fieldsSteps.pop();
  367. console.log(this.fieldsSteps.length);
  368. this.gameManager.gui.starBar.stepNow = this.gameManager.gui.starBar.stepNow - 2;
  369. this.gameManager.gui.starBar.addStep();
  370. for (var t = 0; t < this.figures.length; t++) this.removeChild(this.figures[t]);
  371. this.figures.length = 0;
  372. this.findFigures()
  373. }
  374. this.traceSteps()
  375. };
  376. FieldContainer.prototype.traceSteps = function() {};
  377. FigureBlocks = function(e, t, n) {
  378. createjs.Container.call(this);
  379. this.gameManager = t;
  380. this.field = e;
  381. this.fieldContainer = n;
  382. this._moveClipsNames = this.fieldContainer._moveClipsNames;
  383. this.cells = [];
  384. this.id = (new Jok.JokG).getNewid();
  385. this.figuresStep = [];
  386. this.connecting = false;
  387. this.tweenMove = null;
  388. this.eventMoveComplete = createjs.proxy(this.moveComplete, this);
  389. this.MOVE_TIME = 320;
  390. this.MOVE_CLOSE_PATH = this.gameManager.CELL_SIZE / 10
  391. };
  392. FigureBlocks.prototype = Object.create(createjs.Container.prototype);
  393. FigureBlocks.prototype.constructor = FigureBlocks;
  394. FigureBlocks.prototype.setCells = function(e) {
  395. this.cells = e
  396. };
  397. FigureBlocks.prototype.findAllCells = function(e, t) {
  398. this.cells.length = 0;
  399. if (this.field[e][t] == 0 || this.field[e][t] == this.fieldContainer.BLACK_ID) return false;
  400. this.cellId = this.field[e][t];
  401. this.addCell(e, t);
  402. this.drawOne(this.cellId);
  403. return true
  404. };
  405. FigureBlocks.prototype.testFigure = function() {
  406. var e = "" + this.cellId + " ";
  407. for (var t = 0; t < this.cells.length; t++) e += "" + this.cells[t].x + " " + this.cells[t].y + " ";
  408. console.log(e)
  409. };
  410. FigureBlocks.prototype.addCell = function(e, t) {
  411. if (e <= -1 || t <= -1 || e >= this.gameManager.FIELD_WIDTH || t >= this.gameManager.FIELD_HEIGHT) return;
  412. if (this.field[e][t] != this.cellId) return;
  413. if (!this.isCellFigure(e, t)) {
  414. this.cells.push(new createjs.Point(e, t));
  415. this.addCell(e - 1, t);
  416. this.addCell(e + 1, t);
  417. this.addCell(e, t - 1);
  418. this.addCell(e, t + 1)
  419. }
  420. };
  421. FigureBlocks.prototype.isCellFigure = function(e, t) {
  422. var n = 0;
  423. for (n = 0; n < this.cells.length; n++)
  424. if (this.cells[n].x == e && t == this.cells[n].y) return true;
  425. return false
  426. };
  427. FigureBlocks.prototype.drawOne = function(e) {
  428. var t = -1;
  429. var n = -1;
  430. for (t = -1; t < this.gameManager.FIELD_WIDTH; t++)
  431. for (n = -1; n < this.gameManager.FIELD_HEIGHT; n++) {
  432. var r = this.getSprTile(t, n, e);
  433. if (r != null) {
  434. r.x = this.gameManager.CELL_SIZE * t;
  435. r.y = this.gameManager.CELL_SIZE * n;
  436. this.addChild(r)
  437. }
  438. }
  439. this.casheAllTTTT()
  440. };
  441. FigureBlocks.prototype.casheAllTTTT = function() {};
  442. FigureBlocks.prototype.getSprTile = function(e, t, n) {
  443. var r = this.getTileId(e, t);
  444. var i = this.getTileId(e + 1, t);
  445. var s = this.getTileId(e + 1, t + 1);
  446. var o = this.getTileId(e, t + 1);
  447. if (r != n) r = 0;
  448. else r = 1; if (i != n) i = 0;
  449. else i = 1; if (s != n) s = 0;
  450. else s = 1; if (o != n) o = 0;
  451. else o = 1; if (r == 0 && i == 0 && s == 0 && o == 0) return null;
  452. var u = new createjs.Sprite(Jok.JokG().animLoader.spriteSheet, this._moveClipsNames["" + n] + r + "_" + i + "_" + s + "_" + o);
  453. u.stop();
  454. return u
  455. };
  456. FigureBlocks.prototype.getTileId = function(e, t) {
  457. if (e <= -1 || t <= -1 || e >= this.gameManager.FIELD_WIDTH || t >= this.gameManager.FIELD_HEIGHT) return 0;
  458. if (this.isCellFigure(e, t)) return this.field[e][t];
  459. return 0
  460. };
  461. FigureBlocks.prototype.step = function(e, t) {
  462. this.step_id = this.gameManager.STEP_CLOSE;
  463. this.figuresStep.length = 0;
  464. var n = [];
  465. for (var r = 0; r < this.cells.length; r++) {
  466. var i = this.stepCell(r, e, t);
  467. if (i == this.gameManager.STEP_CLOSE) return this.gameManager.STEP_CLOSE;
  468. if (i == this.gameManager.STEP_CLOSE_FIGURE) n.push(new createjs.Point(this.cells[r].x + e, this.cells[r].y + t))
  469. }
  470. if (n.length == 0) {
  471. this.step_id = this.gameManager.STEP_OPEN;
  472. return this.gameManager.STEP_OPEN
  473. }
  474. for (var r = 0; r < n.length; r++) this.addFigureStep(this.fieldContainer.getFigureByCell(n[r].x, n[r].y));
  475. this.step_id = this.gameManager.STEP_CLOSE_FIGURE;
  476. return this.gameManager.STEP_CLOSE_FIGURE
  477. };
  478. FigureBlocks.prototype.addFigureStep = function(e) {
  479. if (e == null) return;
  480. for (var t = 0; t < this.figuresStep.length; t++)
  481. if (this.figuresStep[t].id == e.id) return;
  482. this.figuresStep.push(e)
  483. };
  484. FigureBlocks.prototype.stepCell = function(e, t, n) {
  485. var r = this.cells[e].x + t;
  486. var i = this.cells[e].y + n;
  487. if (r <= -1 || i <= -1 || r >= this.gameManager.FIELD_WIDTH || i >= this.gameManager.FIELD_HEIGHT) return this.gameManager.STEP_CLOSE;
  488. var s = this.field[r][i];
  489. if (s == 0 || s == this.cellId) return this.gameManager.STEP_OPEN;
  490. if (s == this.fieldContainer.BLACK_ID) return this.gameManager.STEP_CLOSE;
  491. return this.gameManager.STEP_CLOSE_FIGURE
  492. };
  493. FigureBlocks.prototype.postStep = function() {
  494. if (this.step_id == this.gameManager.STEP_CLOSE_FIGURE)
  495. for (var e = 0; e < this.figuresStep.length; e++)
  496. if (this.figuresStep[e].step_id == this.gameManager.STEP_CLOSE) {
  497. this.step_id = this.gameManager.STEP_CLOSE;
  498. return true
  499. }
  500. return false
  501. };
  502. FigureBlocks.prototype.preGo = function() {
  503. if (this.step_id == this.gameManager.STEP_CLOSE) return;
  504. for (var e = 0; e < this.cells.length; e++) this.field[this.cells[e].x][this.cells[e].y] = 0
  505. };
  506. FigureBlocks.prototype.go = function(e, t) {
  507. if (this.step_id == this.gameManager.STEP_CLOSE) {
  508. this.tweenMove = createjs.Tween.get(this).to({
  509. x: this.x + e * this.MOVE_CLOSE_PATH,
  510. y: this.y + t * this.MOVE_CLOSE_PATH
  511. }, this.MOVE_TIME / 2, createjs.Ease.quartInOut).to({
  512. x: this.x,
  513. y: this.y
  514. }, this.MOVE_TIME / 2, createjs.Ease.quartInOut).call(this.eventMoveComplete);
  515. return false
  516. }
  517. for (var n = 0; n < this.cells.length; n++) {
  518. this.cells[n].x += e;
  519. this.cells[n].y += t;
  520. this.field[this.cells[n].x][this.cells[n].y] = this.cellId
  521. }
  522. this.tweenMove = createjs.Tween.get(this).to({
  523. x: this.x + e * this.gameManager.CELL_SIZE,
  524. y: this.y + t * this.gameManager.CELL_SIZE
  525. }, this.MOVE_TIME, createjs.Ease.quartInOut).call(this.eventMoveComplete);
  526. return true
  527. };
  528. FigureBlocks.prototype.moveComplete = function(e) {
  529. this.fieldContainer.moveComplete()
  530. };
  531. FigureBlocks.prototype.connectToFigure = function(e) {
  532. if (e.cellId == this.cellId)
  533. for (var t = 0; t < this.cells.length; t++) {
  534. if (e.isCellFigure(this.cells[t].x + 1, this.cells[t].y)) {
  535. this.connecting = true;
  536. e.connecting = true;
  537. return true
  538. }
  539. if (e.isCellFigure(this.cells[t].x - 1, this.cells[t].y)) {
  540. this.connecting = true;
  541. e.connecting = true;
  542. return true
  543. }
  544. if (e.isCellFigure(this.cells[t].x, this.cells[t].y + 1)) {
  545. this.connecting = true;
  546. e.connecting = true;
  547. return true
  548. }
  549. if (e.isCellFigure(this.cells[t].x, this.cells[t].y - 1)) {
  550. this.connecting = true;
  551. e.connecting = true;
  552. return true
  553. }
  554. }
  555. return false
  556. };
  557. GameManager = function() {
  558. Jok.JokState.call(this);
  559. this.FIELD_WIDTH = 10;
  560. this.FIELD_HEIGHT = 10;
  561. this.CELL_SIZE = 60.9;
  562. this.levelId = 51;
  563. this.STEP_OPEN = 0;
  564. this.STEP_CLOSE = 1;
  565. this.STEP_CLOSE_FIGURE = 2
  566. };
  567. GameManager.prototype = Object.create(Jok.JokState.prototype);
  568. GameManager.prototype.constructor = GameManager;
  569. GameManager.prototype.create = function() {
  570. this.loadLevel();
  571. console.log("GameManager.create");
  572. var e = new createjs.Sprite(Jok.JokG().animLoader.spriteSheet, "allField_1_mc");
  573. this.addChild(e);
  574. this.gui = new GuiBlock(this);
  575. this.fieldContainer = new FieldContainer(this.field, this);
  576. this.addChild(this.fieldContainer);
  577. this.addChild(this.gui);
  578. if (this.levelId == 0) this.addChild(new HelpDialog(this))
  579. };
  580. GameManager.prototype.dispose = function() {
  581. this.fieldContainer.offMouse();
  582. this.gui.offButton()
  583. };
  584. GameManager.prototype.loadLevel = function() {
  585. this.field = [];
  586. for (var e = 0; e < this.FIELD_WIDTH; e++) {
  587. this.field[e] = [];
  588. for (var t = 0; t < this.FIELD_HEIGHT; t++) this.field[e][t] = 0
  589. }
  590. var n = [];
  591. n.push(1);
  592. n.push(2);
  593. n.push(4);
  594. n.push(12);
  595. n.push(48);
  596. n.push(8);
  597. n.push(10);
  598. n.push(14);
  599. n.push(3);
  600. n.push(11);
  601. n.push(5);
  602. n.push(25);
  603. n.push(15);
  604. n.push(30);
  605. n.push(6);
  606. n.push(34);
  607. n.push(16);
  608. n.push(47);
  609. n.push(7);
  610. n.push(27);
  611. n.push(40);
  612. n.push(19);
  613. n.push(51);
  614. n.push(35);
  615. n.push(13);
  616. n.push(43);
  617. n.push(38);
  618. n.push(22);
  619. n.push(23);
  620. n.push(39);
  621. n.push(49);
  622. n.push(36);
  623. n.push(20);
  624. n.push(52);
  625. n.push(17);
  626. n.push(50);
  627. n.push(21);
  628. n.push(32);
  629. n.push(31);
  630. n.push(26);
  631. n.push(37);
  632. n.push(33);
  633. n.push(29);
  634. n.push(45);
  635. n.push(28);
  636. n.push(44);
  637. n.push(18);
  638. n.push(42);
  639. n.push(9);
  640. n.push(24);
  641. n.push(46);
  642. n.push(41);
  643. var r = (new Jok.JokG).queue.getResult("gameLevels_1");
  644. var i = r.getElementsByTagName("Level")[n[this.levelId] - 1].getElementsByTagName("tiles")[0].getAttribute("id");
  645. this.numStar = parseInt(r.getElementsByTagName("Level")[n[this.levelId] - 1].getAttribute("numStar"));
  646. var s = 0;
  647. for (var e = 0; e < this.FIELD_WIDTH; e++)
  648. for (var t = 0; t < this.FIELD_HEIGHT; t++) {
  649. this.field[e][t] = parseInt(i[s]);
  650. s++
  651. }
  652. };
  653. GameManager.prototype.restart = function() {
  654. var e = new GameManager;
  655. e.levelId = this.levelId;
  656. (new Jok.JokG).jokEngine.transitionScreen(e, null, null)
  657. };
  658. GameManager.prototype.setPause = function() {
  659. this.addChild(new PauseDialog(this))
  660. };
  661. GameManager.prototype.toLevelSelect = function() {
  662. (new Jok.JokG).jokEngine.transitionScreen(new LevelSelectMenu, null, null)
  663. };
  664. GameManager.prototype.setGameOver = function() {
  665. this.addChild(new GameOverDialog(this))
  666. };
  667. MusicManager = function() {
  668. var e = arguments.callee;
  669. if (e.instance) return e.instance;
  670. this._mute = false;
  671. this._globalMute = false;
  672. this._paused = false;
  673. var t = createjs.Sound.activePlugin instanceof createjs.WebAudioPlugin;
  674. console.log("this.isWebAudio = " + createjs.Sound.activePlugin);
  675. this._soundSupport = t || !t && !createjs.Sound.BrowserDetect.isIOS && !createjs.Sound.BrowserDetect.isAndroid;
  676. console.log("this._soundSupport = " + this._soundSupport);
  677. this.musicInstance = createjs.Sound.createInstance("mus_1");
  678. this.enableSound = false;
  679. this.eventMouseDown = (new Jok.JokG).stage.on("stagemousedown", createjs.proxy(this.cccMouseDown, this));
  680. var n = "hidden";
  681. var r = createjs.proxy(this.onchangeVisable, this);
  682. if (n in document) {
  683. console.log("mus_1 = " + document.hidden);
  684. if (document.hidden == true) this._globalMute = true;
  685. document.addEventListener("visibilitychange", r)
  686. } else if ((n = "mozHidden") in document) {
  687. console.log("mus_2 = " + document.mozHidden);
  688. if (document.mozHidden == true) this._globalMute = true;
  689. document.addEventListener("mozvisibilitychange", r)
  690. } else if ((n = "webkitHidden") in document) {
  691. console.log("mus_3 = " + document.webkitHidden);
  692. if (document.webkitHidden == true) this._globalMute = true;
  693. document.addEventListener("webkitvisibilitychange", r)
  694. } else if ((n = "msHidden") in document) {
  695. console.log("mus_4 = " + document.msHidden);
  696. if (document.hidden == true) this._globalMute = true;
  697. document.addEventListener("msvisibilitychange", r)
  698. } else if ("onfocusin" in document) {
  699. console.log("mus_5 = " + document.onfocusin);
  700. document.onfocusin = document.onfocusout = r
  701. } else {
  702. console.log("mus_6");
  703. window.onpageshow = window.onpagehide = window.onfocus = window.onblur = r
  704. }
  705. e.instance = this
  706. };
  707. MusicManager.prototype.constructor = MusicManager;
  708. MusicManager.prototype.onchangeVisable = function(e) {
  709. this._globalMute = !this._globalMute;
  710. console.log("onchangeVisable this._globalMute = " + this._globalMute);
  711. if (this._globalMute) {
  712. if (!this._mute && this.enableSound) {
  713. this._paused = true;
  714. this.musicInstance.pause()
  715. }
  716. } else if (!this._mute && this.enableSound) this.playMusic()
  717. };
  718. MusicManager.prototype.cccMouseDown = function(e) {
  719. console.log("this.enableSound = " + this._globalMute);
  720. this.enableSound = true;
  721. (new Jok.JokG).stage.off("stagemousedown", this.eventMouseDown);
  722. this.playMusic()
  723. };
  724. MusicManager.prototype.playMusic = function() {
  725. if (!this._mute && this.enableSound && !this._globalMute)
  726. if (this._paused) this.musicInstance.resume();
  727. else this.musicInstance.play({
  728. loop: -1,
  729. interrupt: createjs.Sound.INTERRUPT_ANY
  730. })
  731. };
  732. MusicManager.prototype.playSound = function(e, t) {
  733. if (!this._mute && this.enableSound && this._soundSupport && !this._globalMute) createjs.Sound.play(e, {
  734. volume: t
  735. })
  736. };
  737. MusicManager.prototype.getMute = function() {
  738. return this._mute
  739. };
  740. MusicManager.prototype.setMute = function(e) {
  741. this._mute = e;
  742. if (this._mute) {
  743. this._paused = true;
  744. this.musicInstance.pause()
  745. } else this.playMusic()
  746. };
  747. MusicManager.prototype.playStar = function() {
  748. this.playSound("starSound", 1)
  749. };
  750. MusicManager.prototype.playMouse = function() {
  751. this.playSound("mouseClick", 1)
  752. };
  753. MusicManager.prototype.playWin = function() {
  754. this.playSound("winSound", .5)
  755. };
  756. MusicManager.prototype.playStep = function() {
  757. this.playSound("stepSound_1", .25)
  758. };
  759. MusicManager.prototype.playConnect = function() {
  760. this.playSound("connectSound", .4)
  761. };
  762. PreloadState = function() {
  763. Jok.JokState.call(this)
  764. };
  765. PreloadState.prototype = Object.create(Jok.JokState.prototype);
  766. PreloadState.prototype.constructor = PreloadState;
  767. PreloadState.prototype.create = function() {
  768. console.log("PreloadState.prototype.create");
  769. (new Jok.JokG).showZibbo = true;
  770. this.queue = (new Jok.JokG).queue;
  771. var e = [{
  772. src: "zibbo/Zibbo_logo_rgb-01.png",
  773. id: "zibboLogoBig"
  774. }];
  775. this.initAllEvent = this.queue.on("complete", createjs.proxy(this.initAll, this));
  776. this.queue.setMaxConnections(5);
  777. this.queue.loadManifest(e)
  778. };
  779. PreloadState.prototype.initAll = function(e) {
  780. console.log("PreloadState.initAll");
  781. this.queue.off("complete", this.initAllEvent);
  782. this._apiLoad = false;
  783. this._gameLoad = false;
  784. this.initFont();
  785. this.initBackground();
  786. this.initCookie();
  787. (new Jok.JokG).MAX_LEVEL = 52;
  788. var t = [createjs.WebAudioPlugin, createjs.HTMLAudioPlugin];
  789. if (createjs.Sound.BrowserDetect.isFirefox) t = [createjs.HTMLAudioPlugin];
  790. createjs.Sound.registerPlugins(t);
  791. console.log("createjs.Sound.isReady() = " + createjs.Sound.isReady());
  792. this.queue = (new Jok.JokG).queue;
  793. createjs.Sound.alternateExtensions = ["m4a"];
  794. this.queue.installPlugin(createjs.Sound);
  795. var n = [{
  796. src: "imagesPack/BlockGame.png",
  797. id: "gameImg_1"
  798. }, {
  799. src: "imagesPack/BlockGame.json",
  800. id: "gameImgJson_1",
  801. type: createjs.LoadQueue.JSON
  802. }, {
  803. src: "text.json",
  804. id: "text_1",
  805. type: createjs.LoadQueue.JSON
  806. }, {
  807. src: "HelpAnim/allAnim.xml",
  808. id: "gameImgXml_1",
  809. type: createjs.LoadQueue.XML
  810. }, {
  811. src: "levels/bin/Levels.xml",
  812. id: "gameLevels_1",
  813. type: createjs.LoadQueue.XML
  814. }, {
  815. src: "audio/music/mus_1.ogg",
  816. id: "mus_1",
  817. type: createjs.LoadQueue.SOUND
  818. }, {
  819. src: "font/font.png",
  820. id: "fontImg_1"
  821. }, {
  822. src: "font/font.fnt",
  823. id: "fontDataXml_1",
  824. type: createjs.LoadQueue.XML
  825. }, {
  826. src: "audio/sound/mouse_1.ogg",
  827. id: "mouseClick",
  828. type: createjs.LoadQueue.SOUND
  829. }, {
  830. src: "audio/sound/StarUp_2.ogg",
  831. id: "starSound",
  832. type: createjs.LoadQueue.SOUND
  833. }, {
  834. src: "audio/sound/StarMenu.ogg",
  835. id: "winSound",
  836. type: createjs.LoadQueue.SOUND
  837. }, {
  838. src: "audio/sound/rotate_1.ogg",
  839. id: "stepSound_1",
  840. type: createjs.LoadQueue.SOUND
  841. }, {
  842. src: "audio/sound/connect.ogg",
  843. id: "connectSound",
  844. type: createjs.LoadQueue.SOUND
  845. }];
  846. this.queue.on("progress", createjs.proxy(this.handleProgress, this));
  847. this.queue.on("complete", createjs.proxy(this.handleComplete, this));
  848. this.queue.on("fileload", createjs.proxy(this.handleFileLoad, this));
  849. this.queue.setMaxConnections(5);
  850. this.queue.loadManifest(n);
  851. createjs.proxy(this.apiLoad, this)
  852. };
  853. PreloadState.prototype.initFont = function() {};
  854. PreloadState.prototype.initCookie = function() {
  855. if (typeof window.localStorage != "undefined")
  856. if (window.localStorage.getItem("levelComplete") == null) window.localStorage.setItem("levelComplete", 1)
  857. };
  858. PreloadState.prototype.initBackground = function() {
  859. var e = new createjs.Shape;
  860. e.x = -(new Jok.JokG).width / 2;
  861. e.y = -(new Jok.JokG).height / 2;
  862. e.graphics.beginFill("rgba(255,255,255,1)").rect(0, 0, (new Jok.JokG).width, (new Jok.JokG).height);
  863. this.addChild(e);
  864. this.PROGRESS_BAR_WIDTH = 580;
  865. this.PROGRESS_BAR_HEIGHT = 36;
  866. this.Y_BAR = 200;
  867. this.barShape = new createjs.Shape;
  868. this.barShape.x = -this.PROGRESS_BAR_WIDTH / 2;
  869. this.barShape.y = -this.PROGRESS_BAR_HEIGHT / 2 + this.Y_BAR;
  870. this.addChild(this.barShape);
  871. e = new createjs.Shape;
  872. e.x = -this.PROGRESS_BAR_WIDTH / 2;
  873. e.y = -this.PROGRESS_BAR_HEIGHT / 2 + this.Y_BAR;
  874. e.graphics.beginStroke("rgba(221,33,113,1)").setStrokeStyle(3).drawRoundRect(0, 0, this.PROGRESS_BAR_WIDTH, this.PROGRESS_BAR_HEIGHT, 5);
  875. this.addChild(e);
  876. var t = new createjs.Bitmap((new Jok.JokG).queue.getResult("zibboLogoBig"));
  877. t.x = -t.getBounds().width / 2;
  878. t.y = -t.getBounds().height / 2;
  879. this.addChild(t);
  880. t.on("click", createjs.proxy(this.openUrl, this))
  881. };
  882. PreloadState.prototype.handleProgress = function(e) {
  883. this.barShape.graphics.beginFill("rgba(219,71,132,1)").drawRoundRect(0, 0, this.PROGRESS_BAR_WIDTH * e.progress, this.PROGRESS_BAR_HEIGHT, 5)
  884. };
  885. PreloadState.prototype.handleFileLoad = function(e) {};
  886. PreloadState.prototype.handleComplete = function(e) {
  887. console.log("handleComplete");
  888. this._gameLoad = true;
  889. if (this._gameLoad) this.allLoadComplete()
  890. };
  891. PreloadState.prototype.apiLoad = function(e) {
  892. this._apiLoad = true;
  893. if (this._gameLoad) this.allLoadComplete()
  894. };
  895. PreloadState.prototype.openUrl = function() {
  896. ZibboUtils.logoAction()
  897. };
  898. PreloadState.prototype.allLoadComplete = function() {
  899. console.log("PreloadState.prototype.allLoadComplete");
  900. new MusicManager;
  901. console.log("new MusicManager();");
  902. (new Jok.JokG).text.init(this.queue.getResult("text_1"));
  903. console.log('new Jok.JokG().text.init(this.queue.getResult("text_1"));');
  904. (new Jok.JokG).animLoader.loadAnim(this.queue.getResult("gameImgXml_1"), this.queue.getResult("gameImgJson_1"), this.queue.getResult("gameImg_1"));
  905. console.log('new Jok.JokG().animLoader.loadAnim(this.queue.getResult("gameImgXml_1"), this.queue.getResult("gameImgJson_1"), this.queue.getResult("gameImg_1"));');
  906. (new Jok.JokG).animLoader.loadBitmapFont(this.queue.getResult("fontDataXml_1"), this.queue.getResult("fontImg_1"));
  907. console.log('ew Jok.JokG().animLoader.loadBitmapFont(this.queue.getResult("fontDataXml_1"), this.queue.getResult("fontImg_1"));');
  908. (new Jok.JokG).jokEngine.switchState(new SplashScreenZibbo)
  909. };
  910. GuiBlock = function(e) {
  911. createjs.Container.call(this);
  912. this.y = -315;
  913. this.gameManager = e;
  914. var t = 85;
  915. this.buttonPause = new MyButtonBase(createjs.proxy(this.pauseAction, this), new createjs.Point(-270, 0), new createjs.Point(1, 1), "buttonBase_mc");
  916. this.buttonPause.initUp("buttonStop_mc");
  917. this.addChild(this.buttonPause);
  918. this.buttonRestart = new MyButtonBase(createjs.proxy(this.restartAction, this), new createjs.Point(this.buttonPause.x + t, 0), new createjs.Point(1, 1), "buttonBase_mc");
  919. this.buttonRestart.initUp("buttonRestart_mc");
  920. this.addChild(this.buttonRestart);
  921. this.buttonUndo = new MyButtonBase(createjs.proxy(this.removeStepAction, this), new createjs.Point(this.buttonRestart.x + t, 0), new createjs.Point(1, 1), "buttonBase_mc");
  922. this.buttonUndo.initUp("buttonUndo_mc");
  923. this.addChild(this.buttonUndo);
  924. this.initStarBar(e.numStar);
  925. var n = new createjs.Text("关卡 " + (e.levelId + 1), "bold 30px Arial, Microsoft Yahei, 微软雅黑, STXihei, 华文细黑, sans-serif", "#fff");
  926. n.x = (new Jok.JokG).width / 2 - n.getBounds().width * n.scaleX - 5;
  927. n.y = -24 / 2 - 20;
  928. this.addChild(n);
  929. if ((new Jok.JokG).showZibbo) {
  930. var r = {};
  931. r["type"] = ".png";
  932. r["width"] = 202;
  933. r["height"] = 50
  934. }
  935. };
  936. GuiBlock.prototype = Object.create(createjs.Container.prototype);
  937. GuiBlock.prototype.constructor = GuiBlock;
  938. GuiBlock.prototype.moreAction = function(e) {
  939. ZibboUtils.buttonAction("more_games")
  940. };
  941. GuiBlock.prototype.offButton = function() {
  942. this.buttonPause.offWork();
  943. this.buttonRestart.offWork();
  944. if (this.buttonLogo) this.buttonLogo.offWork()
  945. };
  946. GuiBlock.prototype.onButton = function() {
  947. this.buttonPause.onWork();
  948. this.buttonRestart.onWork();
  949. if (this.buttonLogo) this.buttonLogo.onWork()
  950. };
  951. GuiBlock.prototype.pauseAction = function() {
  952. this.gameManager.setPause()
  953. };
  954. GuiBlock.prototype.restartAction = function() {
  955. this.gameManager.restart()
  956. };
  957. GuiBlock.prototype.removeStepAction = function() {
  958. this.gameManager.fieldContainer.deleteStep()
  959. };
  960. GuiBlock.prototype.initStarBar = function(e) {
  961. this.starBar = new StarBar(e);
  962. this.addChild(this.starBar)
  963. };
  964. LevelButton = function(e, t, n, r) {
  965. MyButtonBase.call(this, null, e, t, "LevelSelectButton_mc");
  966. this.idLevel = n;
  967. this.initStar();
  968. this._open = r;
  969. if (!r) this.sprDown.currentAnimationFrame = 1;
  970. var i = new createjs.BitmapText("" + this.idLevel, (new Jok.JokG).animLoader.fontSheet);
  971. i.scaleX = i.scaleY = .6;
  972. i.y = -i.getBounds().height / 2 * i.scaleX - 17;
  973. i.x = -i.getBounds().width / 2 * i.scaleX;
  974. this.addChild(i);
  975. this.actionFunc = createjs.proxy(this.levelAction, this)
  976. };
  977. LevelButton.prototype = Object.create(MyButtonBase.prototype);
  978. LevelButton.prototype.constructor = LevelButton;
  979. LevelButton.prototype.initStar = function() {
  980. this.sprDown.stop();
  981. var e = 0;
  982. if (typeof window.localStorage != "undefined") {
  983. if (window.localStorage.getItem("levelStar" + this.idLevel) == null) window.localStorage.setItem("levelStar" + this.idLevel, 0);
  984. e = window.localStorage.getItem("levelStar" + this.idLevel)
  985. }
  986. var t = 30;
  987. for (var n = 0; n < 3; n++) {
  988. var r = new createjs.Sprite(Jok.JokG().animLoader.spriteSheet, "LevelMenuStar_mc");
  989. r.x = -t + t * n;
  990. r.y = 30;
  991. r.stop();
  992. if (n < e) r.currentAnimationFrame = 1;
  993. else r.currentAnimationFrame = 0;
  994. this.addChild(r)
  995. }
  996. };
  997. LevelButton.prototype.levelAction = function() {
  998. if (this._open) {
  999. var e = new GameManager;
  1000. e.levelId = this.idLevel - 1;
  1001. (new Jok.JokG).jokEngine.transitionScreen(e, null, null)
  1002. }
  1003. };
  1004. SoundButton = function(e, t) {
  1005. MyButtonBase.call(this, null, e, t, "MainMenuButton_1_mc");
  1006. this.initUp("ButtonMusic_mc");
  1007. if ((new MusicManager).getMute()) this.sprUp.currentAnimationFrame = 1;
  1008. this.actionFunc = createjs.proxy(this.soundAction, this)
  1009. };
  1010. SoundButton.prototype = Object.create(MyButtonBase.prototype);
  1011. SoundButton.prototype.constructor = SoundButton;
  1012. SoundButton.prototype.soundAction = function() {
  1013. (new MusicManager).setMute(!(new MusicManager).getMute());
  1014. if ((new MusicManager).getMute()) this.sprUp.currentAnimationFrame = 1;
  1015. else this.sprUp.currentAnimationFrame = 0
  1016. };
  1017. StarBar = function(e) {
  1018. createjs.Container.call(this);
  1019. this.x = 60;
  1020. this.y = 0;
  1021. this.txtColor = "#FFF";
  1022. this.MASK_SIZE = 237.15;
  1023. this.barMask = new createjs.Shape;
  1024. this.barMask.x = -this.MASK_SIZE / 2;
  1025. this.barMask.y = -25 / 2;
  1026. this.barMask.graphics.beginFill("rgba(255,255,255,1)").rect(0, 0, this.MASK_SIZE, 25);
  1027. this.starNum = 3;
  1028. this.stepNow = 0;
  1029. this.numStarThree = e;
  1030. this.numStarTwo = Math.ceil(this.numStarThree * .4) + e;
  1031. this.numStarOne = Math.ceil(this.numStarTwo * .5) + this.numStarTwo;
  1032. this.numStarAll = this.numStarOne + 1;
  1033. console.log("this.numStarThree = " + this.numStarThree);
  1034. console.log("this.numStarTwo = " + this.numStarTwo);
  1035. console.log("this.numStarOne = " + this.numStarOne);
  1036. console.log("this.numStarAll = " + this.numStarAll);
  1037. this.initStars();
  1038. var t = new createjs.Sprite(Jok.JokG().animLoader.spriteSheet, "scoreBar_1_mc");
  1039. this.addChild(t);
  1040. this.barSpr = new createjs.Sprite(Jok.JokG().animLoader.spriteSheet, "scoreBar_2_mc");
  1041. this.barSpr.mask = this.barMask;
  1042. this.addChild(this.barSpr);
  1043. var n = new createjs.Sprite(Jok.JokG().animLoader.spriteSheet, "scoreBar_3_mc");
  1044. this.addChild(n);
  1045. this.stepTxt = new createjs.BitmapText("0", (new Jok.JokG).animLoader.fontSheet);
  1046. this.stepTxt.scaleX = this.stepTxt.scaleY = .35;
  1047. this.stepTxt.x = 0;
  1048. this.stepTxt.y = -this.stepTxt.getBounds().height / 2 + 20;
  1049. this.addChild(this.stepTxt)
  1050. };
  1051. StarBar.prototype = Object.create(createjs.Container.prototype);
  1052. StarBar.prototype.constructor = StarBar;
  1053. StarBar.prototype.initStars = function() {
  1054. var e = 0;
  1055. this.starTree = new createjs.Sprite(Jok.JokG().animLoader.spriteSheet, "star_3_mc");
  1056. this.starTree.stop();
  1057. this.starTree.y = -25;
  1058. this.starTree.x = -this.MASK_SIZE / 2 + this.MASK_SIZE * (this.numStarThree / this.numStarAll) + e;
  1059. this.addChild(this.starTree);
  1060. this.starTwoo = new createjs.Sprite(Jok.JokG().animLoader.spriteSheet, "star_2_mc");
  1061. this.starTwoo.y = this.starTree.y;
  1062. this.starTwoo.stop();
  1063. this.starTwoo.x = -this.MASK_SIZE / 2 + this.MASK_SIZE * (this.numStarTwo / this.numStarAll) + e;
  1064. this.addChild(this.starTwoo);
  1065. this.starOne = new createjs.Sprite(Jok.JokG().animLoader.spriteSheet, "star_1_mc");
  1066. this.starOne.y = this.starTree.y;
  1067. this.starOne.stop();
  1068. this.starOne.x = -this.MASK_SIZE / 2 + this.MASK_SIZE * (this.numStarOne / this.numStarAll) + e;
  1069. this.addChild(this.starOne);
  1070. this.initStarsText(this.numStarThree);
  1071. this.initStarsText(this.numStarTwo);
  1072. this.initStarsText(this.numStarOne)
  1073. };
  1074. StarBar.prototype.initStarsText = function(e) {
  1075. var t = 0;
  1076. var n = 20;
  1077. var r = 25;
  1078. var i = new createjs.BitmapText("" + e, (new Jok.JokG).animLoader.fontSheet);
  1079. i.scaleX = i.scaleY = .3;
  1080. i.y = r - i.getBounds().height / 2 * i.scaleX;
  1081. i.x = -this.MASK_SIZE / 2 + this.MASK_SIZE * (e / this.numStarAll) - i.getBounds().width / 2 * i.scaleX + t;
  1082. this.addChild(i)
  1083. };
  1084. StarBar.prototype.addStep = function() {
  1085. if (this.stepNow == this.numStarThree) {
  1086. this.starTree.currentAnimationFrame = 1;
  1087. this.starNum--
  1088. } else if (this.stepNow == this.numStarTwo) {
  1089. this.starTwoo.currentAnimationFrame = 1;
  1090. this.starNum--
  1091. } else if (this.stepNow == this.numStarOne) {
  1092. this.starOne.currentAnimationFrame = 1;
  1093. this.starNum--
  1094. }
  1095. this.stepNow++;
  1096. this.stepTxt.text = "" + this.stepNow;
  1097. if (this.stepNow >= this.numStarAll) this.barMask.x = 9999;
  1098. else this.barMask.x = -this.MASK_SIZE / 2 + this.MASK_SIZE * (this.stepNow / this.numStarAll)
  1099. };
  1100. CreditsDialog = function(e) {
  1101. createjs.Container.call(this);
  1102. this.mainMenu = e;
  1103. this.mainMenu.offButton();
  1104. var t = "#000";
  1105. var n = " Verdana";
  1106. var r = new createjs.Shape;
  1107. r.x = -(new Jok.JokG).width / 2;
  1108. r.y = -(new Jok.JokG).height / 2;
  1109. r.graphics.beginFill("rgba(255,255,255,0.5)").rect(0, 0, (new Jok.JokG).width, (new Jok.JokG).height);
  1110. this.addChild(r);
  1111. var i = new createjs.Text((new Jok.JokG).text.getText("developed"), "36px" + n, t);
  1112. i.x = -i.getBounds().width / 2;
  1113. i.y = -260;
  1114. this.addChild(i);
  1115. var s = new createjs.Text((new Jok.JokG).text.getText("author"), "36px" + n, t);
  1116. s.x = -s.getBounds().width / 2;
  1117. s.y = i.y + 55;
  1118. this.addChild(s);
  1119. var o = new createjs.Text((new Jok.JokG).text.getText("email"), "36px" + n, t);
  1120. o.x = -o.getBounds().width / 2;
  1121. o.y = s.y + 80;
  1122. this.addChild(o);
  1123. this.alpha = 0;
  1124. createjs.Tween.get(this).to({
  1125. alpha: 1
  1126. }, 400, createjs.Ease.quadOut);
  1127. this.eventMouseDown = (new Jok.JokG).stage.on("stagemousedown", createjs.proxy(this.cccMouseDown, this))
  1128. };
  1129. CreditsDialog.prototype = Object.create(createjs.Container.prototype);
  1130. CreditsDialog.prototype.constructor = CreditsDialog;
  1131. CreditsDialog.prototype.cccMouseDown = function(e) {
  1132. (new Jok.JokG).stage.off("stagemousedown", this.eventMouseDown);
  1133. this.mainMenu.onButton();
  1134. if (this.parent) this.parent.removeChild(this)
  1135. };
  1136. GameDialogBase = function(e) {
  1137. createjs.Container.call(this);
  1138. this.gameManager = e;
  1139. e.gui.offButton();
  1140. e.fieldContainer.offMouse();
  1141. var t = new createjs.Shape;
  1142. t.x = -(new Jok.JokG).width / 2;
  1143. t.y = -(new Jok.JokG).height / 2;
  1144. t.graphics.beginFill("rgba(0,0,0,0.45)").rect(0, 0, (new Jok.JokG).width, (new Jok.JokG).height);
  1145. this.addChild(t);
  1146. this.addChild(new createjs.Sprite(Jok.JokG().animLoader.spriteSheet, "FrameDialogBase_mc"));
  1147. this.alpha = 0;
  1148. createjs.Tween.get(this).to({
  1149. alpha: 1
  1150. }, 400, createjs.Ease.quadOut).call(createjs.proxy(this.alphaEnd, this))
  1151. };
  1152. GameDialogBase.prototype = Object.create(createjs.Container.prototype);
  1153. GameDialogBase.prototype.constructor = GameDialogBase;
  1154. GameDialogBase.prototype.restartAction = function() {
  1155. this.gameManager.restart()
  1156. };
  1157. GameDialogBase.prototype.backAction = function() {
  1158. this.gameManager.toLevelSelect()
  1159. };
  1160. GameDialogBase.prototype.onAll = function() {
  1161. this.gameManager.gui.onButton();
  1162. this.gameManager.fieldContainer.onMouse()
  1163. };
  1164. GameDialogBase.prototype.alphaEnd = function() {};
  1165. GameDialogBase.prototype.moreAction = function(e) {
  1166. if ((new Jok.JokG).showZibbo) ZibboUtils.buttonAction("more_games")
  1167. };
  1168. GameOverDialog = function(e) {
  1169. GameDialogBase.call(this, e);
  1170. (new MusicManager).playWin();
  1171. var t = new MyButtonBase(createjs.proxy(this.playAction, this), new createjs.Point(157, 69), new createjs.Point(.9, .9), "MainMenuButton_1_mc");
  1172. t.initUp("ButtonPlay_mc");
  1173. this.addChild(t);
  1174. var n = .6;
  1175. t = new MyButtonBase(createjs.proxy(this.backAction, this), new createjs.Point(-19, 90), new createjs.Point(n, n), "MainMenuButton_1_mc");
  1176. t.initUp("ButtonBack_mc");
  1177. this.addChild(t);
  1178. t = new MyButtonBase(createjs.proxy(this.restartAction, this), new createjs.Point(-180, 90), new createjs.Point(n, n), "MainMenuButton_1_mc");
  1179. t.initUp("buttonRestart_2_mc");
  1180. this.addChild(t);
  1181. this.idAdd = 0;
  1182. if (typeof window.localStorage != "undefined") {
  1183. var r = window.localStorage.getItem("levelComplete");
  1184. if (this.gameManager.levelId + 1 >= r) window.localStorage.setItem("levelComplete", this.gameManager.levelId + 2);
  1185. r = window.localStorage.getItem("levelStar" + (this.gameManager.levelId + 1));
  1186. console.log("numLevelComplete =" + r);
  1187. if (this.gameManager.gui.starBar.starNum > r) window.localStorage.setItem("levelStar" + (this.gameManager.levelId + 1), this.gameManager.gui.starBar.starNum)
  1188. }
  1189. if ((new Jok.JokG).showZibbo) {
  1190. var i = {};
  1191. i["type"] = ".png";
  1192. i["width"] = 202;
  1193. i["height"] = 50
  1194. }
  1195. this._oldMute = (new MusicManager).getMute();
  1196. if ((new Jok.JokG).showZibbo) {}
  1197. };
  1198. GameOverDialog.prototype = Object.create(GameDialogBase.prototype);
  1199. GameOverDialog.prototype.constructor = GameOverDialog;
  1200. GameOverDialog.prototype.playAction = function(e) {
  1201. if (this.gameManager.levelId + 1 < (new Jok.JokG).MAX_LEVEL) {
  1202. var t = new GameManager;
  1203. t.levelId = this.gameManager.levelId + 1;
  1204. (new Jok.JokG).jokEngine.transitionScreen(t, null, null)
  1205. } else this.gameManager.toLevelSelect()
  1206. };
  1207. GameOverDialog.prototype.adsBegin = function() {
  1208. console.log("showAds");
  1209. if (!this._oldMute)(new MusicManager).setMute(true)
  1210. };
  1211. GameOverDialog.prototype.adsEnd = function() {
  1212. console.log("adsEnd");
  1213. if ((new MusicManager).getMute() != this._oldMute)(new MusicManager).setMute(this._oldMute)
  1214. };
  1215. GameOverDialog.prototype.alphaEnd = function() {
  1216. if (this.buttonLogo) createjs.Tween.get(this.buttonLogo).to({
  1217. y: 300
  1218. }, 2500, createjs.Ease.elasticOut);
  1219. var e = 157;
  1220. var t = -65;
  1221. var n = this.gameManager.gui.starBar.starNum;
  1222. for (var r = 0; r < 3; r++)
  1223. if (this.idAdd == r) {
  1224. var i = new createjs.Sprite(Jok.JokG().animLoader.spriteSheet, "starGameOver_mc");
  1225. i.x = -e + e * r;
  1226. i.y = t;
  1227. i.stop();
  1228. if (r < n) {
  1229. i.currentAnimationFrame = 0;
  1230. i.scaleX = i.scaleY = 0;
  1231. createjs.Tween.get(i).to({
  1232. scaleX: 1,
  1233. scaleY: 1
  1234. }, 1500, createjs.Ease.elasticOut);
  1235. (new MusicManager).playStar()
  1236. } else {
  1237. i.currentAnimationFrame = 1;
  1238. i.alpha = 0;
  1239. createjs.Tween.get(i).to({
  1240. alpha: 1
  1241. }, 800, createjs.Ease.quadOut)
  1242. }
  1243. this.addChild(i)
  1244. }
  1245. this.idAdd++;
  1246. if (this.idAdd < 3) createjs.Tween.get(this).to({
  1247. x: this.x
  1248. }, 500, createjs.Ease.linear).call(createjs.proxy(this.alphaEnd, this))
  1249. };
  1250. HelpDialog = function(e) {
  1251. createjs.Container.call(this);
  1252. this.gameManager = e;
  1253. this.field = this.gameManager.field;
  1254. this.finger = new createjs.Sprite(Jok.JokG().animLoader.spriteSheet, "Finger_mc");
  1255. this.addChild(this.finger);
  1256. this.SCALE_BEGIN = 1.5;
  1257. this.Y_BEGIN = 200;
  1258. this.Y_END = 100;
  1259. this.X_END = 200;
  1260. this.finger.y = this.Y_BEGIN;
  1261. this.finger.stop();
  1262. this.finger.scaleX = this.finger.scaleY = this.SCALE_BEGIN;
  1263. this.finger.alpha = 0;
  1264. this.tween = createjs.Tween.get(this.finger, {
  1265. loop: true
  1266. }).to({
  1267. x: -this.X_END,
  1268. y: this.Y_END,
  1269. alpha: 1,
  1270. scaleX: 1,
  1271. scaleY: 1
  1272. }, 500, createjs.Ease.quadOut).call(createjs.proxy(this.stepHelp_1, this)).wait(750).to({
  1273. x: this.X_END
  1274. }, 900, createjs.Ease.quadInOut).wait(750).call(createjs.proxy(this.stepHelp_2, this)).to({
  1275. scaleX: this.SCALE_BEGIN,
  1276. scaleY: this.SCALE_BEGIN,
  1277. y: this.Y_END + 50,
  1278. alpha: 0
  1279. }, 500, createjs.Ease.quadInOut).to({
  1280. x: 0,
  1281. y: this.Y_BEGIN
  1282. }, 1500, createjs.Ease.quadInOut)
  1283. };
  1284. HelpDialog.prototype = Object.create(createjs.Container.prototype);
  1285. HelpDialog.prototype.constructor = GameDialogBase;
  1286. HelpDialog.prototype.stepHelp_1 = function() {
  1287. this.finger.currentAnimationFrame = 1;
  1288. this.checkDelete()
  1289. };
  1290. HelpDialog.prototype.stepHelp_2 = function() {
  1291. this.finger.currentAnimationFrame = 0;
  1292. this.checkDelete()
  1293. };
  1294. HelpDialog.prototype.checkDelete = function() {
  1295. if (this.field[3][3] == 0) {
  1296. if (this.parent) this.parent.removeChild(this);
  1297. createjs.Tween.removeTweens(this.finger)
  1298. }
  1299. };
  1300. LevelSelectMenu = function() {
  1301. Jok.JokState.call(this)
  1302. };
  1303. LevelSelectMenu.prototype = Object.create(Jok.JokState.prototype);
  1304. LevelSelectMenu.prototype.constructor = LevelSelectMenu;
  1305. LevelSelectMenu.prototype.create = function() {
  1306. this.MAX_LEVEL_ID = Math.floor((new Jok.JokG).MAX_LEVEL / 20);
  1307. this._nowLevelId = 0;
  1308. var e = new createjs.Sprite(Jok.JokG().animLoader.spriteSheet, "MainMenuBack_mc");
  1309. this.addChild(e);
  1310. this.buttonBack = new MyButtonBase(createjs.proxy(this.backsAction, this), new createjs.Point(-(new Jok.JokG).width / 2 + 64, 300), new createjs.Point(.67, .67), "MainMenuButton_1_mc");
  1311. this.buttonBack.initUp("ButtonBack_mc");
  1312. this.addChild(this.buttonBack);
  1313. this.buttonLevelBack = new MyButtonBase(createjs.proxy(this.buttonLevelBackAction, this), new createjs.Point(-(new Jok.JokG).width / 2 + 40, 0), new createjs.Point(1, 1), "ButtonLevel_mc");
  1314. this.buttonLevelBack.sprDown.stop();
  1315. this.buttonLevelBack.sprDown.currentAnimationFrame = 1;
  1316. this.addChild(this.buttonLevelBack);
  1317. this.buttonLevelNext = new MyButtonBase(createjs.proxy(this.buttonLevelNextAction, this), new createjs.Point(-this.buttonLevelBack.x, 0), new createjs.Point(-1, 1), "ButtonLevel_mc");
  1318. this.buttonLevelNext.sprDown.stop();
  1319. this.addChild(this.buttonLevelNext);
  1320. if ((new Jok.JokG).showZibbo) {
  1321. var t = {};
  1322. t["type"] = ".png";
  1323. t["width"] = 202;
  1324. t["height"] = 50;
  1325. console.log("new Jok.JokG().showZibbo = " + (new Jok.JokG).showZibbo)
  1326. }
  1327. this.drawLevelButtons()
  1328. };
  1329. LevelSelectMenu.prototype.backsAction = function(e) {
  1330. (new Jok.JokG).jokEngine.transitionScreen(new MainMenu, null, null)
  1331. };
  1332. LevelSelectMenu.prototype.moreAction = function(e) {
  1333. ZibboUtils.buttonAction("more_games")
  1334. };
  1335. LevelSelectMenu.prototype.buttonLevelBackAction = function(e) {
  1336. if (this._nowLevelId <= 0) return;
  1337. this.buttonLevelNext.sprDown.currentAnimationFrame = 0;
  1338. this._nowLevelId--;
  1339. if (this._nowLevelId == 0) this.buttonLevelBack.sprDown.currentAnimationFrame = 1;
  1340. this.drawLevelButtons()
  1341. };
  1342. LevelSelectMenu.prototype.buttonLevelNextAction = function(e) {
  1343. if (this._nowLevelId >= this.MAX_LEVEL_ID) return;
  1344. this.buttonLevelBack.sprDown.currentAnimationFrame = 0;
  1345. this._nowLevelId++;
  1346. if (this._nowLevelId == this.MAX_LEVEL_ID) this.buttonLevelNext.sprDown.currentAnimationFrame = 1;
  1347. this.drawLevelButtons()
  1348. };
  1349. LevelSelectMenu.prototype.drawLevelButtons = function() {
  1350. if (this._levelButtonsContainer) this._levelButtonsContainer.removeAllChildren();
  1351. else {
  1352. this._levelButtonsContainer = new createjs.Container;
  1353. this.addChild(this._levelButtonsContainer)
  1354. }
  1355. var e = 100;
  1356. var t = 712 - e - 140;
  1357. t = t / 4;
  1358. var n = 140;
  1359. var r = ((new Jok.JokG).width - n - n) / 3;
  1360. n -= (new Jok.JokG).width / 2;
  1361. e -= 712 / 2;
  1362. var i = this._nowLevelId * 20 + 1;
  1363. var s = 1;
  1364. if (typeof window.localStorage != "undefined") s = window.localStorage.getItem("levelComplete");
  1365. for (var o = 0; o < 5; o++)
  1366. for (var u = 0; u < 4; u++) {
  1367. if ((new Jok.JokG).MAX_LEVEL >= i) {
  1368. var a = new LevelButton(new createjs.Point(n + r * u, e + t * o), new createjs.Point(1, 1), i, s >= i);
  1369. this._levelButtonsContainer.addChild(a)
  1370. }
  1371. i++
  1372. }
  1373. };
  1374. MainMenu = function() {
  1375. Jok.JokState.call(this)
  1376. };
  1377. MainMenu.prototype = Object.create(Jok.JokState.prototype);
  1378. MainMenu.prototype.constructor = MainMenu;
  1379. MainMenu.prototype.create = function() {
  1380. var e = new createjs.Sprite(Jok.JokG().animLoader.spriteSheet, "MainMenuBack_mc");
  1381. this.addChild(e);
  1382. this.buttonMusic = new SoundButton(new createjs.Point((new Jok.JokG).width / 2 - 100, 280), new createjs.Point(.67, .67));
  1383. this.addChild(this.buttonMusic);
  1384. this.eventPlay = createjs.proxy(this.playAction, this);
  1385. this.buttonPlay = new MyButtonBase(this.eventPlay, new createjs.Point(0, 10), new createjs.Point(1, 1), "MainMenuButton_1_mc");
  1386. this.buttonPlay.initUp("ButtonPlay_mc");
  1387. this.addChild(this.buttonPlay);
  1388. this.buttonMore = new MyButtonBase(createjs.proxy(ZibboUtils.moreAction, this), new createjs.Point(0, 170), new createjs.Point(.67, .67), "MainMenuButton_1_mc");
  1389. this.buttonMore.initUp("ButtonMoreGames_mc");
  1390. this.addChild(this.buttonMore);
  1391. if ((new Jok.JokG).showZibbo) {
  1392. var t = {};
  1393. t["type"] = ".png";
  1394. t["width"] = 202;
  1395. t["height"] = 50
  1396. }
  1397. this.buttonPlay.scaleX = this.buttonPlay.scaleY = 0;
  1398. createjs.Tween.get(this.buttonPlay).to({
  1399. scaleX: 1,
  1400. scaleY: 1
  1401. }, 1800, createjs.Ease.elasticOut);
  1402. var n = 390;
  1403. var r = new createjs.Sprite(Jok.JokG().animLoader.spriteSheet, "MainMenuTitle_mc");
  1404. r.y = -((new Jok.JokG).height - n) / 2 + (new Jok.JokG).height / 2 - n;
  1405. this.addChild(r);
  1406. r.scaleX = r.scaleY = 0;
  1407. createjs.Tween.get(r).to({
  1408. scaleX: 1,
  1409. scaleY: 1
  1410. }, 2500, createjs.Ease.elasticOut)
  1411. };
  1412. MainMenu.prototype.onButton = function() {
  1413. this.buttonCredits.onWork();
  1414. this.buttonPlay.onWork();
  1415. this.buttonMusic.onWork();
  1416. this.buttonMore.onWork();
  1417. if (this.buttonLogo) this.buttonLogo.onWork()
  1418. };
  1419. MainMenu.prototype.offButton = function() {
  1420. this.buttonCredits.offWork();
  1421. this.buttonPlay.offWork();
  1422. this.buttonMusic.offWork();
  1423. this.buttonMore.offWork();
  1424. if (this.buttonLogo) this.buttonLogo.offWork()
  1425. };
  1426. MainMenu.prototype.logoAction = function(e) {
  1427. if ((new Jok.JokG).showZibbo) ZibboUtils.buttonAction("logo")
  1428. };
  1429. MainMenu.prototype.moreAction = function(e) {
  1430. if ((new Jok.JokG).showZibbo) ZibboUtils.buttonAction("more_games")
  1431. };
  1432. MainMenu.prototype.creditsAction = function(e) {};
  1433. MainMenu.prototype.playAction = function(e) {
  1434. (new Jok.JokG).jokEngine.transitionScreen(new LevelSelectMenu, null, null)
  1435. };
  1436. PauseDialog = function(e) {
  1437. GameDialogBase.call(this, e);
  1438. var t = new MyButtonBase(createjs.proxy(this.playAction, this), new createjs.Point(0, -51), new createjs.Point(.9, .9), "MainMenuButton_1_mc");
  1439. t.initUp("ButtonPlay_mc");
  1440. this.addChild(t);
  1441. var n = .6;
  1442. var r = 90;
  1443. var i = 170;
  1444. t = new MyButtonBase(createjs.proxy(this.backAction, this), new createjs.Point(0, r), new createjs.Point(n, n), "MainMenuButton_1_mc");
  1445. t.initUp("ButtonBack_mc");
  1446. this.addChild(t);
  1447. t = new MyButtonBase(createjs.proxy(this.restartAction, this), new createjs.Point(-i, r), new createjs.Point(n, n), "MainMenuButton_1_mc");
  1448. t.initUp("buttonRestart_2_mc");
  1449. this.addChild(t);
  1450. t = new SoundButton(new createjs.Point(i, r), new createjs.Point(n, n));
  1451. this.addChild(t);
  1452. t = new MyButtonBase(createjs.proxy(ZibboUtils.moreAction, this), new createjs.Point(-180, -67), new createjs.Point(n, n), "MainMenuButton_1_mc");
  1453. t.initUp("ButtonMoreGames_mc");
  1454. this.addChild(t);
  1455. t = new MyButtonBase(createjs.proxy(ZibboUtils.walkAction, this), new createjs.Point(180, -67), new createjs.Point(n, n), "MainMenuButton_1_mc");
  1456. t.initUp("ButtonWalk_mc");
  1457. this.addChild(t)
  1458. };
  1459. PauseDialog.prototype = Object.create(GameDialogBase.prototype);
  1460. PauseDialog.prototype.constructor = PauseDialog;
  1461. PauseDialog.prototype.walkAction = function(e) {
  1462. if ((new Jok.JokG).showZibbo) ZibboUtils.buttonAction("walkthrough")
  1463. };
  1464. PauseDialog.prototype.playAction = function(e) {
  1465. createjs.Tween.get(this).to({
  1466. alpha: 0
  1467. }, 400, createjs.Ease.quadOut).call(createjs.proxy(this.playActionEnd, this))
  1468. };
  1469. PauseDialog.prototype.playActionEnd = function(e) {
  1470. if (this.parent) this.parent.removeChild(this);
  1471. this.onAll()
  1472. };
  1473. Jok.JokAnimLoader = function() {
  1474. this.data = null
  1475. };
  1476. Jok.JokAnimLoader.prototype.constructor = Jok.JokAnimLoader;
  1477. Jok.JokAnimLoader.prototype.loadAnim = function(e, t, n) {
  1478. console.log("xmlArchorData = " + e);
  1479. console.log("jsonFrameData = " + t);
  1480. console.log("image = " + n);
  1481. // console.log("image.srs = " + n.src);
  1482. console.log("image.getContext = " + n.getContext);
  1483. console.log("image.data = " + n.data);
  1484. console.log("jsonFrameData.frames[0].filename = " + t.frames[0].frame.x);
  1485. var r = 0;
  1486. var i;
  1487. console.log("Jok.JokAnimLoader.prototype.loadAnim 1");
  1488. this.spriteSheetData = {
  1489. framerate: 24,
  1490. images: [n],
  1491. frames: [],
  1492. animations: {}
  1493. };
  1494. var s = 0;
  1495. console.log("Jok.JokAnimLoader.prototype.loadAnim 2");
  1496. while (true) {
  1497. var o = e.getElementsByTagName("Parametr")[r];
  1498. if (o) {
  1499. i = o.getAttribute("n");
  1500. var u = 0;
  1501. while (true) {
  1502. var a = o.getElementsByTagName("info")[u];
  1503. if (a) {
  1504. var f = -parseInt(a.getAttribute("x"));
  1505. var l = -parseInt(a.getAttribute("y"));
  1506. var c = this.getFrameData(t, this.getFrameName(i, u));
  1507. this.spriteSheetData.frames.push([c.x, c.y, c.w, c.h, 0, f, c.h - l]);
  1508. u++;
  1509. s++
  1510. } else break
  1511. }
  1512. this.spriteSheetData.animations[i] = [s - u, s - 1];
  1513. r++
  1514. } else break
  1515. }
  1516. console.log("Jok.JokAnimLoader.prototype.loadAnim 3");
  1517. this.spriteSheet = new createjs.SpriteSheet(this.spriteSheetData);
  1518. console.log("Jok.JokAnimLoader.prototype.loadAnim 4")
  1519. };
  1520. Jok.JokAnimLoader.prototype.getFrameName = function(e, t) {
  1521. var n = "000" + t;
  1522. n = n.substr(n.length - 3, 3);
  1523. return e + "_" + n + ".png"
  1524. };
  1525. Jok.JokAnimLoader.prototype.getFrameData = function(e, t) {
  1526. var n = 0;
  1527. while (e.frames[n]) {
  1528. if (e.frames[n].filename == t) return {
  1529. x: parseInt(e.frames[n].frame.x),
  1530. y: parseInt(e.frames[n].frame.y),
  1531. w: parseInt(e.frames[n].frame.w),
  1532. h: parseInt(e.frames[n].frame.h)
  1533. };
  1534. n++
  1535. }
  1536. return null
  1537. };
  1538. Jok.JokAnimLoader.prototype.loadBitmapFont = function(e, t) {
  1539. var n = {};
  1540. n[65] = "A";
  1541. n[66] = "B";
  1542. n[67] = "C";
  1543. n[68] = "D";
  1544. n[69] = "E";
  1545. n[70] = "F";
  1546. n[71] = "G";
  1547. n[72] = "H";
  1548. n[73] = "I";
  1549. n[74] = "J";
  1550. n[75] = "K";
  1551. n[76] = "L";
  1552. n[77] = "M";
  1553. n[78] = "N";
  1554. n[79] = "O";
  1555. n[80] = "P";
  1556. n[81] = "Q";
  1557. n[82] = "R";
  1558. n[83] = "S";
  1559. n[84] = "T";
  1560. n[85] = "U";
  1561. n[86] = "V";
  1562. n[87] = "W";
  1563. n[88] = "X";
  1564. n[89] = "Y";
  1565. n[90] = "Z";
  1566. n[47] = "/";
  1567. n[48] = "0";
  1568. n[49] = "1";
  1569. n[50] = "2";
  1570. n[51] = "3";
  1571. n[52] = "4";
  1572. n[53] = "5";
  1573. n[54] = "6";
  1574. n[55] = "7";
  1575. n[56] = "8";
  1576. n[57] = "9";
  1577. var r = 0;
  1578. this.fontData = {
  1579. images: [t],
  1580. frames: [],
  1581. animations: {}
  1582. };
  1583. var i = 0;
  1584. while (true) {
  1585. var s = e.getElementsByTagName("chars")[0];
  1586. s = s.getElementsByTagName("char")[r];
  1587. if (s) {
  1588. var o = parseInt(s.getAttribute("id"));
  1589. var u = parseInt(s.getAttribute("x"));
  1590. var a = parseInt(s.getAttribute("y"));
  1591. var f = parseInt(s.getAttribute("width"));
  1592. var l = parseInt(s.getAttribute("height"));
  1593. var c = parseInt(s.getAttribute("xoffset"));
  1594. var h = parseInt(s.getAttribute("yoffset"));
  1595. if (f > 0 && l > 0) {
  1596. c = h = 0;
  1597. this.fontData.frames.push([u, a, f, l, 0, c, h]);
  1598. this.fontData.animations[n[o]] = {
  1599. frames: [i]
  1600. };
  1601. i++
  1602. }
  1603. r++
  1604. } else break
  1605. }
  1606. console.log("allNode = " + r);
  1607. this.fontSheet = new createjs.SpriteSheet(this.fontData)
  1608. };
  1609. Jok.JokEngine = function(e) {
  1610. console.log("Jok.JokEngine");
  1611. this.state = null;
  1612. (new Jok.JokG).init(e, this);
  1613. this.stage = (new Jok.JokG).stage;
  1614. this.asd = 55;
  1615. this.fpsLabel = new createjs.Text("-- fps", "bold 14px Arial", "#000");
  1616. this.fpsLabel.x = 10 - (new Jok.JokG).width / 2;
  1617. this.fpsLabel.y = 20 - 712 / 2
  1618. };
  1619. Jok.JokEngine.prototype.constructor = Jok.JokEngine;
  1620. Jok.JokEngine.prototype.initState = function(e) {
  1621. console.log("Jok.JokEngine.prototype.initState");
  1622. this.switchState(e);
  1623. if (!createjs.Ticker.hasEventListener("tick")) {
  1624. this.tickEvent = createjs.proxy(this.tick, this);
  1625. createjs.Ticker.on("tick", this.tickEvent)
  1626. }
  1627. };
  1628. Jok.JokEngine.prototype.transitionScreen = function(e, t, n) {
  1629. (new Jok.JokTransitionScreenBase).init(t, n, e, 1e3)
  1630. };
  1631. Jok.JokEngine.prototype.switchState = function(e) {
  1632. if (this.state) {
  1633. this.stage.removeChild(this.state);
  1634. this.state.dispose()
  1635. }
  1636. this.state = e;
  1637. this.state.create();
  1638. this.stage.addChildAt(this.state, 0)
  1639. };
  1640. Jok.JokEngine.prototype.tick = function(e) {
  1641. this.state.update();
  1642. this.fpsLabel.text = Math.round(createjs.Ticker.getMeasuredFPS()) + " fps";
  1643. this.stage.update(e)
  1644. };
  1645. Jok.JokG = function() {
  1646. var e = arguments.callee;
  1647. if (e.instance) return e.instance;
  1648. this.queue = new createjs.LoadQueue(true, "assets/");
  1649. this.animLoader = new Jok.JokAnimLoader;
  1650. this._idNow = 0;
  1651. this.text = new Jok.JokTextData;
  1652. e.instance = this
  1653. };
  1654. Jok.JokG.prototype.constructor = Jok.JokG;
  1655. Jok.JokG.prototype.getNewid = function() {
  1656. return this._idNow++
  1657. };
  1658. Jok.JokG.prototype.init = function(e, t) {
  1659. console.log("Jok.JokG.prototype.init");
  1660. this.canvas = this.createGameCanvas(e);
  1661. this.stage = new createjs.Stage(this.canvas);
  1662. this.stage.autoClear = false;
  1663. this.stage.enableMouseOver(15);
  1664. this.jokEngine = t;
  1665. this.resize();
  1666. var n = createjs.proxy(this.resize, this);
  1667. window.addEventListener("resize", n, false);
  1668. window.addEventListener("viewportchange", n, false);
  1669. window.addEventListener("viewportready", n, false);
  1670. createjs.Touch.enable(this.stage);
  1671. createjs.Ticker.setFPS(30);
  1672. this.fonts = {};
  1673. console.log("this.jokEngine = " + this.jokEngine)
  1674. };
  1675. Jok.JokG.prototype.createGameCanvas = function(e) {
  1676. console.log("Jok.JokG.prototype.createGameCanvas");
  1677. var t = document.getElementById(e);
  1678. return t
  1679. };
  1680. Jok.JokG.prototype.addFont = function(e, t) {
  1681. this.fonts[e] = t
  1682. };
  1683. Jok.JokG.prototype.resize = function() {
  1684. console.log("Jok.JokG.prototype.resize");
  1685. var e = 640;
  1686. var t = 712;
  1687. var n = 960;
  1688. var r = window.innerWidth;
  1689. var i = window.innerHeight;
  1690. var s = document.getElementById("portraitLock");
  1691. if (!this.isLandscape()) {
  1692. s.style.display = "none";
  1693. (new Jok.JokG).canvas.style.display = "block"
  1694. } else {
  1695. s.style.display = "block";
  1696. (new Jok.JokG).canvas.style.display = "none"
  1697. }
  1698. var o = Math.min(r / e, i / t);
  1699. var u = (new Jok.JokG).canvas;
  1700. u.width = e;
  1701. u.height = Math.min(Math.floor(i / o), n);
  1702. var a = Math.floor(u.width * o);
  1703. var f = Math.floor(u.height * o);
  1704. u.style.width = a + "px";
  1705. u.style.height = f + "px";
  1706. this.width = this.canvas.width;
  1707. this.height = this.canvas.height;
  1708. this.stage.x = this.width / 2;
  1709. this.stage.y = this.height / 2;
  1710. var l = u.parentElement;
  1711. l.style.width = a + "px";
  1712. l.style.height = f + "px";
  1713. var c = (r - a) / 2;
  1714. l.style.left = c + "px";
  1715. var h = (i - f) / 2;
  1716. l.style.top = h + "px"
  1717. };
  1718. Jok.JokG.prototype.isLandscape = function() {
  1719. console.log("Jok.JokG.prototype.isLandscape");
  1720. if (createjs.Sound.BrowserDetect.isIOS || createjs.Sound.BrowserDetect.isAndroid || createjs.Sound.BrowserDetect.isBlackberry) return window.innerWidth > window.innerHeight && window.innerWidth <= 640;
  1721. return false
  1722. };
  1723. Jok.JokTextData = function() {
  1724. this.text = null;
  1725. this._noText = "textNotFound"
  1726. };
  1727. Jok.JokTextData.prototype.constructor = Jok.JokTextData;
  1728. Jok.JokTextData.prototype.init = function(e) {
  1729. this.text = e;
  1730. console.log(this.text)
  1731. };
  1732. Jok.JokTextData.prototype.getText = function(e) {
  1733. if (this.text != null) {
  1734. var t = 0;
  1735. while (true) {
  1736. var n = this.text.texts[t];
  1737. if (n) {
  1738. if (n.id == e) return n.text
  1739. } else break;
  1740. t++
  1741. }
  1742. return this._noText
  1743. }
  1744. return "this.text=null"
  1745. };
  1746. Jok.JokTransitionScreenBase = function() {
  1747. createjs.Container.call(this);
  1748. this.shape = new createjs.Shape;
  1749. this.shape.x = -(new Jok.JokG).width / 2;
  1750. this.shape.y = -(new Jok.JokG).height / 2;
  1751. this.shape.graphics.beginFill("rgba(255,255,255,1)").rect(0, 0, (new Jok.JokG).width, (new Jok.JokG).height);
  1752. this.addChild(this.shape);
  1753. this.eventTween = createjs.proxy(this.endTeen, this)
  1754. };
  1755. Jok.JokTransitionScreenBase.prototype = Object.create(createjs.Container.prototype);
  1756. Jok.JokTransitionScreenBase.prototype.constructor = Jok.JokTransitionScreenBase;
  1757. Jok.JokTransitionScreenBase.prototype.init = function(e, t, n, r) {
  1758. this._state = n;
  1759. this._funcBegin = e;
  1760. this._funcEnd = t;
  1761. (new Jok.JokG).stage.addChild(this);
  1762. this.alpha = 0;
  1763. this._time = r / 2;
  1764. createjs.Tween.get(this).to({
  1765. alpha: 1
  1766. }, this._time, createjs.Ease.quadOut).call(this.eventTween)
  1767. };
  1768. Jok.JokTransitionScreenBase.prototype.endTeen = function(e) {
  1769. if (this.alpha > .9) {
  1770. createjs.Tween.get(this).to({
  1771. alpha: 0
  1772. }, this._time, createjs.Ease.quadOut).call(this.eventTween);
  1773. if (this._funcBegin != null) this._funcBegin();
  1774. (new Jok.JokG).jokEngine.switchState(this._state)
  1775. } else {
  1776. (new Jok.JokG).stage.removeChild(this);
  1777. if (this._funcEnd != null) this._funcEnd()
  1778. }
  1779. }