Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Class Horde que construye un Horde que controla a los enemigos.
- * @class Horde
- * @constructors
- * @this {Horde}
- * @returns {Horde}
- */
- function Horde() {
- /***
- * Contador que indica si añade un nuevo Enemy a la Array
- * @type Number
- */
- this.count = 0;
- /**
- * Array de Enemy
- * @type Array
- */
- this.ArrayEnemy = Array();
- /**
- * Indice de la oleada que se encuentra para
- * cojer la informacion de los enemigos en el json oleada.
- * @type Number
- */
- this.index = -1;
- /**
- * Cantidad de enemigos
- * @type Number
- */
- this.Ammount = 0;
- /**
- * Metodo para añadir nuevos Enemy a la ArrayEnemy
- * @returns {void}
- */
- this.addEnemy = function() {
- if (this.index >= 0) {
- if (this.count >= 1500 && this.Ammount > 0) {
- var img = new Image();
- img.src = oleada[this.index].img;
- 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));
- this.Ammount--;
- this.count = 0;
- } else if (this.Ammount == 0 && this.ArrayEnemy.length == 0) {
- var start = document.getElementById("start");
- start.setAttribute("style", "background-image: url(../Resources/iconogo.jpg);");
- }
- this.count += 30;
- }
- }
- /**
- * Metodo para ir a la siguiente oleada de Enemy
- * @returns {void}
- */
- this.nextHorde = function() {
- var start = document.getElementById("start");
- if (countoleada > this.index && this.Ammount <= 0 && this.ArrayEnemy.length == 0 && this.index < oleada.length-1) {
- this.index++;
- this.Ammount = oleada[this.index].ammount;
- if (timespeed == 10) {
- start.setAttribute("style", "background-image: url(../Resources/iconorapido1.jpg);");
- } else if (timespeed == 20) {
- start.setAttribute("style", "background-image: url(../Resources/iconorapido.jpg);");
- }
- } else {
- if (timespeed == 20) {
- setTimeSpeed(10);
- start.setAttribute("style", "background-image: url(../Resources/iconorapido1.jpg);");
- } else if (timespeed == 10) {
- setTimeSpeed(20);
- start.setAttribute("style", "background-image: url(../Resources/iconorapido.jpg);");
- }
- }
- }
- /**
- * Metodo para eliminar Enemy de la ArrayEnemi a partir del index
- * @param {type} index posicion que se encuentra dentro de la Array el Enemy
- * @returns {void}
- */
- this.spliceEnemy = function(index) {
- gunters += this.ArrayEnemy[index].gunter;
- this.ArrayEnemy.splice(index, 1);
- soundead.volume = volumen;
- soundead.play();
- }
- /**
- * Metodo que resetea las oleadas al inicio
- * @returns {void}
- */
- this.reset = function() {
- this.ArrayEnemy = new Array();
- this.index = -1;
- this.Ammount = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment