Пример #1
0
 public void AddPhysicalObject(PhysicalObject Object)
 {
     if (!PhysicalObjects.Contains(Object))
     {
         PhysicalObjects.Add(Object);
     }
 }
Пример #2
0
 private void SetColliderLocation(PhysicalObject Object)
 {
     Object.ColliderHandler.BoxCollider.Margin = Object.ObjectImage.Margin;
     Object.ColliderHandler.AdjustColliderLocation(Object.ColliderHandler.AdjustmentX, Object.ColliderHandler.AdjustmentY);
     Object.ColliderHandler.UpdateVerticesCoordinates();
     Object.ColliderHandler.BoxCollider.SetValue(Canvas.ZIndexProperty,
                                                 Object.ColliderHandler.BoxCollider.Margin.Top);
 }
Пример #3
0
 private void SetLocation(PhysicalObject Object, double LocationX, double LocationY)
 {
     Object.ObjectImage.Margin = new Thickness(Object.ObjectImage.Margin.Left + LocationX, Object.ObjectImage.Margin.Top + LocationY,
                                               Object.ObjectImage.Margin.Right, Object.ObjectImage.Margin.Bottom);
     Object.ObjectImage.SetValue(Canvas.ZIndexProperty,
                                 Object.ObjectImage.Margin.Top + Object.Adjustment);
     if (Object.ColliderHandler != null)
     {
         SetColliderLocation(Object);
     }
 }
Пример #4
0
        public void AddPhysicalObjectToStage(PhysicalObject Object, Vector2 Location)
        {
            if (!MainStage.Children.Contains(Object.ObjectImage) && PhysicalObjects.Contains(Object))
            {
                MainStage.Children.Add(Object.ObjectImage);

                if (Object.ColliderHandler != null)
                {
                    MainStage.Children.Add(Object.ColliderHandler.BoxCollider);
                    ManagerCollision.AddCollider(Object.ColliderHandler);
                }

                SetLocation(Object, Location.X, Location.Y);
            }
        }
Пример #5
0
        public void RemovePhysicalObject(PhysicalObject Object)
        {
            if (PhysicalObjects.Contains(Object))
            {
                PhysicalObjects.Remove(Object);

                if (MainStage.Children.Contains(Object.ObjectImage))
                {
                    MainStage.Children.Remove(Object.ObjectImage);

                    if (Object.ColliderHandler != null)
                    {
                        MainStage.Children.Remove(Object.ColliderHandler.BoxCollider);
                        ManagerCollision.RemoveCollider(Object.ColliderHandler);
                    }
                }
            }
        }