void Solver_OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e) { var colliderWorld = ObiColliderWorld.GetInstance(); for (int i = 0; i < e.contacts.Count; ++i) { if (e.contacts.Data[i].distance < 0.001f) { var col = colliderWorld.colliderHandles[e.contacts.Data[i].bodyB].owner; if (col != null) { int k = e.contacts.Data[i].bodyA; Vector4 userData = solver.userData[k]; if (col == hotCollider) { userData[0] = Mathf.Max(0.05f, userData[0] - heat * Time.fixedDeltaTime); userData[1] = Mathf.Max(0.5f, userData[1] - heat * Time.fixedDeltaTime); } else if (col == coldCollider) { userData[0] = Mathf.Min(10, userData[0] + cooling * Time.fixedDeltaTime); userData[1] = Mathf.Min(2, userData[1] + cooling * Time.fixedDeltaTime); } solver.userData[k] = userData; } } } }
private void Solver_OnCollision(ObiSolver s, ObiSolver.ObiCollisionEventArgs e) { // reset to unwrapped state: foreach (var wrappable in wrappables) { wrappable.Reset(); } var world = ObiColliderWorld.GetInstance(); foreach (Oni.Contact contact in e.contacts) { // look for actual contacts only: if (contact.distance < 0.025f) { var col = world.colliderHandles[contact.other].owner; if (col != null) { var wrappable = col.GetComponent <Wrappable>(); if (wrappable != null) { wrappable.SetWrapped(); } } } } }
void Solver_OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e) { var colliderWorld = ObiColliderWorld.GetInstance(); Oni.Contact[] contacts = e.contacts.Data; for (int i = 0; i < e.contacts.Count; ++i) { Oni.Contact c = contacts[i]; // make sure this is an actual contact: if (c.distance < 0.01f) { // get the collider: var col = colliderWorld.colliderHandles[c.other].owner; if (col != null) { // make it blink: Blinker blinker = col.GetComponent <Blinker>(); if (blinker) { blinker.Blink(); } } } } }
private void Solver_OnCollision(ObiSolver solver, ObiSolver.ObiCollisionEventArgs e) { onGround = false; var world = ObiColliderWorld.GetInstance(); foreach (Oni.Contact contact in e.contacts) { // look for actual contacts only: if (contact.distance > 0.01) { var col = world.colliderHandles[contact.other].owner; if (col != null) { onGround = true; return; } } } }
public void Solver_OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e) { var world = ObiColliderWorld.GetInstance(); foreach (Oni.Contact contact in e.contacts) { ObiColliderBase collider = world.colliderHandles[contact.other].owner; if (collider != null) { if (collider.tag != "Ground" || collider.tag != "Walls") { if (contact.distance < 0.01) { ObiSolver.ParticleInActor pa = solver.particleToActor[contact.particle]; Slime s = pa.actor.gameObject.GetComponent <Slime> (); switch (collider.tag) { case "Food": for (var f = 0; f < s.food.Count; f++) { if (s.food[f] == collider.transform) { if (s.testingFood[f]) { s.testingFood[f] = false; s.AddReward(1f); break; } } } break; case "Enemy": s.Death(); break; } } } } } }
private void Solver_OnCollision(ObiSolver s, ObiSolver.ObiCollisionEventArgs e) { var world = ObiColliderWorld.GetInstance(); foreach (Oni.Contact contact in e.contacts) { // look for actual contacts only: if (contact.distance > 0.01) { var col = world.colliderHandles[contact.other].owner; if (col == deathPitCollider) { onDeath.Invoke(); return; } if (col == finishCollider) { onFinish.Invoke(); return; } } } }
/** * Grabs all particles currently touching the grabber. */ public void Grab() { Release(); var world = ObiColliderWorld.GetInstance(); if (solvers != null && collisionEvents != null) { foreach (ObiSolver solver in solvers) { ObiSolver.ObiCollisionEventArgs collisionEvent; if (collisionEvents.TryGetValue(solver, out collisionEvent)) { foreach (Oni.Contact contact in collisionEvent.contacts) { // this one is an actual collision: if (contact.distance < 0.01f) { var contactCollider = world.colliderHandles[contact.other].owner; // if the current contact references our collider, proceed to grab the particle. if (contactCollider == localCollider) { // try to grab the particle, if not already grabbed. if (GrabParticle(solver, contact.particle)) { grabbedActors.Add(solver.particleToActor[contact.particle].actor); } } } } } } } UpdateParticleProperties(); }
private void Solver_OnCollision(ObiSolver s, ObiSolver.ObiCollisionEventArgs e) { var world = ObiColliderWorld.GetInstance(); foreach (Oni.Contact contact in e.contacts) { // look for actual contacts only: if (contact.distance < 0.01f) { var col = world.colliderHandles[contact.bodyB].owner; if (colorizers[0].collider == col) { solver.userData[contact.bodyA] = colorizers[0].color; if (coloredParticles.Add(contact.bodyA)) { UpdateScore(finishedParticles.Count, coloredParticles.Count); } } else if (colorizers[1].collider == col) { solver.userData[contact.bodyA] = colorizers[1].color; if (coloredParticles.Add(contact.bodyA)) { UpdateScore(finishedParticles.Count, coloredParticles.Count); } } else if (finishLine == col) { if (finishedParticles.Add(contact.bodyA)) { UpdateScore(finishedParticles.Count, coloredParticles.Count); } } } } }