PageRenderTime 150ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 3ms

/dist/dka-game.js

https://gitlab.com/free-electrons-labs/dka-game
JavaScript | 15634 lines | 12615 code | 1017 blank | 2002 comment | 645 complexity | 58d04a1db1d903e6c1a5f9b5ffd68b33 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. /*
  2. * Copyright © Romain Fouquet, 2012-2015
  3. * Copyright © Clément Joly, 2012-2015
  4. #
  5. * romain.fouquet18@gmail.com
  6. * leowzukw@vmail.me
  7. #
  8. * This file is part of Diseases Killer Academy.
  9. #
  10. * Diseases Killer Academy is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. #
  15. * Diseases Killer Academy is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. #
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with Diseases Killer Academy. If not, see http://www.gnu.org/licenses/agpl-3.0.html.
  22. */
  23. (function() {
  24. 'use strict';
  25. window.dka = window.dka || {};
  26. dka.colors = {
  27. darkBlue: '#003d65',
  28. lightBlue: '#0da0ff',
  29. veryLightBlue: '#70c7ff',
  30. shinyBlue: '#19f1f1',
  31. lightGreen: '#00f000',
  32. gold: '#f0d400',
  33. darkGrey: '#2C3835',
  34. black: '#000'
  35. };
  36. }).call(this);
  37. /*
  38. * Copyright © Romain Fouquet, 2012-2015
  39. * Copyright © Clément Joly, 2012-2015
  40. #
  41. * romain.fouquet18@gmail.com
  42. * leowzukw@vmail.me
  43. #
  44. * This file is part of Diseases Killer Academy.
  45. #
  46. * Diseases Killer Academy is free software: you can redistribute it and/or modify
  47. * it under the terms of the GNU Affero General Public License as published by
  48. * the Free Software Foundation, either version 3 of the License, or
  49. * (at your option) any later version.
  50. #
  51. * Diseases Killer Academy is distributed in the hope that it will be useful,
  52. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  53. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  54. * GNU Affero General Public License for more details.
  55. #
  56. * You should have received a copy of the GNU Affero General Public License
  57. * along with Diseases Killer Academy. If not, see http://www.gnu.org/licenses/agpl-3.0.html.
  58. */
  59. (function() {
  60. 'use strict';
  61. dka.GameSettings = (function() {
  62. function GameSettings() {
  63. this._towerPill();
  64. this._towerAntibiotic();
  65. this._towerCellB();
  66. this._towerCellMacrophage();
  67. this._towerHospital();
  68. this._labs();
  69. this._diseases();
  70. }
  71. GameSettings.prototype._towerPill = function() {
  72. this.towers = {};
  73. return this.towers.pill = {
  74. title: 'Pill Labs',
  75. description: 'Pills are generic remedies to all kind of diseases.',
  76. buildingTime: 30,
  77. upgrade0: {
  78. cost: 70,
  79. reloadTime: 20,
  80. range: 150,
  81. magazineSize: 20,
  82. haziness: 8,
  83. bulletDamage: [2, 5]
  84. },
  85. upgrade1: {
  86. cost: 90,
  87. reloadTime: 17,
  88. range: 180,
  89. magazineSize: 4,
  90. haziness: 6,
  91. bulletDamage: [3, 6]
  92. },
  93. upgrade2: {
  94. cost: 120,
  95. reloadTime: 15,
  96. range: 200,
  97. magazineSize: 8,
  98. haziness: 2,
  99. bulletDamage: [5, 8]
  100. },
  101. upgrade3: {
  102. cost: 180,
  103. reloadTime: 9,
  104. range: 230,
  105. magazineSize: 8,
  106. haziness: 10,
  107. bulletDamage: [10, 15]
  108. }
  109. };
  110. };
  111. GameSettings.prototype._towerAntibiotic = function() {
  112. return this.towers.antibiotic = {
  113. title: 'Antibiotic Labs',
  114. description: 'Antibiotics deal area damage to all alive germs. Be carefull! Viruses are not alive. They are totally immune to antibiotics!',
  115. buildingTime: 50,
  116. upgrade0: {
  117. cost: 90,
  118. reloadTime: 60,
  119. range: 170,
  120. magazineSize: 7,
  121. bulletRadiusDamage: 70,
  122. bulletDamage: [7, 15]
  123. },
  124. upgrade1: {
  125. cost: 110,
  126. reloadTime: 65,
  127. range: 220,
  128. magazineSize: 7,
  129. bulletRadiusDamage: 70,
  130. bulletDamage: [13, 18]
  131. },
  132. upgrade2: {
  133. cost: 150,
  134. reloadTime: 65,
  135. range: 250,
  136. magazineSize: 8,
  137. bulletRadiusDamage: 70,
  138. bulletDamage: [18, 25]
  139. },
  140. upgrade3: {
  141. cost: 200,
  142. reloadTime: 91,
  143. range: 270,
  144. magazineSize: 7,
  145. bulletRadiusDamage: 70,
  146. bulletDamage: [30, 45]
  147. }
  148. };
  149. };
  150. GameSettings.prototype._towerCellB = function() {
  151. return this.towers.cellB = {
  152. title: 'B Cell',
  153. description: ' B cells are part of immune defense system, they create plasma cells who can prevent diseases multiplicating, brake them, or even damage them!',
  154. buildingTime: 30,
  155. upgrade0: {
  156. cost: 90,
  157. range: 200,
  158. cellSpeed: 3,
  159. cellTtl: 4
  160. },
  161. upgrade1: {
  162. cost: 110,
  163. range: 200,
  164. cellSpeed: 2,
  165. cellTtl: 5
  166. },
  167. upgrade2: {
  168. cost: 150,
  169. range: 200,
  170. cellSpeed: 3,
  171. cellTtl: 6
  172. },
  173. upgrade3: {
  174. cost: 230,
  175. range: 200,
  176. cellSpeed: 5,
  177. cellTtl: 7
  178. }
  179. };
  180. };
  181. GameSettings.prototype._towerCellMacrophage = function() {
  182. return this.towers.cellMacrophage = {
  183. title: 'Macrophage Cell',
  184. description: 'Macrophage cells are part of immune defense system, they directly eat diseases! but target only the ones with antibodies.',
  185. buildingTime: 20,
  186. upgrade0: {
  187. cost: 70,
  188. range: 200,
  189. cellSpeed: 6,
  190. cellTtl: 4,
  191. cellDamage: 1,
  192. respawnReload: 40
  193. },
  194. upgrade1: {
  195. cost: 110,
  196. range: 160,
  197. cellSpeed: 6,
  198. cellTtl: 4,
  199. cellDamage: 1.5,
  200. respawnReload: 40
  201. },
  202. upgrade2: {
  203. cost: 150,
  204. range: 160,
  205. cellSpeed: 6,
  206. cellTtl: 4,
  207. cellDamage: 2,
  208. respawnReload: 40
  209. },
  210. upgrade3: {
  211. cost: 230,
  212. range: 160,
  213. cellSpeed: 5,
  214. cellTtl: 4,
  215. cellDamage: 3,
  216. respawnReload: 40
  217. }
  218. };
  219. };
  220. GameSettings.prototype._towerHospital = function() {
  221. return this.towers.hospital = {
  222. abilities: {
  223. subsidies: {
  224. title: 'Subsidies',
  225. description: 'The city helps you a little by giving you some coins each wave.',
  226. cost: [60, 140],
  227. action: [40, 80]
  228. },
  229. supply: {
  230. title: 'Better supply',
  231. description: 'A better supply will make your pill and antibiotic towers shoot faster.',
  232. cost: [40, 350],
  233. action: [10, 15]
  234. },
  235. education: {
  236. img: 'Up3',
  237. title: 'Education',
  238. description: 'Educating the population about hygiene enable the reduction of the multiplication rate of diseases.',
  239. cost: [40, 100],
  240. action: [100, 200]
  241. }
  242. }
  243. };
  244. };
  245. GameSettings.prototype._labs = function() {
  246. return this.labs = {
  247. fever: [
  248. {
  249. duration: 45,
  250. reloadTime: 300,
  251. title: 'Fever',
  252. description: 'Increase duration and reduce reload time.'
  253. }, {
  254. cost: 70,
  255. duration: 55,
  256. reloadTime: 350,
  257. title: 'Fever',
  258. description: 'Increase duration and reduce reload time.'
  259. }, {
  260. cost: 90,
  261. duration: 75,
  262. reloadTime: 450,
  263. title: 'Fever',
  264. description: 'Increase duration and reduce reload time.'
  265. }
  266. ],
  267. vaccine: [
  268. {
  269. damage: 0.5,
  270. duration: 100,
  271. reloadTime: 450,
  272. title: 'Vaccine',
  273. description: 'Increase damage and reduce reload time.'
  274. }, {
  275. cost: 70,
  276. duration: 150,
  277. damage: 1,
  278. reloadTime: 350,
  279. title: 'Vaccine',
  280. description: 'Increase damage and reduce reload time.'
  281. }, {
  282. cost: 100,
  283. duration: 200,
  284. damage: 1.5,
  285. reloadTime: 300,
  286. title: 'Vaccine',
  287. description: 'Increase damage and reduce reload time.'
  288. }
  289. ],
  290. hintNxtWave: [
  291. {
  292. cost: 40,
  293. title: 'Next wave',
  294. description: 'Add informations about the next wave.'
  295. }, {
  296. cost: 60,
  297. title: 'Next wave',
  298. description: 'Add informations about the next wave.'
  299. }
  300. ]
  301. };
  302. };
  303. GameSettings.prototype.getLabsSetting = function(setting, prop) {
  304. return this.labs[setting][dka.academy.game.labs.getUpgradeLevel(setting)][prop];
  305. };
  306. GameSettings.prototype._diseases = function() {
  307. this.diseasesList = ['Tuberculosis', 'Plague', 'HIV', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unknown'];
  308. return this.diseases = {
  309. Tuberculosis: {
  310. type: 'Bacterium',
  311. speed: DEBUG_MODE ? 3 : 1.3,
  312. life: 20,
  313. lifeCost: 1,
  314. delayToMultiplicate: 300
  315. },
  316. HIV: {
  317. type: 'Virus',
  318. speed: 1.5,
  319. life: 40,
  320. lifeCost: 3
  321. },
  322. Plague: {
  323. type: 'Bacterium',
  324. speed: 2,
  325. life: 25,
  326. lifeCost: 1,
  327. delayToMultiplicate: 200
  328. }
  329. };
  330. };
  331. GameSettings.prototype.isBetter = function(before, after, criteria) {
  332. var diff, whatIsBetter;
  333. if (criteria === 'damage') {
  334. before = (before[1] - before[0]) / 2 + before[0];
  335. after = (after[1] - after[0]) / 2 + after[0];
  336. }
  337. diff = after - before;
  338. if (diff === 0) {
  339. return 'equal';
  340. }
  341. whatIsBetter = (function() {
  342. switch (criteria) {
  343. case 'range':
  344. return 'higher';
  345. case 'reloadTime':
  346. return 'lower';
  347. case 'damage':
  348. return 'higher';
  349. case 'cellDamage':
  350. return 'higher';
  351. case 'magazineSize':
  352. return 'higher';
  353. case 'haziness':
  354. return 'lower';
  355. case 'cellTtl':
  356. return 'higher';
  357. case 'cellSpeed':
  358. return 'higher';
  359. }
  360. })();
  361. if (whatIsBetter === 'higher' && diff > 0 || whatIsBetter === 'lower' && diff < 0) {
  362. return 'better';
  363. }
  364. return 'worse';
  365. };
  366. GameSettings.prototype.getReloadString = function(reloadTime, nbPlus) {
  367. var i, plusString;
  368. if (reloadTime < 0) {
  369. return '';
  370. }
  371. plusString = '';
  372. i = 0;
  373. while (i < nbPlus) {
  374. plusString += '+';
  375. i++;
  376. }
  377. switch (false) {
  378. case !(reloadTime <= 10):
  379. return 'Very fast' + plusString;
  380. case !(reloadTime <= 20):
  381. return 'Fast' + plusString;
  382. case !(reloadTime <= 50):
  383. return 'Average' + plusString;
  384. case !(reloadTime <= 70):
  385. return 'Slow' + plusString;
  386. default:
  387. return 'Very slow' + plusString;
  388. }
  389. };
  390. GameSettings.prototype.getMoveString = function(moveSpeed) {
  391. switch (false) {
  392. case !(moveSpeed < 0):
  393. return '';
  394. case !(moveSpeed <= 1):
  395. return 'Very slow';
  396. case !(moveSpeed <= 2):
  397. return 'Slow';
  398. case !(moveSpeed <= 4):
  399. return 'Average';
  400. case !(moveSpeed <= 6):
  401. return 'Fast';
  402. default:
  403. return 'Very fast';
  404. }
  405. };
  406. GameSettings.prototype.getDiseaseSpeedString = function(speed) {
  407. switch (false) {
  408. case !(speed < 0):
  409. return '';
  410. case !(speed <= 1):
  411. return 'Very slow';
  412. case !(speed <= 1.5):
  413. return 'Slow';
  414. case !(speed <= 2):
  415. return 'Average';
  416. case !(speed <= 2.5):
  417. return 'Fast';
  418. default:
  419. return 'Very fast';
  420. }
  421. };
  422. GameSettings.prototype.getRespawnString = function(respwanTime) {
  423. switch (false) {
  424. case !(respwanTime < 0):
  425. return '';
  426. case !(respwanTime <= 20):
  427. return 'Very fast';
  428. case !(respwanTime <= 30):
  429. return 'Fast';
  430. case !(respwanTime <= 40):
  431. return 'Average';
  432. case !(respwanTime <= 50):
  433. return 'Slow';
  434. default:
  435. return 'Very slow';
  436. }
  437. };
  438. GameSettings.prototype.getPrecisionString = function(haziness) {
  439. switch (false) {
  440. case !(haziness < 0):
  441. return '';
  442. case !(haziness <= 2):
  443. return 'Great';
  444. case !(haziness <= 5):
  445. return 'Good';
  446. case !(haziness <= 7):
  447. return 'Average';
  448. default:
  449. return 'Poor';
  450. }
  451. };
  452. return GameSettings;
  453. })();
  454. }).call(this);
  455. /*
  456. * Copyright © Romain Fouquet, 2012-2015
  457. * Copyright © Clément Joly, 2012-2015
  458. #
  459. * romain.fouquet18@gmail.com
  460. * leowzukw@vmail.me
  461. #
  462. * This file is part of Diseases Killer Academy.
  463. #
  464. * Diseases Killer Academy is free software: you can redistribute it and/or modify
  465. * it under the terms of the GNU Affero General Public License as published by
  466. * the Free Software Foundation, either version 3 of the License, or
  467. * (at your option) any later version.
  468. #
  469. * Diseases Killer Academy is distributed in the hope that it will be useful,
  470. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  471. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  472. * GNU Affero General Public License for more details.
  473. #
  474. * You should have received a copy of the GNU Affero General Public License
  475. * along with Diseases Killer Academy. If not, see http://www.gnu.org/licenses/agpl-3.0.html.
  476. */
  477. (function() {
  478. 'use strict';
  479. this.geom = this.geom || {};
  480. geom.Ellipse = (function() {
  481. function Ellipse(x, y, rw, rh) {
  482. this.x = x || 0;
  483. this.y = y || 0;
  484. this.rw = rw || 0;
  485. this.rh = rh || 0;
  486. this;
  487. }
  488. Ellipse.prototype.contains = function(x, y) {
  489. return (Math.pow(x - this.x, 2) / Math.pow(this.rw, 2) + (Math.pow(y - this.y, 2) / Math.pow(this.rh, 2))) <= 1;
  490. };
  491. Ellipse.prototype.containsPoint = function(p) {
  492. return this.contains(p.x, p.y);
  493. };
  494. Ellipse.prototype.toString = function() {
  495. return '[Ellipse (x:' + this.x + ' y:' + this.y + ' rw:' + this.rw + ' rh:' + this.rh + ')]';
  496. };
  497. return Ellipse;
  498. })();
  499. }).call(this);
  500. /*
  501. * Copyright © Romain Fouquet, 2012-2015
  502. * Copyright © Clément Joly, 2012-2015
  503. #
  504. * romain.fouquet18@gmail.com
  505. * leowzukw@vmail.me
  506. #
  507. * This file is part of Diseases Killer Academy.
  508. #
  509. * Diseases Killer Academy is free software: you can redistribute it and/or modify
  510. * it under the terms of the GNU Affero General Public License as published by
  511. * the Free Software Foundation, either version 3 of the License, or
  512. * (at your option) any later version.
  513. #
  514. * Diseases Killer Academy is distributed in the hope that it will be useful,
  515. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  516. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  517. * GNU Affero General Public License for more details.
  518. #
  519. * You should have received a copy of the GNU Affero General Public License
  520. * along with Diseases Killer Academy. If not, see http://www.gnu.org/licenses/agpl-3.0.html.
  521. */
  522. (function() {
  523. window.TXT_NBR = false;
  524. window.DEBUG_MODE = true;
  525. window.LEVEL_MODE = true;
  526. window.TIMELINE_MODE = false;
  527. window.LEO_DEV_MODE = false;
  528. window.moveConfig = function(target) {
  529. target.cursor = 'move';
  530. target.on('pressmove', function(e) {
  531. target.x = e.stageX;
  532. return target.y = e.stageY;
  533. });
  534. return target.on('pressup', function() {
  535. return console.log(target.x, target.y);
  536. });
  537. };
  538. }).call(this);
  539. /*
  540. * Copyright © Romain Fouquet, 2012-2015
  541. * Copyright © Clément Joly, 2012-2015
  542. #
  543. * romain.fouquet18@gmail.com
  544. * leowzukw@vmail.me
  545. #
  546. * This file is part of Diseases Killer Academy.
  547. #
  548. * Diseases Killer Academy is free software: you can redistribute it and/or modify
  549. * it under the terms of the GNU Affero General Public License as published by
  550. * the Free Software Foundation, either version 3 of the License, or
  551. * (at your option) any later version.
  552. #
  553. * Diseases Killer Academy is distributed in the hope that it will be useful,
  554. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  555. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  556. * GNU Affero General Public License for more details.
  557. #
  558. * You should have received a copy of the GNU Affero General Public License
  559. * along with Diseases Killer Academy. If not, see http://www.gnu.org/licenses/agpl-3.0.html.
  560. */
  561. (function() {
  562. 'use strict';
  563. var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  564. hasProp = {}.hasOwnProperty;
  565. dka.Button = (function(superClass) {
  566. extend(Button, superClass);
  567. function Button(x, y, img) {
  568. Button.__super__.constructor.call(this);
  569. this.set({
  570. regX: 20,
  571. regY: 20
  572. });
  573. this.set({
  574. x: x,
  575. y: y || this.regY + 5,
  576. cursor: 'pointer'
  577. });
  578. if (img) {
  579. this.img = this.addChild(img);
  580. }
  581. this.cache(0, 0, 2 * this.regX, 2 * this.regY);
  582. this.on('mouseover', function() {
  583. this.filters = [new createjs.ColorMatrixFilter(new createjs.ColorMatrix().adjustBrightness(30))];
  584. this.updateCache();
  585. if (gameStage.cacheCanvas) {
  586. gameStage.updateCache();
  587. }
  588. if (createjs.Ticker.paused) {
  589. return gameStage.update();
  590. }
  591. });
  592. this.on('mouseout', function() {
  593. return this.removeAllFilters();
  594. });
  595. }
  596. Button.prototype.removeAllFilters = function() {
  597. this.filters = [];
  598. this.updateCache();
  599. if (gameStage.cacheCanvas) {
  600. gameStage.updateCache();
  601. }
  602. if (createjs.Ticker.paused) {
  603. return gameStage.update();
  604. }
  605. };
  606. return Button;
  607. })(createjs.Container);
  608. }).call(this);
  609. /*
  610. * Copyright © Romain Fouquet, 2012-2015
  611. * Copyright © Clément Joly, 2012-2015
  612. #
  613. * romain.fouquet18@gmail.com
  614. * leowzukw@vmail.me
  615. #
  616. * This file is part of Diseases Killer Academy.
  617. #
  618. * Diseases Killer Academy is free software: you can redistribute it and/or modify
  619. * it under the terms of the GNU Affero General Public License as published by
  620. * the Free Software Foundation, either version 3 of the License, or
  621. * (at your option) any later version.
  622. #
  623. * Diseases Killer Academy is distributed in the hope that it will be useful,
  624. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  625. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  626. * GNU Affero General Public License for more details.
  627. #
  628. * You should have received a copy of the GNU Affero General Public License
  629. * along with Diseases Killer Academy. If not, see http://www.gnu.org/licenses/agpl-3.0.html.
  630. */
  631. (function() {
  632. 'use strict';
  633. var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  634. hasProp = {}.hasOwnProperty;
  635. dka.MenuButton = (function(superClass) {
  636. extend(MenuButton, superClass);
  637. function MenuButton(x, y, img) {
  638. MenuButton.__super__.constructor.call(this);
  639. this.set({
  640. regX: 183 / 2,
  641. regY: 167 / 2
  642. });
  643. this.set({
  644. x: x,
  645. y: y,
  646. cursor: 'pointer'
  647. });
  648. if (img) {
  649. this.img = this.addChild(img);
  650. }
  651. this.cache(0, 0, 2 * this.regX, 2 * this.regY);
  652. this.on('mouseover', function() {
  653. this.filters = [new createjs.ColorMatrixFilter(new createjs.ColorMatrix().adjustBrightness(30))];
  654. return this.updateCache();
  655. });
  656. this.on('mouseout', function() {
  657. return this.removeAllFilters();
  658. });
  659. }
  660. MenuButton.prototype.removeAllFilters = function() {
  661. this.filters = [];
  662. return this.updateCache();
  663. };
  664. return MenuButton;
  665. })(createjs.Container);
  666. }).call(this);
  667. /*
  668. * Copyright © Romain Fouquet, 2012-2015
  669. * Copyright © Clément Joly, 2012-2015
  670. #
  671. * romain.fouquet18@gmail.com
  672. * leowzukw@vmail.me
  673. #
  674. * This file is part of Diseases Killer Academy.
  675. #
  676. * Diseases Killer Academy is free software: you can redistribute it and/or modify
  677. * it under the terms of the GNU Affero General Public License as published by
  678. * the Free Software Foundation, either version 3 of the License, or
  679. * (at your option) any later version.
  680. #
  681. * Diseases Killer Academy is distributed in the hope that it will be useful,
  682. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  683. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  684. * GNU Affero General Public License for more details.
  685. #
  686. * You should have received a copy of the GNU Affero General Public License
  687. * along with Diseases Killer Academy. If not, see http://www.gnu.org/licenses/agpl-3.0.html.
  688. */
  689. (function() {
  690. 'use strict';
  691. var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  692. hasProp = {}.hasOwnProperty;
  693. dka.ButtonBitmap = (function(superClass) {
  694. extend(ButtonBitmap, superClass);
  695. function ButtonBitmap(bmp, brightness) {
  696. ButtonBitmap.__super__.constructor.call(this, bmp || null);
  697. this.set({
  698. cursor: 'pointer',
  699. available: true,
  700. brightness: (brightness ? brightness : 30)
  701. });
  702. this.on('mouseover', function() {
  703. if (!this.available) {
  704. return;
  705. }
  706. return this.lighten();
  707. });
  708. this.on('mouseout', function() {
  709. this.filters = [];
  710. if (!this.available) {
  711. this.darken();
  712. }
  713. this.updateCache();
  714. if (gameStage.cacheCanvas) {
  715. gameStage.updateCache();
  716. }
  717. if (createjs.Ticker.paused) {
  718. return gameStage.update();
  719. }
  720. });
  721. }
  722. ButtonBitmap.prototype.lighten = function() {
  723. this.filters = [new createjs.ColorMatrixFilter(new createjs.ColorMatrix().adjustBrightness(this.brightness))];
  724. this.updateCache();
  725. if (gameStage.cacheCanvas) {
  726. gameStage.updateCache();
  727. }
  728. if (createjs.Ticker.paused) {
  729. return gameStage.update();
  730. }
  731. };
  732. ButtonBitmap.prototype.darken = function() {
  733. this.filters = [new createjs.ColorMatrixFilter(new createjs.ColorMatrix().adjustSaturation(-100))];
  734. this.updateCache();
  735. if (gameStage.cacheCanvas) {
  736. gameStage.updateCache();
  737. }
  738. if (createjs.Ticker.paused) {
  739. gameStage.update();
  740. }
  741. return this.available = false;
  742. };
  743. ButtonBitmap.prototype.removeAllFilters = function() {
  744. this.filters = [];
  745. this.updateCache();
  746. if (gameStage.cacheCanvas) {
  747. gameStage.updateCache();
  748. }
  749. if (createjs.Ticker.paused) {
  750. gameStage.update();
  751. }
  752. return this.available = true;
  753. };
  754. return ButtonBitmap;
  755. })(createjs.Bitmap);
  756. }).call(this);
  757. /*
  758. * Copyright © Romain Fouquet, 2012-2015
  759. * Copyright © Clément Joly, 2012-2015
  760. #
  761. * romain.fouquet18@gmail.com
  762. * leowzukw@vmail.me
  763. #
  764. * This file is part of Diseases Killer Academy.
  765. #
  766. * Diseases Killer Academy is free software: you can redistribute it and/or modify
  767. * it under the terms of the GNU Affero General Public License as published by
  768. * the Free Software Foundation, either version 3 of the License, or
  769. * (at your option) any later version.
  770. #
  771. * Diseases Killer Academy is distributed in the hope that it will be useful,
  772. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  773. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  774. * GNU Affero General Public License for more details.
  775. #
  776. * You should have received a copy of the GNU Affero General Public License
  777. * along with Diseases Killer Academy. If not, see http://www.gnu.org/licenses/agpl-3.0.html.
  778. */
  779. (function() {
  780. 'use strict';
  781. var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  782. hasProp = {}.hasOwnProperty;
  783. dka.ButtonLabs = (function(superClass) {
  784. extend(ButtonLabs, superClass);
  785. function ButtonLabs(bmp, point, upgrade, index, screen) {
  786. var settings;
  787. this.upgrade = upgrade;
  788. this.index = index;
  789. this.screen = screen;
  790. ButtonLabs.__super__.constructor.call(this);
  791. this.addChild(new createjs.Bitmap(dka.academy.assetManager.getAsset(bmp)));
  792. this.set({
  793. x: point.x,
  794. y: point.y,
  795. regX: 50 / 2,
  796. regY: 62 / 2
  797. });
  798. settings = dka.academy.game.settings.labs[this.upgrade][index];
  799. this.cost = settings.cost;
  800. this.addChild(new createjs.Text(this.cost, '12px karnivoreRegular, Arial', dka.colors.gold).set({
  801. x: 50 / 2,
  802. y: 56,
  803. textAlign: 'center',
  804. textBaseline: 'alphabetic'
  805. }));
  806. this.cache(0, 0, 50, 62);
  807. this.hintData = {
  808. title: settings.title,
  809. description: settings.description
  810. };
  811. this.screen.on(this.screen.RESET_EVENT, (function(_this) {
  812. return function() {
  813. return _this.reset();
  814. };
  815. })(this));
  816. this.screen.on(this.screen.UPGRADE_BOUGHT_EVENT, (function(_this) {
  817. return function() {
  818. if (_this.bought) {
  819. return;
  820. }
  821. if (_this.isAvailable()) {
  822. if (_this.available) {
  823. return;
  824. }
  825. _this.removeAllFilters();
  826. return _this.makeBuyable();
  827. } else {
  828. _this.darken();
  829. return _this.cursor = 'default';
  830. }
  831. };
  832. })(this));
  833. this.reset();
  834. }
  835. ButtonLabs.prototype.reset = function() {
  836. this.removeAllFilters();
  837. this.removeAllEventListeners('click');
  838. this.removeAllEventListeners('mouseover');
  839. this.removeAllEventListeners('mouseout');
  840. this.on('mouseover', function() {
  841. return this.screen.addToolTip(this, this.hintData);
  842. });
  843. this.on('mouseout', function() {
  844. return this.screen.removeToolTip();
  845. });
  846. this.available = false;
  847. this.bought = false;
  848. if (this.isBought()) {
  849. this.setBought();
  850. return;
  851. }
  852. if (!this.isAvailable()) {
  853. this.darken();
  854. this.cursor = 'default';
  855. return;
  856. }
  857. return this.makeBuyable();
  858. };
  859. ButtonLabs.prototype.isAvailable = function() {
  860. if (dka.academy.game.getTotalGold() < this.cost) {
  861. return false;
  862. }
  863. if (dka.academy.game.labs.getUpgradeLevel(this.upgrade) + 1 >= this.index) {
  864. return true;
  865. }
  866. };
  867. ButtonLabs.prototype.isBought = function() {
  868. return dka.academy.game.labs.getUpgradeLevel(this.upgrade) + 1 > this.index;
  869. };
  870. ButtonLabs.prototype.makeBuyable = function() {
  871. this.cursor = 'pointer';
  872. this.on('mouseover', function() {
  873. if (!this.isBought()) {
  874. return this.lighten(30);
  875. }
  876. });
  877. this.on('mouseout', function() {
  878. if (!this.isBought()) {
  879. return this.removeAllFilters();
  880. }
  881. });
  882. this.on('click', function() {
  883. dka.academy.game.labs.buy(this.upgrade, this.cost);
  884. this.removeAllEventListeners('click');
  885. this.setBought();
  886. this.screen.dispatchEvent(new createjs.Event(this.screen.UPGRADE_BOUGHT_EVENT));
  887. this.screen.timeline.updateCoinScore();
  888. return this.screen.undoStack.push(this);
  889. });
  890. return this.available = true;
  891. };
  892. ButtonLabs.prototype.setBought = function() {
  893. this.lighten(60);
  894. this.cursor = 'default';
  895. return this.bought = true;
  896. };
  897. ButtonLabs.prototype.lighten = function(brightness) {
  898. this.filters = [new createjs.ColorMatrixFilter(new createjs.ColorMatrix().adjustBrightness(brightness))];
  899. return this.updateCache();
  900. };
  901. ButtonLabs.prototype.darken = function() {
  902. this.filters = [new createjs.ColorMatrixFilter(new createjs.ColorMatrix().adjustSaturation(-100))];
  903. return this.updateCache();
  904. };
  905. ButtonLabs.prototype.removeAllFilters = function() {
  906. this.filters = [];
  907. return this.updateCache();
  908. };
  909. return ButtonLabs;
  910. })(createjs.Container);
  911. }).call(this);
  912. /*
  913. * Copyright © Romain Fouquet, 2012-2015
  914. * Copyright © Clément Joly, 2012-2015
  915. #
  916. * romain.fouquet18@gmail.com
  917. * leowzukw@vmail.me
  918. #
  919. * This file is part of Diseases Killer Academy.
  920. #
  921. * Diseases Killer Academy is free software: you can redistribute it and/or modify
  922. * it under the terms of the GNU Affero General Public License as published by
  923. * the Free Software Foundation, either version 3 of the License, or
  924. * (at your option) any later version.
  925. #
  926. * Diseases Killer Academy is distributed in the hope that it will be useful,
  927. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  928. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  929. * GNU Affero General Public License for more details.
  930. #
  931. * You should have received a copy of the GNU Affero General Public License
  932. * along with Diseases Killer Academy. If not, see http://www.gnu.org/licenses/agpl-3.0.html.
  933. */
  934. (function() {
  935. 'use strict';
  936. var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  937. hasProp = {}.hasOwnProperty;
  938. dka.ButtonSprite = (function(superClass) {
  939. extend(ButtonSprite, superClass);
  940. function ButtonSprite(sps, brightness) {
  941. var bounds;
  942. ButtonSprite.__super__.constructor.call(this, sps || null);
  943. this.set({
  944. cursor: 'pointer',
  945. available: true,
  946. brightness: (brightness ? brightness : 30)
  947. });
  948. if (sps) {
  949. bounds = sps.getFrameBounds(0);
  950. this.cache(bounds.x, bounds.y, bounds.width, bounds.height);
  951. }
  952. this.on('mouseover', function() {
  953. if (!this.available) {
  954. return;
  955. }
  956. this.filters = [new createjs.ColorMatrixFilter(new createjs.ColorMatrix().adjustBrightness(this.brightness))];
  957. this.updateCache();
  958. return gameStage.update();
  959. });
  960. this.on('mouseout', function() {
  961. this.filters = [];
  962. if (!this.available) {
  963. this.darken();
  964. }
  965. this.updateCache();
  966. return gameStage.update();
  967. });
  968. }
  969. ButtonSprite.prototype.darken = function() {
  970. this.filters = [new createjs.ColorMatrixFilter(new createjs.ColorMatrix().adjustSaturation(-100))];
  971. this.updateCache();
  972. gameStage.update();
  973. return this.available = false;
  974. };
  975. ButtonSprite.prototype.removeAllFilters = function() {
  976. this.filters = [];
  977. this.updateCache();
  978. gameStage.update();
  979. return this.available = true;
  980. };
  981. return ButtonSprite;
  982. })(createjs.Sprite);
  983. }).call(this);
  984. /*
  985. * Copyright © Romain Fouquet, 2012-2015
  986. * Copyright © Clément Joly, 2012-2015
  987. #
  988. * romain.fouquet18@gmail.com
  989. * leowzukw@vmail.me
  990. #
  991. * This file is part of Diseases Killer Academy.
  992. #
  993. * Diseases Killer Academy is free software: you can redistribute it and/or modify
  994. * it under the terms of the GNU Affero General Public License as published by
  995. * the Free Software Foundation, either version 3 of the License, or
  996. * (at your option) any later version.
  997. #
  998. * Diseases Killer Academy is distributed in the hope that it will be useful,
  999. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1000. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1001. * GNU Affero General Public License for more details.
  1002. #
  1003. * You should have received a copy of the GNU Affero General Public License
  1004. * along with Diseases Killer Academy. If not, see http://www.gnu.org/licenses/agpl-3.0.html.
  1005. */
  1006. (function() {
  1007. 'use strict';
  1008. var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  1009. hasProp = {}.hasOwnProperty;
  1010. dka.BulletDecal = (function(superClass) {
  1011. extend(BulletDecal, superClass);
  1012. function BulletDecal(x, y, level) {
  1013. BulletDecal.__super__.constructor.call(this, dka.academy.assetManager.getAsset('spriteBulletEffect'));
  1014. this.level = level;
  1015. this.set({
  1016. x: x,
  1017. y: y
  1018. });
  1019. this.on('animationend', function(e) {
  1020. this.stop();
  1021. return createjs.Tween.get(this, {
  1022. useTicks: true
  1023. }).wait(20).to({
  1024. alpha: 0
  1025. }, 50, createjs.Ease.circIn).call(function() {
  1026. return this.parent.removeChild(this);
  1027. });
  1028. });
  1029. this.gotoAndPlay('boum');
  1030. this.level.decalsLayer.addChild(this);
  1031. }
  1032. return BulletDecal;
  1033. })(createjs.Sprite);
  1034. }).call(this);
  1035. /*
  1036. * Copyright © Romain Fouquet, 2012-2015
  1037. * Copyright © Clément Joly, 2012-2015
  1038. #
  1039. * romain.fouquet18@gmail.com
  1040. * leowzukw@vmail.me
  1041. #
  1042. * This file is part of Diseases Killer Academy.
  1043. #
  1044. * Diseases Killer Academy is free software: you can redistribute it and/or modify
  1045. * it under the terms of the GNU Affero General Public License as published by
  1046. * the Free Software Foundation, either version 3 of the License, or
  1047. * (at your option) any later version.
  1048. #
  1049. * Diseases Killer Academy is distributed in the hope that it will be useful,
  1050. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1051. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1052. * GNU Affero General Public License for more details.
  1053. #
  1054. * You should have received a copy of the GNU Affero General Public License
  1055. * along with Diseases Killer Academy. If not, see http://www.gnu.org/licenses/agpl-3.0.html.
  1056. */
  1057. (function() {
  1058. 'use strict';
  1059. var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  1060. hasProp = {}.hasOwnProperty;
  1061. dka.TutoBubble = (function(superClass) {
  1062. extend(TutoBubble, superClass);
  1063. function TutoBubble(text, position, level, closeEvent, invertDirection, alternateText) {
  1064. var ref;
  1065. TutoBubble.__super__.constructor.call(this);
  1066. this.text = text;
  1067. this.position = position;
  1068. this.level = level;
  1069. this.closeEvent = closeEvent;
  1070. this.invertDirection = invertDirection;
  1071. this.alternateText = alternateText;
  1072. this.SMALL_BUBBLE_WIDTH = 100;
  1073. this.LARGE_BUBBLE_WIDTH = 150;
  1074. this.set({
  1075. x: this.position.x,
  1076. y: this.position.y,
  1077. alpha: 0
  1078. });
  1079. this.addText();
  1080. this.addBubble();
  1081. createjs.Tween.get(this, {
  1082. useTicks: true
  1083. }).to({
  1084. alpha: 1
  1085. }, 15, createjs.Ease.backIn);
  1086. createjs.Tween.get(this, {
  1087. useTicks: true,
  1088. loop: true
  1089. }).to({
  1090. scaleX: 0.85
  1091. }, 15, createjs.Ease.backIn).to({
  1092. scaleX: 1
  1093. }, 15, createjs.Ease.backOut);
  1094. if ((ref = this.level) != null) {
  1095. ref.on(this.closeEvent, (function(_this) {
  1096. return function(e) {
  1097. e.remove();
  1098. return createjs.Tween.get(_this, {
  1099. useTicks: true
  1100. }).to({
  1101. alpha: 0,
  1102. scaleX: 0
  1103. }, 3).call(function() {
  1104. return this.parent.removeChild(this);
  1105. });
  1106. };
  1107. })(this));
  1108. }
  1109. if (alternateText) {
  1110. this.on('tick', this.tick);
  1111. this.switchDelay = 1 * 30;
  1112. this.switchCounter = 0;
  1113. }
  1114. }
  1115. TutoBubble.prototype.tick = function() {
  1116. this.switchCounter++;
  1117. if (this.switchCounter >= this.switchDelay) {
  1118. this.textToast.alpha = 0;
  1119. createjs.Tween.get(this.textToast, {
  1120. useTicks: true
  1121. }).to({
  1122. alpha: 1
  1123. }, 5);
  1124. this.switchCounter = 0;
  1125. if (this.textToast.text === this.text) {
  1126. return this.textToast.text = this.alternateText;
  1127. } else {
  1128. return this.textToast.text = this.text;
  1129. }
  1130. }
  1131. };
  1132. TutoBubble.prototype.addText = function() {
  1133. this.textToast = new createjs.Text(this.text, '17px Arial', dka.colors.lightBlue);
  1134. this.textToast.set({
  1135. y: 18,
  1136. textAlign: 'center',
  1137. textBaseline: 'alphabetic'
  1138. });
  1139. return this.addChild(this.textToast);
  1140. };
  1141. TutoBubble.prototype.addBubble = function() {
  1142. var bg, bubble, width;
  1143. bg = 'tutoBubbleSmall';
  1144. width = this.SMALL_BUBBLE_WIDTH;
  1145. if (this.textToast.getMeasuredWidth() > 90) {
  1146. bg = 'tutoBubbleLarge';
  1147. width = this.LARGE_BUBBLE_WIDTH;
  1148. }
  1149. bubble = new createjs.Bitmap(dka.academy.assetManager.getAsset(bg));
  1150. bubble.regX = width / 2;
  1151. if (this.invertDirection) {
  1152. bubble.scaleY = -1;
  1153. bubble.y = 25;
  1154. }
  1155. return this.addChildAt(bubble, 0);
  1156. };
  1157. return TutoBubble;
  1158. })(createjs.Container);
  1159. }).call(this);
  1160. /*
  1161. * Copyright © Romain Fouquet, 2012-2015
  1162. * Copyright © Clément Joly, 2012-2015
  1163. #
  1164. * romain.fouquet18@gmail.com
  1165. * leowzukw@vmail.me
  1166. #
  1167. * This file is part of Diseases Killer Academy.
  1168. *
  1169. * Diseases Killer Academy is free software: you can redistribute it and/or modify
  1170. * it under the terms of the GNU Affero General Public License as published by
  1171. * the Free Software Foundation, either version 3 of the License, or
  1172. * (at your option) any later version.
  1173. *
  1174. * Diseases Killer Academy is distributed in the hope that it will be useful,
  1175. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1176. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1177. * GNU Affero General Public License for more details.
  1178. *
  1179. * You should have received a copy of the GNU Affero General Public License
  1180. * along with Diseases Killer Academy. If not, see http://www.gnu.org/licenses/agpl-3.0.html.
  1181. */
  1182. (function() {
  1183. 'use strict';
  1184. var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  1185. hasProp = {}.hasOwnProperty;
  1186. dka.TabletSmoke = (function(superClass) {
  1187. extend(TabletSmoke, superClass);
  1188. function TabletSmoke(x, y) {
  1189. TabletSmoke.__super__.constructor.call(this, dka.academy.assetManager.getAsset('spriteTabletSmoke'));
  1190. this.x = x;
  1191. this.y = y;
  1192. this.gotoAndPlay(0);
  1193. this.on('animationend', this.animationend);
  1194. }
  1195. TabletSmoke.prototype.animationend = function() {
  1196. return this.parent.removeChild(this);
  1197. };
  1198. return TabletSmoke;
  1199. })(createjs.Sprite);
  1200. }).call(this);
  1201. /*
  1202. * Copyright © Romain Fouquet, 2012-2015
  1203. * Copyright © Clément Joly, 2012-2015
  1204. #
  1205. * romain.fouquet18@gmail.com
  1206. * leowzukw@vmail.me
  1207. #
  1208. * This file is part of Diseases Killer Academy.
  1209. #
  1210. * Diseases Killer Academy is free software: you can redistribute it and/or modify
  1211. * it under the terms of the GNU Affero General Public License as published by
  1212. * the Free Software Foundation, either version 3 of the License, or
  1213. * (at your option) any later version.
  1214. #
  1215. * Diseases Killer Academy is distributed in the hope that it will be useful,
  1216. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1217. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1218. * GNU Affero General Public License for more details.
  1219. #
  1220. * You should have received a copy of the GNU Affero General Public License
  1221. * along with Diseases Killer Academy. If not, see http://www.gnu.org/licenses/agpl-3.0.html.
  1222. */
  1223. (function() {
  1224. 'use strict';
  1225. var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  1226. hasProp = {}.hasOwnProperty;
  1227. dka.CapsuleSmoke = (function(superClass) {
  1228. extend(CapsuleSmoke, superClass);
  1229. function CapsuleSmoke(x, y) {
  1230. CapsuleSmoke.__super__.constructor.call(this, dka.academy.assetManager.getAsset('spCapsuleSmoke'));
  1231. this.x = x;
  1232. this.y = y;
  1233. this.gotoAndPlay(0);
  1234. this.on('animationend', this.animationend);
  1235. }
  1236. CapsuleSmoke.prototype.animationend = function() {
  1237. return this.parent.removeChild(this);
  1238. };
  1239. return CapsuleSmoke;
  1240. })(createjs.Sprite);
  1241. }).call(this);
  1242. /*
  1243. * Copyright © Romain Fouquet, 2012-2015
  1244. * Copyright © Clément Joly, 2012-2015
  1245. #
  1246. * romain.fouquet18@gmail.com
  1247. * leowzukw@vmail.me
  1248. #
  1249. * This file is part of Diseases Killer Academy.
  1250. #
  1251. * Diseases Killer Academy is free software: you can redistribute it and/or modify
  1252. * it under the terms of the GNU Affero General Public License as published by
  1253. * the Free Software Foundation, either version 3 of the License, or
  1254. * (at your option) any later version.
  1255. #
  1256. * Diseases Killer Academy is distributed in the hope that it will be useful,
  1257. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1258. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1259. * GNU Affero General Public License for more details.
  1260. #
  1261. * You should have received a copy of the GNU Affero General Public License
  1262. * along with Diseases Killer Academy. If not, see http://www.gnu.org/licenses/agpl-3.0.html.
  1263. */
  1264. (function() {
  1265. 'use strict';
  1266. var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  1267. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  1268. hasProp = {}.hasOwnProperty;
  1269. dka.WaveFlag = (function(superClass) {
  1270. extend(WaveFlag, superClass);
  1271. function WaveFlag(level, road) {
  1272. this.clickRemove = bind(this.clickRemove, this);
  1273. this.update = bind(this.update, this);
  1274. var hitCircle, newBmp, progressBar, settings;
  1275. WaveFlag.__super__.constructor.call(this);
  1276. this.level = level;
  1277. this.road = road;
  1278. settings = this.level.waves[this.level.getFresherWaveIndex() + 1].roads[road].callButton;
  1279. this.set({
  1280. x: settings.x,
  1281. y: settings.y,
  1282. regX: 20,
  1283. regY: 20,
  1284. scaleX: 0.7,
  1285. scaleY: 0.7,
  1286. cursor: 'pointer'
  1287. });
  1288. hitCircle = new createjs.Shape();
  1289. hitCircle.graphics.beginFill('#000000').dc(20, 20, 20).endFill();
  1290. this.hitArea = hitCircle;
  1291. progressBar = new createjs.Shape();
  1292. progressBar.set({
  1293. x: 10,
  1294. y: 8
  1295. });
  1296. if (this.level.getFresherWaveIndex() + 1 > 0) {
  1297. progressBar.on('tick', this.update);
  1298. }
  1299. newBmp = new createjs.Bitmap(dka.academy.assetManager.getAsset('callWave')).set({
  1300. x: 16,
  1301. y: 16,
  1302. regX: 16,
  1303. regY: 16
  1304. });
  1305. if (this.level.game.labs.getUpgradeLevel('hintNxtWave') >= 0) {
  1306. this.addHintBox();
  1307. }
  1308. this.addChild(progressBar, newBmp);
  1309. this.cache(0, 0, 2 * this.regX, 2 * this.regY);
  1310. createjs.Tween.get(this, {
  1311. useTicks: true,
  1312. loop: true
  1313. }).to({
  1314. scaleX: 1,
  1315. scaleY: 1
  1316. }, 15, createjs.Ease.backOut).to({
  1317. scaleX: 0.7,
  1318. scaleY: 0.7
  1319. }, 15, createjs.Ease.backIn);
  1320. this.on('click', this.clickRemove);
  1321. this.on('mouseover', function() {
  1322. this.filters = [new createjs.ColorMatrixFilter(new createjs.ColorMatrix().adjustBrightness(30))];
  1323. return this.updateCache();
  1324. });
  1325. this.on('mouseout', function() {
  1326. this.filters = [];
  1327. return this.updateCache();
  1328. });
  1329. }
  1330. WaveFlag.prototype.addHintBox = function() {
  1331. var dis, disease, i, len, name, nbTypeDiseases, nxtWaveDiseases, prop, props, ref;
  1332. nxtWaveDiseases = {};
  1333. ref = this.level.waves[this.level.getFresherWaveIndex() + 1].roads[this.road].diseasesList;
  1334. for (i = 0, len = ref.length; i < len; i++) {
  1335. disease = ref[i];
  1336. dis = disease.dis;
  1337. if (nxtWaveDiseases[dis]) {
  1338. nxtWaveDiseases[dis]++;
  1339. } else {
  1340. nxtWaveDiseases[dis] = 1;
  1341. }
  1342. }
  1343. if (this.level.game.labs.getUpgradeLevel('hintNxtWave') >= 1) {
  1344. for (name in nxtWaveDiseases) {
  1345. nxtWaveDiseases[name] = 'x ' + nxtWaveDiseases[name];
  1346. }
  1347. } else {
  1348. for (name in nxtWaveDiseases) {
  1349. nxtWaveDiseases[name] = 'x ?';
  1350. }
  1351. }
  1352. props = [];
  1353. nbTypeDiseases = 0;
  1354. for (name in nxtWaveDiseases) {
  1355. prop = props[nbTypeDiseases] = {};
  1356. prop.caption = name;
  1357. prop.separator = ' ';
  1358. prop.value = nxtWaveDiseases[name];
  1359. prop.color = 'green';
  1360. nbTypeDiseases++;
  1361. }
  1362. this.on('mouseover', function() {
  1363. return this.level.addToolTip(this, {
  1364. title: 'Wave ' + (this.level.getFresherWaveIndex() + 2),
  1365. props: props
  1366. });
  1367. });
  1368. return this.on('mouseout', function() {
  1369. return this.level.removeToolTip();
  1370. });
  1371. };
  1372. WaveFlag.prototype.update = function() {
  1373. var ratio;
  1374. ratio = this.level.waitForNewWave / this.level.delayForNxtWave;
  1375. ratio = (ratio === 0 ? 1 : ratio);
  1376. this.getChildAt(0).graphics.clear();
  1377. this.getChildAt(0).graphics.beginFill(dka.colors.lightBlue).rect(0, 19, 19, -19 * ratio).endFill();
  1378. return this.updateCache();
  1379. };
  1380. WaveFlag.prototype.remove = function() {
  1381. this.removeAllEventListeners('click');
  1382. createjs.Tween.get(this, {
  1383. useTicks: true,
  1384. override: true
  1385. }).to({
  1386. scaleX: 0,
  1387. scaleY: 0
  1388. }, 15, createjs.Ease.backIn).call(function() {
  1389. return this.parent.removeChild(this);
  1390. });
  1391. if (this.level.getFresherWaveIndex() >= 0) {
  1392. return this.level.getHospital().getAbilityResult('subsidies');
  1393. }
  1394. };
  1395. WaveFlag.prototype.clickRemove = function() {
  1396. var goldEarned, timeEco;
  1397. this.level.towerMenu.fade();
  1398. this.level.ui.removeWaveFlags();
  1399. this.level.dispatchEvent(new createjs.Event(this.level.WAVE_FLAG_CLICKED_EVENT, true, false));
  1400. if (this.level.getFresherWaveIndex() === -1) {
  1401. dka.academy.removeStageTicker();
  1402. this.level.addLevelTicker();
  1403. this.level.ui.helpButtonsHolder.allow();
  1404. }
  1405. timeEco = this.level.delayForNxtWave - this.level.waitForNewWave;
  1406. goldEarned = (timeEco / 10) | 0;
  1407. if (goldEarned > 0) {
  1408. this.level.addGold(goldEarned);
  1409. this.level.ui.helpButtonsHolder.advanceLoading(timeEco, this.level);
  1410. createjs.Tween.get(null, {
  1411. useTicks: true
  1412. }).wait(30).call((function(_this) {
  1413. return function() {
  1414. var reward;
  1415. reward = new dka.BouncingText('+' + goldEarned, 'bold 12px karnivoreRegular, Arial', dka.colors.gold, new createjs.Point(_this.x, _this.y));
  1416. return _this.level.ui.addChild(reward);
  1417. };
  1418. })(this));
  1419. }
  1420. this.level.addWave();
  1421. return this.level.ui.hudBar.updateWaves();
  1422. };
  1423. return WaveFlag;
  1424. })(createjs.Container);
  1425. }).call(this);
  1426. /*
  1427. * Copyright © Romain Fouquet, 2012-2015
  1428. * Copyright © Clément Joly, 2012-2015
  1429. #
  1430. * romain.fouquet18@gmail.com
  1431. * leowzukw@vmail.me
  1432. #
  1433. * This file is part of Diseases Killer Academy.
  1434. #
  1435. * Diseases Killer Academy is free software: you can redistribute it and/or modify
  1436. * it under the terms of the GNU Affero General Public License as published by
  1437. * the Free Software Foundation, either version 3 of the License, or
  1438. * (at your option) any later version.
  1439. #
  1440. * Diseases Killer Academy is distributed in the hope that it will be useful,
  1441. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1442. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1443. * GNU Affero General Public License for more details.
  1444. #
  1445. * You should have received a copy of the GNU Affero General Public License
  1446. * along with Diseases Killer Academy. If not, see http://www.gnu.org/licenses/agpl-3.0.html.
  1447. */
  1448. (function() {
  1449. 'use strict';
  1450. var extend = f

Large files files are truncated, but you can click here to view the full file