internal void Events_ContactRemoved(BEPUphysics.BroadPhaseEntries.MobileCollidables.EntityCollidable sender, BEPUphysics.BroadPhaseEntries.Collidable other, BEPUphysics.NarrowPhaseSystems.Pairs.CollidablePairHandler pair, BEPUphysics.CollisionTests.ContactData contact) { var collision = GenerateCollision(sender, other, pair, contact); foreach (var m in this.gameObject.GetComponents <MonoBehaviour>()) { m.OnCollisionExit(collision); } }
private void Events_DetectingInitialCollision(BEPUphysics.BroadPhaseEntries.MobileCollidables.EntityCollidable sender, BEPUphysics.BroadPhaseEntries.Collidable other, BEPUphysics.NarrowPhaseSystems.Pairs.CollidablePairHandler pair) { Health--; if (other.Tag is IEnemy) { ((IEnemy)other.Tag).Destroy(); } }
private void Events_InitialCollisionDetected(BEPUphysics.BroadPhaseEntries.MobileCollidables.EntityCollidable sender, BEPUphysics.BroadPhaseEntries.Collidable other, BEPUphysics.NarrowPhaseSystems.Pairs.CollidablePairHandler pair) { Console.WriteLine(fuelPackID + " FuellPack Collision"); var otherEntityInformation = other as EntityCollidable; string tag = (string)otherEntityInformation.Entity.Tag; // only remove object if comes in contact with the ship if (tag.Equals("ship")) { if (Game.Components.Contains(this)) { RemoveFromGame(); } } }
private Collision GenerateCollision(BEPUphysics.BroadPhaseEntries.MobileCollidables.EntityCollidable sender, BEPUphysics.BroadPhaseEntries.Collidable other, BEPUphysics.NarrowPhaseSystems.Pairs.CollidablePairHandler pair, BEPUphysics.CollisionTests.ContactData contact) { var otherEntity = other as BEPUphysics.BroadPhaseEntries.MobileCollidables.EntityCollidable; var otherCollider = otherEntity.Entity.Tag as Collider; var collision = new Collision() { gameObject = otherCollider.gameObject, contacts = new Collision.ContactPoint[1], }; collision.contacts[0] = new Collision.ContactPoint() { normal = contact.Normal, point = contact.Position, otherCollider = otherCollider, thisCollider = this.gameObject.GetComponent <Collider>(), }; return(collision); }
private void Events_InitialCollisionDetected(BEPUphysics.BroadPhaseEntries.MobileCollidables.EntityCollidable sender, BEPUphysics.BroadPhaseEntries.Collidable other, BEPUphysics.NarrowPhaseSystems.Pairs.CollidablePairHandler pair) { System.Console.WriteLine("bump" + sender.Tag); }
private void Events_InitialCollisionDetected(BEPUphysics.BroadPhaseEntries.MobileCollidables.EntityCollidable sender, BEPUphysics.BroadPhaseEntries.Collidable other, BEPUphysics.NarrowPhaseSystems.Pairs.CollidablePairHandler pair) { Console.WriteLine(torpedoID + " Collision"); var otherEntityInformation = other as EntityCollidable; string tag = (string)otherEntityInformation.Entity.Tag; // hitting the ship doesn't remove the torpedo (would interfer with firing logic if (!tag.Equals("ship")) { if (Game.Components.Contains(this)) { RemoveFromGame(); } } }
/// <summary> /// Event to detect and process collision of the spaceship with something and process mission completeness /// </summary> /// <param name="sender"></param> /// <param name="other"></param> /// <param name="pair"></param> private void Events_InitialCollisionDetected(BEPUphysics.BroadPhaseEntries.MobileCollidables.EntityCollidable sender, BEPUphysics.BroadPhaseEntries.Collidable other, BEPUphysics.NarrowPhaseSystems.Pairs.CollidablePairHandler pair) { if (pair.EntityA.Tag.ToString() == "Mothership" || pair.EntityB.Tag.ToString() == "Mothership") { goalReached = true; if (speed > 6) { goalReachedTooFast = true; } else { goalReachedTooFast = false; } } }
private void Events_InitialCollisionDetected(BEPUphysics.BroadPhaseEntries.MobileCollidables.EntityCollidable sender, BEPUphysics.BroadPhaseEntries.Collidable other, BEPUphysics.NarrowPhaseSystems.Pairs.CollidablePairHandler pair) { // issues with motion upon impact with other objects Console.WriteLine("Ship Collision"); var otherEntityInformation = other as EntityCollidable; string tag = (string)otherEntityInformation.Entity.Tag; if (tag.Contains("duck")) { Console.WriteLine("Hit DUCK"); if (!shieldActive) { health -= duckDamage; generalInfoMessage = "DAMAGE TAKEN"; } } if (tag.Equals("turtle")) { Console.WriteLine("Hit Turtle"); if (Vector3.Distance(linearVelocity, maxVelocityToWin) <= 2f) { conclusionMessage = "You successfully claimed the sacred Turtle!"; } else { conclusionMessage = "Your ship was going too fast! Failed to safely aquire the Turtle."; } } if (tag.Contains("fuelPack")) { float newValue = fuelLevel + fuelPackValue; // can't go over 100 fuel if (newValue > 100) { fuelLevel = 100; } else { fuelLevel = newValue; } generalInfoMessage = "FUEL PACK AQUIRED "; } if (tag.Contains("torpedoPack")) { // TODO - broken // AddTorpedo(); generalInfoMessage = "TORPEDO PACK AQUIRED"; } }
private void Events_InitialCollisionDetected(BEPUphysics.BroadPhaseEntries.MobileCollidables.EntityCollidable sender, BEPUphysics.BroadPhaseEntries.Collidable other, BEPUphysics.NarrowPhaseSystems.Pairs.CollidablePairHandler pair) { Console.WriteLine(duckID + " Duck Collision"); var otherEntityInformation = other as EntityCollidable; string tag = (string)otherEntityInformation.Entity.Tag; // don't remove if it hits any of the packs if (!tag.Contains("fuelPack") && !tag.Contains("torpedoPack")) { RemoveFromGame(); } }