コード例 #1
0
        private void Effect()
        {
            Player        pl     = Program.pl;
            ConsoleBuffer buffer = Program.buffer;

            switch (id)
            {
            case 0:
                if (!pl.GetMaldicion(4))
                {
                    List <Room> r0 = Program.lvlLayout;
                    for (int i = 0; i < r0.Count; i++)
                    {
                        if (r0[i].IsVisible() == 0)
                        {
                            r0[i].SetVisible(3);
                        }
                    }
                    buffer.InsertText("¡El piso se ha revelado!");
                }
                else
                {
                    buffer.InsertText("¡La maldición del ciego ha anulado el efecto!");
                }
                break;

            case 1:
                List <Room> r1 = Program.lvlLayout;
                for (int i = 0; i < r1.Count; i++)
                {
                    if (r1[i].GetType() == typeof(RoomExit))
                    {
                        if (pl.GetMaldicion(4))
                        {
                            pl.currentRoom.SetVisible(0);
                        }
                        pl.currentRoom = r1[i];
                        r1[i].SetVisible(2);
                        buffer.InsertText("¡Te has teletransportado!");
                        if (Program.inCombat == false)
                        {
                            buffer.InsertText(pl.currentRoom.GetDescriptionTotal());
                        }
                        i = r1.Count;
                    }
                }
                break;
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Wendfrey/TextAdventure
 public static void Introduccion()
 {
     buffer.InsertText("En lo mas profundo de un bosque, en el pie de la montaña mas alta, se dice que existe la cueva del diablo, un lugar laberintico y lleno de monstruos. Se dice que cuando alguien entra no vuelve a salir nunca, o almenos no como humano.");
     buffer.InsertText("Tras años de viaje, un explorador se refugia dentro de una cueva. Al entrar, decide mirar el exterior, pero ya no encuentra salida");
     buffer.InsertText("Ese explorador eres tu");
     buffer.InsertText("");
     buffer.InsertText("Pulsa cualquier tecla para continuar");
     buffer.PrintBackground();
     buffer.PrintText(height - 3);
     buffer.PrintScreen();
     Console.ReadKey();
     buffer.ClearBox();
 }
コード例 #3
0
        public static void Combate(Enemigo ene)
        {
            StartCombate();
            buffer.InsertText("¡Ha aparecido un " + ene.GetName() + "!");
            BackgroundCombat();
            string[] comandos = { "atacar", "defender", "huir", "consumir", "habilidad" };
            bool     huir     = false;
            int      itemHuir = -1;

            while (!(pl.IsDead() || ene.IsDead() || huir))
            {
                Console.SetCursorPosition(1, 18);
                string decide = Console.ReadLine().ToLower();
                buffer.InsertText("");
                buffer.InsertText(decide);
                if (decide.Equals(comandos[0]))
                {
                    Attack(pl, ene);
                }
                else if (decide.Equals(comandos[1]))
                {
                    buffer.InsertText("Te has puesto en guardia");
                    AtaqueDirigidoA(ene, pl, -2);
                }
                else if (decide.Equals(comandos[2]))
                {
                    float rand      = (float)CustomMath.RandomUnit();
                    float probHuida = (pl.GetMaldicion(3)) ? 0.25f + pl.GetSpeed() / (float)(2 * (pl.GetSpeed() + ene.GetSpeed())) : 0.25f + pl.GetSpeed() / (float)(pl.GetSpeed() + ene.GetSpeed());
                    if (rand < probHuida)
                    {
                        buffer.InsertText("¡Has huido!");
                        huir = true;
                    }
                    else
                    {
                        if (pl.GetMaldicion(3) && rand < (probHuida - 0.25f) * 2 + 0.25f)
                        {
                            buffer.InsertText("Notas como las piernas no te responden y eres incapaz de moverte");
                        }
                        else
                        {
                            buffer.InsertText("¡No has podido huir!");
                            AtaqueDirigidoA(ene, pl);
                        }
                    }
                }
                else if (decide.Equals(comandos[3]))
                {
                    int i = Comando.ConsumeItemCombat();
                    if (i > -1)
                    {
                        if (pl.GetBag()[i].GetType() == typeof(ItemScroll))
                        {
                            ItemScroll itemScroll = (ItemScroll)pl.GetBag()[i];
                            if (itemScroll.GetId() == 1)
                            {
                                itemHuir = i;
                                huir     = true;
                            }
                        }
                        if (itemHuir == -1)
                        {
                            pl.ConsumeItem(i);
                            AtaqueDirigidoA(ene, pl);
                        }
                    }
                }
                else if (decide.Equals(comandos[4]))
                {
                    buffer.InsertText("¿Que habilidad quieres usar?");
                    buffer.InsertText("[0]-> Ataque Veloz [1]-> Golpe Aplastador [2]-> Curación Menor [3]-> MegaGolpe [4]-> Dardos Mágicos");
                    buffer.Print(1, buffer.height - 2, ">");
                    BackgroundCombat();
                    Console.SetCursorPosition(2, Program.buffer.height - 2);
                    bool obj = int.TryParse(Console.ReadLine(), out int num);
                    if (!obj)
                    {
                        Program.buffer.InsertText("Solo acepta numeros");
                    }
                    else if (num >= 0 && num <= 4)
                    {
                        bool used = true;
                        if (num == 0 && pl.GetMana() - 10 >= 0)
                        {
                            pl.SetMana(pl.GetMana() - 10);
                        }
                        else if (num == 1 && pl.GetMana() - 5 >= 0)
                        {
                            pl.SetMana(pl.GetMana() - 5);
                        }
                        else if (num == 2 && pl.GetMana() - 5 >= 0)
                        {
                            pl.SetMana(pl.GetMana() - 5);
                        }
                        else if (num == 3 && pl.GetMana() - 10 >= 0)
                        {
                            pl.SetMana(pl.GetMana() - 10);
                        }
                        else if (num == 4 && pl.GetMana() - 10 >= 0)
                        {
                            pl.SetMana(pl.GetMana() - 10);
                        }
                        else
                        {
                            buffer.InsertText("No tienes suficiente maná");
                            used = false;
                        }
                        if (used)
                        {
                            Attack(pl, ene, num);
                        }
                    }
                    else
                    {
                        Program.buffer.InsertText("Ese número no es válido");
                    }
                }
                else
                {
                    buffer.InsertText("Comando no valido");
                }


                BackgroundCombat();
            }
            if (pl.IsDead())
            {
                buffer.InsertText("Has muerto...");
            }
            else if (ene.IsDead())
            {
                buffer.InsertText("");
                int exp = 5 + 3 * ene.GetLevel();
                buffer.InsertText("¡Has derrotado a " + ene.GetName() + "!");
                int money = CustomMath.RandomIntNumber(5 + 5 * Program.GetLevel(), 5 + 2 * Program.GetLevel());
                buffer.InsertText("Has conseguido " + money + " monedas");
                pl.GainMoney(money);
                pl.currentRoom.ene = null;
            }
            if (huir && itemHuir == -1)
            {
                ene.RestoreHealth();
                pl.currentRoom.SetVisible(1);
                switch (pl.lastRoom)
                {
                case 0:
                    Comando.MoveNorth();
                    break;

                case 1:
                    Comando.MoveWest();
                    break;

                case 2:
                    Comando.MoveSouth();
                    break;

                case 3:
                    Comando.MoveEast();
                    break;

                default:
                    throw new Exception("Error a la hora de huir");
                }
            }
            else if (huir)
            {
                ene.RestoreHealth();
                pl.ConsumeItem(itemHuir);
            }
            buffer.InsertText("pulsa cualquier boton para continuar");
            BackgroundCombat();
            Console.ReadKey();
        }