예제 #1
0
    public IEnumerator SwordAttack()
    {
        if (!ai.attacking)
        {
            attackNumber  += 1;
            ai.anim.speed  = ai.startAnimSpeed;
            ai.attacking   = true;
            ai.rb.velocity = Vector2.zero;     //Stop moving to make the animation look better
            ai.anim.SetBool("Moving", false);
            ai.anim.SetBool("Attacking", true);
            while (!ai.anim.GetCurrentAnimatorStateInfo(0).IsTag("Attack")) //wait for first frame of attack anim before starting
            {
                yield return(null);
            }
            yield return(new WaitForSeconds(ai.anim.GetCurrentAnimatorStateInfo(0).length)); //wait while current anim is still playing

            {
                yield return(null);
            }
            ai.anim.SetBool("Attacking", false);
            ai.attacking = false;
        }
        ai.CheckEnemyState();

        yield return(null);
    }
예제 #2
0
파일: Minotaur.cs 프로젝트: scurfield/Iso
    public IEnumerator Axe()
    {
        if (!ai.attacking)
        {
            ai.anim.speed = ai.startAnimSpeed;
            ai.attacking  = true;
            rb.velocity   = Vector2.zero;
            ai.anim.SetBool("Axe", true);
            while (!ai.anim.GetCurrentAnimatorStateInfo(0).IsTag("Axe")) //wait for first frame of attack anim before starting
            {
                yield return(null);
            }
            directionToPlayer = (ai.player.transform.position - gameObject.transform.position).normalized;
            rb.AddForce(directionToPlayer * 20000);
            yield return(new WaitForSeconds(ai.anim.GetCurrentAnimatorStateInfo(0).length)); //wait while current anim is still playing

            {
                yield return(null);
            }
            ai.anim.SetBool("Axe", false);
            ai.attacking = false;
        }
        ai.CheckEnemyState();
        yield return(null);
    }
예제 #3
0
    public IEnumerator Stab()
    {
        if (!ai.attacking)
        {
            ai.anim.speed  = ai.startAnimSpeed;
            ai.attacking   = true;
            ai.rb.velocity = Vector2.zero;
            ai.anim.SetTrigger("Stab");
            while (!ai.anim.GetCurrentAnimatorStateInfo(0).IsTag("Stab")) //wait for first frame of attack anim before starting
            {
                yield return(null);
            }
            yield return(new WaitForSeconds(ai.anim.GetCurrentAnimatorStateInfo(0).length)); //wait while current anim is still playing

            {
                yield return(new WaitForSeconds(0.5f));//to give space between attacks
            }
            ai.attacking = false;
        }
        ai.CheckEnemyState();
        yield return(null);
    }