public IEnumerator WhenMoveFindNearestNeighbour_ThenNearestNeighbourUpdate() { FindNearestNeighbour firstNearestNeighbour = Object.Instantiate(prefab); firstNearestNeighbour.GetComponent <RandomMove>().gameObject.SetActive(false); FindNearestNeighbour secondNearestNeighbour = Object.Instantiate(prefab); secondNearestNeighbour.GetComponent <RandomMove>().gameObject.SetActive(false); FindNearestNeighbour thirdNearestNeighbour = Object.Instantiate(prefab); thirdNearestNeighbour.GetComponent <RandomMove>().gameObject.SetActive(false); //Act & Asserts firstNearestNeighbour.transform.position = Vector3.zero; secondNearestNeighbour.transform.position = Vector3.one; thirdNearestNeighbour.transform.position = new Vector3(10, 10, 10); positionHandler.UpdatePositions(); yield return(0); Assert.AreSame(secondNearestNeighbour, firstNearestNeighbour.CurrentNearestNeighbour, "No the correct neighbour"); yield return(0); secondNearestNeighbour.transform.position = new Vector3(11, 11, 11); yield return(0); positionHandler.UpdatePositions(); yield return(0); Assert.AreSame(thirdNearestNeighbour, firstNearestNeighbour.CurrentNearestNeighbour, "No the correct neighbour"); }
// Update is called once per frame void Update() { positionHandler.UpdatePositions(objects); foreach (MovingObject obj in objects) { obj.Update(); } }
private void Update() { positionHandler.UpdatePositions(); }