コード例 #1
0
ファイル: Engine.cs プロジェクト: GStoykov/BattleField
        private void StartInteraction(GameField field)
        {
            string readBuffer = null;
            int blownMines = 0;

            while (field.ContainsMines())
            {
                field.DrawField();
                Console.Write("Please enter coordinates: ");
                readBuffer = Console.ReadLine();
                Mine mineToBlow = GameServices.ExtractMineFromString(readBuffer);

                while (mineToBlow == null)
                {
                    Console.Write("Please enter coordinates: ");
                    readBuffer = Console.ReadLine();
                    mineToBlow = GameServices.ExtractMineFromString(readBuffer);
                }

                bool isValidMove = GameServices.IsValidMove(field.Field, mineToBlow.X, mineToBlow.Y);
                if (!isValidMove)
                {
                    Console.WriteLine("Invalid move!");
                    continue;
                }

                Explosion.Explode(field.Field, mineToBlow);
                blownMines++;
            }

            field.DrawField();
            Console.WriteLine("Game over. Detonated mines: {0}", blownMines);
        }
コード例 #2
0
ファイル: Engine.cs プロジェクト: TeamXenon/BattleField
 public void Start()
 {
     Console.WriteLine(GameMessage.IntroMessage);
     int size = this.GetFieldSize();
     IGameField field = new GameField(size);
     field.GenerateField();
     this.StartInteraction(field);
 }
コード例 #3
0
ファイル: Engine.cs プロジェクト: GStoykov/BattleField
 public void Start()
 {
     Console.WriteLine(@"Welcome to ""Battle Field"" game. ");
     int size = this.GetFieldSize();
     GameField field = new GameField(size);
     field.GenerateField();
     this.StartInteraction(field);
 }