Exemple #1
0
 private void Form1_KeyDown(object sender, KeyEventArgs e)
 {
     if (_keysMap.TryGetValue(e.KeyCode, out var direction))
     {
         _game.ChangeDirection(direction);
     }
 }
Exemple #2
0
 public async void CheckForKeyPress()
 {
     if (IsKeyDown(Keys.Left))
     {
         await _game.ChangeDirection(Direction.Left);
     }
     else if (IsKeyDown(Keys.Right))
     {
         await _game.ChangeDirection(Direction.Right);
     }
     else if (IsKeyDown(Keys.Up))
     {
         await _game.ChangeDirection(Direction.Up);
     }
     else if (IsKeyDown(Keys.Down))
     {
         await _game.ChangeDirection(Direction.Down);
     }
 }
Exemple #3
0
 public async void RequestNextMoveFromBot()
 {
     if (_game.Status == GameStatus.Alive)
     {
         var nextDirection = NextMove();
         if (nextDirection is object)
         {
             await _game.ChangeDirection(nextDirection.Value);
         }
     }
 }
Exemple #4
0
 public async void CheckForKeyPress()
 {
     if (_game.Status == GameStatus.AttractMode && IsKeyDown(Keys.Space))
     {
         await _game.PressStart();
     }
     else if (IsKeyDown(Keys.Left))
     {
         await _game.ChangeDirection(Direction.Left);
     }
     else if (IsKeyDown(Keys.Right))
     {
         await _game.ChangeDirection(Direction.Right);
     }
     else if (IsKeyDown(Keys.Up))
     {
         await _game.ChangeDirection(Direction.Up);
     }
     else if (IsKeyDown(Keys.Down))
     {
         await _game.ChangeDirection(Direction.Down);
     }
 }