Example #1
0
        public Fighter pvpMenus(Fighter player)
        {
            while (true)
            {
                Console.WriteLine($"{player.name}, Would you like to make a new fighter or try an exisiting one?");
                var useExsistingdData = new Menu();
                useExsistingdData.options = new[] { "Make New Fighter", "Browse exsisting Fighters" };

                useExsistingdData.Render();


                if (useExsistingdData.getSelected() == 0)
                {
                    player.Create();
                    break;
                }


                var playerFighter = player.Load(player);
                Console.Clear();
                Console.WriteLine($"You've accepted: {player.name}!");
                return(playerFighter);



                //exit fighter selection
            }

            return(player);
        }
Example #2
0
        public Fighter Load(Fighter player)
        {
            while (true)
            {
                Console.WriteLine("Please chose any of the listed fighters below:");
                var           selectFighter = new Menu();
                DirectoryInfo d             = new DirectoryInfo("attacks"); //Folder to search
                FileInfo[]    Files         = d.GetFiles("*.json");         //Getting fighters
                var           FilesMenu     = new List <String>();
                foreach (var fileData in Files)
                {
                    FilesMenu.Add(fileData.Name);
                }

                FilesMenu.Add("Create new Fighter!");
                selectFighter.options = FilesMenu.ToArray();

                selectFighter.Render();
                if (selectFighter.getSelected() !=
                    Array.LastIndexOf(selectFighter.options, "Create new Fighter!"))
                {
                    player.name = selectFighter.options[selectFighter.getSelected()];
                    player.name = player.name.Replace(".json", "");
                    var jsonLoad = File.ReadAllText($"attacks/{selectFighter.options[selectFighter.getSelected()]}");
                    player.attacks = JsonSerializer.Deserialize <List <Attack> >(jsonLoad);
                    Console.Clear();

                    Console.WriteLine($"Fighter {player.name}, Loaded Successfully!");
                    Console.SetCursorPosition(10, 5);
                    Console.WriteLine("Following attacks have been applied:");
                    Console.SetCursorPosition(10, 6);
                    Console.WriteLine($"{player.attacks[0].attack} ({player.attacks[0].effect})");
                    Console.SetCursorPosition(10, 7);
                    Console.WriteLine($"{player.attacks[1].attack} ({player.attacks[1].effect})");
                    Console.SetCursorPosition(10, 8);
                    Console.WriteLine($"{player.attacks[2].attack} ({player.attacks[2].effect})");
                    Console.SetCursorPosition(10, 9);
                    Console.WriteLine($"{player.attacks[3].attack} ({player.attacks[3].effect})");
                    Console.WriteLine("");
                    if (selectFighter.comfirm("you would like to use this fighter"))
                    {
                        Console.Clear();
                        Console.WriteLine($"You've accepted: {player.name}!");
                        return(player);
                    }
                    player = Load(player);
                    return(player);
                }

                player = player.Create();
                return(player);
            }
        }
        static void Main(string[] args)
        {
            string fighter = "";


            List <Fighter> list = new List <Fighter>();

            Console.WriteLine("");
            Console.WriteLine("Welcome to text based Battle Royal!");
            Console.WriteLine("");
            Console.WriteLine("Please select game mode using the arrow keys. (Select with enter):");


            // adds the main menue for game mode
            var mode = new Menu();

            mode.options = new[] { "Solo VS AI", "Player VS Player" };


            mode.Render();



            if (mode.getSelected() == 0)
            {
                Console.Clear();
                Console.WriteLine("You selected 'Solo VS AI'");
                var player = new Fighter();
                var foe    = new Fighter();


                Console.WriteLine("Would you like to make a new fighter or try an exisiting one?");
                var useExsistingdData = new Menu();
                useExsistingdData.options = new[] { "Make New Fighter", "Browse exsisting Fighters" };

                useExsistingdData.Render();


                if (useExsistingdData.getSelected() == 0)
                {
                    player = player.Create();
                }

                if (useExsistingdData.getSelected() == 1)
                {
                    player = player.Load(player);
                }

                // AI opponent mode
                Console.WriteLine("Would you like to have a random AI selected, or choose your own?");

                var aiType = new Menu();
                aiType.options = new[]
                {
                    "Generate Random AI",
                    "Let me pick AI manualy"
                };
                aiType.Render();

                if (aiType.getSelected() == 0)
                {
                    foe = foe.LoadRandom(aiType, foe, player);
                }

                if (aiType.getSelected() == 1)
                {
                    foe = foe.Load(foe);
                }



                // Launch the game Player VS AI
                var match = new Game(player, foe);
                gameInstance = match;
                match.play(player, foe, "1P");


                while (true)
                {
                    var rematch = new Menu();
                    rematch.options = new[] { "Rematch", "Quit" };

                    Console.WriteLine("Would you like a rematch?");

                    rematch.Render();

                    if (rematch.getSelected() == 1)
                    {
                        break;
                    }

                    player.fighterStatus = null;
                    foe.fighterStatus    = null;
                    match.play(player, foe, "1P");
                }
            } // closes "Selected AI"

            if (mode.getSelected() == 1)
            {
                Console.Clear();
                Console.WriteLine("You selected 'Player VS Player'");
                Console.WriteLine();
                var player1 = new Fighter();
                player1.name = "player1";
                player1      = player1.pvpMenus(player1);
                var player2 = new Fighter();
                player2.name = "player2";
                player2      = player2.pvpMenus(player2);


                var match = new Game(player1, player2);
                gameInstance = match;
                match.play(player1, player2, "2P");

                while (true)
                {
                    var rematch = new Menu();
                    rematch.options = new[] { "Rematch", "Quit" };

                    Console.WriteLine("Would you like a rematch?");

                    rematch.Render();

                    if (rematch.getSelected() == 1)
                    {
                        break;
                    }

                    player1.fighterStatus = null;
                    player2.fighterStatus = null;
                    match.play(player1, player2, "2P");
                }
            }
        }