protected override IEnumerator <BHiveState> Update() { Food targetFood = null; while (true) { if (retard > 3) { targetFood = FoodController.Instance.GetFoodNear(Target.transform.position); retard = 0; } retard++; if (targetFood == null) { break; } if (targetFood.foodValue < 0) { break; } if (Distance(targetFood.position) <= GetFloat("foodDistance")) { break; } character.WalkTo(targetFood.position, false); yield return(BHiveState.Running); } character.StopWalking(); yield return(BHiveState.Done); }
protected override IEnumerator <BHiveState> Update() { float timeElapsed = 0; while (timeElapsed < 1) { timeElapsed += Time.deltaTime; var tummy = Controller.GetFloat("tummy"); tummy -= Time.deltaTime * 20; Controller.SetValue("tummy", tummy); character.WalkTo(targetPos, false); yield return(BHiveState.Running); } yield return(BHiveState.Done); }
protected override IEnumerator <BHiveState> Update() { float elapsedTime = 0; while (elapsedTime < GetFloat("duration")) { if (enemy == null) { break; } Vector3 targetDirection = -(enemy.gameObject.transform.position - Target.transform.position); character.WalkTo(Target.transform.position + targetDirection.normalized, true); elapsedTime += Time.deltaTime; yield return(BHiveState.Running); } character.StopWalking(); yield return(BHiveState.Done); }