public void ReleaseFlockChild() { if (_controller._flock.gameObject.activeInHierarchy && (landingChild != null)) { _gotcha = false; lerpCounter = 0; if (_controller._featherPS != null) { _controller._featherPS.position = landingChild._thisT.position; _controller._featherPS.GetComponent <ParticleSystem>().Emit(Random.Range(0, 3)); } landing = false; _idle = false; landingChild._avoid = true; //Reset flock child to flight mode landingChild._damping = landingChild._spawner._maxDamping; landingChild._model.GetComponent <Animation>().CrossFade(landingChild._spawner._flapAnimation, .2f); landingChild._dived = true; landingChild._speed = 0.0f; landingChild._move = true; landingChild._landing = false; landingChild.Flap(); landingChild._wayPoint = new Vector3(landingChild._wayPoint.x, _thisT.position.y + 10, landingChild._wayPoint.z); if (_controller._autoCatchDelay.x > 0) { StartCoroutine(GetFlockChild(_controller._autoCatchDelay.x + 0.1f, _controller._autoCatchDelay.y + 0.1f)); } landingChild = null; _controller._activeLandingSpots--; } }
public IEnumerator ReleaseFlockChild(float minDelay, float maxDelay) { yield return(new WaitForSeconds(UnityEngine.Random.Range(minDelay, maxDelay))); if (_controller._flock.gameObject.activeInHierarchy && (landingChild != null)) { lerpCounter = 0; if (_controller._featherPS != null) { _controller._featherPS.position = landingChild._thisT.position; _controller._featherPS.GetComponent <ParticleSystem>().Emit(UnityEngine.Random.Range(0, 3)); } landing = false; _idle = false; landingChild._avoid = true; //Reset flock child to flight mode landingChild._damping = landingChild._spawner._maxDamping; landingChild._model.GetComponent <Animation>().CrossFade(landingChild._spawner._flapAnimation, .2f); landingChild._dived = true; landingChild._speed = 0.0f; landingChild._move = true; landingChild._landing = false; landingChild.Flap(); landingChild._wayPoint = new Vector3(landingChild._wayPoint.x, _thisT.position.y + 10, landingChild._wayPoint.z); yield return(new WaitForSeconds(.1f)); if (_controller._autoCatchDelay.x > 0) { StartCoroutine(GetFlockChild(_controller._autoCatchDelay.x, _controller._autoCatchDelay.y)); } landingChild = null; } }