IEnumerator AutoMove()
    {
        yield return(new WaitForSeconds(0.2f));

        // Move left
        while (Mathf.Abs(transform.position.x - leftMarker.transform.position.x) > 0.1f)
        {
            lumberjack.MoveHorizontalInput(-1);
            yield return(new WaitForEndOfFrame());
        }

        lumberjack.MoveHorizontalInput(0);

        while (true)
        {
            for (int i = 0; i < 10; i++)
            {
                lumberjack.SwingAxe();
                yield return(new WaitForSeconds(1.5f));
            }

            yield return(new WaitForSeconds(0.5f));

            // Move right
            while (Mathf.Abs(transform.position.x - rightMarker.transform.position.x) > 0.1f)
            {
                lumberjack.MoveHorizontalInput(1);
                yield return(new WaitForEndOfFrame());
            }

            lumberjack.MoveHorizontalInput(0);

            yield return(new WaitForSeconds(0.5f));

            lumberjack.GetComponent <SpriteRenderer>().flipX = true;
            for (int i = 0; i < 10; i++)
            {
                lumberjack.SwingAxe();
                yield return(new WaitForSeconds(1.5f));
            }
            lumberjack.GetComponent <SpriteRenderer>().flipX = false;

            // Move left
            while (Mathf.Abs(transform.position.x - leftMarker.transform.position.x) > 0.1f)
            {
                lumberjack.MoveHorizontalInput(-1);
                yield return(new WaitForEndOfFrame());
            }

            lumberjack.MoveHorizontalInput(0);
        }
    }
Exemplo n.º 2
0
    void HeavyAttack()
    {
        Collider2D[] hits = Physics2D.OverlapCircleAll(attackPoint.position, heavyAttackRange, LumberjackLayer);
        attackHeavySource.Play();

        foreach (Collider2D Lumberjack in hits)
        {
            Lumberjack.GetComponent <Lumberjack>().TakeDamage(heavyAttackDamage);
        }

        Collider2D[] hits2 = Physics2D.OverlapCircleAll(attackPoint.position, heavyAttackRange, HunterLayer);


        foreach (Collider2D Hunter in hits2)
        {
            Hunter.GetComponent <Hunter>().TakeDamage(heavyAttackDamage);
        }
    }