Esempio n. 1
0
 public static void UpdateTrivia()
 {
     if (!EnteredTrivia && WumpusGame.TriviaState == TriviaState.NotAnswered)
     {
         CurrentTrivia = TriviaList.GetTrivia();
         EnteredTrivia = true;
         WumpusGame.TriviaState = TriviaState.NotAnswered;
     }
     if (WumpusGame.KeyboardState.IsKeyDown(Keys.A) && WumpusGame.OldKeyboardState.IsKeyUp(Keys.A))
     {
         if (CurrentTrivia.CorrectAnswer == 1)
         {
             EnteredTrivia = false;
             TriviaWinCounter++;
             WumpusGame.TriviaState = TriviaState.Correct;
         }
         else
         {
             EnteredTrivia = false;
             WumpusGame.TriviaState = TriviaState.Incorrect;
         }
     }
     if (WumpusGame.KeyboardState.IsKeyDown(Keys.B) && WumpusGame.OldKeyboardState.IsKeyUp(Keys.B))
     {
         if (CurrentTrivia.CorrectAnswer == 2)
         {
             EnteredTrivia = false;
             TriviaWinCounter++;
             WumpusGame.TriviaState = TriviaState.Correct;
         }
         else
         {
             EnteredTrivia = false;
             WumpusGame.TriviaState = TriviaState.Incorrect;
         }
     }
     if (WumpusGame.KeyboardState.IsKeyDown(Keys.C) && WumpusGame.OldKeyboardState.IsKeyUp(Keys.C))
     {
         if (CurrentTrivia.CorrectAnswer == 3)
         {
             EnteredTrivia = false;
             TriviaWinCounter++;
             WumpusGame.TriviaState = TriviaState.Correct;
         }
         else
         {
             EnteredTrivia = false;
             WumpusGame.TriviaState = TriviaState.Incorrect;
         }
     }
     if (WumpusGame.KeyboardState.IsKeyDown(Keys.D) && WumpusGame.OldKeyboardState.IsKeyUp(Keys.D))
     {
         if (CurrentTrivia.CorrectAnswer == 4)
         {
             EnteredTrivia = false;
             TriviaWinCounter++;
             WumpusGame.TriviaState = TriviaState.Correct;
         }
         else
         {
             EnteredTrivia = false;
             WumpusGame.TriviaState = TriviaState.Incorrect;
         }
     }
     //If the question has been answered
     if (WumpusGame.TriviaState != TriviaState.NotAnswered)
     {
         if (WumpusGame.MouseState.LeftButton == ButtonState.Pressed && WumpusGame.OldMouseState.LeftButton == ButtonState.Released)
         {
             WumpusGame.GameState = GameState.Cave;
         }
     }
 }
Esempio n. 2
0
        private static void ReadFromFile()
        {
            StreamReader streamReader = new StreamReader("Content/Text Files/TriviaList.txt");

            string line;

            while (true)
            {
                line = streamReader.ReadLine();
                if (line == null)
                    break;
                string[] data = line.Split(',');
                string question = data[0];
                int position = 1;
                List<string> answers = new List<string>();
                while (position <= data.Length - 2)
                {
                    answers.Add(data[position]);
                    position++;
                }
                int correctAnswer = int.Parse(data[data.Length - 1]);
                Trivia trivia = new Trivia(data[0], answers.ToArray(), correctAnswer);
                TriviaQuestions.Add(trivia);
            }
            streamReader.Close();
        }