예제 #1
0
파일: Bullet.cs 프로젝트: MrPhil/LD18
 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();
     }
 }
예제 #2
0
파일: Demo.cs 프로젝트: bsvercl/physics2d
 void clipper_Collided(object sender, CollisionEventArgs e)
 {
     OpenGlObject o = (OpenGlObject)e.Other.Tag;
     if (o == null) { return; }
     o.collided = true;
 }
예제 #3
0
파일: Demo.cs 프로젝트: bsvercl/physics2d
 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;
 }
예제 #4
0
파일: Demo.cs 프로젝트: bsvercl/physics2d
 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;
             }
         }
     }  
 }
예제 #5
0
파일: Demo.cs 프로젝트: bsvercl/physics2d
 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;
     }
 }
예제 #6
0
파일: Demo.cs 프로젝트: bsvercl/physics2d
 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);
     //}
 }
예제 #7
0
파일: Player.cs 프로젝트: MrPhil/LD18
 void Body_Collided(object sender, CollisionEventArgs e)
 {
     Health -= 10;
 }
예제 #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;
     }
 }
예제 #9
0
 void entity_Collided2(object sender, CollisionEventArgs e)
 {
     lock (points)
     {
         foreach (IContactPointInfo info in e.Contact.Points)
         {
             points.Add(info.Position);
         }
     }
 }
예제 #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();
        }