public IEnumerator MoveToPointBSkippingA() { MovementTestPoint pointA = MovementTestPoint.Create(new Vector3(5f, 5f, 5f)); MovementTestPoint pointB = MovementTestPoint.Create(2 * pointA.transform.position); TestEnemy hamster = TestEnemy.Create(5f); hamster.AiEnabled = false; hamster.gameObject.SetActive(true); hamster.MoveTo(pointA.transform.position); hamster.MoveTo(pointB.transform.position); yield return(new WaitWhile(() => hamster.IsMoving)); Assert.True(pointA.reached, "Object did not pass through point A"); Assert.True(pointB.reached, "Object did not reach the end."); }
public IEnumerator MoveToBTurningBeforeA() { MovementTestPoint pointA = MovementTestPoint.Create(new Vector3(5f, 0f, 5f)); MovementTestPoint pointB = MovementTestPoint.Create(new Vector3(10f, 10f, 10f)); TestEnemy hamster = TestEnemy.Create(5f); hamster.AiEnabled = false; hamster.gameObject.SetActive(true); hamster.MoveTo(pointA.transform.position); yield return(new WaitUntil( () => hamster.transform.position.magnitude > pointA.transform.position.magnitude / 2)); hamster.MoveTo(pointB.transform.position); yield return(new WaitWhile(() => hamster.IsMoving)); Assert.True(pointB.reached, "Object did not reach the end."); Assert.False(pointA.reached, "Object must not pass through point A"); }
public IEnumerator MoveFromPointAToPointB() { TestEnemy hamster = TestEnemy.Create(2f); hamster.AiEnabled = false; hamster.gameObject.SetActive(true); MovementTestPoint testPoint = MovementTestPoint.Create(new Vector3(10f, 10f, 10f)); hamster.MoveTo(testPoint.transform.position); yield return(new WaitWhile(() => hamster.IsMoving)); Assert.That(testPoint.reached, "Test object must move to the designated test point."); }
public IEnumerator MoveAroundPlayer() { TestEnemy hamster = TestEnemy.Create(5f, 0, 0, -5f); hamster.AiEnabled = false; hamster.gameObject.SetActive(true); Player.Create(); MovementTestPoint endPoint = MovementTestPoint.Create(-hamster.transform.position); hamster.MoveTo(endPoint.transform.position); yield return(new WaitWhile(() => hamster.IsMoving)); Assert.True(endPoint.reached); }
public IEnumerator IgnoreBumpOnOtherEnemy() { TestEnemy hamster = TestEnemy.Create(5f); hamster.AiEnabled = false; hamster.gameObject.SetActive(true); TestEnemy e = TestEnemy.Create(0f, 0, 0, 0f, 0f, 5f); // enemy blocking the path e.AiEnabled = false; e.gameObject.SetActive(true); Vector3 initialPosition = e.transform.position; MovementTestPoint endPoint = MovementTestPoint.Create(new Vector3(0f, 0f, 10f)); hamster.MoveTo(endPoint.transform.position); yield return(new WaitWhile(() => hamster.IsMoving)); Assert.True(endPoint.reached); // Also assert that the other enemy was not bounced: Assert.That(Equals(initialPosition, e.transform.position)); }