Пример #1
0
        public void TakeHit(float val)
        {
            health -= val;

            if (health <= 0)
            {
                health = 0;
                if (!SplintersCreated)
                {
                    CreateSplinters();
                    SplintersCreated = true;
                }

                RaiseFlag(Jabber.Flags.DELETE);
                Body.CollisionGroup = BodyNoneCollisionGroup;
                Body.IgnoreRayCast  = true;

                Event e = new BreakableDestroyed(material);
                e.Position = Body.Position;
                EventManager.Get.SendEvent(e);
            }
            else
            {
                Event e = new BreakableHit(material);
                e.Position = Body.Position;
                EventManager.Get.SendEvent(e);
            }
        }
Пример #2
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;
                }
            }
        }
Пример #3
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;
                }
            }
        }
Пример #4
0
        public void TakeHit(float val)
        {
            health -= val;

            if (health <= 0)
            {
                health = 0;
                if (!SplintersCreated)
                {
                    CreateSplinters();
                    SplintersCreated = true;
                }

                RaiseFlag(Jabber.Flags.DELETE);
                Body.CollisionGroup = BodyNoneCollisionGroup;
                Body.IgnoreRayCast = true;

                Event e = new BreakableDestroyed(material);
                e.Position = Body.Position;
                EventManager.Get.SendEvent(e);
            }
            else
            {
                Event e = new BreakableHit(material);
                e.Position = Body.Position;
                EventManager.Get.SendEvent(e);
            }
        }