Ejemplo n.º 1
0
    private void OnTriggerStay2D(Collider2D other)
    {
        if (other.gameObject.tag == "Enemy")
        {
            inRange = true;
        }

        if (other.gameObject.tag == "Enemy" && targetHealth == null)
        {
            targetHealth = other.GetComponent <EnemyMeleeScript>();
        }


        if (other.gameObject.tag == "Ranged")
        {
            inRangeRanged = true;
        }

        if (other.gameObject.tag == "Ranged" && enemyHealth == null)
        {
            enemyHealth = other.GetComponent <EnemyRangedScript>();
        }


        if (other.gameObject.tag == "Boss")
        {
            inRangeBoss = true;
        }

        if (other.gameObject.tag == "Boss" && BossHealth == null)
        {
            BossHealth = other.GetComponent <BossScript>();
        }
    }
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        enemyMelee   = enemyMelee ?? animator.GetComponent <EnemyMeleeScript>();
        jottunScript = jottunScript ?? animator.GetComponent <JottunScript>();

        enemyMelee.ToggleAttackTrigger(true);
    }
Ejemplo n.º 3
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Enemy")
        {
            targetHealth = other.GetComponent <EnemyMeleeScript>();
            targetHealth.Damage(ArrowDamage);

            if (secondHit)
            {
                Destroy(gameObject);
            }

            secondHit = true;
            // Destroy(gameObject);
        }

        else if (other.tag == "Ranged")
        {
            enemyHealth = other.GetComponent <EnemyRangedScript>();
            enemyHealth.Damage(ArrowDamage);

            if (secondHit)
            {
                Destroy(gameObject);
            }

            secondHit = true;
        }

        else if (other.tag == "Boss")
        {
            bossHealth = other.GetComponent <BossScript>();
            bossHealth.Damage(ArrowDamage);

            if (secondHit)
            {
                Destroy(gameObject);
            }

            secondHit = true;
        }
    }
Ejemplo n.º 4
0
    private void OnTriggerExit2D(Collider2D other)
    {
        if (other.gameObject.tag == "Enemy")
        {
            inRange      = false;
            targetHealth = null;
        }

        if (other.gameObject.tag == "Ranged")
        {
            inRangeRanged = false;
            enemyHealth   = null;
        }

        if (other.gameObject.tag == "Boss")
        {
            inRangeBoss = false;
            BossHealth  = null;
        }
    }