private void CheckIntersectionAndHandleCollision(INpc npc, IBlock block) { Rectangle collisionFound = Rectangle.Intersect(npc.GetRectangle(), block.GetRectangle()); if (!collisionFound.IsEmpty) { Constants.Direction side = UtilityMethods.GetCollisionDirection(npc.GetRectangle(), block.GetRectangle(), collisionFound); handlerDictionary.GetNpcBlockHandler(npc.GetType()).HandleCollision(npc, block, side); } }
private void CheckIntersectionAndHandleCollision(INpc npc, IProjectile projectile) { Rectangle collisionFound = Rectangle.Intersect(npc.GetRectangle(), projectile.GetRectangle()); if (!collisionFound.IsEmpty) { Constants.Direction side = UtilityMethods.GetCollisionDirection(npc.GetRectangle(), projectile.GetRectangle(), collisionFound); if (projectile.GetType() == typeof(SwordAttackingProjectile)) { SwordAttackingProjectile tempProjectile = (SwordAttackingProjectile)projectile; side = tempProjectile.Direction; } handlerDictionary.GetNpcProjectileHandler(projectile.GetType()).HandleCollision(npc, projectile, side); } }
private void CheckIntersectionAndHandleCollision(IPlayer player, INpc npc) { Rectangle collisionFound = Rectangle.Intersect(player.GetRectangle(), npc.GetRectangle()); if (!collisionFound.IsEmpty) { Constants.Direction side = UtilityMethods.GetCollisionDirection(player.GetRectangle(), npc.GetRectangle(), collisionFound); handlerDictionary.GetPlayerNpcHandler(npc.GetType()).HandleCollision(player, npc, side); } }