Пример #1
0
 public override List<Unidad> ObjetivosProximos(Mapa mapa)
 {
     List<Unidad> u = new List<Unidad>();
     mapa.encontrarPosAlcanzable(this.posicion, this.velocidad, this.tipo, true);
     foreach (int[] i in mapa.alcanzables)
     {
         var adyacentes = objetivosDisparables(i, mapa);
         if (adyacentes.Count != 0)
         {
             foreach (Unidad a in adyacentes)
             {
                 if (!(u.Contains(a)))
                 {
                     u.Add(a);
                 }
             }
         }
     }
     if (u.Count == 0)
     {
         this.estado = estados.defensivo;
     }
     else
     {
         this.estado = estados.ofensivo;
     }
     return u;
 }
Пример #2
0
        //Por defecto para terrestres
        public override bool moverse(Mapa mapa, int[] pos2)
        {
            if (pos2[0] < 1 || pos2[1] < 1 || mapa.matrizTerrestre[pos2[0] - 1, pos2[1] - 1] is Unidad)
            {
                Console.SetCursorPosition(0, 29);

                return false;
                //Console.WriteLine("No puede moverse a un espacio ocupado");
            }
            else
            {
                if (this.combustible < this.CombustiblePorUnidad)
                {
                    if (this.tiempoRestante == 1)
                    {
                        this.tiempoRestante = 0;
                        this.combustible = this.capacidadEstanque * 1;
                        return true;
                    }
                    else
                    {
                        this.tiempoRestante -= 1;
                    }
                }

                Console.BackgroundColor = ConsoleColor.DarkGreen;
                var a = mapa.eliminarTerrestre(this.posicion);
                mapa.agregarTerrestre(pos2, a);

                Console.ForegroundColor = ConsoleColor.Black;
                Console.SetCursorPosition(this.posicion[0], this.posicion[1]);
                if (mapa.entregarElemento(this.posicion[0], this.posicion[1], Tipo.aereo) is Unidad)
                {
                    if (mapa.entregarElemento(this.posicion[0], this.posicion[1], Tipo.aereo).bandera == bandos.azul)
                    {
                        Console.ForegroundColor = ConsoleColor.Blue;
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                    }
                }
                Console.Write(mapa.entregaricono(this.posicion[0], this.posicion[1]));

                if (bandera == bandos.azul)
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                }
                Console.SetCursorPosition(pos2[0], pos2[1]);

                Console.Write(this.icono);
                this.posicion = pos2;
                return true;
            }
        }
Пример #3
0
 public override List<Unidad> objetivosDisparables(int[] pos, Mapa mapa)
 {
     List<Unidad> adyacentes = new List<Unidad>();
     if (mapa.matrizTerrestre[pos[0] - 1, pos[1] - 1] is Unidad && mapa.matrizTerrestre[pos[0] - 1, pos[1] - 1].bandera != this.bandera)
     {
         adyacentes.Add(mapa.matrizTerrestre[pos[0] - 1, pos[1] - 1]);
     }
     return adyacentes;
 }
Пример #4
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 + ")");
 }
Пример #5
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");
        }
Пример #6
0
 public override List<Unidad> objetivosDisparables(int[] pos, Mapa mapa)
 {
     List<Unidad> adyacentes = new List<Unidad>();
     for (int i = pos[0] - this.rango; i <= pos[0] + this.rango; i++)
     {
         for (int j = pos[1] - this.rango; j <= pos[1] + this.rango; j++)
         {
             if (i >= 1 && j >= 1 && j <= 25 && i <= 79)
             {
                 if (mapa.matrizTerrestre[i - 1, j - 1] is Mecanicos && mapa.matrizTerrestre[i - 1, j - 1].bandera == this.bandera && !(i == 0 && j == 0))
                 {
                     adyacentes.Add(mapa.matrizTerrestre[i - 1, j - 1]);
                 }
             }
         }
     }
     return adyacentes;
 }
Пример #7
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 + ")");
 }
Пример #8
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+")");
        }
Пример #9
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 + ")");
 }
Пример #10
0
 public override List<Unidad> ObjetivosProximos(Mapa mapa)
 {
     List<Unidad> u = new List<Unidad>();
     mapa.encontrarPosAlcanzable(this.posicion, this.velocidad, this.tipo, true);
     foreach (int[] i in mapa.alcanzables)
     {
         var adyacentes = objetivosDisparables(i, mapa);
         if (adyacentes.Count != 0)
         {
             foreach (Unidad a in adyacentes)
             {
                 if (!(u.Contains(a)))
                 {
                     u.Add(a);
                 }
             }
         }
     }
     u.RemoveAll(x => x.hpActual + 10 > x.hpInicial);
     return u;
 }
Пример #11
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 + ") ");
            }
        }
Пример #12
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 + ") ");
            }
        }
Пример #13
0
 public abstract List<Unidad> ObjetivosProximos(Mapa mapa);
Пример #14
0
 public abstract List<Unidad> objetivosDisparables(int[] pos, Mapa mapa);
Пример #15
0
        public void prepararEstados()
        {
            Console.Title = "Zod-To vs Dr. Fadic";
            this.mapa = new Mapa();

            int[] posBase1 = { 3, 3 };
            int[] posBase2 = { 75, 20 };
            this.b1 = new Base(Guerra.bandos.azul, posBase1);
            mapa.cambiar(posBase1, b1);
            posBase1[0] += 1;
            mapa.cambiar(posBase1, b1);
            posBase1[1] += 1;
            mapa.cambiar(posBase1, b1);
            posBase1[0] -= 1;
            mapa.cambiar(posBase1, b1);

            this.b2 = new Base(Guerra.bandos.rojo, posBase2);
            mapa.cambiar(posBase2, b2);
            posBase2[0] += 1;
            mapa.cambiar(posBase2, b2);
            posBase2[1] += 1;
            mapa.cambiar(posBase2, b2);
            posBase2[0] -= 1;
            mapa.cambiar(posBase2, b2);

            Console.WriteLine("Bienvenido!\n (1) Para simular con un ejercito por defecto\n (2) Para crear un ejercito a tu gusto");
            var a = Console.ReadKey().KeyChar.ToString();
            Console.Clear();
            if (a == "1")
            {
                Console.WriteLine("Elija el tamaño de cada ejercito. 1-9");
                var b = Int32.Parse(Console.ReadKey().KeyChar.ToString());
                this.bat1 = new Batallon(mapa, Guerra.bandos.azul, b, b, b, b, b, b, b, b, b, b, b);
                this.bat2 = new Batallon(mapa, Guerra.bandos.rojo, b, b, b, b, b, b, b, b, b, b, b);
            }
            else
            {
                bool cont = true;
                int a1 = 0;
                int a2 = 0;
                int a3 = 0;
                int a4 = 0;
                int a5 = 0;
                int a6 = 0;
                int a7 = 0;
                int a8 = 0;
                int a9 = 0;
                int a10 = 0;
                int a11 = 0;

                while (cont)
                {
                    Console.Clear();
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.BackgroundColor = ConsoleColor.White;
                    Console.Clear();
                    Console.WriteLine("Elija la cantidad de cada tipo de tropa para el ejército azul.\n Presione cualquier otra tecla para continuar\n\n");
                    Console.WriteLine("(1) Terrestre Anti-aereo : " + a1);
                    Console.WriteLine("(2) Anti-infanteria : " + a2);
                    Console.WriteLine("(3) Bombardero : " + a3);
                    Console.WriteLine("(4) Aereo Anti-Aereo : " + a4);
                    Console.WriteLine("(5) Guerrero : " + a5);
                    Console.WriteLine("(6) Kamikaze : " + a6);
                    Console.WriteLine("(7) Arquero : " + a7);
                    Console.WriteLine("(8) Ingeniero : " + a8);
                    Console.WriteLine("(9) Medico : " + a9);
                    Console.WriteLine("(0) Groupie : " + a10);
                    Console.WriteLine("(-)Desmoralizador : " + a11);
                    var b = Console.ReadKey().KeyChar.ToString();
                    if (b == "1")
                    {
                        a1+=1;
                    }
                    else if (b == "2")
                    {
                        a2++;
                    }
                    else if (b == "3")
                    {
                        a3++;
                    }
                    else if (b == "4")
                    {
                        a4++;
                    }
                    else if (b == "5")
                    {
                        a5++;
                    }
                    else if (b == "6")
                    {
                        a6++;
                    }
                    else if (b == "7")
                    {
                        a7++;
                    }
                    else if (b == "8")
                    {
                        a8++;
                    }
                    else if (b == "9")
                    {
                        a9++;
                    }
                    else if (b == "0")
                    {
                        a10++;
                    }
                    else if (b == "-")
                    {
                        a11++;
                    }
                    else
                    {
                        cont = false;
                        this.bat1 = new Batallon(mapa, Guerra.bandos.azul, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
                    }
                }
                cont = true;
                a1 = 0;
                a2 = 0;
                a3 = 0;
                a4 = 0;
                a5 = 0;
                a6 = 0;
                a7 = 0;
                a8 = 0;
                a9 = 0;
                a10 = 0;
                a11 = 0;
                while (cont)
                {
                    Console.Clear();
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.BackgroundColor = ConsoleColor.White;
                    Console.Clear();
                    Console.WriteLine("Elija la cantidad de cada tipo de tropa para el ejército rojo.\n Presione cualquier otra tecla para continuar\n\n");
                    Console.WriteLine("(1) Terrestre Anti-aereo : " + a1);
                    Console.WriteLine("(2) Anti-infanteria : " + a2);
                    Console.WriteLine("(3) Bombardero : " + a3);
                    Console.WriteLine("(4) Aereo Anti-Aereo : " + a4);
                    Console.WriteLine("(5) Guerrero : " + a5);
                    Console.WriteLine("(6) Kamikaze : " + a6);
                    Console.WriteLine("(7) Arquero : " + a7);
                    Console.WriteLine("(8) Ingeniero : " + a8);
                    Console.WriteLine("(9) Medico : " + a9);
                    Console.WriteLine("(0) Groupie : " + a10);
                    Console.WriteLine("(-)Desmoralizador : " + a11);
                    var b = Console.ReadKey().KeyChar.ToString();
                    if (b == "1")
                    {
                        a1 += 1;
                    }
                    else if (b == "2")
                    {
                        a2++;
                    }
                    else if (b == "3")
                    {
                        a3++;
                    }
                    else if (b == "4")
                    {
                        a4++;
                    }
                    else if (b == "5")
                    {
                        a5++;
                    }
                    else if (b == "6")
                    {
                        a6++;
                    }
                    else if (b == "7")
                    {
                        a7++;
                    }
                    else if (b == "8")
                    {
                        a8++;
                    }
                    else if (b == "9")
                    {
                        a9++;
                    }
                    else if (b == "0")
                    {
                        a10++;
                    }
                    else if (b == "-")
                    {
                        a11++;
                    }
                    else
                    {
                        cont = false;
                        this.bat2 = new Batallon(mapa, Guerra.bandos.rojo, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
                    }
                }

            }

            mapa.mostrarMapa();
        }
Пример #16
0
        public Batallon(Mapa mapa, bandos bando, int terrestreAntiAereo, int antiInfanteria, int bombardero, int aereoAntiAereo, int guerrero, int kamikaze, int arquero, int ingeniero, int medico, int groupie, int desmoralizador)
        {
            for (int i = 0; i < terrestreAntiAereo; i++)
            {
                var pos = mapa.espacioVacio(bando);
                TerrestreAntiAereo a = new TerrestreAntiAereo(bando, pos);
                this.batallon.Add(a);
                mapa.cambiar(pos, a);

            }

            for (int i = 0; i < antiInfanteria; i++)
            {
                var pos = mapa.espacioVacio(bando);
                var a = new AntiInfanteria(bando, pos);
                mapa.cambiar(pos, a);
                this.batallon.Add(a);
            }

            for (int i = 0; i < bombardero; i++)
            {
                var pos = mapa.espacioVacio(bando);
                var a = new Bombardero(bando, pos);
                mapa.cambiar(pos, a);
                this.batallon.Add(a);
            }

            for (int i = 0; i < aereoAntiAereo; i++)
            {
                var pos = mapa.espacioVacio(bando);
                var a = new AereoAntiAereo(bando, pos);
                mapa.cambiar(pos, a);
                this.batallon.Add(a);
            }

            for (int i = 0; i < guerrero; i++)
            {
                var pos = mapa.espacioVacio(bando);
                var a = new Guerrero(bando, pos); mapa.cambiar(pos, a);
                this.batallon.Add(a);
            }

            for (int i = 0; i < kamikaze; i++)
            {
                var pos = mapa.espacioVacio(bando);
                var a = new Kamikaze(bando, pos);
                mapa.cambiar(pos, a);
                this.batallon.Add(a);
            }

            for (int i = 0; i < arquero; i++)
            {
                var pos = mapa.espacioVacio(bando);
                var a = new Arquero(bando, pos);
                mapa.cambiar(pos, a);
                this.batallon.Add(a);
            }

            for (int i = 0; i < ingeniero; i++)
            {
                var pos = mapa.espacioVacio(bando);
                var a = new Ingeniero(bando, pos); mapa.cambiar(pos, a);
                this.batallon.Add(a);
            }

            for (int i = 0; i < medico; i++)
            {
                var pos = mapa.espacioVacio(bando);
                var a = new Medico(bando, pos); mapa.cambiar(pos, a);
                this.batallon.Add(a);
            }

            for (int i = 0; i < groupie; i++)
            {
                var pos = mapa.espacioVacio(bando);
                var a = new Groupie(bando, pos);
                mapa.cambiar(pos, a);
                this.batallon.Add(a);
            }
            for (int i = 0; i < desmoralizador; i++)
            {
                var pos = mapa.espacioVacio(bando);
                var a = new Desmoralizador(bando, pos);
                mapa.cambiar(pos, a);
                this.batallon.Add(a);
            }
        }
Пример #17
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
        }