public void Execute() { if (!player.IsDamaged) { if (player.DestinationRectangle.Intersects(enemy.DestinationRectangle)) { float dx = player.DestinationRectangle.X - enemy.DestinationRectangle.X; float dy = player.DestinationRectangle.Y - enemy.DestinationRectangle.Y; //top bottom collision if (System.Math.Abs(dx) < System.Math.Abs(dy)) { if (dy > 0) { player.North(); player.BeDamaged(); } else { player.South(); player.BeDamaged(); } } //left right collision else { if (dx > 0) { player.West(); player.BeDamaged(); } else { player.East(); player.BeDamaged(); } } } else { enemy.BeDamaged(); } } }