示例#1
0
        private void OnDeath()
        {
            Commands.PrintField(bombs);
            Console.Write("\nBoom! Gameover with {0} points. Please enter your name: ", this.counter);
            string name = Console.ReadLine();
            Highscore score = new Highscore(name, this.counter);
            if (this.highscores.Count < 5)
            {
                this.highscores.Add(score);
            }
            else
            {
                for (int i = 0; i < this.highscores.Count; i++)
                {
                    if (this.highscores[i].Points < score.Points)
                    {   this.highscores.Insert(i, score);
                        this.highscores.RemoveAt(this.highscores.Count - 1);
                        break;
                    }
                }
            }

            this.highscores.Sort((r1, r2) => r2.Name.CompareTo(r1.Name));
            this.highscores.Sort((r1, r2) => r2.Points.CompareTo(r1.Points));
            Commands.HighScores(this.highscores);

            this.playField = Commands.CreatePlayField();
            this.bombs = Commands.PlaceBombs();
            this.counter = 0;
            this.dead = false;
            this.welcomeMessege = true;
        }
示例#2
0
 private void OnWin()
 {
     Console.WriteLine("\nCongratulations! You opened all cells!");
     Commands.PrintField(bombs);
     Console.WriteLine("Please enter your name: ");
     string name = Console.ReadLine();
     Highscore score = new Highscore(name, this.counter);
     this.highscores.Add(score);
     Commands.HighScores(this.highscores);
     this.playField = Commands.CreatePlayField();
     this.bombs = Commands.PlaceBombs();
     this.counter = 0;
     this.winner = false;
     this.welcomeMessege = true;
 }