Ejemplo n.º 1
0
        private void InitializePlayers(InitialGameSetting i_NameSettings)
        {
            m_Player1.InitializePlayer(i_NameSettings.player1Name, Checkers_LogicAndDataSection.ePlayerOptions.Player1);
            switch (Checkers_LogicAndDataSection.SessionData.gameType)
            {
            case Checkers_LogicAndDataSection.eTypeOfGame.singlePlayer:
                m_Player2.InitializePlayer("PC", Checkers_LogicAndDataSection.ePlayerOptions.ComputerPlayer);
                break;

            case Checkers_LogicAndDataSection.eTypeOfGame.doublePlayer:
                m_Player2.InitializePlayer(i_NameSettings.player2Name, Checkers_LogicAndDataSection.ePlayerOptions.Player2);
                break;
            }
        }
Ejemplo n.º 2
0
 private void setup(out InitialGameSetting o_Settings)
 {
     o_Settings = new InitialGameSetting();
     o_Settings.SetGameSettings("Ori", "Amir", eBoardSizeOptions.SmallBoard, eTypeOfGame.singlePlayer);
 }
Ejemplo n.º 3
0
 private void InitializeAnotherGame(InitialGameSetting o_GameDemoSettings)
 {
     SessionData.m_CurrentActivePlayer = ePlayerOptions.Player1;
     SessionData.InitializePlayers(o_GameDemoSettings);
     m_CheckersBoard.InitializeCheckersBoard();
 }
Ejemplo n.º 4
0
        public static void ReadGameInitialInputFromUser(out InitialGameSetting io_GameInitialValues)
        {
            string userInputValue;
            string tempPlayer1NameHolder = string.Empty;
            string tempPlayer2NameHolder = string.Empty;

            bool[]            inputValidityArray = new bool[k_NumberOfInputValues]; // holds true/false for each input value in this order: player1name, player2name, boardSize, gameType
            bool              gotAllInput        = false;
            eBoardSizeOptions chosenBoardSize    = eBoardSizeOptions.Undefined;
            eTypeOfGame       chosenGameType     = eTypeOfGame.Undefined;

            Console.WriteLine(s_StartMessage);
            while (!gotAllInput)
            {
                while (!inputValidityArray[k_PlayerXName])
                {
                    Console.WriteLine(s_UsernameMessage);
                    userInputValue = Console.ReadLine();
                    if (checkUsernameValidity(userInputValue))
                    {
                        inputValidityArray[k_PlayerXName] = true;
                        tempPlayer1NameHolder             = userInputValue;
                    }
                    else
                    {
                        Console.WriteLine(s_InvalidInputMessage);
                    }
                }

                Ex02.ConsoleUtils.Screen.Clear();
                while (!inputValidityArray[k_BoardSize])
                {
                    Console.WriteLine(s_ChooseBoardSizeMessage);
                    userInputValue = Console.ReadLine();
                    if (checkBoardSizeValidity(userInputValue))
                    {
                        inputValidityArray[k_BoardSize] = true;
                        chosenBoardSize = (eBoardSizeOptions)Enum.Parse(typeof(eBoardSizeOptions), userInputValue);
                    }
                    else
                    {
                        Console.WriteLine(s_InvalidInputMessage);
                    }
                }

                Ex02.ConsoleUtils.Screen.Clear();
                while (!inputValidityArray[k_GameType])
                {
                    Console.WriteLine(s_ChooseGameTypeMessge);
                    userInputValue = Console.ReadLine();
                    if (checkGameTypeValidity(userInputValue))
                    {
                        inputValidityArray[k_GameType] = true;
                        chosenGameType = (eTypeOfGame)Enum.Parse(typeof(eTypeOfGame), userInputValue);
                        Ex02.ConsoleUtils.Screen.Clear();
                        if (chosenGameType == eTypeOfGame.doublePlayer)
                        {
                            while (!inputValidityArray[k_PlayerOName])
                            {
                                Console.Write("{0}, ", ePlayerOptions.Player2.ToString());
                                Console.WriteLine(s_UsernameMessage);
                                userInputValue = Console.ReadLine();
                                if (checkUsernameValidity(userInputValue))
                                {
                                    inputValidityArray[k_PlayerOName] = true;
                                    tempPlayer2NameHolder             = userInputValue;
                                }
                                else
                                {
                                    Console.WriteLine(s_InvalidInputMessage);
                                }
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine(s_InvalidInputMessage);
                    }
                }

                Ex02.ConsoleUtils.Screen.Clear();
                gotAllInput = true;
            }

            io_GameInitialValues = new InitialGameSetting();
            io_GameInitialValues.SetGameSettings(tempPlayer1NameHolder, tempPlayer2NameHolder, chosenBoardSize, chosenGameType);
        }