Juckniz

Untitled

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