//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(); }
//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; }