Example #1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        BaseAvatar avatar = null;

        switch (this.type)
        {
        case BulletType.PlayerSpiralBullet:
        case BulletType.PlayerBullet:
            avatar = other.gameObject.GetComponent <EnemyAvatar>();
            break;

        case BulletType.EnemyBullet:
            avatar = other.gameObject.GetComponent <PlayerAvatar>();
            break;

        default:
            Debug.LogError("Unknown bullet type " + this.type);
            break;
        }

        if (avatar != null)
        {
            avatar.TakeDamage(this.Damage);
            BulletFactory.Instance.Release(this);
        }
    }
Example #2
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        BaseAvatar avatar = other.gameObject.GetComponent <BaseAvatar>();

        if (avatar != null)
        {
            avatar.TakeDamage(this.DamageDealthAtCollision);
            this.TakeDamage(avatar.DamageDealthAtCollision);
        }
    }
Example #3
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        string tag = other.gameObject.tag;

        if (tag == "Bullet")
        {
            other.gameObject.SetActive(false);
            this.gameObject.SetActive(false);
        }
        else if (tag == "Player" || tag == "Enemy")
        {
            BaseAvatar avatar = other.GetComponent <BaseAvatar>();
            avatar.TakeDamage(damage);
            this.gameObject.SetActive(false);
        }
    }
Example #4
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        BaseAvatar avatar = collision.gameObject.GetComponent <BaseAvatar>();

        if (avatar != null)
        {
            avatar.TakeDamage(Damage);
            BulletFactory.ReleaseBullet(this);
        }
        else
        {
            Bullet bullet = collision.gameObject.GetComponent <Bullet>();
            if (bullet != null)
            {
                BulletFactory.ReleaseBullet(this);
                BulletFactory.ReleaseBullet(bullet);
            }
        }
    }
Example #5
0
    void OnTriggerEnter2D(Collider2D other)
    {
        //Selon la nature de la balle, on cible le joueur on l'ennemi
        BaseAvatar target = null;

        if (bulletType == BulletType.Player)
        {
            target = other.GetComponent <EnemyAvatar> ();
        }
        else if (bulletType == BulletType.EnnemyBullet)
        {
            target = other.GetComponent <PlayerAvatar> ();
        }
        //On blesse la cible acquise et on détruit la balle
        if (target)
        {
            target.TakeDamage(Damage);
            BulletFactory.Instance.Relase(gameObject.GetComponent <Bullet>());
        }
    }