Ejemplo n.º 1
0
    void OnMouseDown()
    {
        if (!enabled)
        {
            return;
        }

        _descriptionBox.text = _behaviour.ReturnBehaviourDescription();
        _soundHandler.PlaySound("Select", 0.8f);
    }
    /*
     * Depending on whether guard still detects player or not after baffling
     * Guard will set either suspicion or alarmed state for the pursuit (travel to last seen position)
     */
    private void SetNavigationState(RaycastHit2D playerLastSeen, RaycastHit2D detectPlayer)
    {
        Node nodeLastSeen = _detection.CalculateNodeLastSeen(playerLastSeen);

        if (detectPlayer.collider != null && detectPlayer.collider.tag == PlayerTag)
        {
            //Debug.Log("pursue");
            _coneRender.ActivateState(_alarmed);
            _soundHandler.PlaySound("Alarmed", 0.75f);
            _pathFinder.SetSpeed(_pathFinder.ReturnChaseSpeed());
            _pathFinder.SetGoal(nodeLastSeen); // last seen when detect, not after baffled
        }
        else
        {
            _pathFinder.SetSpeed(_pathFinder.ReturnCautiousSpeed());
            _pathFinder.SetGoal(nodeLastSeen);
            SeenPlayer = false; //so still chase
        }

        if (nodeLastSeen.GetY() > _patrolBehav.ReturnNodeGuardAt().GetY())
        {
            transform.parent.gameObject.layer = 11;
        }
    }