private void PickupBaby(BabyMovement babyMovement) { babyMovement.WasPickedUp(); gameObject.GetComponent <AudioSource> ().Play(); heldBaby = babyMovement; currentBehavior = DingoBehaviorState.LeavingWithBaby; }
private BabyMovement FindClosestBaby() { var allBabies = FindObjectsOfType <BabyMovement>(); if (allBabies == null) { return(null); } float minDistSqrd = 100000f; BabyMovement closeBaby = null; for (int i = 0; i < allBabies.Length; i++) { if (allBabies[i].BabyState == BabyState.Carried) { continue; } float distSqrd = (transform.position - allBabies[i].transform.position).sqrMagnitude; if (distSqrd < minDistSqrd) { minDistSqrd = distSqrd; closeBaby = allBabies[i]; } } return(closeBaby); }
private void DropBaby() { if (heldBaby != null) { heldBaby.transform.position = transform.position; heldBaby.WasDropped(); heldBaby = null; } }
public void handCollisionDetection(BabyMovement otherBaby) { if (this == otherBaby) { return; } else if (currentState != PlayerState.crying && canCry) { startCrying(); } }
public void DropResource() { holdingState = PlayerHoldingState.Nothing; if (heldBaby != null) { var position = transform.position; position.x -= 1.0f; heldBaby.transform.position = position; heldBaby.WasDropped(); heldBaby = null; } }
private void LeaveWithBaby() { var targetPosition = startingPoint; var direction = (targetPosition - transform.position).normalized; Move(direction * creepSpeed * Time.deltaTime); if ((transform.position - targetPosition).sqrMagnitude <= 1f) { if (ReturnedFromHunt != null) { ReturnedFromHunt(this, new DingoReturnedFromHuntEventArgs() { WithBaby = true }); } heldBaby.HandleBeingEaten(); heldBaby = null; } }
// Use this for initialization void Start() { baby = GetComponentInParent <BabyMovement> (); }
private void Awake() { babyMovement = GetComponent <BabyMovement>(); }
public void PickupBaby(BabyMovement babyMovement) { babyMovement.WasPickedUp(); heldBaby = babyMovement; holdingState = PlayerHoldingState.Baby; }