Esempio n. 1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Obstacle"))
        {
            Destroy(gameObject);
        }

        if (shooter == Shooter.player)
        {
            EnemyAIController enemy   = collision.GetComponent <EnemyAIController>();
            BossBehaviour     boss    = collision.GetComponent <BossBehaviour>();
            ProtectionAntenna antenna = collision.GetComponent <ProtectionAntenna>();

            if (enemy != null)
            {
                Vector2 knockbackDirection = (enemy.transform.position - transform.position).normalized * shootKnockback;
                enemy.TakeDamage(shootDamage, knockbackDirection);
                Destroy(gameObject);
            }

            if (boss != null)
            {
                boss.TakeDamage(shootDamage);
                Destroy(gameObject);
            }

            if (antenna != null)
            {
                antenna.TakeDamage(shootDamage);
                Destroy(gameObject);
            }

            /*    if (!collision.CompareTag("Player"))
             *      Destroy(gameObject);*/
        }
        else
        {
            PlayerCombat enemy = collision.GetComponent <PlayerCombat>();
            if (enemy != null)
            {
                Vector2 knockbackDirection = (enemy.transform.position - transform.position).normalized * shootKnockback;
                enemy.TakeDamage(shootDamage, knockbackDirection);
                Destroy(gameObject);
            }

            /*     if (!collision.CompareTag("Enemy"))
             *       Destroy(gameObject);*/
        }
    }
Esempio n. 2
0
    private void Impact(Collider2D collider)
    {
        BossBehaviour bossBehaviour = collider.GetComponent <BossBehaviour>();

        if (bossBehaviour)
        {
            bossBehaviour.TakeDamage(transform.position, collider);
            gameObject.layer = BossProjectileCollisionLayer;
            bDidHitDragon    = true;
        }
        else if (bDidHitDragon)
        {
            gameObject.layer = BossProjectileCollisionLayer;
        }
        else
        {
            gameObject.layer = BossAndPlayerProjectileCollisionLayer;
        }
        bReturning             = true;
        PostHitLandingLocation = GameRule.get.GetPositionInBounds(0, GameRule.get.GetDragonAvoidanceRadius());
    }
Esempio n. 3
0
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        if (hitInfo.tag == "Enemy")
        {
            Enemy enemy = hitInfo.GetComponent <Enemy>();

            if (enemy != null)
            {
                enemy.TakeDamage(damage);
            }
        }
        else if (hitInfo.tag == "Boss")
        {
            BossBehaviour boss = hitInfo.GetComponent <BossBehaviour>();

            if (boss != null)
            {
                boss.TakeDamage(damage);
            }
        }
        Destroy(gameObject);
    }