示例#1
0
 /// <summary>
 /// Comprueba si se ha terminado la partida
 /// </summary>
 /// <param name="map"></param>
 /// <param name="player"></param>
 /// <returns></returns>
 static bool EndGame(Map map, Player player)
 {
     // si sales del mapa
     if (player.atExit(map))
     {
         Console.Write(map.GetDungeonInfo(player.GetPosition()));
         Console.WriteLine("\n\nYOU WIN!!!\n");
         Prompt();
         Console.ReadLine();
         return(true);
     }
     // si mueres
     else if (!player.IsAlive())
     {
         Console.Write("You have died.\n");
         Console.WriteLine("YOU LOSE!!!\n");
         Prompt();
         Console.ReadLine();
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#2
0
文件: Program.cs 项目: danielgsel/MAP
 static void DEBUG(Map m, Player p)
 {
     Console.WriteLine("Dungeon: " + p.GetPosition());
     Console.WriteLine();
     Console.WriteLine(p.PrintStats());
     Console.WriteLine();
     Console.WriteLine("Enemies: \n" + m.GetenemiesInfo(p.GetPosition()));
     Console.WriteLine();
     Console.WriteLine("Dungeon info: " + m.GetDungeonInfo(p.GetPosition()));
 }
示例#3
0
文件: Program.cs 项目: danielgsel/MAP
        static void ProcesaInput(string com, Player p, Map m)  //procesa el comando representado en la string com
        {
            string[] div;
            div = com.Split(' ');
            try
            {
                switch (div[0])
                {
                case "go":
                    if (div.Length > 1 && (div[1] == "north" || div[1] == "south" || div[1] == "west" || div[1] == "east"))
                    {
                        p.Move(m, StringToDir(div[1]));     //Solo si el jugador introduce una direccion
                        EnemiesAttackPlayer(m, p);
                    }
                    else
                    {
                        Console.WriteLine("Direccion cardinal erronea");
                    }
                    break;

                case "enemies":
                    Console.WriteLine(m.GetenemiesInfo(p.GetPosition()));
                    break;

                case "attack":
                    Console.WriteLine("Enemies eliminated: " + PlayerAttackEnemies(m, p));
                    EnemiesAttackPlayer(m, p);
                    break;

                case "info":
                    Console.WriteLine(m.GetDungeonInfo(p.GetPosition()));
                    break;

                case "stats":
                    Console.WriteLine(p.PrintStats());
                    break;
                }
            }
            catch (Exception)
            {
                Console.WriteLine("No has introducido un input correcto");
            }
        }
示例#4
0
        /// <summary>
        /// Procesa el input del usuario en el juego
        /// </summary>
        /// <param name="com"></param>
        /// <param name="p"></param>
        /// <param name="m"></param>
        static void ProcesaInput(string com, Player p, Map m, ref Record rec)
        {
            Console.Clear();
            mode = Mode.Playing;
            try
            {
                string[] entrada = com.Split(' ');
                switch (entrada[0].ToLower())
                {
                case "go":
                    if (p.Move(m, (Direction)Enum.Parse(typeof(Direction), entrada[1])))
                    {
                        AddAction(com, ref rec);
                        // si hay enemigos en la sala te atacan
                        if (EnemiesAttackPlayer(m, p))
                        {
                            EscribeEnColor("You have been attacked!!!\n", ConsoleColor.Red);
                        }
                    }
                    break;

                case "attack":
                    AddAction(com, ref rec);
                    int killedEnemies = PlayerAttackEnemies(m, p);
                    EscribeEnColor("You have killed " + killedEnemies + " enemy/ies\n", ConsoleColor.Green);
                    // si hay enemigos en la sala te atacan
                    if (EnemiesAttackPlayer(m, p))
                    {
                        EscribeEnColor("You have been attacked!!!\n", ConsoleColor.Red);
                    }
                    // si no te atacan y no has matado a un enemigo, es que has atacado a la nada
                    else if (killedEnemies <= 0)
                    {
                        EraseAction(ref rec);
                    }
                    break;

                case "enemies":
                    Console.WriteLine(m.GetEnemiesInfo(p.GetPosition()));
                    break;

                case "info":
                    Console.Write(m.GetDungeonInfo(p.GetPosition()) + "\n" + m.GetMoves(p.GetPosition()));
                    break;

                case "stats":
                    Console.WriteLine(p.PrintStats());
                    break;

                case "quit":
                    mode = Mode.Exit;
                    break;

                case "menu":
                    mode = Mode.Menu;
                    break;

                case "help":
                    Console.Write(
                        @"help:          to see the list of commands.
go direction:  to go in that direction.
attack:        to attack all the enemies in the room.
enemies:       to show the enemies in the current room.
info:          to see the information about the room.
stats:         to see the player stats.
refresh:       cleans the screen.
commands file: read from file a sequence of instructions.
save file:     save progress in file.
menu:          goes back to the Main menu.
quit:          to exit the program.

");
                    break;

                case "commands":
                    ReadCommands(entrada[1], m, p, ref rec);
                    break;

                case "save":
                    SaveGame(entrada[1], rec);
                    break;

                case "refresh":
                    Console.Clear();
                    break;

                default:
                    Console.WriteLine("Input introducido no valido.\nEscriba help para ver los posibles comandos.\n");
                    break;
                }
            }
            catch
            {
                Console.WriteLine("Input introducido no valido.\nEscriba help para ver los posibles comandos.\n");
            }
        }
示例#5
0
 /// <summary>
 /// Devuelve un string con la informacion de la dungeon index del mapa m
 /// </summary>
 /// <param name="m"></param>
 /// <param name="index"></param>
 /// <returns></returns>
 static string PrintDungeon(Map m, int index)
 {
     return("dungeon" + index + ": " + m.GetDungeonInfo(index) + "\n" + m.GetMoves(index) + "\n");
 }