Beispiel #1
0
        private void submitAnswer()
        {
            textBox2.SelectAll();
            // lame-o Easter egg
            if (isCorrectAnswer(textBox2.Text, "Greg is cool"))
            {
                yep.Play();
                textBox3.Text = "You betcha";
                return;
            }
            if (isCorrectAnswer(textBox2.Text, "Hi Greg") || isCorrectAnswer(textBox2.Text, "Hi, Greg"))
            {
                yep.Play();
                textBox3.Text = "Hi";
                return;
            }
            bool correct = false;

            if (currentQuestionElement1 && isCorrectAnswer(textBox2.Text, entryList[currentEntryIndex].getElementTwo()))
                    correct = true;
            else if (!currentQuestionElement1 && isCorrectAnswer(textBox2.Text, entryList[currentEntryIndex].getElementOne()))
                    correct = true;

            if (correct)
            {
                yep.Stop();
                nope.Stop();
                yep.Play();
                textBox3.Text = "That is correct";
                points += 40;
                numCorrect++;
                educationalIndex2 = -1;
            }
            else
            {
                yep.Stop();
                nope.Stop();
                nope.Play();
                if (currentQuestionElement1)
                {
                    textBox3.Text = "Nice try.  The correct answer is\r\n" + entryList[currentEntryIndex].getElementTwo()[0];
                }
                else //current question is element2
                {
                    textBox3.Text = "Nice try.  The correct answer is\r\n" + entryList[currentEntryIndex].getElementOne()[0];
                }
                points -= 10;

                if (playWithPoints && points < 0)
                {

                    points = 0;
                    if (!timer1.Enabled)
                    {
                        button2.Text = ":(";
                        button2.Update();
                        textBox3.Update();
                        Splash gameOverScreen = new Splash();
                        gameOverScreen.BackgroundImage = Image.FromFile("zsrc\\gameover.jpg");
                        gameOverScreen.Width = gameOverScreen.BackgroundImage.Width;
                        gameOverScreen.Height = gameOverScreen.BackgroundImage.Height;
                        gameOverScreen.timer1.Interval = 1500;
                        gameOverScreen.Show();
                        Thread.Sleep(1500);
                    }
                }
                numIncorrect++;
                educationalIndex2 = currentEntryIndex;
                if (!incorrectEntryIndexes.Contains(currentEntryIndex))
                {
                    incorrectEntryIndexes.Add(currentEntryIndex);
                }
            }

            if (playWithPoints)
            {
                button2.Text = points.ToString();
            }

            generateNextEntry();
        }
Beispiel #2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            countdown--;
            if (countdown <= 0)
            {
                bool awarded = false;
                for (int i = yay.Count - 1; i >= 0; i--)
                {
                    if (points >= 50 * (i+1))
                    {
                        Splash award = new Splash();
                        try
                        {
                            Image img = Image.FromFile("zsrc\\yay" + (i+1) + ".jpg");
                            award.BackgroundImage = img;
                            award.Height = img.Height;
                            award.Width = img.Width;
                            award.timer1.Interval = 4000;
                            award.Show();
                            award.PlaySound(yay[i]);
                            awarded = true;
                            break;
                        }
                        catch (FileNotFoundException) {  }
                    }
                }
                if(awarded == false)
                {
                    try
                    {
                        Splash emptySplash = new Splash();
                        Image img = Image.FromFile("zsrc\\gameover.jpg");
                        emptySplash.BackgroundImage = img;
                        emptySplash.Width = img.Width;
                        emptySplash.Height = img.Height;
                        emptySplash.timer1.Interval = 1000;
                        emptySplash.Show();
                        emptySplash.PlaySound(ding);

                    }
                    catch (FileNotFoundException) { }
                }
                button3.Text = "Start Timed Game";
                timer1.Enabled = false;

                checkBox1.Enabled = true;
                checkBox2.Enabled = true;
                checkBox3.Enabled = true;
                if (hsFilePath != null)
                {
                    bool refreshHighScores = false;
                    if (!File.Exists(hsFilePath))
                    {
                        File.Create(hsFilePath).Close();
                    }
                    TextReader tr = new StreamReader(hsFilePath);
                    string line;
                    List<string> highscores = new List<string>();
                    line = tr.ReadLine();
                    while (line != null)
                    {
                        highscores.Add(line);
                        line = tr.ReadLine();
                    }
                    tr.Close();
                    foreach (string s in highscores)
                    {
                        if (this.points > Convert.ToInt32(s.Substring(s.LastIndexOf('=') + 1)))
                        {
                            refreshHighScores = true;
                        }
                    }
                    if (highscores.Count < 5 && refreshHighScores == false)
                    {
                        refreshHighScores = true;
                    }
                    if (refreshHighScores)
                    {
                        hs.Show();
                    }
                }
            }
            else
            {
                button3.Text = countdown.ToString();
            }
        }
Beispiel #3
0
 private void Form1_Load(object sender, EventArgs e)
 {
     Splash splash = new Splash();
     splash.Show();
 }