IEnumerator DoMyUpdate() { Vector3 center = Vector3.zero; if (Direction2D.right == _direction2D) { center = _branch.transform.position; center.x = center.x - _branchSpriteSize.x * 0.5f; } else { center = _branch.transform.position; center.x = center.x + _branchSpriteSize.x * 0.5f; } int up = 1; while (true) { if (Vector2DUtils.IsOutsideScreen(transform.position, Direction2D.up)) { Log.Debug("E10 out of screen"); gameObject.SetActive(false); yield break; } if (!pausing) { _branch.transform.RotateAround(center, new Vector3(0, 0, 1), up * speed * Time.deltaTime); // Log.Debug ("erule {0}", transform.eulerAngles); float z = transform.eulerAngles.z; if (up == 1 && z > angle && z < 180) { up = -1; } else if (up == -1 && z < 360 - angle && z > 180) { up = 1; } } yield return(null); } }
void Update() { if (_startedShow && Vector2DUtils.IsOutsideScreen(transform.position, Direction2D.down, null)) { Log.Debug("left screen, destroy."); StopAct(); return; } if (pausing) { // Log.Debug (" 01 ..."); return; } float tdis = Mathf.Abs(transform.position.y - GameController.GetSingleton().levelsController.eggController.transform.position.y); if (!_startedShow && tdis < 0.5f) { // Log.Debug (" 1 ..."); //start fall Fall(); } }
IEnumerator DoUpdate(float speed, Vector3 target) { animator.StartPlay(); while (true) { transform.eulerAngles = startAngulars; if (target.x < transform.position.x) { Vector2DUtils.Flip(transform); } while (transform.position != target) { // Log.Debug ("gooooo : {0},{1}",transform.position , target); if (Vector2DUtils.IsOutsideScreen(transform.position, Direction2D.up)) { // Log.Debug ("{0} outof screen.",gameObject.name); StopAct(); yield break; } if (!pausing) { Vector2DUtils.MoveToSmoothly(transform, target, speed); } yield return(null); } Vector2[] scope = Vector2DUtils.GetScreenScope(); float xbound = render.bounds.size.x * .5f; float rightX = scope [1].x + xbound + 10; float leftX = scope [0].x - xbound - 10; target.x = UnityEngine.Random.Range(leftX, rightX); target.y = UnityEngine.Random.Range(scope[0].y, scope[1].y); // Log.Debug ("move to new pos : {0}",target); } }