Ejemplo n.º 1
0
        [Ignore] //ignoring this while I refactor
        public void Physics_Verify_RemoveFlaggedObjects()
        {
            List <bool> tfl = new List <bool>()
            {
                true, false
            };

            foreach (bool tf in tfl)
            {
                Physics  physics      = new Physics();
                Universe universe     = new Universe(tf);
                int      numBodies    = 10;
                int      countFlagged = 0;
                for (int i = 0; i < numBodies; i++)
                {
                    Body b = tf ? new Body() : new RelativeBody();
                    if (random.NextDouble() < 0.5)
                    {
                        b.deletionFlag = true;
                        countFlagged++;
                    }
                    universe.AddBody(b);
                }
                physics.RemoveFlaggedObjects(ref universe);
                Assert.AreEqual(numBodies - countFlagged, universe.GetBodies().Count);
            }
        }
Ejemplo n.º 2
0
        public void Physics_Verify_UpdateBodies()
        {
            List <bool> tfl = new List <bool>()
            {
                true, false
            };

            foreach (bool tf in tfl)
            {
                Physics       physics   = new Physics();
                Universe      universe  = new Universe(tf);
                List <Vector> newVects  = new List <Vector>();
                int           numBodies = 4;
                for (int i = 0; i < numBodies; i++)
                {
                    Body b = tf ? new Body() : new RelativeBody();
                    b.p = Vector.RandVect();
                    Vector rVecNext = Vector.RandVect();
                    newVects.Add(rVecNext);
                    b.pNext = rVecNext;
                    universe.AddBody(b);
                }
                physics.UpdateBodies(universe);
                for (int i = 0; i < numBodies; i++)
                {
                    Assert.IsTrue(newVects[i] == universe.GetBodies()[i].p);
                }
            }
        }
Ejemplo n.º 3
0
 // Use this for initialization
 protected void Start()
 {
     lr = gameObject.AddComponent(typeof(LineRenderer)) as LineRenderer;
     lr.SetColors(Color.grey, Color.black);
     lr.SetWidth(.1f, .05f);
     lr.material = lineRendererMaterial;
     position    = new Vector2d(transform.position.x * Universe.scale, transform.position.y * Universe.scale);
     if (double.IsNaN(position.x) || double.IsNaN(position.y))
     {
         position = new Vector2d(0, 0);
     }
     Universe.AddBody(this);
 }