IEnumerator move() { while (true) { if (!inCollision && thrower && !thrower.inThrowing) { float moveTileNum = Mathf.Ceil(Random.Range(-1, 7)) / 2f; curDir = RandomDirVelo.GetPossibleNewDir(transform); velocity = Direction.GetVector3ByDirection(curDir); animator.SetInteger("direction", curDir); animator.speed = 1f; for (float i = 0; i < moveTileNum; i += Time.deltaTime * moveSpeed) { yield return(new WaitForFixedUpdate()); } transform.position = RandomDirVelo.Round2NearestPosHalfTile(transform); thrower.ThrowBoomerang(curDir, AttackRegion.ENEMY); } else if (thrower && thrower.inThrowing) { yield return(new WaitForSeconds(0.2f)); } else { yield return(new WaitForSeconds(0.2f)); } } }
IEnumerator Detour(GameObject collisionGameObject) { inCollision = true; transform.position = RandomDirVelo.Round2NearestPosHalfTile(transform); curDir = RandomDirVelo.GetPossibleNewDir(transform); velocity = Direction.GetVector3ByDirection(curDir); animator.SetInteger("direction", curDir); animator.speed = 1f; inCollision = false; yield return(null); }