Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public Vector2 GetHeading(Vector2 currentPosition)
        {
            var gridCoords = GridTransformer.ToGrid(currentPosition);

            if (gridCoords == TargetNode)
            {
                return((TargetWorldPosition - currentPosition).Normalized);
            }
            return(this[gridCoords.X, gridCoords.Y]);
        }
Esempio n. 3
0
        public void UpdateGridPosition(GridTransformer gridTransformer)
        {
            var worldPosition = _worldPositionProvider.Invoke();

            GridPosition = gridTransformer.ToGrid(worldPosition);
        }