public static void StartCombat(GameObjects options, string obj)
        {

            foreach (Mobs mob in options.Mobs)
            {
                if (obj.Contains(mob.Name.ToLower()))
                {
                    Mobs cloneMob = mob;

                    options = FightTarget(options, options.Player, mob);


                    if (mob.HP <= 0)
                    {
                        mob.HP = cloneMob.HP;
                        mob.RoomID = "R6";
                        mob.Cooldown = 3;
                    }
                }





            }
            if (options.Player.HP <= 0)
            {
                Console.WriteLine("Game Over");
                Console.ReadLine();
                Console.WriteLine("\n\n\n\n\n\n\n\n\n\n");
                GameOptions.Startup();
            }

        }
Esempio n. 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);
        }