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);
            BulletsFactory.ReleaseBullet(this);
        }
    }
Example #2
0
    private void Update()
    {
        this.UpdatePosition();

        // Very simple test if out of bound bullet.
        if (this.Position.x > 20 || this.Position.x < -20 || this.Position.y > 20 || this.Position.y < -20)
        {
            BulletsFactory.ReleaseBullet(this);
        }
    }