コード例 #1
0
        private void CheckGameStatus()
        {
            string eaten    = farmer.AnimalAteFood();
            bool   gameOver = false;

            if (farmer.DetermineWin())
            {
                MessageBox.Show("Congratulations! You win!");
                synth.Speak("I am so impressed! Only the top 10% of the most elite farmers are able to operate a farm this smoothly. And you did it all without a tractor. Good work!");
                gameOver = true;
            }
            else if (eaten == "FoxAteChicken")
            {
                MessageBox.Show("The FOX ate the CHICKEN!");
                synth.Speak("Oh no! That chicken has been murdered by the brutal fox.");
                gameOver = true;
            }

            else if (eaten == "ChickenAteGrain")
            {
                MessageBox.Show("The CHICKEN ate the GRAIN!");
                synth.Speak("That's not good! The grain is dead! The chicken murdered it in cold blood.");
                gameOver = true;
            }
            if (gameOver)
            {
                btnMove.Visible  = false;
                btnReset.Visible = true;
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: progdawn/CSharp-Farmer-Game
        public void ProcessChoice(string choice)
        {
            theGame.Move(choice);

            if (theGame.AnimalAteFood() == false)
            {
                bool userWon = theGame.DetermineWin();

                if (userWon == true)
                {
                    MessageBox.Show("YOU WON!");
                }
            }
            else
            {
                MessageBox.Show("GAME OVER!");
                ResetLocations();
            }
        }