Пример #1
0
 //Aplicar polimorfismo
 public virtual string atacar(Unidad victima, Mapa mapa, Batallon bvictima, Batallon bAtacante)
 {
     var dañoRecibido = victima.recibirDaño(this.dañoMecanico, this.dañoNoMecanico);
     Console.SetCursorPosition(0,27);
     Console.BackgroundColor = ConsoleColor.Black;
     Console.WriteLine(" ");
     Console.SetCursorPosition(0, 27);
     Console.BackgroundColor = ConsoleColor.DarkGreen;
     if (victima.hpActual <= 0)
     {
         bvictima.eliminarUnidad(mapa, victima);
     }
     return (this.GetType().Name + " (" + this.icono + ") " + " Ha hecho " + dañoRecibido + " de daño a " + victima.GetType().Name + " (" + victima.icono + ") " + "(HP=" + victima.hpActual + "/" + victima.hpInicial + ")");
 }
Пример #2
0
 public void cambiar(int[] pos, Unidad nuevo) 
 {
     if (nuevo.tipo == Unidad.Tipo.aereo)
     {
         this.matrizAerea[pos[0] - 1, pos[1] - 1] = nuevo;
     }
     else if (nuevo.tipo == Unidad.Tipo.terrestre)
     {
         this.matrizTerrestre[pos[0] - 1, pos[1] - 1] = nuevo;
     }
     else
     {
         Console.WriteLine("No es de tipo aereo ni terrestre");
     }
 }
Пример #3
0
        //Aplicar polimorfismo
        public override string atacar(Unidad victima, Mapa mapa, Batallon bvictima, Batallon bAtacante)
        {
            if (this.TurnosParaUsarPoder > 0)
            {
                this.TurnosParaUsarPoder -= 1;
                return (this.GetType().Name + " (" + this.icono + ") " + " Debe esperar " + this.TurnosParaUsarPoder + " turnos más para usar habilidad");
            }

            //Uso de habilidad
            this.TurnosParaUsarPoder = this.enfriamiento * 1;
            int a = new Random().Next(0, 100);
            if (a < 60)
            {
                victima.bandera = this.bandera;
                return (this.GetType().Name + " (" + this.icono + ") " + " Neo-Wololeó a " + victima.GetType().Name + " (" + victima.icono + ") ");
            }
            return (this.GetType().Name + " (" + this.icono + ") " + " Trató de Neo-Wololear a " + victima.GetType().Name + " (" + victima.icono + ") " + " pero no pudo");
        }
Пример #4
0
 //Aplicar polimorfismo
 public override string atacar(Unidad victima, Mapa mapa, Batallon bvictima, Batallon bAtacante)
 {
     var dañoRecibido = victima.recibirDaño(this.dañoMecanico, this.dañoNoMecanico);
     Console.SetCursorPosition(0, 27);
     Console.BackgroundColor = ConsoleColor.Black;
     Console.WriteLine(" ");
     Console.SetCursorPosition(0, 27);
     Console.BackgroundColor = ConsoleColor.DarkGreen;
     if (victima.hpActual <= 0)
     {
         bvictima.eliminarUnidad(mapa, victima);
     }
     this.hpActual = -100;
     mapa.matrizTerrestre[this.posicion[0] - 1, this.posicion[1] - 1] = null;
     Console.ForegroundColor = ConsoleColor.Black;
     Console.SetCursorPosition(this.posicion[0], this.posicion[1]);
     Console.Write("·");
     return (this.GetType().Name + " (" + this.icono + ") " + " Ha hecho " + dañoRecibido + " de daño a " + victima.GetType().Name + " (" + victima.icono + ") " + "(HP=" + victima.hpActual + "/" + victima.hpInicial + ")");
 }
Пример #5
0
        //Aplicar polimorfismo
        public override string atacar(Unidad victima, Mapa mapa, Batallon bvictima, Batallon bAtacante)
        {
            var dañoRecibido = victima.recibirDaño(this.dañoMecanico, this.dañoNoMecanico);
            Console.SetCursorPosition(0, 27);
            Console.BackgroundColor = ConsoleColor.Black;
            Console.WriteLine(" ");
            Console.SetCursorPosition(0, 27);
            Console.BackgroundColor = ConsoleColor.DarkGreen;
            if (victima.hpActual <= 0)
            {
                bvictima.eliminarUnidad(mapa, victima);
            }

            //Para empujar a la victima hacia atras:
            if (Math.Abs(this.posicion[0] - victima.posicion[0]) > Math.Abs(this.posicion[1] - victima.posicion[1])) //Cuando empuja en el eje x
            {
                if (this.posicion[0] > victima.posicion[0])
                {
                    int[] pos2 = {victima.posicion[0]-1, victima.posicion[1]};
                    victima.moverse(mapa, pos2);
                }
                else
                {
                    int[] pos2 = { victima.posicion[0] + 1, victima.posicion[1] };
                    victima.moverse(mapa, pos2);
                }
            }
            else // Cuando empuja en el eje y
            {
                if (this.posicion[1] > victima.posicion[1])
                {
                    int[] pos2 = { victima.posicion[0], victima.posicion[1]-1 };
                    victima.moverse(mapa, pos2);
                }
                else
                {
                    int[] pos2 = { victima.posicion[0], victima.posicion[1] + 1 };
                    victima.moverse(mapa, pos2);
                }
            }
            return (this.GetType().Name + " (" + this.icono + ") " + " Ha hecho " + dañoRecibido + " de daño a " + victima.GetType().Name + " (" + victima.icono + ") " + "(HP=" + victima.hpActual + "/"+victima.hpInicial+")");
        }
Пример #6
0
 //Aplicar polimorfismo
 public override string atacar(Unidad victima, Mapa mapa, Batallon bvictima, Batallon bAtacante)
 {
     if (this.TurnosParaUsarPoder > 0)
     {
         this.TurnosParaUsarPoder -= 1;
         return (this.GetType().Name + " (" + this.icono + ") " + " Debe esperar " + this.TurnosParaUsarPoder + " turnos más para curar");
     }
     victima.hpActual += 100;
     if (victima.hpActual > victima.hpInicial)
     {
         victima.hpActual = victima.hpInicial*1;
     }
     Console.SetCursorPosition(0, 27);
     Console.BackgroundColor = ConsoleColor.Black;
     Console.WriteLine(" ");
     Console.SetCursorPosition(0, 27);
     Console.BackgroundColor = ConsoleColor.DarkGreen;
     this.TurnosParaUsarPoder = this.enfriamiento * 1;
     return (this.GetType().Name + " (" + this.icono + ") " + " Ha sanado 100 HP a " + victima.GetType().Name + " (" + victima.icono + ") " + "(HP=" + victima.hpActual + "/" + victima.hpInicial + ")");
 }
Пример #7
0
        //Aplicar polimorfismo
        public override string atacar(Unidad victima, Mapa mapa, Batallon bvictima, Batallon bAtacante)
        {
            if (victima.bandera != this.bandera)
            {
                var dañoRecibido = victima.recibirDaño(this.dañoMecanico, this.dañoNoMecanico);

                if (victima.hpActual <= 0)
                {
                    bvictima.eliminarUnidad(mapa, victima);
                }
                return (this.GetType().Name + " (" + this.icono + ") " + " Ha hecho " + dañoRecibido + " de daño a " + victima.icono + "(HP=" + victima.hpActual + "/" + victima.hpInicial + ")");
            }

            if (this.TurnosParaUsarPoder > 0)
            {
                this.TurnosParaUsarPoder -= 1;
                return (this.GetType().Name + " (" + this.icono + ") " + " Debe esperar " + this.TurnosParaUsarPoder + " turnos más para usar habilidad");
            }

            //Uso de habilidad
            //int a = new Random().Next(1, 2);
            if (victima.hpInicial != victima.hpActual) //Reparar
            {
                victima.hpActual += 100;
                if (victima.hpActual > victima.hpInicial)
                {
                    victima.hpActual = victima.hpInicial * 1;
                }
                this.TurnosParaUsarPoder = this.enfriamiento * 1;
                return (this.GetType().Name + " (" + this.icono + ") " + " Ha reparado 100 HP a " + victima.GetType().Name + " (" + victima.icono + ") " + "(HP=" + victima.hpActual +"/"+victima.hpInicial+ ")");
            }
            else
            {
                victima.dañoMecanico += 15;
                victima.dañoNoMecanico += 15;
                this.TurnosParaUsarPoder = this.enfriamiento * 1;
                return (this.GetType().Name + " (" + this.icono + ") " + " Ha mejorado 15 de ataque a " + victima.GetType().Name + " (" + victima.icono + ") ");
            }
        }
Пример #8
0
        //Aplicar polimorfismo
        public override string atacar(Unidad victima, Mapa mapa, Batallon bvictima, Batallon bAtacante)
        {
            if (this.TurnosParaUsarPoder > 0)
            {
                this.TurnosParaUsarPoder -= 1;
                return (this.GetType().Name + " (" + this.icono + ") " + " Debe esperar " + this.TurnosParaUsarPoder + " turnos más para usar habilidad");
            }

            //Uso de habilidad
            int a = new Random().Next(1, 2);
            if (a==1) //Velocidad
            {
                victima.velocidad /= 2;
                this.TurnosParaUsarPoder = this.enfriamiento * 1;
                return (this.GetType().Name + " (" + this.icono + ") " + " Ha hecho mas lento por 4 turnos a " + victima.GetType().Name + " (" + victima.icono + ") ");
            }
            else // Daño
            {
                victima.dañoMecanico /= 2;
                victima.dañoNoMecanico /= 2;
                this.TurnosParaUsarPoder = this.enfriamiento * 1;
                return (this.GetType().Name + " (" + this.icono + ") " + " Ha bajado el daño a la mitad a " + victima.GetType().Name + " (" + victima.icono + ") ");
            }
        }
Пример #9
0
 public void agregarAereo(int[] pos, Unidad u)
 {
     this.matrizAerea[pos[0] - 1, pos[1] - 1] = u;
 }
Пример #10
0
 public Unidad entregarElemento(int posx, int posy, Unidad.Tipo tipo)
 {
     if (tipo == Unidad.Tipo.terrestre)
     {
          return this.matrizTerrestre[posx-1, posy-1];
     }
     else
     {
         return this.matrizAerea[posx - 1, posy - 1];
     }
 }
Пример #11
0
        public virtual void encontrarPosAlcanzable(int[] pos, int distanciaPorAvanzar, Unidad.Tipo tipo, bool inicio) // Retorna una lista con coordenadas caminables dado un rango
        {
            if (inicio && alcanzables.Count != 0)
            {
                alcanzables.Clear();
            }

            foreach (int[] i in this.posicionesAdyacentes(pos, tipo))
            {
                if (!(inLista(alcanzables, i)))
                {
                    alcanzables.Add(i);
                    if (distanciaPorAvanzar > 0)
                    {
                        encontrarPosAlcanzable(i, distanciaPorAvanzar - 1, tipo, false);
                    }
                }
            }
        }
Пример #12
0
 public List<int[]> posicionesAdyacentes(int[] pos, Unidad.Tipo tipo) //Entrega las posiciones adyacentes que son caminables
 {
     List<int[]> posiciones = new List<int[]>();
     if (pos[0] == 1 && pos[1] == 1) //Manejo de casos borde
     {
         int[] a = {pos[0], pos[1]+1};
         posiciones.Add(a);
         int[] b = {pos[0]+1, pos[1]};
         posiciones.Add(b);
     }
     else if (pos[0] == 1 && pos[1] == 25)
     {
         int[] a = {pos[0], pos[1] - 1 };
         posiciones.Add(a);
         int[] b = {pos[0] + 1, pos[1] };
         posiciones.Add(b);
     }
     else if (pos[0] == 79 && pos[1] == 1)
     {
         int[] a = { pos[0], pos[1] + 1 };
         posiciones.Add(a);
         int[] b = { pos[0] - 1, pos[1] };
         posiciones.Add(b);
     }
     else if (pos[0] == 79 && pos[1] == 25)
     {
         int[] a = { pos[0], pos[1] - 1 };
         posiciones.Add(a);
         int[] b = { pos[0] - 1, pos[1] };
         posiciones.Add(b);
     }
     else if (pos[0] == 1)
     {
         int[] a = { pos[0], pos[1] - 1 };
         posiciones.Add(a);
         int[] b = { pos[0], pos[1] + 1 };
         posiciones.Add(b);
         int[] c = { pos[0] + 1, pos[1] };
         posiciones.Add(c);
     }
     else if (pos[0] == 79)
     {
         int[] a = { pos[0], pos[1] - 1 };
         posiciones.Add(a);
         int[] b = { pos[0], pos[1] + 1 };
         posiciones.Add(b);
         int[] c = { pos[0] - 1, pos[1] };
         posiciones.Add(c);
     }
     else if (pos[1] == 1)
     {
         int[] a = { pos[0] +1, pos[1]};
         posiciones.Add(a);
         int[] b = { pos[0] -1, pos[1]};
         posiciones.Add(b);
         int[] c = { pos[0], pos[1] +1};
         posiciones.Add(c);
     }
     else if (pos[1] == 25)
     {
         int[] a = { pos[0] + 1, pos[1]};
         posiciones.Add(a);
         int[] b = { pos[0] - 1, pos[1]};
         posiciones.Add(b);
         int[] c = { pos[0], pos[1] -1};
         posiciones.Add(c);
     }
     else //Termino de manejo de casos borde
     {
         int[] a = { pos[0] + 1, pos[1]};
         posiciones.Add(a);
         int[] b = { pos[0], pos[1] + 1 };
         posiciones.Add(b);
         int[] c = { pos[0] -1, pos[1]};
         posiciones.Add(c);
         int[] d = { pos[0], pos[1] - 1 };
         posiciones.Add(d);
     }
     List<int[]> posicionesf = new List<int[]>();
     if (tipo == Unidad.Tipo.terrestre)
     {
         foreach (int[] i in posiciones)
         {
             if (!(this.matrizTerrestre[i[0] - 1, i[1] - 1] is Unidad))
             {
                 posicionesf.Add(i);
             }
         }
     }
     else
     {
         foreach (int[] i in posiciones)
         {
             if (!(this.matrizAerea[i[0] - 1, i[1] - 1] is Unidad))
             {
                 posicionesf.Add(i);
             }
         }
     }
     
     return posicionesf;
 }
Пример #13
0
 public void agregarTerrestre(int[] pos, Unidad u)
 {
     this.matrizTerrestre[pos[0] - 1, pos[1] - 1] = u;
 }
Пример #14
0
        public void eliminarUnidad(Mapa mapa, Unidad fallecido)
        {
            if (fallecido.tipo == Unidad.Tipo.aereo){
                mapa.matrizAerea[fallecido.posicion[0]-1,fallecido.posicion[1]-1] = null;
            }
            else
            {
                mapa.matrizTerrestre[fallecido.posicion[0]-1,fallecido.posicion[1]-1] = null;
            }
            this.batallon.Remove(fallecido);

            Console.ForegroundColor = ConsoleColor.Black;
            Console.SetCursorPosition(fallecido.posicion[0], fallecido.posicion[1]);
            Console.Write("·");
            // Cuidado con la muerte de bombarderos y aereos
        }