Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        viewDistance    = state.GetStateComponent().viewDistance;
        viewAngle       = state.GetStateComponent().viewAngle;
        hearingDistance = state.GetStateComponent().hearingDistance;
        smellDistance   = state.GetStateComponent().smellDistance;

        DebugDrawing();
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        // Get awareness value for currently active state
        AwarenessState currentState = trollState.GetStateComponent();

        //if(currentState.atMax())
        //{
        //
        //}



        // Update awareness

        distToPlayer  = Vector3.Distance(transform.position, player.position);
        angleToPlayer = Quaternion.FromToRotation(head.forward, player.position - transform.position).eulerAngles.y;
        angleToPlayer = angleToPlayer > 180 ? angleToPlayer = angleToPlayer - 360 : angleToPlayer;

        bool awarenessUpdated = UpdateVisionAwareness() ||
                                UpdateHearingAwareness() ||
                                UpdateSmellAwareness();


        if (!awarenessUpdated)
        {
            awareness = awareness - currentState.awarenessDecrease;
        }

        visionState = VisionState.UNSEEN;
        if (currentState.checkMin(awareness))
        {
            awareness = currentState.min;
        }

        if (currentState.checkMax(awareness))
        {
            awareness   = currentState.max;
            visionState = VisionState.SEEN;
        }
    }
Ejemplo n.º 3
0
 void SetState(TrollState.State nextState)
 {
     state.SetState(nextState);
     sense.ResetAwareness();
     GetComponent <NavMeshAgent>().speed = state.GetStateComponent().movementSpeed;
 }