public static void UserMove(string direction, Player player, List <Rooms> rooms)
        {
            Rooms room = GameOptions.MakeRoom(rooms, player.RoomID);



            string returnID = player.RoomID;

            switch (direction)
            {
            case "n":
                if (room.North == "N/A" && player.RoomID == "R3")
                {
                    Console.WriteLine("\nYou ran into the cash register...too bad it's empty.\n");
                }

                if (room.North == "N/A" && player.RoomID == "R5")
                {
                    Console.WriteLine("\nYou walked into the mayor's desk...\n");
                }



                player.RoomID = room.North;

                break;

            case "s":
                if (room.North == "N/A" && player.RoomID == "R3")
                {
                    Console.WriteLine("\nClean up on Aisle 1...\n");
                }
                if (room.North == "N/A" && player.RoomID == "R4")
                {
                    Console.WriteLine("\nPretty sure that's not chocolate...\n");
                }

                player.RoomID = room.South;
                break;

            case "e":
                if (room.East == "N/A" && player.RoomID == "R1")
                {
                    Console.WriteLine("\nYou walked into your wall...\n");
                }
                if (room.East == "N/A" && player.RoomID == "R4")
                {
                    Console.WriteLine("\nYou're a tough guy but that Alligator is tougher...\n");
                }
                if (room.East == "N/A" && player.RoomID == "R5")
                {
                    Console.WriteLine("\nNothing but trash bin.\n");
                }
                player.RoomID = room.East;
                break;

            case "w":
                if (room.West == "N/A" && player.RoomID == "R2")
                {
                    Console.WriteLine("\nThis is West street territory, even a tough S.O.B like you can't enter a made up territory.\n");
                }
                if (room.West == "N/A" && player.RoomID == "R5")
                {
                    Console.WriteLine("\nNothing but trash bin.\n");
                }

                player.RoomID = room.West;
                break;
            }

            if (player.RoomID == "R6")
            {
                //rooms.RemoveAt(6);
                player.RoomID = "R1";
            }

            if (player.RoomID == "R6")
            {
                player.RoomID = "N/A";
            }


            if (player.RoomID == "N/A")
            {
                Console.WriteLine("There is no exit this way");
                player.RoomID = returnID;
            }



            room = GameOptions.MakeRoom(rooms, player.RoomID);
            SearchCommands.ViewRoom(room.Name);
        }
Beispiel #2
0
        public static GameObjects LoadObjects(string name)
        {
            Player       player = Player.GetPlayer(" ", " ", Player.Classes.Brawler, Player.Body.Athletic, "R1");
            StreamReader inputFile;
            string       input   = " ";
            GameObjects  options = new GameObjects();

            if (name == " ")
            {
                Console.Write("\nEnter the player's name: ");
                input = Console.ReadLine();
                string inputFileName = input + ".save";
                string folder        = Environment.CurrentDirectory;
                try
                {
                    inputFile = File.OpenText($"{folder}/save/{input}/{inputFileName}");
                    string user     = inputFile.ReadLine();
                    string password = inputFile.ReadLine();
                    bool   run      = true;
                    int    i        = 0;
                    do
                    {
                        if (i == 3)
                        {
                            Console.WriteLine("\nToo many wrong passwords\n");
                            GameOptions.Startup();
                        }
                        Console.Write("\nEnter your password: "******"\nInvalid Password, Please try again\n");
                            i++;
                        }
                    }while (run == true);

                    input = inputFile.ReadLine();
                    Player.Classes userClass = Player.Classes.Brawler;
                    switch (input)
                    {
                    case "Brawler":
                        userClass = Player.Classes.Brawler;
                        break;

                    case "Martial Artist":
                        userClass = Player.Classes.MartialArtist;
                        break;

                    case "Soldier":
                        userClass = Player.Classes.Soldier;
                        break;
                    }
                    input = inputFile.ReadLine();
                    Player.Body type = Player.Body.Athletic;
                    switch (input)
                    {
                    case "Athletic":
                        type = Player.Body.Athletic;
                        break;

                    case "Body Builder":
                        type = Player.Body.BodyBuilder;
                        break;

                    case "Fat":
                        type = Player.Body.Fat;
                        break;

                    case "Skinny":
                        type = Player.Body.Skinny;
                        break;
                    }

                    player  = Player.GetPlayer(user, password, userClass, type, "R1");
                    options = GameObjects.GetObjects(LoadMobs(user), LoadRooms(user), LoadItems(user), LoadPotions(user), LoadTreasures(user), LoadWeapons(user), player);
                    inputFile.Close();
                    return(options);
                }
                catch (FileNotFoundException)
                {
                    Console.Write("\nFile not found\nWould you like to start a new game or exit?\n>");
                    input = Console.ReadLine();
                    switch (input.ToLower())
                    {
                    case "new game":
                        player = GameOptions.NewPlayer();
                        GameOptions.CreateUserOptions(player.Name);
                        options = LoadObjects(player.Name);
                        break;

                    default:
                        Environment.Exit(0);
                        break;
                    }
                }
            }


            return(options);
        }