Example #1
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            // test, zda je uživatelem napsaný text číslo
            int result;

            try
            {
                result = Convert.ToInt32(textBox.Text);
            }
            catch
            {
                new SoundPlayer(@"Zvuky/chybně zadané číslo.wav").Play();
                return;
            }

            // správný výsledek
            if (result == _currentExample.Result)
            {
                new SoundPlayer(@"Zvuky/správně.wav").Play();
                pictureBoxMonster.ImageLocation = _image2Location;
                MessageBox.Show("Super! Paráda! Máš to správně.");
                pictureBoxMonster.ImageLocation = _image1Location;
                if (_currentMonster != null)
                {
                    _currentMonster.OnSuccess();
                }
                new SoundPlayer(@"Zvuky/cinkot peněz.wav").Play();

                IncreaseMoney(_currentExample.SuccessPrice);
                SaveSettings();
            }
            // špatný výsledek
            else
            {
                new SoundPlayer(@"Zvuky/špatně.wav").Play();
                MessageBox.Show($"Ale néé, máš to blbě, správný výsledek je {_currentExample.Result}.");
                if (_currentMonster != null)
                {
                    _currentMonster.OnFail();
                }
                new SoundPlayer(@"Zvuky/odebrání peněz.wav").Play();

                DecreaseMoney(_currentExample.FailPrice);
                SaveSettings();
            }

            CreateNewExample();
        }