Пример #1
0
        private bool HandleSecondTick()
        {
            _secondsRemaining--;
            if (_secondsRemaining > 0)
            {
                UpdateTimeLabel();
                return(true);
            }
            else
            {
                _playing        = false;
                _timeLabel.Text = "Game complete (saving results...)";
                using (var db = new GameContext()) {
                    db.Games.Add(new Game {
                        Clicks          = _clickCount,
                        Duration        = _gameDuration,
                        ClicksPerSecond = (double)_clickCount / _gameDuration,
                        Played          = DateTime.Now
                    });
                    db.SaveChanges();
                }
                _timeLabel.Text = "Game complete (results saved)";

                return(false);
            }
        }
Пример #2
0
        private bool HandleSecondTick()
        {
            _secondsRemaining--;
            if (_secondsRemaining > 0) {
                UpdateTimeLabel ();
                return true;
            } else {
                _playing = false;
                _timeLabel.Text = "Game complete (saving results...)";
                using (var db = new GameContext ()) {
                    db.Games.Add (new Game {
                        Clicks = _clickCount,
                        Duration = _gameDuration,
                        ClicksPerSecond = (double)_clickCount / _gameDuration,
                        Played = DateTime.Now
                    });
                    db.SaveChanges ();
                }
                _timeLabel.Text = "Game complete (results saved)";

                return false;
            }
        }