void Update() { if (!Vector2DUtils.IsInScreen(transform.position)) { StopAct(); Log.Debug("go to pooll..."); } }
IEnumerator DoMyUpdate() { while (true) { if (null == GameController.GetSingleton() || null == GameController.GetSingleton().levelsController || null == GameController.GetSingleton().levelsController.eggController) { //for design yield return(null); } Vector3 pos = GameController.GetSingleton().levelsController.eggController.transform.position; float dis = Mathf.Abs((pos - transform.position).magnitude); //Log.Debug ("E1 see egg {0}",dis); if (sensibleDistance > dis) { Log.Debug("E1 see egg {0}", dis); //start fly animIdle.StopPlay(); animFly.StartPlay(); GameController.singleton.audioController.PlayBirdFly(); break; } yield return(null); } while (true) { if (!Vector2DUtils.IsInScreen(transform.position)) { Log.Debug("E1 out of screen"); gameObject.SetActive(false); yield break; } if (_flyIndex > flyPoints.Length - 1) { gameObject.SetActive(false); break; } Vector3 fp = flyPoints [_flyIndex]; Vector2DUtils.MoveToSmoothly(transform, fp, flySpeed); if (fp == transform.position) { _flyIndex++; } yield return(null); } }