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; }
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); }
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; }
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); }
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); }
/** * @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)); }
protected void UpdateCollisionCategroy() { FixtureCollisionCategroy.SetCollsionCategroy( m_body, (FixtureCollisionCategroy.Kind)(m_collisionCategroy.GetValue())); }