public override Status Tick() { for (int i = 0; i < globalBlackboard.guardBlackboards.Length; i++) { // if this blackboard is i, ignore it if (globalBlackboard.guardBlackboards[i] == guardBlackboard) { continue; } // if there is another guard nearby if (guardBlackboard.GetDistance(globalBlackboard.guardBlackboards[i].GetPosition()) < 5f) { // Check if they are already in the conversation state if (globalBlackboard.guardBlackboards[i].GetGuardState() == Guardblackboard.GuardState.converse) { // Check if the nearby guard is conversing with another agent if (globalBlackboard.guardBlackboards[i].nearbyFriendly != guardBlackboard.gameObject) { guardBlackboard.SetTriedToConverse(true); return(Status.FAILURE); } } // Assign the nearby guard guardBlackboard.nearbyFriendly = globalBlackboard.guardBlackboards[i].gameObject; return(Status.SUCCESS); } } return(Status.FAILURE); }
public override Status Tick() { // Set the guard to stand with the agent they are conversing with if (guardblackboard.finishedConversation == false) { navAgent.isStopped = true; guardblackboard.SetState(Guardblackboard.GuardState.converse); } // Look at the agent if (guardblackboard.GetGuardState() == Guardblackboard.GuardState.converse) { guardblackboard.gameObject.transform.LookAt(guardblackboard.nearbyFriendly.transform); } // Once the conversation has finished then reset values and continue on patrol route if (guardblackboard.finishedConversation) { Debug.Log("Finished conversation"); navAgent.isStopped = false; navAgent.SetDestination(guardblackboard.destination); guardblackboard.nearbyFriendly = null; guardblackboard.SetState(Guardblackboard.GuardState.idle); guardblackboard.nearbyFriendly = null; guardblackboard.SetTriedToConverse(true); guardblackboard.finishedConversation = false; // Reset conversation time if (guardblackboard.conversationTimer <= 0) { guardblackboard.conversationTimer = time; } return(Status.SUCCESS); } return(Status.RUNNING); }