コード例 #1
0
        //constructor, sets the game as the default difficulty (Easy)
        public GameManager(string playerName, bool readFromFile, Difficulty difficulty = default)
        {
            //create a player with the name provided(parameter)
            GamePlayer = new Player(playerName);

            //check if it should use the data in the txt file
            if (readFromFile)
            {
                ReadFromFile();
                //set the difficulty
                GameDifficulty = difficulty;
            }
            //default wordbank
            else
            {
                //Init the Default WordBank
                WordGenerator.InitDefaultWordBank();
                //set the difficulty to the given parameter only if the default word bank can support the difficulty
                if ((byte)difficulty <= WordGenerator.NumberOfDefaultLevels)
                {
                    GameDifficulty = difficulty;
                }
                //if can't then default
                else
                {
                    GameDifficulty = default;
                }
            }

            //generate a new word based on the difficulty
            WordToGuess = WordGenerator.Generate(GameDifficulty);
            //set the hangman status to 0
            HangedManStatus = 0;
            //activate the game (flag)
            IsGameActive = true;
        }
コード例 #2
0
 public static void UseDefaultWordBank()
 {
     WordGenerator.InitDefaultWordBank();
 }