public void ToGrid_CorrectPosition(Point2 gridSize, Vector2 scale, Vector2 position, Vector2 worldPositionToTransform, Point2 expectedGridPosition) { var transformer = new GridTransformer(gridSize, scale, position); var gridPosition = transformer.ToGrid(worldPositionToTransform); Assert.AreEqual(expectedGridPosition, gridPosition); }
public Vector2 GetHeading(Vector2 currentPosition) { var gridCoords = GridTransformer.ToGrid(currentPosition); if (gridCoords == TargetNode) { return((TargetWorldPosition - currentPosition).Normalized); } return(this[gridCoords.X, gridCoords.Y]); }
public void UpdateGridPosition(GridTransformer gridTransformer) { var worldPosition = _worldPositionProvider.Invoke(); GridPosition = gridTransformer.ToGrid(worldPosition); }