Juckniz

Untitled

May 28th, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. /**
  2. * Class Horde que construye un Horde que controla a los enemigos.
  3. * @class Horde
  4. * @constructors
  5. * @this {Horde}
  6. * @returns {Horde}
  7. */
  8. function Horde() {
  9. /***
  10. * Contador que indica si añade un nuevo Enemy a la Array
  11. * @type Number
  12. */
  13. this.count = 0;
  14. /**
  15. * Array de Enemy
  16. * @type Array
  17. */
  18. this.ArrayEnemy = Array();
  19. /**
  20. * Indice de la oleada que se encuentra para
  21. * cojer la informacion de los enemigos en el json oleada.
  22. * @type Number
  23. */
  24. this.index = -1;
  25. /**
  26. * Cantidad de enemigos
  27. * @type Number
  28. */
  29. this.Ammount = 0;
  30. /**
  31. * Metodo para añadir nuevos Enemy a la ArrayEnemy
  32. * @returns {void}
  33. */
  34. this.addEnemy = function() {
  35. if (this.index >= 0) {
  36. if (this.count >= 1500 && this.Ammount > 0) {
  37. var img = new Image();
  38. img.src = oleada[this.index].img;
  39. this.ArrayEnemy.push(new Enemy(path[0].x, path[0].y, squareSize, squareSize, 0, img, oleada[this.index].hp, oleada[this.index].gunter, oleada[this.index].princess));
  40. this.Ammount--;
  41. this.count = 0;
  42. } else if (this.Ammount == 0 && this.ArrayEnemy.length == 0) {
  43. var start = document.getElementById("start");
  44. start.setAttribute("style", "background-image: url(../Resources/iconogo.jpg);");
  45. }
  46. this.count += 30;
  47. }
  48. }
  49.  
  50. /**
  51. * Metodo para ir a la siguiente oleada de Enemy
  52. * @returns {void}
  53. */
  54. this.nextHorde = function() {
  55. var start = document.getElementById("start");
  56. if (countoleada > this.index && this.Ammount <= 0 && this.ArrayEnemy.length == 0 && this.index < oleada.length-1) {
  57.  
  58. this.index++;
  59. this.Ammount = oleada[this.index].ammount;
  60.  
  61. if (timespeed == 10) {
  62. start.setAttribute("style", "background-image: url(../Resources/iconorapido1.jpg);");
  63. } else if (timespeed == 20) {
  64. start.setAttribute("style", "background-image: url(../Resources/iconorapido.jpg);");
  65. }
  66. } else {
  67. if (timespeed == 20) {
  68. setTimeSpeed(10);
  69. start.setAttribute("style", "background-image: url(../Resources/iconorapido1.jpg);");
  70. } else if (timespeed == 10) {
  71. setTimeSpeed(20);
  72. start.setAttribute("style", "background-image: url(../Resources/iconorapido.jpg);");
  73. }
  74. }
  75. }
  76.  
  77. /**
  78. * Metodo para eliminar Enemy de la ArrayEnemi a partir del index
  79. * @param {type} index posicion que se encuentra dentro de la Array el Enemy
  80. * @returns {void}
  81. */
  82. this.spliceEnemy = function(index) {
  83.  
  84. gunters += this.ArrayEnemy[index].gunter;
  85. this.ArrayEnemy.splice(index, 1);
  86. soundead.volume = volumen;
  87. soundead.play();
  88. }
  89.  
  90. /**
  91. * Metodo que resetea las oleadas al inicio
  92. * @returns {void}
  93. */
  94. this.reset = function() {
  95. this.ArrayEnemy = new Array();
  96. this.index = -1;
  97. this.Ammount = 0;
  98. }
  99.  
  100.  
  101.  
  102.  
  103. }
Advertisement
Add Comment
Please, Sign In to add comment