Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        switch (curState)
        {
        case FlyerState.Patrol:
            if (Vector3.Distance(transform.position, player.position) <= DistanceToThreaten)
            {
                curState = FlyerState.Threaten;
            }
            else
            {
                patrol.Patrolling();
            }
            break;

        case FlyerState.Threaten:
            if (!isThreatening)
            {
                StopCoroutine(Threat());
                StartCoroutine(Threat());
            }
            break;

        case FlyerState.Attack:
            if (!isAttacking)
            {
                StopCoroutine(Attack());
                StartCoroutine(Attack());
            }
            break;

        case FlyerState.Die:
            break;
        }
    }
    /*
     * Resume patrolling and re-activate detectors
     */
    protected IEnumerator ResumeCoroutines()
    {
        _visionCone.enabled     = true;
        _playerDetector.enabled = true;

        yield return(StartCoroutine(_pathFinding.FinishPatrol()));

        yield return(StartCoroutine(_patrolBehav.Wait()));

        _pathFinding.ResumePatrolStabaliser();

        _patrolBehav.enabled = true;
        StartCoroutine(_patrolBehav.Patrolling());
    }
Exemple #3
0
    public void Update()
    {
        switch (curState)
        {
        case BurrowerState.Patrol:
            if (!isUnderGround && !isDigging)
            {
                if (Random.Range(0, 1000) <= 1)
                {
                    StopCoroutine(Dig());
                    StartCoroutine(Dig());
                }
            }

            if (!isDigging)
            {
                if (Vector3.Distance(transform.position, player.position) <= DistanceToChase)
                {
                    curState = BurrowerState.Chase;
                }
                else
                {
                    patrol.Patrolling();
                }
            }

            break;

        case BurrowerState.Chase:
            if (!isChasing)
            {
                StopCoroutine(Chasing());
                StartCoroutine(Chasing());
            }
            break;

        case BurrowerState.Dead:
            GetComponent <Rigidbody>().velocity = Vector3.zero;
            break;
        }
    }
Exemple #4
0
    /*
     * For certain conditions after finishing a pursuit performs the according action
     * If player is dead or not seen after visual search, return to patrol
     */
    private IEnumerator PostPursuit()
    {
        if (!_player.GetComponent <PlayerNPCRelation>().dead)
        {
            _detector.SeenPlayer = false;
            _postSearch.enabled  = true;
            _spriteHand.PlayAnimation("idle");
            yield return(StartCoroutine(_postSearch.VisualSearch()));
        }

        if (_postSearch.ResumePatrol)
        {
            _player.GetComponent <PlayerNPCRelation>().CanDie = false;
            _spriteHand.StopAnimation("idle");
            yield return(StartCoroutine(FinishPatrol()));

            yield return(StartCoroutine(_patrolBehav.Wait()));

            ResumePatrolStabaliser();

            _patrolBehav.enabled = true;
            StartCoroutine(_patrolBehav.Patrolling());
        }
    }