Пример #1
0
 public Form2(Form1 form1)
 {
     sounds = new Sounds();
     sounds.playLetsStart();
     this.Game  = new Game();
     highScores = new HighScores();
     this.form1 = form1;
     InitializeComponent();
     getNewQuestion();
 }
Пример #2
0
        private void pickAnswer(object sender, EventArgs e)
        {
            sounds.playFinalAnswer();
            string            answer  = (sender as Label).Text;
            string            message = LabelTextConstants.Is + "'" + answer + "'" + LabelTextConstants.FinalAnswer;
            string            title   = LabelTextConstants.FinalDecision;
            MessageBoxButtons buttons = MessageBoxButtons.YesNo;
            DialogResult      result  = MessageBox.Show(message, title, buttons);

            if (result == DialogResult.Yes)
            {
                var pickedAnswer = answer.Substring(0, 1);
                if (Game.checkAnswer(currentQuestion.RightAnswer, pickedAnswer))
                {
                    sounds.playCorrectAnswer();
                    (sender as Label).ForeColor = Color.Lime;
                    var cash = Game.getCurrentCash();
                    changeCashLabel.Text = cash.ToString() + LabelTextConstants.Dollar;
                    title = LabelTextConstants.Congratulation + LabelTextConstants.exclamationMark;
                    if (currentQuestion.Number != 15)
                    {
                        message = LabelTextConstants.YouWon + cash + LabelTextConstants.Dollar +
                                  LabelTextConstants.exclamationMark + "\n" + LabelTextConstants.NextQuestion;

                        result = MessageBox.Show(message, title, buttons);

                        if (result == DialogResult.Yes)
                        {
                            changeCashLabel.Text = cash.ToString() + LabelTextConstants.Dollar;
                            if (currentQuestion.Number != 15)
                            {
                                Game.rightAnswer();
                                ((PictureBox)Controls.Find("question" + currentQuestion.Number + "Picture", true)[0]).Visible = false;
                                ((PictureBox)Controls.Find("question" + Game.questionCounter + "Picture", true)[0]).Visible   = true;
                                clearQuestion();
                                getNewQuestion();
                                sounds.playLetsStart();
                            }
                        }
                        else
                        {
                            title   = LabelTextConstants.YouGaveUp;
                            message = LabelTextConstants.YouWon + cash + LabelTextConstants.Dollar + LabelTextConstants.exclamationMark;
                            buttons = MessageBoxButtons.OK;
                            MessageBox.Show(message, title, buttons);
                            highScores.saveScore(form1.PlayerName, cash);
                            form1.Show();
                            this.Hide();
                            this.Dispose();
                        }
                    }
                    else
                    {
                        message = LabelTextConstants.YouWon + cash + LabelTextConstants.Dollar +
                                  LabelTextConstants.exclamationMark + "\n" + LabelTextConstants.Millionaire;
                        buttons = MessageBoxButtons.OK;
                        MessageBox.Show(message, title, buttons);
                        highScores.saveScore(form1.PlayerName, cash);
                        form1.Show();
                        this.Hide();
                        this.Dispose();
                        sounds.playIntro();
                    }
                }
                else
                {
                    sounds.playWrongAnswer();
                    (sender as Label).ForeColor = Color.Red;
                    ((Label)Controls.Find("Answer" + currentQuestion.RightAnswer, true)[0]).ForeColor = Color.Lime;
                    var cash = Game.playerGetsHowMuchCash(false);
                    changeCashLabel.Text = cash.ToString() + LabelTextConstants.Dollar;
                    title   = LabelTextConstants.WrongAnswer;
                    message = LabelTextConstants.YouWon + cash + LabelTextConstants.Dollar + LabelTextConstants.exclamationMark;
                    buttons = MessageBoxButtons.OK;
                    highScores.saveScore(form1.PlayerName, cash);
                    MessageBox.Show(message, title, buttons);
                    form1.Show();
                    this.Hide();
                    this.Dispose();
                    sounds.playIntro();
                }
            }
        }