public override void OnCollision(Collidable obj) { //if player is already destroy, return if (!active) { return; } //if collide with an enemy, destroy player if (obj.GetType() == typeof(Enemy)) { this.active = false; FireDestroyEvent(new RemoveGameObjectEventArgs(0)); } //if collide with a projectile from enemy, destory player if (obj.GetType() == typeof(EnemyProjectile)) { this.active = false; FireDestroyEvent(new RemoveGameObjectEventArgs(0)); } //if ocllide with a power up, remove the object from the world, //event will be sent to here from powerup manager if (obj.GetType() == typeof(PowerUp)) { PowerUp pu = obj as PowerUp; //if cast succeessed if (pu != null) { pu.Active = false; } } }
public override void OnCollision(Collidable obj) { if (obj != owner) { if (typeof(Enemy) == obj.GetType()) //compare class { Enemy e = obj as Enemy; e.ReduceHP(); active = false; } } }
public override bool CollisionTest(Collidable obj) { if (obj != null) { if (obj.GetType() == typeof(Enemy)) { return(BoundingBox.Intersects(obj.BoundingBox)); } } return(false); }