Exemple #1
0
 void Body_Collided(object sender, CollisionEventArgs e)
 {
     Body gotHitBy = null;
     if (e.Contact.Body1 == Body)
     {
         gotHitBy = e.Contact.Body2;
     }
     else
     {
         gotHitBy = e.Contact.Body1;
     }
     if (gotHitBy.Tag == (object)"BeamTag")
     {
         Body.ApplyImpulse(new Vector2D(10, 10));
     }
     else
     {
         Kill();
     }
 }
Exemple #2
0
 void clipper_Collided(object sender, CollisionEventArgs e)
 {
     OpenGlObject o = (OpenGlObject)e.Other.Tag;
     if (o == null) { return; }
     o.collided = true;
 }
Exemple #3
0
 void weapon_Collided(object sender, CollisionEventArgs e)
 {
     Body weapon = (Body)sender;
     weapon.Lifetime.IsExpired = true;
     AddParticles(weapon.State.Position.Linear, weapon.State.Velocity.Linear*.5f, 200);
     weapon.Collided -= weapon_Collided;
 }
Exemple #4
0
 void DemoI_Body_Collided(object sender, CollisionEventArgs e)
 {
     Body b = (Body)sender;
     foreach( BodyProxy prox in  b.Proxies)
     {
         if (e.Other == prox.Body2)
         {
             if (b.ID > e.Other.ID)
             {
                 b.Lifetime.IsExpired = true;
             }
             else
             {
                 e.Other.Lifetime.IsExpired = true;
             }
         }
     }  
 }
Exemple #5
0
 void particle_Collided(object sender, CollisionEventArgs e)
 {
     Body b1 = (Body)sender;
     Body b2 = e.Other;
     Vector2D p = e.Contact.Points[0].Position;
     Vector2D p1, p2, rv;
     Vector2D.Subtract(ref p, ref b1.State.Position.Linear, out p1);
     Vector2D.Subtract(ref p, ref b2.State.Position.Linear, out p2);
     PhysicsHelper.GetRelativeVelocity(ref b1.State.Velocity, ref b2.State.Velocity, ref p1, ref p2, out rv);
     if (rv.Magnitude < 1)
     {
         b1.Lifetime.IsExpired = true;
     }
 }
Exemple #6
0
 void body2_Collided(object sender, CollisionEventArgs e)
 {
    /* if ((sender == body1IT ||
         sender == body2IT) &&
         (e.Other == body1IT ||
         e.Other == body2IT))
     {*/
         Console.WriteLine("HAHA");
         e.Contact.Ended += new EventHandler(Contact_Ended);
     //}
 }
Exemple #7
0
 void Body_Collided(object sender, CollisionEventArgs e)
 {
     Health -= 10;
 }
Exemple #8
0
 void OnParticleCollided(object sender, CollisionEventArgs e)
 {
     Body b1 = (Body)sender;
     Body b2 = (Body)e.Other;
     if ((b1.State.Velocity.Linear - b2.State.Velocity.Linear).MagnitudeSq < 1)
     {
         b1.Lifetime.IsExpired = true;
     }
 }
Exemple #9
0
 void entity_Collided2(object sender, CollisionEventArgs e)
 {
     lock (points)
     {
         foreach (IContactPointInfo info in e.Contact.Points)
         {
             points.Add(info.Position);
         }
     }
 }
Exemple #10
0
        /// <summary>
        /// Triggered when an object hits the player.
        /// </summary>
        private void OnBodyCollided(object sender, CollisionEventArgs args)
        {
            // If we aren't connected, we don't care
            if (args.Other.Tag == null)
                return;

            // See if we are a module
            Module m = args.Other.Tag as Module;

            if (m == null || m == this)
                return;

            // Add a bit of the radius to ours
            if (m is EngineModule)
                EnginePower += (float) Math.Log(m.Radius);
            if (m is ContainmentModule)
                ContainmentPower += (float) Math.Log(m.Radius);

            // Kill the old one
            args.Other.Tag = null;
            State.Physics.Remove(m);

            // Rebuild the body
            RebuildBody();
        }