public static void Move(MovesHandling.MoveDirection direction) // move tiles in one of specified directions { try { if (GameBoard.CurrentGameState != GameBoard.GameState.GameOver) // don't move in case of gameover { TilesMovePlan mp = MovesHandling.GetTilesMovePlan(direction); // get move plan in context of specified direction if (!GameBoard.CheckAndSetGameStateGameOver(mp) && !mp.IsBlindAlley()) // if move is possible in some direction and also possible in specified direction { MovesHandling.GetTIlesDistinationCoordinates(mp); // perform all calculations for move plan GameBoard.UpdateTileStates(mp); // change state of tiles if needed GameBoard.SetNewCoordinatesToTilesInGrid(mp); // perform move graphically AddNewTileOnBoard(mp); // add one tile after each move } } } catch (InvalidOperationException e) { Debug.Print("Wow, wow, wow... slow down, cowboy!"); // ignoring extremely fast keyboard actions } }
public void Execute(object parameter) { MovesHandling.MoveDirection direction = (MovesHandling.MoveDirection)parameter; this.action(direction); }