Example #1
0
        public void ListOfGems()
        {
            string text = "    ";
            int    acc  = 0;

            for (int j = 0; j < gemas.Length; j++)
            {
                if (gemas[j] != null)
                {
                    string temp = "[" + j + "]->" + gemas[j].GetName();
                    if (text.Length + temp.Length > 100)
                    {
                        ConsoleBuffer.ObteBuffer().InsertText(text);
                        text = "    ";
                    }
                    text += temp + "  ";
                    acc++;
                }
            }
            if (!text.Equals("    "))
            {
                ConsoleBuffer.ObteBuffer().InsertText(text);
            }
        }
 private static void StartCombate()
 {
     buffer = ConsoleBuffer.ObteBuffer();
     pl     = Program.ObteJuego().pl;
 }
Example #3
0
        public void PickItem(int num)
        {
            Item item = currentRoom.GetRoomItems()[num];

            if (item.GetType().BaseType == typeof(ItemEquipable))
            {
                if (!FilledGemas() && item.GetType() == typeof(ItemGema))
                {
                    for (int i = 0; i < gemas.Length; i++)
                    {
                        if (gemas[i] == null)
                        {
                            gemas[i] = (ItemGema)currentRoom.DropItem(num);
                            ConsoleBuffer.ObteBuffer().InsertText("Te has equipado " + item.GetName());
                            i = bag.Length;
                        }
                    }
                }
                else if (GetWeapon() == null && item.GetType() == typeof(ItemWeapon))
                {
                    arma = (ItemWeapon)currentRoom.DropItem(num);
                    ConsoleBuffer.ObteBuffer().InsertText("Te has equipado " + item.GetName());
                }
                else if (GetArmor() == null && item.GetType() == typeof(ItemArmor))
                {
                    armadura = (ItemArmor)currentRoom.DropItem(num);
                    ConsoleBuffer.ObteBuffer().InsertText("Te has equipado " + item.GetName());
                }
                else if (!FilledBag())
                {
                    for (int i = 0; i < bag.Length; i++)
                    {
                        if (bag[i] == null)
                        {
                            bag[i] = currentRoom.DropItem(num);
                            ConsoleBuffer.ObteBuffer().InsertText("Has guardado en la mochila " + item.GetName());
                            i = bag.Length;
                        }
                    }
                }
                else
                {
                    ConsoleBuffer.ObteBuffer().InsertText("Tienes la mochila llena");
                }
            }
            else
            {
                if (!FilledBag())
                {
                    for (int i = 0; i < bag.Length; i++)
                    {
                        if (bag[i] == null)
                        {
                            bag[i] = currentRoom.DropItem(num);
                            ConsoleBuffer.ObteBuffer().InsertText("Has guardado en la mochila " + item.GetName());
                            i = bag.Length;
                        }
                    }
                }
                else
                {
                    ConsoleBuffer.ObteBuffer().InsertText("Tienes la mochila llena");
                }
            }
        }
Example #4
0
        public void EquipItem(int num)
        {
            Item item = bag[num];

            if (item.GetType().BaseType == typeof(ItemEquipable))
            {
                if (item.GetType() == typeof(ItemWeapon))
                {
                    if (arma == null)
                    {
                        ConsoleBuffer.ObteBuffer().InsertText("Te has equipado " + item.GetName());
                        arma     = (ItemWeapon)item;
                        bag[num] = null;
                    }
                    else
                    {
                        ConsoleBuffer.ObteBuffer().InsertText("Te has equipado " + item.GetName());
                        ConsoleBuffer.ObteBuffer().InsertText("Te has desequipado " + arma.GetName());
                        ItemWeapon temp = arma;
                        arma     = (ItemWeapon)item;
                        bag[num] = temp;
                    }
                }
                else if (item.GetType() == typeof(ItemGema))
                {
                    bool check = true;
                    for (int i = 0; i < gemas.Length; i++)
                    {
                        if (gemas[i] == null)
                        {
                            ConsoleBuffer.ObteBuffer().InsertText("Te has equipado " + item.GetName());
                            gemas[i] = (ItemGema)item;
                            bag[num] = null;
                            i        = bag.Length;
                            check    = false;
                        }
                    }
                    if (check)
                    {
                        ConsoleBuffer.ObteBuffer().InsertText("¿Que gema quieres desequiparte?");
                        ListOfGems();
                        ConsoleBuffer.ObteBuffer().PrintBackground();
                        ConsoleBuffer.ObteBuffer().PrintText(ConsoleBuffer.ObteBuffer().height - 3);
                        ConsoleBuffer.ObteBuffer().Print(1, 0, "PRINCIPAL");
                        ConsoleBuffer.ObteBuffer().Print(1, ConsoleBuffer.ObteBuffer().height - 2, ">");
                        ConsoleBuffer.ObteBuffer().SmallMap();
                        ConsoleBuffer.ObteBuffer().PrintScreen();
                        Console.SetCursorPosition(2, ConsoleBuffer.ObteBuffer().height - 2);

                        bool obj = int.TryParse(Console.ReadLine(), out int num1);
                        if (obj && num1 >= 0 && num1 < gemas.Length && gemas[num1] != null)
                        {
                            ConsoleBuffer.ObteBuffer().InsertText("Te has equipado " + item.GetName());
                            ConsoleBuffer.ObteBuffer().InsertText("Te has desequipado " + item.GetName());
                            ItemGema temp = gemas[num1];
                            gemas[num1] = (ItemGema)item;
                            bag[num]    = temp;
                        }
                        else if (!obj)
                        {
                            ConsoleBuffer.ObteBuffer().InsertText("Tiene que ser un numero");
                        }
                        else
                        {
                            ConsoleBuffer.ObteBuffer().InsertText("Esa posicion no es válida");
                        }
                    }
                }
                else if (item.GetType() == typeof(ItemArmor))
                {
                    if (armadura == null)
                    {
                        ConsoleBuffer.ObteBuffer().InsertText("Te has equipado " + item.GetName());
                        armadura = (ItemArmor)bag[num];
                        bag[num] = null;
                    }
                    else
                    {
                        ConsoleBuffer.ObteBuffer().InsertText("Te has equipado " + item.GetName());
                        ConsoleBuffer.ObteBuffer().InsertText("Te has desequipado " + armadura.GetName());
                        ItemArmor temp = armadura;
                        armadura = (ItemArmor)item;
                        bag[num] = temp;
                    }
                }
            }
            else
            {
                ConsoleBuffer.ObteBuffer().InsertText("Este objeto no es equipable");
            }
        }
        //pantalla principal, donde pasa toda la magia
        public void MainScreen()
        {
            CommandMethod method;
            string        textInput;

            //Dibuja el fondo de primeras
            ConsoleBuffer.ObteBuffer().Print(1, 0, "PRINCIPAL");
            ConsoleBuffer.ObteBuffer().PrintBackground();
            ConsoleBuffer.ObteBuffer().InsertText(pl.currentRoom.GetDescriptionTotal());
            ConsoleBuffer.ObteBuffer().PrintText(height - 3);
            ConsoleBuffer.ObteBuffer().SmallMap();
            ConsoleBuffer.ObteBuffer().PrintScreen();

            do
            {
                //Pon el cursos en la posicion de escribir
                //Console.SetCursorPosition(1, 18);

                Monitor.Enter(this);
                Monitor.Wait(this);

                //Espera input
                textInput = comando;

                //Espacio para facilitar lectura
                ConsoleBuffer.ObteBuffer().InsertText("");

                //Lo inserta en el lineTexto
                ConsoleBuffer.ObteBuffer().InsertText(textInput);

                //Si el comando es valido
                if (Comando.CheckCommand(textInput))
                {
                    // obten el metodo
                    method = Comando.ReturnCommand(textInput);

                    //si ha obtenido metodo
                    if (method != null)
                    {
                        bool temp = method();
                        if ((method.Method.Name.Equals("MoveNorth") || method.Method.Name.Equals("MoveSouth") || method.Method.Name.Equals("MoveWest") || method.Method.Name.Equals("MoveEast")) && temp)
                        {
                            pl.currentRoom.SetVisible(2);
                            if (pl.GetMaldicion(1))
                            {
                                if (pl.GetHealth() > 1 && CustomMath.RandomUnit() < 0.1f)
                                {
                                    ConsoleBuffer.ObteBuffer().InsertText("Te has tropezado y has perdido 1 punto de vida");
                                    pl.ReceiveDamage(1, 0);
                                }
                            }

                            /*if (pl.currentRoom.ene != null)
                             * {
                             *  ConsoleBuffer.ObteBuffer().InsertText("Un enemigo ha aparecido");
                             *  ConsoleBuffer.ObteBuffer().Print(1, 0, "PRINCIPAL");
                             *  ConsoleBuffer.ObteBuffer().PrintBackground();
                             *  ConsoleBuffer.ObteBuffer().PrintText(17);
                             *  SmallMap(this);
                             *  ConsoleBuffer.ObteBuffer().PrintScreen();
                             *  Console.ReadKey();
                             *  ConsoleBuffer cbMain = ConsoleBuffer.ObteBuffer();
                             *  ConsoleBuffer.ObteBuffer() = new ConsoleBuffer(width, height, height - 5,this);
                             *  EscenaCombate.Combate(pl.currentRoom.ene);
                             *  ConsoleBuffer.ObteBuffer() = cbMain;
                             *  if (pl.IsDead())
                             *  {
                             *      textInput = "exit";
                             *  }
                             * }*/

                            ConsoleBuffer.ObteBuffer().InsertText(pl.currentRoom.GetDescriptionTotal());
                        }
                    }
                    else
                    {
                        //En caso contrario avisa
                        ConsoleBuffer.ObteBuffer().InsertText("Not implemented");
                    }
                }
                else
                {
                    ConsoleBuffer.ObteBuffer().InsertText("Comando no valido");
                }
                if (goNextLevel)
                {
                    level++;
                    goNextLevel = false;
                    // hola
                    int cRooms = 10 + 5 * level;
                    Level.StartLevel(cRooms);
                    lvlLayout      = Level.actualRooms;
                    pl.currentRoom = lvlLayout[0];
                    ConsoleBuffer.ObteBuffer().ClearBox();
                    if (pl.GetMaldicion(3))
                    {
                        if (CustomMath.RandomUnit() < 0.5)
                        {
                            ConsoleBuffer.ObteBuffer().InsertText("Tu invalidez ha hecho que ruedes escaleras abajo de manera muy sonora y cómica. Milagrosamente no has recibido ningún daño. La escalera por la que has rebotado se ha destruido");
                        }
                        else
                        {
                            ConsoleBuffer.ObteBuffer().InsertText("Tu invalidez ha hecho que tus piernas dejen de responder y tengas que bajar usando las manos. Después de media hora has conseguido bajar. Al tocar el suelo del siguiente piso tus piernas vuelven a responder. La escalera por la que te has arrastrado se ha destruido");
                        }
                    }
                    else
                    {
                        ConsoleBuffer.ObteBuffer().InsertText("Cuando bajas escuchas un fuerte estruendo. Al mirar arriba las escaleras acaban en el techo de la sala");
                    }

                    ConsoleBuffer.ObteBuffer().InsertText(pl.currentRoom.GetDescriptionTotal());
                    if (pl.GetMaldicion(4))
                    {
                        ConsoleBuffer.ObteBuffer().InsertText("Sientes como un peso se levanta de ti");
                        for (int i = 0; i < pl.GetArrMal().Length; i++)
                        {
                            if (pl.GetArrMal()[i].GetId() == 4)
                            {
                                pl.GetArrMal()[i] = null;
                                i = pl.GetArrMal().Length;
                            }
                        }
                    }
                }

                ConsoleBuffer.ObteBuffer().Print(1, 0, "PRINCIPAL");
                ConsoleBuffer.ObteBuffer().PrintBackground();
                ConsoleBuffer.ObteBuffer().PrintText(17);
                ConsoleBuffer.ObteBuffer().SmallMap();
                ConsoleBuffer.ObteBuffer().PrintScreen();
            } while (!textInput.Equals("exit") && !pl.IsDead());
        }