public void GivenKnownPoints_WhenCollectCollisionDetectionPointsAt45Degrees_ThenReturnCorrectPoints() { var startPosition = new Position(0, 0); var endPoint = new Position(4, 4); var heading = 45; var result = vectorCalculatorService.CollectCollisionDetectionPointsAlongPath(startPosition, endPoint, heading); Assert.Contains(new Position(1, 1), result); Assert.Contains(new Position(2, 2), result); Assert.Contains(new Position(3, 3), result); Assert.Contains(new Position(4, 4), result); Assert.Contains(endPoint, result); Assert.AreEqual(4, result.Count); }
public void GivenForwardAction_WhenHeadingIs18AndSpeedIs6_ThenDistanceTraveledIs6() { SetupFakeWorld(true, false); var bot = FakeGameObjectProvider.GetBotAt(new Position(0, 0)); bot.PendingActions = new List <PlayerAction> { new PlayerAction { Action = PlayerActions.Forward, Heading = 23, PlayerId = bot.Id } }; bot.Speed = 6; var expectedEndpoint = new Position(6, 2); var expectedDistance = VectorCalculatorService.GetDistanceBetween(bot.Position, expectedEndpoint); Assert.DoesNotThrow(() => engineService.SimulateTickForBots(WorldStateService.GetPlayerBots())); Assert.DoesNotThrow(() => WorldStateService.ApplyAfterTickStateChanges()); var resultingDistanceTravelled = VectorCalculatorService.GetDistanceBetween(new Position(0, 0), bot.Position); var varianceBetweenExpectedAndActualEndpoint = VectorCalculatorService.GetDistanceBetween(bot.Position, expectedEndpoint); var pathPoints = VectorCalculatorService.CollectCollisionDetectionPointsAlongPath(new Position(0, 0), new Position(6, 2), 23); Assert.AreEqual(6, expectedDistance); Assert.AreEqual(expectedEndpoint, bot.Position); Assert.AreEqual(expectedDistance, resultingDistanceTravelled); Assert.Zero(varianceBetweenExpectedAndActualEndpoint); }