Exemplo n.º 1
0
 public void OnContact(Collision col)
 {
     if (col.HasActor(Body) != null)
     {
         Body.LinearDamping = 0.5f;
         JabActor other = col.HasActor(Body);
         if (!(other.UserData is Chicken) && !World.IsEntityGroup(other.CollisionGroup))
         {
             hasCollidedOnce = true;
         }
         if (other.Friction <= 0.005f)
         {
             Body.Restitution = 0.0f;
             if (Body.LinearVelocity.Length() > 0.5f && !IsSliding)
             {
                 AudioQueue.PlaySlide(true);
                 IsSliding = true;
             }
             else if(IsSliding)
             {
                 IsSliding = false;
                 AudioQueue.PlaySlide(false);
             }
         }
         else
         {
             if (IsSliding)
             {
                 IsSliding = false;
                 AudioQueue.PlaySlide(false);
             }
             Body.Restitution = 0.5f;
         }
     }
 }
Exemplo n.º 2
0
 public void EndContact(Collision col)
 {
     if (col.HasActor(Body) != null)
     {
         JabActor other = col.HasActor(Body);
         if (IsSliding)
         {
             IsSliding = false;
             AudioQueue.PlaySlide(false);
         }
     }
 }
Exemplo n.º 3
0
        void AfterContact(Collision col)
        {
            JabActor other = col.HasActor(Body);
            if (other != null && health > 0)
            {
                Vector2 relativeForce = other.LinearVelocity * other.Mass - Body.LinearVelocity * Body.Mass;

                if (health <= 0)
                {
                }
                else if (other.UserData is Chicken && health > 0)
                {
                    (other.UserData as Chicken).AfterBreakableHit(this);
                }
            }
        }
Exemplo n.º 4
0
        void OnContact(Collision col)
        {
            JabActor other = col.HasActor(Body);
            if (other != null && health > 0 && !World.IsEntityGroup(other.CollisionGroup))
            {
                Vector2 relativeForce = other.LinearVelocity * other.Mass - Body.LinearVelocity * Body.Mass;

                if (other.UserData is BreakableBody)// || other.UserData is Fox)
                {
                    relativeForce /= 30.0f; //reduced once because of uluru 9, concrete falling on glass failed to break it
                }
                else if (other.UserData is Fox)
                {
                    relativeForce /= 10.0f;
                }
                else
                {
                    relativeForce /= 6.0f;
                }
                if (relativeForce.Length() > 0.1f)
                {
                    health -= relativeForce.Length();
                    Event e = new BreakableHit(material);
                    e.Position = Body.Position;
                    EventManager.Get.SendEvent(e);
                    PlayHitSFXForMaterial(material);
                }
                if (health <= 0)
                {
                    Event e = new BreakableDestroyed(material);
                    e.Position = Body.Position;
                    EventManager.Get.SendEvent(e);
                    PlaySFXBreakForMaterial(material);
                    health = 0;
                    if (!SplintersCreated)
                    {
                        CreateSplinters();
                        SplintersCreated = true;
                    }
                    if (other.UserData is Chicken)
                    {
                        (other.UserData as Chicken).OnBreakableDestroyed(this);
                    }
                    else if (other.UserData is Fox)
                    {
                        other.LinearVelocity *= 0.5f;
                    }

                    RaiseFlag(Jabber.Flags.DELETE);
                    Body.CollisionGroup = BodyNoneCollisionGroup;
                    Body.IgnoreRayCast = true;
                }
                else if (other.UserData is Chicken && health > 0)
                {
                    (other.UserData as Chicken).OnBreakableHit(this);
                }
            }
            else if (other != null && World.IsEntityGroup(other.CollisionGroup) && other.UserData is Fan)
            {
                if (other.Rot == 0.0f)
                {
                    InFan = true;
                }
                else
                {
                    InBentFan = true;
                }
            }
        }
Exemplo n.º 5
0
 void OnContact(Collision col)
 {
     JabActor other = col.HasActor(Body);
     if (other != null && !World.IsEntityGroup(other.CollisionGroup))
     {
         if ((other.LinearVelocity - Body.LinearVelocity).Length() + Math.Abs(Body.AngularVelocity - other.AngularVelocity) > 2.5f)
         {
             Detonate();
         }
     }
 }