private void FindNewTarget() { ChildBehaviour closest = null; foreach (ChildBehaviour child in GameManager.Children) { if (child.found) { continue; } if (closest == null) { closest = child; target = closest.transform; continue; } else if (Vector3.Distance(child.transform.position, transform.position) <= Vector3.Distance(closest.transform.position, transform.position)) { target = closest.transform; } } Vector3 targetPosition = new Vector3(target.position.x, 0, target.position.z); //Vector3 targetPosition = new Vector3(0, 0, 0); agent.SetDestination(targetPosition); Debug.Log("Chasing " + agent.destination); }
private void OnTriggerEnter(Collider collision) { if (collision.gameObject.tag == "Child") { ChildBehaviour childBehaviour = collision.gameObject.GetComponent <ChildBehaviour>(); if (childBehaviour.found == false) { //childBehaviour.SetFound(myIdentity); //childFound?.Invoke(childBehaviour); } } }
//TODO this isnt being used public GameObject GetClosestHeatSourceToPlayer() { GameObject currentClosestGameObject = bonfire; float currentClosestDistance = GetDistanceToBonfire(); foreach (GameObject child in children) { //Children that are following or already at home are not heat sources anymore ChildBehaviour tempChild = child.GetComponent <ChildBehaviour>(); if (tempChild.isFollowingPlayer || tempChild.isDroppedOff) { continue; } float nextDistance = Vector3.Distance(player.transform.position, child.transform.position); if (nextDistance < currentClosestDistance) { currentClosestGameObject = child; } } return(currentClosestGameObject); }
public void ChildFound(ChildBehaviour childBehaviour) { FindNewTarget(); }
public static void PlayerChildFound(ChildBehaviour childBehaviour) { childrenFound++; instance.hud.UpdateUI(); }
public static void EnemyChildFound(ChildBehaviour childBehaviour) { childrenLost++; instance.hud.UpdateUI(); }