Beispiel #1
0
        public static void AddHighScore(string name, int score)
        {
            if (HighScore.IsTopTen(score) == false)
            {
                return;
            }

            string           outputString = String.Empty;
            List <HighScore> scores       = HighScore.GetAllHighScores();
            string           thisScore    = name + "\t" + score.ToString();

            bool beatPreviousScore = false;
            bool outputtedScore    = false;

            foreach (HighScore s in scores)
            {
                if (s.Score <= score && outputtedScore == false)
                {
                    outputString     += thisScore + Environment.NewLine;
                    beatPreviousScore = true;
                    outputtedScore    = true;
                }
                outputString += s.Name + "\t" + s.Score.ToString() + Environment.NewLine;
            }

            if (!beatPreviousScore && scores.Count < 10 && scores.Count > 0)
            {
                outputString += Environment.NewLine + thisScore;
            }
            else if (!beatPreviousScore && scores.Count < 10 && scores.Count == 0)
            {
                outputString = thisScore;
            }
            File.WriteAllText(OUTPUT_FILE, outputString);
        }
Beispiel #2
0
        private void _cmbSelectedCity_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_alreadySaidGameOver)
            {
                return;
            }

            if (_cmbSelectedCity.Text == _game.CurrentCity.Name || _cmbSelectedCity.Text == String.Empty)
            {
                return;
            }
            if (_game.DaysLeft <= 0)
            {
                /*
                 * if (_game.Player.OwnedGums.Count > 0)
                 * {
                 *  for (int i = _game.Player.OwnedGums.Count - 1; i >= 0; i--)
                 *  {
                 *      OwnedGum g = _game.Player.OwnedGums[i];
                 *      MarketGum mGum = _game.CurrentCity.FindGum(g);
                 *
                 *      if (mGum == null)
                 *          mGum = _game.CurrentCity.Gums[0];
                 *
                 *      if (mGum != null)
                 *          _game.Player.SellGum(mGum, g.Quantity);
                 *
                 *  }
                 * }
                 */

                MessageBox.Show("Game over.");
                alertStatus("Game over.");
                _alreadySaidGameOver = true;
                _grpYou.Enabled      = false;
                if (HighScore.IsTopTen(_game.Player.TotalWealth))
                {
                    AddHighScoreForm addScore = new AddHighScoreForm(_game.Player.TotalWealth);
                    addScore.ShowDialog(this);

                    HighScores hsf = new HighScores();
                    hsf.ShowDialog(this);
                }

                _cmbSelectedCity.Enabled = false;
                _grdMarket.Enabled       = false;

                return;
            }
            _game.Move(_cmbSelectedCity.Text);
            outputGameState();

            alertStatus(String.Empty);
            alertStatus(_game.CurrentMessage);
        }