コード例 #1
0
 //generate new word
 void NewWord()
 {
     //get new word from the generator
     WordToGuess = WordGenerator.Generate(GameDifficulty);
     //allways reset the hangman status when resetting the word
     HangedManStatus = 0;
     //allways reset the guesses when resetting the word
     GamePlayer.ResetPlayerGuesses();
 }
コード例 #2
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;
        }
コード例 #3
0
 public static void UseDefaultWordBank()
 {
     WordGenerator.InitDefaultWordBank();
 }
コード例 #4
0
 //Read from the words file
 void ReadFromFile()
 {
     //will throw an exception if cant read file correctly
     WordGenerator.OverrideWordBank(WordBankFromFile.GetWordBank());
 }