Example #1
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        Fireball fireball = collision.GetComponent <Fireball>();

        if (fireball != null)
        {
            fireball.Destroyed();
            StartCoroutine(Damaged(fireball.GetDamage()));
        }
    }
Example #2
0
    private void MoveTowardsTarget()
    {
        if (target == null)
        {
            Destroy(gameObject);
        }

        transform.position = Vector3.MoveTowards(transform.position, targetPos, 0.25f);
        if (transform.position == targetPos)
        {
            GetFireballStats();
            int dmg = fireball.GetDamage();
            gi.SetDmgTextColor(1);
            if (target != null)
            {
                target.DecreaseHP(dmg, null);
                Destroy(gameObject);
            }
        }
    }