Ejemplo n.º 1
0
 private void buttonTimed_Click(object sender, EventArgs e)
 {
     if (gameRunning == null)
     {
         settings = SettingsSystem.GetSettings();
         TimeSpan span = (DateTime.Now - settings.lastTry);
         if (settings.waitToPlay < span)
         {
             timerTimedGame.Interval = (int)settings.timedGame.TotalMilliseconds;
             Game game = (Game)listBoxGames.SelectedItem;
             if (game == null)
             {
                 return;
             }
             listBoxGames.Enabled   = false;
             gameRunning            = game.CheckOut();
             timerCheckOut.Enabled  = true;
             timerTimedGame.Enabled = true;
             label1.Visible         = true;
             label2.Visible         = true;
             progressBar1.Visible   = true;
         }
         else
         {
             TimeSpan sp = (settings.waitToPlay - (DateTime.Now - settings.lastTry));
             MessageBox.Show("You must wait at least " + span.Hours + ":" + span.Minutes + ":" + span.Seconds + " before you can play again");
         }
     }
 }
Ejemplo n.º 2
0
        private void buttonPlay_Click(object sender, EventArgs e)
        {
            //run the improbability drive
            imProbabilityDrive drive = new imProbabilityDrive();
            Random             rand  = new Random();
            TimeSpan           span;

            if (gameRunning == null)
            {
                span = DateTime.Now - settings.lastTry;
                if (settings.waitToPlay <= span)
                {
                    if (drive.ShowDialog() == DialogResult.OK)
                    {
                        if (drive.numericUpDownPicker.Value == rand.Next(settings.probability + 1))
                        {
                            settings.lastTry = DateTime.Now;
                            settings         = SettingsSystem.GetSettings();
                            Game game = (Game)listBoxGames.SelectedItem;
                            if (game == null)
                            {
                                return;
                            }
                            listBoxGames.Enabled  = false;
                            gameRunning           = game.CheckOut();
                            timerCheckOut.Enabled = true;
                        }
                        else
                        {
                            span = settings.incorrectWait;
                            MessageBox.Show("You have guessed incorrectly, you must wait " + span.Hours + ":" + span.Minutes + ":" + span.Seconds + " before trying again", "oops");
                        }
                    }
                }
                else
                {
                    span = settings.waitToPlay - (DateTime.Now - settings.lastTry);
                    MessageBox.Show("Sorry, but you must wait at least " + span.Hours + ":" + span.Minutes + ":" + span.Seconds + " to try playing again", "Oops");
                }
            }
        }
Ejemplo n.º 3
0
 private void timerCheckOut_Tick(object sender, EventArgs e)
 {
     if (!gameRunning.hasExited())
     {
         //game is still running
         refreshRunning();
     }
     //on game exit, reset
     else
     {
         if (gameRunning.checkedout)
         {
             gameRunning.CheckIn(false);
         }
         timerCheckOut.Enabled = false;
         refreshList();
         listBoxGames.Enabled   = true;
         gameRunning            = null;
         timerTimedGame.Enabled = false;
         progressBar1.Visible   = false;
         label2.Visible         = false;
         label1.Visible         = false;
     }
 }
Ejemplo n.º 4
0
 private void buttonTimed_Click(object sender, EventArgs e)
 {
     if (gameRunning == null)
     {
         settings = SettingsSystem.GetSettings();
         TimeSpan span = (DateTime.Now - settings.lastTry);
         if (settings.waitToPlay < span)
         {
             timerTimedGame.Interval = (int)settings.timedGame.TotalMilliseconds;
             Game game = (Game)listBoxGames.SelectedItem;
             if (game == null)
             {
                 return;
             }
             listBoxGames.Enabled = false;
             gameRunning = game.CheckOut();
             timerCheckOut.Enabled = true;
             timerTimedGame.Enabled = true;
             label1.Visible = true;
             label2.Visible = true;
             progressBar1.Visible = true;
         }
         else
         {
             TimeSpan sp = (settings.waitToPlay - (DateTime.Now - settings.lastTry));
             MessageBox.Show("You must wait at least " + span.Hours + ":" + span.Minutes + ":" + span.Seconds + " before you can play again");
         }
     }
 }
Ejemplo n.º 5
0
 private void timerCheckOut_Tick(object sender, EventArgs e)
 {
     if (!gameRunning.hasExited())
     {
         //game is still running
         refreshRunning();
     }
     //on game exit, reset
     else
     {
         if (gameRunning.checkedout)
             gameRunning.CheckIn(false);
         timerCheckOut.Enabled = false;
         refreshList();
         listBoxGames.Enabled = true;
         gameRunning = null;
         timerTimedGame.Enabled = false;
         progressBar1.Visible = false;
         label2.Visible = false;
         label1.Visible = false;
     }
 }
Ejemplo n.º 6
0
 private void buttonPlay_Click(object sender, EventArgs e)
 {
     //run the improbability drive
     imProbabilityDrive drive = new imProbabilityDrive();
     Random rand = new Random();
     TimeSpan span;
     if (gameRunning == null)
     {
         span = DateTime.Now - settings.lastTry;
         if (settings.waitToPlay <= span)
         {
             if (drive.ShowDialog() == DialogResult.OK)
             {
                 if (drive.numericUpDownPicker.Value == rand.Next(settings.probability + 1))
                 {
                     settings.lastTry = DateTime.Now;
                     settings = SettingsSystem.GetSettings();
                     Game game = (Game)listBoxGames.SelectedItem;
                     if (game == null)
                     {
                         return;
                     }
                     listBoxGames.Enabled = false;
                     gameRunning = game.CheckOut();
                     timerCheckOut.Enabled = true;
                 }
                 else
                 {
                     span = settings.incorrectWait;
                     MessageBox.Show("You have guessed incorrectly, you must wait " + span.Hours + ":" + span.Minutes + ":" + span.Seconds + " before trying again", "oops");
                 }
             }
         }
         else
         {
             span = settings.waitToPlay - (DateTime.Now - settings.lastTry);
             MessageBox.Show("Sorry, but you must wait at least " + span.Hours + ":" + span.Minutes + ":" + span.Seconds + " to try playing again", "Oops");
         }
     }
 }