Пример #1
0
 public bool CollisionsWithObjects(RoundObject obj, List <GameObject> objects)
 {
     foreach (RoundObject Obj in objects.OfType <RoundObject>())
     {
         if (obj != Obj)
         {
             if (Vector2.Distance(Obj.Position, obj.Position) < (Obj.Radius + obj.Radius))
             {
                 return(true);
             }
         }
     }
     foreach (SquareObject Obj in objects.OfType <SquareObject>())
     {
         if (Math.Abs(Obj.IW.Position.Y - obj.Position.Y) <= Obj.RadiusHeight)
         {
             if (Math.Abs(Obj.IW.Position.X - obj.Position.X) <= Obj.RadiusWidth + obj.Radius)
             {
                 return(true);
             }
         }
         if (Math.Abs(Obj.IW.Position.Y - obj.Position.Y) <= Obj.RadiusHeight + obj.Radius)
         {
             if (Math.Abs(Obj.IW.Position.X - obj.Position.X) <= Obj.RadiusWidth +
                 Math.Sqrt(obj.Radius * obj.Radius - Math.Pow(Math.Abs(Obj.IW.Position.Y - obj.Position.Y) - Obj.RadiusHeight, 2.0)))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Пример #2
0
 public bool CollisionsWithBondary(RoundObject obj, Maps Map)
 {
     if (obj.Position.X - obj.Radius <= 0 ||
         obj.Position.Y - obj.Radius <= 0 ||
         obj.Position.X + obj.Radius >= Map.Info.WidthTexture ||
         obj.Position.Y + obj.Radius >= Map.Info.HeightTexture)
     {
         return(true);
     }
     return(false);
 }