void Update() { switch (currentState) { case (npcState.Idle): { isBusy = false; ResetAITargets(); currentState = PickState(); break; } case (npcState.Talkative): { if (targetConvo == null) { targetConvo = GetRandomFromArray(arrTypes.Convo); } else { if (GetDistanceFrom(targetConvo) > interactionDistance) { movement.Approach(targetConvo); } else if (!isBusy) { Invoke("GoIdle", focusTime); isBusy = true; } } break; } case (npcState.Bored): { if (targetProp == null) { targetProp = GetRandomFromArray(arrTypes.Prop); } else if (GetDistanceFrom(targetProp) > interactionDistance) { movement.Approach(targetProp); } else if (!isBusy) { isBusy = true; Invoke("GoIdle", focusTime); } break; } case (npcState.Violent): { if (targetGuest == null) { currentState = npcState.Idle; } else if (GetDistanceFrom(targetGuest) > interactionDistance) { movement.Approach(targetGuest); } else { Kill(); } break; } case (npcState.Panic): { if (player == null) { currentState = npcState.Idle; } else if (GetDistanceFrom(player) > interactionDistance) { movement.Approach(player); } else { Invoke("GoIdle", 3f); } break; } case (npcState.Interrogated): { if (GetDistanceFrom(player) > interactionDistance * 3f) { currentState = npcState.Idle; ds.SetDialogue(gameObject.name + ": Goodbye"); ds.DelayClearLog(); } else { movement.CancelMovement(); movement.FaceToward(player); ds.SetDialogue(gameObject.name + ": I haven't seen anything"); } break; } default: { movement.Roam(); break; } } nameTitle.transform.position = transform.position + Vector3.up; }