Ejemplo n.º 1
0
 // Use this for initialization
 void Start()
 {
     initPos = transform.position;
     initVel = vel;
     started = false;
     name    = physicsManager.AddObject("ball", mass, Vector3.zero);
     physicsManager.SetObject(name, mass, vel);
     physicsManager.SetObject(name, bounciness, bounceCombineType);
     physicsManager.AddForce(name, "Earth", ForceType.GRAVITY, physicsManager.CalGravity(mass));
     StartCoroutine(UpdatePosition());
 }
Ejemplo n.º 2
0
        public void Test()
        {
            IsMouseVisible = true;

            // Create our Box
            Box = new Box(this);
            Components.Add(Box);

            // Create our Ground
            Ground = new Ground(this);
            Components.Add(Ground);

            // Create our Phsyics Manager
            PhysicsManager = new PhysicsManager(this);
            Components.Add(PhysicsManager);

            // Add our Bodies to our phsyics manager
            PhysicsManager.AddBody(Box);
            PhysicsManager.AddBody(Ground);

            // Add our Forces to our physics manager
            PhysicsManager.AddForce(new GravityForce());

            Run();
        }
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "ball")
     {
         physicsManager.AddForce(name, other.gameObject.name, ForceType.NORMAL);
     }
 }
Ejemplo n.º 4
0
        public void Test()
        {
            IsMouseVisible = true;

            // Create our Phsyics Manager
            PhysicsManager = new PhysicsManager(this);
            Components.Add(PhysicsManager);

            // Add our Forces to our physics manager
            PhysicsManager.AddForce(new Gravity());
            PhysicsManager.AddForce(new Friction());

            #region Box Generation

            for (int i = 0; i < 12; i++)
            {
                // Create our Box
                Box box = new Box(this);
                box.Position = new Vector2(60 * i + 35f, 300);
                Components.Add(box);

                // Add it to our physics manager
                PhysicsManager.AddBody(box);
            }

            for (int i = 0; i < 11; i++)
            {
                // Create our Box
                Box box = new Box(this);
                box.Position = new Vector2(60 * i + 70f, 100);
                Components.Add(box);

                // Add it to our physics manager
                PhysicsManager.AddBody(box);
            }

            for (int i = 0; i < 10; i++)
            {
                // Create our Box
                Box box = new Box(this);
                box.Position = new Vector2(60 * i + 105f, 20);
                Components.Add(box);

                // Add it to our physics manager
                PhysicsManager.AddBody(box);
            }

            for (int i = 0; i < 9; i++)
            {
                // Create our Box
                Box box = new Box(this);
                box.Position = new Vector2(60 * i + 140f, -40);
                Components.Add(box);

                // Add it to our physics manager
                PhysicsManager.AddBody(box);
            }

            #endregion

            // Create our Ground
            Ground = new Ground(this);
            Components.Add(Ground);

            // Add it to our physics manager
            PhysicsManager.AddBody(Ground);

            Run();
        }