Ejemplo n.º 1
0
        private bool CanBeMoved(GameGrid grid, MoveDirection direction)
        {
            var motionOffset = direction.ToOffset();

            foreach (var cell in grid.Where(c => c.Value > 0))
            {
                var newPosition = cell.OriginalGridPosition.Translate(motionOffset);
                if (grid.ContainsPoint(newPosition))
                {
                    var cellAtPosition = grid.TryGetCell(newPosition.X, newPosition.Y);
                    if (cellAtPosition == null ||
                        cellAtPosition.Value == 0 ||
                        cellAtPosition.Value == cell.Value)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }