private IEnumerator setStateSaved() { state = ANIMAL_STATE.SAVED; runAnimation.Stop (); Destroy (this.gameObject); yield break; }
private IEnumerator setStateMoving() { state = ANIMAL_STATE.MOVING; this.transform.rotation.eulerAngles.Set (0,0,0); this.GetComponent<Rigidbody> ().angularVelocity = new Vector3 (0,0,0); runAnimation.Play (); setRandomDestination (); yield return new WaitForSeconds (moveTimeInterval); if (state == ANIMAL_STATE.MOVING) { StartCoroutine ("setStateMoving"); } }
// State coroutines private IEnumerator setStateLured(float hayDuration) { state = ANIMAL_STATE.LURED; runAnimation.Play (); this.agent.destination = this.player.transform.position; yield return new WaitForSeconds (hayDuration); hayCoroutine = null; if (state == ANIMAL_STATE.LURED) { StartCoroutine ("setStateMoving"); } }
private IEnumerator setStateBeamed() { state = ANIMAL_STATE.BEAMED; runAnimation.Stop (); this.agent.enabled = false; this.gameObject.GetComponent<Rigidbody> ().velocity = new Vector3 (0,3.0f,0); this.GetComponent<Rigidbody> ().angularVelocity = new Vector3 (1,3,1); yield return new WaitForSeconds (captureTime); if (OnAnimalCaptured != null) { OnAnimalCaptured (this.type); } Destroy (this.gameObject); yield break; }