Esempio n. 1
0
    public void Kill()
    {
        if (!isDieing)
        {
            player.gameObject.GetComponent <SC_CharacterController>().ScoreUp(100);

            curState = BurrowerState.Dead;

            StopCoroutine(Chasing());
            StopCoroutine(Dig());

            isDieing = true;
            agent.Stop();
            anim.SetBool("Death", true);
            model.SetActive(true);
            attackArea.EndAttack();

            foreach (ParticleSystem ps in underGroundParticles)
            {
                ps.Stop();
            }
            foreach (ParticleSystem ps in diggingParticles)
            {
                ps.Stop();
            }

            Destroy(gameObject, 2f);
        }
    }
Esempio n. 2
0
    public void Start()
    {
        player   = GameObject.FindWithTag("Player").GetComponent <Transform>();
        curState = BurrowerState.Patrol;
        patrol   = GetComponent <Patrol>();

        diggingParticles     = DiggingParticles.GetComponentsInChildren <ParticleSystem>();
        underGroundParticles = UnderGroundParticles.GetComponentsInChildren <ParticleSystem>();

        agent = this.gameObject.GetComponent <NavMeshAgent>();

        model.SetActive(false);
        isUnderGround       = true;
        capCollider.enabled = false;
        foreach (ParticleSystem ps in underGroundParticles)
        {
            ps.Play();
        }
    }
Esempio n. 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;
        }
    }
Esempio n. 4
0
    IEnumerator Chasing()
    {
        isChasing = true;
        if (!isUnderGround && !isDigging)
        {
            StopCoroutine(Dig());
            StartCoroutine(Dig());
        }

        while (isDigging)
        {
            yield return(null);
        }

        float curTime = 0;

        while (!groundCheck.PlayerAbove && curTime < maxTimeToChase)
        {
            curTime += Time.deltaTime;
            agent.SetDestination(player.position);
            yield return(null);
        }


        agent.Stop();

        yield return(new WaitForSeconds(.5f));

        foreach (ParticleSystem ps in diggingParticles)
        {
            ps.Play();
        }

        model.SetActive(true);
        if (curState != BurrowerState.Dead)
        {
            attackArea.ActivateAttack(attack);
        }
        anim.SetBool("Attack", true);

        GetComponent <Rigidbody>().velocity = Vector3.zero;

        yield return(new WaitForSeconds(.33f));

        EndAttack();
        GetComponent <Rigidbody>().velocity = Vector3.zero;
        anim.SetBool("Attack", false);
        capCollider.enabled = true;

        foreach (ParticleSystem ps in underGroundParticles)
        {
            ps.Stop();
        }


        yield return(new WaitForSeconds(.5f));

        agent.Resume();
        isChasing     = false;
        isUnderGround = false;

        curState = BurrowerState.Patrol;
        GetComponent <Rigidbody>().velocity = Vector3.zero;
        yield return(null);
    }