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)); } } }
void Update() { if (FinishingGrid() && !inCollision) { transform.position = RandomDirVelo.Round2NearestPosFullTile(transform); curDir = RandomDirVelo.GetPossibleNewDir(transform); velocity = Direction.GetVector3ByDirection(curDir); } }
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); }
IEnumerator Detour(GameObject collisionGameObject) { inCollision = true; transform.position = RandomDirVelo.Round2NearestPosFullTile(transform); curDir = RandomDirVelo.GetPossibleNewDir(transform); velocity = Direction.GetVector3ByDirection(curDir); inCollision = false; yield return(null); }
IEnumerator Detour(GameObject collisionGameObject) { inCollision = true; transform.position = RandomDirVelo.Round2NearestPosFullTile(transform); curDir = RandomDirVelo.GetPossibleNewDir(transform); velocity = Direction.GetVector3ByDirection(curDir); for (float i = 0; i < 1; i += moveSpeed * Time.deltaTime) { yield return(new WaitForSeconds(Time.deltaTime)); } inCollision = false; }
IEnumerator move() { while (true) { if (!inCollision) { float moveTileNum = Mathf.Ceil(Random.Range(0, 3)); curDir = RandomDirVelo.GetPossibleNewDir(transform); velocity = Direction.GetVector3ByDirection(curDir); for (float i = 0; i < moveTileNum; i += Time.deltaTime * moveSpeed) { yield return(new WaitForFixedUpdate()); } velocity = Vector3.zero; transform.position = RandomDirVelo.Round2NearestPosFullTile(transform); yield return(new WaitForSeconds(waitingTime)); } } }