Exemplo n.º 1
0
    public override Status Tick()
    {
        // If the guard has been notified of player location, move to last sighting
        if (guardblackboard.GetGuardState() == Guardblackboard.GuardState.alerted)
        {
            guardblackboard.destination = globalBlackboard.playerLastSighting;
            return(Status.SUCCESS);
        }

        // If guard can see the player, move towards the player
        if (guardblackboard.GetGuardState() == Guardblackboard.GuardState.combat)
        {
            guardblackboard.destination = guardblackboard.playerPosition;
            return(Status.SUCCESS);
        }
        return(Status.FAILURE);
    }
Exemplo n.º 2
0
    public override Status Tick()
    {
        // Check that the guards state.  Used as a condintional to control which behaviours agent uses depending
        // on the guards current state
        if (guardBlackboard.GetGuardState() == guardState)
        {
            navAgent.isStopped = false;
            return(Status.SUCCESS);
        }

        // If the state is not passed stop the agent
        navAgent.isStopped = true;
        return(Status.FAILURE);
    }
Exemplo n.º 3
0
    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);
    }