Exemplo n.º 1
0
        private void PerformChallenge(PrimeBox box)
        {
            for (int i = 0; i < pillars.Count(); i++)
            {
                pillars[i].Text = "";
            }

            keyword = "truongtrunghocphothongchuyenhanoiamsterdam";

            int minute = 2;

            droplets = box.GetSequence(keyword, minute);

            gameTimer.Interval = minute * 60000 / droplets.Count();
            timeBar.Minimum    = 0;
            timeBar.Maximum    = droplets.Count();
            timeBar.Value      = timeBar.Maximum;
            counter            = 0;

            gameTimer.Start();
            submitButton.Enabled = true;
            startButton.Enabled  = false;
            minBox.Enabled       = false;
            maxBox.Enabled       = false;
        }
Exemplo n.º 2
0
        private void startButton_Click(object sender, EventArgs e)
        {
            DialogResult dr = DialogResult.Yes;

            int minInt = int.Parse(minBox.Text);
            int maxInt = int.Parse(maxBox.Text);
            int bpm    = int.Parse(speedBox.Text);

            if (bpm < 6)
            {
                dr = MessageBox.Show("Speed lower than 6 is too slow for the challenge. Are you sure?", "Warning", MessageBoxButtons.YesNo);
            }

            if (bpm > 120)
            {
                dr = MessageBox.Show("Speed higher than 120 might be too fast for the challenge - this is not a rhythm game! Are you sure?", "Warning", MessageBoxButtons.YesNo);
            }

            if (dr.Equals(DialogResult.Yes))
            {
                PrimeBox box = new PrimeBox(minInt, maxInt, bpm);

                if (box.Primes == null)
                {
                    MessageBox.Show("Fatal error - the range does not contain enough primes - should be at least 26!", "Error");
                    return;
                }

                PerformChallenge(box);
            }
        }