예제 #1
0
        private void UpdateConsole()
        {
            char[,] updatedScreen  = new char[gameHeight, gameWidth];
            char[,] updatedHangMan = man.GetHangMan();

            for (int i = 0; i < screenPhrases[0].Length; i++)
            {
                updatedScreen[8, i] = screenPhrases[0][i];
            }
            for (int i = 0; i < screenPhrases[1].Length; i++)
            {
                updatedScreen[14, i] = screenPhrases[1][i];
            }

            for (int i = 0; i < 7; i++) //display the hangmans noose and current hangman
            {
                for (int j = 0; j < 7; j++)
                {
                    updatedScreen[i, j] = updatedHangMan[i, j];
                }
            }

            //add in the current phrase
            for (int i = 0; i < displayPhrase.Length; i++)
            {
                updatedScreen[12, i] = displayPhrase[i];
            }
            for (int i = 0; i < gameWidth; i++)
            {
                updatedScreen[15, i] = ' ';
            }
            for (int i = 0; i < letterGuesses.Count; i++)
            {
                updatedScreen[15, i * 2 + 1] = letterGuesses[i];
            }

            //Inform if the letter was already guessed
            if (alreadyGuessed)
            {
                for (int i = 0; i < screenPhrases[2].Length; i++)
                {
                    updatedScreen[17, i] = screenPhrases[2][i];
                }
            }

            //if the game is over let them know if they won or lost, and ask about playing again
            if (youWon || youLost)
            {
                if (youLost)
                {
                    for (int i = 0; i < screenPhrases[3].Length; i++)
                    {
                        updatedScreen[2, i + 10] = screenPhrases[3][i];
                    }
                }
                else
                {
                    for (int i = 0; i < screenPhrases[4].Length; i++)
                    {
                        updatedScreen[2, i + 10] = screenPhrases[4][i];
                    }
                }
                for (int i = 0; i < screenPhrases[5].Length; i++)
                {
                    updatedScreen[3, i + 10] = screenPhrases[5][i];
                }
            }

            gameScreen.ConsoleUpdate(updatedScreen);
        }