Exemplo n.º 1
0
    public virtual IEnumerator inflictdamage()
    {
        dontMove();
        canAttack = false;
        anim.animationAttak();
        yield return(new WaitForSeconds(1.5f));

        canAttack = true;
    }
Exemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     distanceToPlayer = Vector3.Distance(transform.position, PlayerController.instance.transform.position);
     if (activeBattle)
     {
         attackCounter -= Time.deltaTime;
         if (attackCounter <= 0)
         {
             enAnimMan.animationAttak();
             attackCounter = attackTime;
         }
     }
 }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        float distanceToPlayer = Vector3.Distance(transform.position, PlayerController.instance.transform.position);

        switch (currentState)
        {
        case enemyState.idle: anim.animationMove(false);
            if (waitCounter > 0)
            {
                waitCounter -= Time.deltaTime;
            }
            else
            {
                currentState = enemyState.patroll;
                agent.SetDestination(patrollPoints[currentPatrollPoint].transform.position);
            }
            if (distanceToPlayer <= chaseRange)
            {
                currentState = enemyState.chasing;
                anim.animationMove(true);
            }
            break;

        case enemyState.patroll: if (agent.remainingDistance <= .2f)
            {
                currentPatrollPoint++;
                if (currentPatrollPoint >= patrollPoints.Length)
                {
                    currentPatrollPoint = 0;
                }
                currentState = enemyState.idle;
                waitCounter  = waitAtPoint;
            }
            if (distanceToPlayer <= chaseRange)
            {
                currentState = enemyState.chasing;
            }
            anim.animationMove(true); break;

        case enemyState.chasing: agent.SetDestination(PlayerController.instance.transform.position);
            if (distanceToPlayer <= attackRange)
            {
                currentState = enemyState.attack;
                if (haveMultipleAttack)
                {
                    anim.randomAttack();
                }
                else
                {
                    anim.animationAttak();
                }

                anim.animationMove(false);
                agent.velocity  = Vector3.zero;
                agent.isStopped = true;
                attackCounter   = timeBetweenAttacks;
            }
            if (distanceToPlayer > chaseRange)
            {
                currentState   = enemyState.idle;
                waitCounter    = waitAtPoint;
                agent.velocity = Vector3.zero;
                agent.SetDestination(transform.position);
            }
            break;

        case enemyState.attack: transform.LookAt(PlayerController.instance.transform.position);
            transform.rotation = Quaternion.Euler(0, transform.rotation.eulerAngles.y, 0);
            attackCounter     -= Time.deltaTime;
            if (attackCounter <= 0)
            {
                if (distanceToPlayer <= attackRange)
                {
                    if (haveMultipleAttack)
                    {
                        anim.randomAttack();
                        attackCounter = timeBetweenAttacks;
                    }
                    else
                    {
                        anim.animationAttak();
                        attackCounter = timeBetweenAttacks;
                    }
                }
                else
                {
                    currentState    = enemyState.idle;
                    waitCounter     = waitAtPoint;
                    agent.isStopped = false;
                }
            }
            break;
        }
    }