Ejemplo n.º 1
0
        public BodiesPair(RoundBodyModel body1, RoundBodyModel body2)
        {
            Body1 = body1;
            Body2 = body2;

            Id = Extensions.CalculateHash(body1.Id, body2.Id);
        }
Ejemplo n.º 2
0
        public void GenerateBlackHole(int mass = 5000000)
        {
            var blackHole = new RoundBodyModel((ushort) (Bodies.Any() ? Bodies.Max(x => x.Id) + 1
                                                                      : 1))
            {
                Mass = new Mass(mass),
                CenterX = new Coordinate(MaxX/2),
                CenterY = new Coordinate(MaxY/2),
            };

            blackHole.SetDiameter();

            Bodies.ForEach(x =>
                          {
                              var pair = new BodiesPair(blackHole, x);
                              Pairs.Add(pair.Id, pair);

                          });

            Bodies.Add(blackHole);
        }
Ejemplo n.º 3
0
        public void GenerateBodies(int count = BodiesCount)
        {
            var random = new Random();

            for (int i = 0; i < count; i++)
            {
                var temp = new RoundBodyModel((ushort) i)
                {
                    Mass = new Mass(random.Next(MaxMass)),
                    CenterX = new Coordinate(random.Next(MaxX)),
                    CenterY = new Coordinate(random.Next(MaxY)),
                    Speed = new Speed(random.Next(-MaxSpeed, MaxSpeed), random.Next(-MaxSpeed, MaxSpeed))
                };

                temp.SetDiameter();

                Bodies.ForEach(x =>
                              {
                                  var pair = new BodiesPair(x, temp);
                                  Pairs.Add(pair.Id, pair);
                              });

                Bodies.Add(temp);
            }
        }
Ejemplo n.º 4
0
        public void OnBodyClicked(RoundBodyModel body, Point mousePosition)
        {
            body.CenterX.Value = mousePosition.X;
            body.CenterY.Value = mousePosition.Y;

            OnPropertyChanged(body, "Top");
            OnPropertyChanged(body, "Left");
        }
Ejemplo n.º 5
0
 private void UIElement_OnPreviewMouseUp(object sender, MouseButtonEventArgs e)
 {
     _selected = null;
 }
Ejemplo n.º 6
0
 private void UIElement_OnPreviewMouseDown(object sender, MouseButtonEventArgs e)
 {
     _selected = (RoundBodyModel)((FrameworkElement)sender).DataContext;
 }