Esempio n. 1
0
        //pantalla principal, donde pasa toda la magia
        public static void MainScreen()
        {
            CommandMethod method;
            string        textInput;

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

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

                //Espera input
                textInput = Console.ReadLine();

                //Espacio para facilitar lectura
                buffer.InsertText("");
                //Lo inserta en el lineTexto
                buffer.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)
                                {
                                    buffer.InsertText("Te has tropezado y has perdido 1 punto de vida");
                                    pl.ReceiveDamage(1, 0);
                                }
                            }

                            if (pl.currentRoom.ene != null)
                            {
                                buffer.InsertText("Un enemigo ha aparecido");
                                buffer.Print(1, 0, "PRINCIPAL");
                                buffer.PrintBackground();
                                buffer.PrintText(17);
                                SmallMap();
                                buffer.PrintScreen();
                                Console.ReadKey();
                                ConsoleBuffer cbMain = buffer;
                                buffer   = new ConsoleBuffer(width, height, height - 5);
                                inCombat = true;
                                EscenaCombate.Combate(pl.currentRoom.ene);
                                inCombat = false;
                                buffer   = cbMain;
                                if (pl.IsDead())
                                {
                                    textInput = "exit";
                                }
                            }
                            buffer.InsertText(pl.currentRoom.GetDescriptionTotal());
                        }
                    }
                    else
                    {
                        //En caso contrario avisa
                        buffer.InsertText("Not implemented");
                    }
                }
                else
                {
                    buffer.InsertText("Comando no valido");
                }
                if (goNextLevel)
                {
                    level++;
                    goNextLevel = false;
                    // hola
                    Level.StartLevel(GetRoomsPerLevel());
                    lvlLayout      = Level.actualRooms;
                    pl.currentRoom = lvlLayout[0];
                    buffer.ClearBox();
                    if (pl.GetMaldicion(3))
                    {
                        if (CustomMath.RandomUnit() < 0.5)
                        {
                            buffer.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
                        {
                            buffer.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
                    {
                        buffer.InsertText("Cuando bajas escuchas un fuerte estruendo. Al mirar arriba las escaleras acaban en el techo de la sala");
                    }

                    buffer.InsertText(pl.currentRoom.GetDescriptionTotal());
                    if (pl.GetMaldicion(4))
                    {
                        buffer.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;
                            }
                        }
                    }
                }

                buffer.Print(1, 0, "PRINCIPAL");
                buffer.PrintBackground();
                buffer.PrintText(17);
                SmallMap();
                buffer.PrintScreen();
            } while (!textInput.Equals("exit") && !pl.IsDead());
        }
Esempio n. 2
0
 private static void StartCombate()
 {
     buffer = Program.buffer;
     pl     = Program.pl;
 }