Esempio n. 1
0
 protected void UpdateSensor()
 {
     if (m_fixture != null)
     {
         PhysicsSystem physicsSystem = m_gameObject.Scene.GetPhysicsSystem();
         m_body.DestroyFixture(m_fixture);
     }
     m_fixture          = CreateSensor();
     m_fixture.IsSensor = true;
     FixtureCollisionCategroy.SetCollsionCategroy(m_fixture, (FixtureCollisionCategroy.Kind)(m_collisionCategroy.GetValue()));
     m_fixture.OnCollision  += OnCollision;
     m_fixture.OnSeparation += OnSeparation;
 }
Esempio n. 2
0
        protected override bool Collision(Fixture _fixtureA, Fixture _fixtureB, FarseerPhysics.Dynamics.Contacts.Contact _contact)
        {
            Fixture other = _fixtureA;

            if (m_fixture == _fixtureA)
            {
                other = _fixtureB;
            }
            GameObject otherGameObject = FixtureCollisionCategroy.GetGameObject(other);

            if (otherGameObject != null &&
                otherGameObject.GetComponent(typeof(CanBeStealthKilled)) != null)
            {
                m_candidateVictims.Add(otherGameObject);
            }
            return(true);
        }
Esempio n. 3
0
        protected override void Separation(Fixture _fixtureA, Fixture _fixtureB)
        {
            Fixture other = _fixtureA;

            if (_fixtureA == m_fixture)
            {
                other = _fixtureB;
            }
            GameObject otherGameObject = FixtureCollisionCategroy.GetGameObject(other);

            if (otherGameObject != null &&
                m_candidateVictims.Contains(otherGameObject))
            {
                m_candidateVictims.Remove(otherGameObject);
            }
            return;
        }
Esempio n. 4
0
        protected void UpdateSensor()
        {
            PhysicsSystem physicsSystem = m_gameObject.Scene.GetPhysicsSystem();

            if (physicsSystem == null)
            {
                return;
            }
            if (m_body != null)
            {
                physicsSystem.GetWorld().RemoveBody(m_body);
                m_body = null;
            }
            m_body = BodyFactory.CreateCircle(physicsSystem.GetWorld(), m_radius,
                                              0.1f, new Tag(3, 0.0f, m_gameObject));
            FixtureCollisionCategroy.SetCollsionCategroy(m_body, FixtureCollisionCategroy.Kind.RoleSensor);
            m_body.BodyType       = BodyType.Static;
            m_body.IsSensor       = true;
            m_body.CollisionGroup = -1;
            m_body.OnCollision   += OnCollision;
            m_debugShape.SetAsCircle(m_radius, m_offset);
        }
Esempio n. 5
0
        protected bool OnCollision(Fixture _fixtureA, Fixture _fixtureB, Contact _contact)
        {
            Fixture other = _fixtureA;

            if (_fixtureA.Body == m_body)
            {
                other = _fixtureB;
            }
            GameObject otherGameObject = FixtureCollisionCategroy.GetGameObject(other);

            if (otherGameObject != null &&
                otherGameObject.GetComponent(typeof(Vulnerable)) != null)
            {
                if (m_belongToGUID == "" || m_belongToGUID != otherGameObject.GUID)
                {
                    Vulnerable vulnerable = otherGameObject.GetComponent(typeof(Vulnerable))
                                            as Vulnerable;
                    vulnerable.GetHurt(m_damage);
                }
            }

            return(true);
        }
Esempio n. 6
0
 /**
  * @brief if the _fixture is between killer and candidate victim, can the
  *  candidate be executed?
  **/
 private bool CanObjectBlockStealthKill(Fixture _fixture)
 {
     return(FixtureCollisionCategroy.IsSolidBlock(_fixture) ||
            FixtureCollisionCategroy.IsRole(_fixture));
 }
Esempio n. 7
0
 protected void UpdateCollisionCategroy()
 {
     FixtureCollisionCategroy.SetCollsionCategroy(
         m_body, (FixtureCollisionCategroy.Kind)(m_collisionCategroy.GetValue()));
 }