Example #1
0
        public virtual bool Collide(ICollidable other)
        {
            lock (disposalLock)
            {
                if (!isDisposed)
                {
                    if (ActiveSprite.Collide(other.ActiveSprite))
                    {
                        if (other is Player.PlayerObject)
                        {
                            return(true);
                        }

                        if (other is Bullet)
                        {
                            if ((other as Bullet).IsPlayerBullet)
                            {
                                health      -= (other as Bullet).Damage;
                                shouldRemove = health <= 0;
                                hitPercent   = 1.0f;
                                (other as Bullet).ShouldRemove = true;
                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
Example #2
0
        public bool Collide(ICollidable other)
        {
            if (!Invulnerable)
            {
                if (other is Bullet)
                {
                    if (!(other as Bullet).IsPlayerBullet)
                    {
                        if (ActiveSprite.Collide(other.ActiveSprite))
                        {
                            incomingDamage += (other as Bullet).Damage;
                            (other as Bullet).ShouldRemove = true;
                            invulnerable     = true;
                            invulnerableTime = 1000;
                            return(true);
                        }
                    }
                }
                if (other is Enemy)
                {
                    if (ActiveSprite.Collide(other.ActiveSprite))
                    {
                        incomingDamage += (other as Enemy).Health / 4.0f;
                        (other as Enemy).TakeDamage((other as Enemy).Health);
                        (other as Enemy).ShouldRemove = true;
                        invulnerable     = true;
                        invulnerableTime = 1000;
                        return(true);
                    }
                }
            }

            return(false);
        }