Esempio n. 1
0
        public CardsAndText()
        {
            InitializeComponent();

            WindowState = FormWindowState.Maximized;

            Card.loadCards();

            question = new Questions.FindPictureFromWord(rand);
            mode = Mode.Guessing;
            font = new Font(Font.FontFamily.Name, 24, FontStyle.Bold);
            brush = new SolidBrush(Color.Black);
            correct = new System.Media.SoundPlayer(Audio.Audio.ShootingStar);
            incorrect = new System.Media.SoundPlayer(Audio.Audio.Error);
        }
Esempio n. 2
0
        public static Question GetNext(Random Random)
        {
            Question[] qs = new Question[10];

            double aimFor = (Kiddy.CurrentPlayer.CurrentLevel + Random.NextDouble() * 4 - 2) / 10;

            #region Find 10 random questions to go with next
            for (int i = 0; i < qs.Length; i++)
            {
                switch (Random.Next(4))
                {
                    case 1:
                        qs[i]= new Questions.FindPictureFromPhrase(Random);
                        break;
                    case 2:
                        qs[i] = new Questions.FindSizedPicture(Random);
                        break;
                    case 3:
                        qs[i] = new Questions.FindFromGroup(Random);
                        break;
                    case 0:
                    default:
                        qs[i] = new Questions.FindPictureFromWord(Random);
                        break;
                }
            }
            #endregion

            Question retVal = qs[0];
            #region Determine question closest to the level to aim for
                for (int i = 1; i < qs.Length; i++)
                    if (Math.Abs(aimFor - qs[i].GetFinishedDifficulty()) < Math.Abs(aimFor-retVal.GetFinishedDifficulty()))
                        retVal = qs[i];
            #endregion

            return retVal;
        }
Esempio n. 3
0
 private void CardsAndText_MouseUp(object sender, MouseEventArgs e)
 {
     switch (mode)
     {
         #region While guessing
         case Mode.Guessing:
             // Determine which card was clicked in
             for (int i = 0; i < question.Cards.Length; i++)
                 if (e.X > question.Cards[i].X && e.X < question.Cards[i].X + question.Cards[i].Card.Image.Width &&
                     e.Y > question.Cards[i].Y && e.Y < question.Cards[i].Y + question.Cards[i].Card.Image.Height)
                     // Make sure it is the same as when the mouse went down
                     if (mouseDown == i)
                     {
                         // If the correct answer
                         if (i == question.AnswerCards[0])
                         {
                             // Guess was correct
                             mode = Mode.Correct;
                             // Play sound effect
                             correct.Play();
                             // Update players score
                             Kiddy.CurrentPlayer.CurrentLevel += 2*question.GetFinishedDifficulty();
                         }
                         else
                         {
                             // Guess was incorrect
                             mode = Mode.Incorrect;
                             // Play sound effect
                             incorrect.Play();
                             // Update players score
                             Kiddy.CurrentPlayer.CurrentLevel -= 4*question.GetFinishedDifficulty();
                         }
                         if (Kiddy.CurrentPlayer.CurrentLevel < 0)
                             Kiddy.CurrentPlayer.CurrentLevel = 0;
                         if (Kiddy.CurrentPlayer.CurrentLevel > 20)
                             Kiddy.CurrentPlayer.CurrentLevel = 20;
                         // Redraw the whole screen
                         Text = Kiddy.CurrentPlayer.CurrentLevel.ToString();
                         Invalidate();
                     }
             break;
         #endregion
         #region Correct/Incorrect screen
         case Mode.Correct:
         case Mode.Incorrect:
         default:
             // Move to next question
             question = Question.GetNext(rand);
             mode = Mode.Guessing;
             Invalidate();
             break;
         #endregion
     }
 }