public void ChooseRandomState() { int randomNumber = Random.Range(1, 3); if (randomNumber == 1) { civillianState = CivillianState.Scared; } else { civillianState = CivillianState.Fleeing; } }
public IEnumerator CivilianCoolDown(float timeToWait) { NavAgent.isStopped = false; NavAgent.ResetPath(); SetAllAnimatorStatesToFalse(); anim.SetBool("Alive", true); anim.SetBool("Idle", true); bool isCooledDown = false; while (!isCooledDown) { yield return(new WaitForSeconds(timeToWait)); civillianState = CivillianState.Patrolling; civPatrol.ChooseNextPoint(); isCooledDown = true; } }
public void ChooseAction() { if (DetectClosestGuard() != null) { NavAgent.ResetPath(); NavAgent.isStopped = false; civPatrol.StopAllCoroutines(); SetAllAnimatorStatesToFalse(); NavAgent.SetDestination(DetectClosestGuard().transform.position); anim.SetBool("Alive", true); anim.SetBool("Idle", true); anim.SetBool("Walking", true); anim.SetBool("Running", true); //Invoke(Alerting(true),.5f); Invoke("Alerting", .5f); civillianState = CivillianState.AlertingGuard; } else { Debug.Log("No Guard Detected"); ChooseRandomState(); } }