Exemplo n.º 1
0
        static void LoadSavedGames()
        {
            DrawGFX.SetDrawPosition(0, 1);
            Console.WriteLine("Load Game");
            if (Data.ShowAllSession().Count() == 0)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("OBS, There is no game session available \n");
                Console.ResetColor();
            }
            else
            {
                DrawGFX.ClearDrawContent(0, 1);

                List <string> sessionOption = Data.ShowAllSession();
                int           loadOption    = CreateInteractable.OptionMenu(false, sessionOption, 0, 2);
                string        sessionName   = sessionOption[loadOption];
                var           SessionData   = Data.LoadGame(sessionName);

                GameBoard gb = new GameBoard(new GameSession(), false);
                gb.SessionName = sessionName;
                List <string> playerAmount = new List <string>();

                var playerData = SessionData
                                 .GroupBy(x => new { x.PlayerName, x.PlayerID, x.Color })
                                 .Select(x => x.ToList()).ToList();

                DrawGFX.SetDrawPosition(0, 4);
                for (int i = 0; i < playerData.Count; i++)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("ID: {0} Name: {1} Color: {2}", playerData[i][i].PlayerID, playerData[i][i].PlayerName, playerData[i][i].Color);
                    Console.ResetColor();
                    playerAmount.Add(playerData[i][i].PlayerName);
                    gb.GamePlayers.Add(new GamePlayer(id: playerData[i][i].PlayerID, name: playerData[i][i].PlayerName, color: playerData[i][i].Color));

                    for (int j = 0; j < 4; j++)
                    {
                        gb.GamePlayers[i].Pieces[j].CurrentPos = SessionData[j].Position;
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine("Piece ID: {0} Position: {1} ", SessionData[j].PieceID, SessionData[j].Position);
                        Console.ResetColor();
                    }
                }

                DrawGFX.SetDrawPosition(0, 2);
                Console.WriteLine("Show loaded gamedata. Game Starts soon. Be ready");
                Thread.Sleep(5000);
                Console.Clear();
                gb.GamePlayerAmnt = playerAmount.Count();
                gb.GameLoop();
            }

            BackButton();
            ReturnToMenu();
        }
Exemplo n.º 2
0
        public static void Display()
        {
            DrawGFX.SetDrawPosition(0, 0);
            Console.WriteLine("Welcome to LudoFrenzy".ToUpper());

            int selected = CreateInteractable.OptionMenu(false, options, 0, 2);

            switch (selected)
            {
            case 0:
                IGameSession gs = new GameSession().
                                  InintializeSession().
                                  SetSessionName().
                                  SetPlayerAmount().
                                  SetSessionData().
                                  SaveState().
                                  StartGame();

                GameBoard gb = new GameBoard(gs, true);
                gb.GameLoop();

                break;

            case 1:
                DisplayHighScore();
                break;

            case 2:
                LoadSavedGames();
                break;

            case 3:
                Environment.Exit(0);
                break;
            }
        }