Beispiel #1
0
    IEnumerator Attack()
    {
        isAttacking = true;
        float timeTaken = 0;

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

        attackArea.ActivateAttack(oozeAttack);

        while (timeTaken < TimeToAttack && curState != BomberState.Die)
        {
            timeTaken += Time.deltaTime;

            transform.position += transform.forward * AttackSpeed * Time.deltaTime;

            yield return(null);
        }

        attackArea.EndAttack();

        isAttacking = false;
        curState    = curState == BomberState.Die ? BomberState.Die : BomberState.Patrol;
        yield return(null);
    }
    IEnumerator ActivatingAttack()
    {
        isActivatingAttack = true;
        yield return(new WaitForSeconds(.25f));

        attackArea.ActivateAttack(attack);
        yield return(new WaitForSeconds(.33f));

        attackArea.EndAttack();
        isActivatingAttack = false;
    }
Beispiel #3
0
    IEnumerator Attack()
    {
        isAttacking = true;
        float      timeTaken = 0;
        Quaternion init      = new Quaternion(transform.rotation.x, transform.rotation.y, transform.rotation.z, transform.rotation.w);

        attackArea.ActivateAttack(diveAttack);
        transform.LookAt(player);

        while (timeTaken < TimeToAttack && curState != FlyerState.Die)
        {
            timeTaken += Time.deltaTime;

            transform.position += transform.forward * AttackSpeed * Time.deltaTime;

            yield return(null);
        }

        attackArea.EndAttack();

        timeTaken = 0;

        while (timeTaken < TimeToAttack * 2 && curState != FlyerState.Die)
        {
            timeTaken += Time.deltaTime;

            transform.position -= transform.forward * AttackSpeed * .5f * Time.deltaTime;

            yield return(null);
        }

        transform.rotation = init;

        isAttacking = false;
        curState    = curState == FlyerState.Die ? FlyerState.Die : FlyerState.Patrol;
        yield return(null);
    }
Beispiel #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);
    }