public void MergeTile(Tile movingTile, Tile mergedTile) { int mergedValue = GetNextValue(movingTile.Value); Tile newMergedTile = new Tile(mergedTile.Position.X, mergedTile.Position.Y, mergedValue); newMergedTile.MergeFrom = movingTile; Board.RemoveTile(movingTile); Board.RemoveTile(mergedTile); movingTile.UpdatePosition(mergedTile.Position); Board.InsertTile(newMergedTile); Score += mergedValue; }
public void Move(Tile tile, Point newPosition) { Board.RemoveTile(tile); tile.UpdatePosition(newPosition); Board.InsertTile(tile); }
private bool IsTilesMergeable(Tile movingTile, Point mergedPosition) { if ((movingTile != null) && (mergedPosition != null) && Board.IsCellOccupied(mergedPosition.X, mergedPosition.Y)) { Tile mergedTile = Board.Tiles[mergedPosition.X, mergedPosition.Y]; return (movingTile.Value == mergedTile.Value) && (mergedTile.MergeFrom == null); } return false; }