public void findCollisions(Entity collider, CollisionCallback callback) { Vector2 tl = collider.position; Vector2 br = collider.position + collider.size; if (collider.center_based) { tl = collider.position - collider.size / 2; br = collider.position + collider.size / 2; } for (int i = entities.Count - 1; i >= 0; --i) { if (collider == entities[i] || entities[i].remove) { continue; } Vector2 etl = entities[i].position; Vector2 ebr = entities[i].position + entities[i].size; if (entities[i].center_based) { etl = entities[i].position - entities[i].size / 2; ebr = entities[i].position + entities[i].size / 2; } if (tl.x < ebr.x && tl.y < ebr.y && br.x > etl.x && br.y > etl.y) { callback(entities[i]); } } }
public TouchTarget(double x, double y, double width, double height, ImageSource image, String characters, int dx, int dy) { X = x; Y = y; Width = width; Height = height; this.image = image; ROutside = (width / 2.0) * 0.9; RInside = ROutside * 1.2; this.callback = null; this.lastState = State.outside; this.characters = characters; this.timeInside = 0.0; this.selection = ' '; this.selectionTime = 0.0; this.dx = dx; this.dy = dy; this.CX = this.X + this.Width / 2.0; this.CY = this.Y + this.Height / 2.0; }
public void Set(float liveTime, Pooling owner = null, CollisionCallback call = null, Team avoid = Team.None) { StartCoroutine(LiveTime(liveTime)); Owner = owner; m_collisionCallback += call; m_avoidTeam = avoid; }
void Start () { tower.atk = 5; tower.atkSpeed = 1; collision2D = gameObject.GetComponent<CollisionCallback>(); collision2D.TriggerEnter2D = getTarget; collision2D.TriggerExit2D = lostTarget; }
public void Launch(float strength, CollisionCallback collisionCallback) { this.collisionCallback = collisionCallback; rigidbody.isKinematic = false; rigidbody.AddForce (transform.TransformDirection (new Vector3 (0.0f, 0.7f, 0.7f)) * strength, ForceMode.Impulse); launchTime = Time.time; launched = true; }
public CollisionShape(bool trigger, float mass) { Position = Vector3.Zero; Rotation = Quaternion.Identity; Mass = mass; if (trigger) { onCollision = new CollisionCallback(OnCollision); IsTrigger = trigger; } }
public DiscreteDynamicsWorld(CollisionDispatcher a_dispatcher, BroadphaseInterface a_broadphase, ConstraintSolver a_solver, CollisionConfiguration a_configuration) { m_objectPtr = DiscreteDynamicsWorld_new(a_dispatcher.Ptr, a_broadphase.Ptr, a_solver.Ptr, a_configuration.Ptr); m_debugDrawerPtr = IntPtr.Zero; m_drawLineEvent = DrawLine; m_errorEvent = Error; m_collisionEvent = OnCollision; m_objectLookup = new Dictionary <IntPtr, CollisionObject>(); }
public void addCallback(GameObject.Type typeA, GameObject.Type typeB, CollisionCallback callback, CallbackType callbackType) { switch (callbackType) { case CallbackType.BEGIN: callbacksBegin[new KeyValuePair <GameObject.Type, GameObject.Type>(typeA, typeB)] = callback; callbacksBegin[new KeyValuePair <GameObject.Type, GameObject.Type>(typeB, typeA)] = callback; break; case CallbackType.DURING: callbacksDuring[new KeyValuePair <GameObject.Type, GameObject.Type>(typeA, typeB)] = callback; callbacksDuring[new KeyValuePair <GameObject.Type, GameObject.Type>(typeB, typeA)] = callback; break; case CallbackType.END: callbacksEnd[new KeyValuePair <GameObject.Type, GameObject.Type>(typeA, typeB)] = callback; callbacksEnd[new KeyValuePair <GameObject.Type, GameObject.Type>(typeB, typeA)] = callback; break; } }
public CollisionListener OnExit(CollisionCallback onExit) { this.onExit = onExit; return(this); }
public CollisionListener OnStay(CollisionCallback onStay) { this.onStay = onStay; return(this); }
// Use this for initialization void Start () { _Colldier = sprite.gameObject.GetComponent<Collider>(); _CollisionCallback = sprite.gameObject.GetComponent<CollisionCallback>(); _CollisionCallback.CollisionEnter = OnHit; }
public static extern void RegisterCollisionCallback(CollisionCallback callback);
private static extern void SetBoxTriggerCallback_Native(IntPtr pworld, IntPtr proxy, CollisionCallback cback);
public void StartEngine(uint engineId, CollisionCallback appCallback, uint intervalMS) { ApplicationCollisionCallback.Add(engineId, appCallback); StartEngineNative(engineId, NativeCollisionReportCallback, intervalMS); }
// Use this for initialization void Start () { _CollisionCallback = gameObject.GetComponent<CollisionCallback>(); _CollisionCallback.TriggerEnter = OnHit; }
public void registerCollisionCallback(CollisionCallback cs) { this.callback = cs; }
public void UnRegisterCollisionListener(CollisionCallback listner) { collisionListeners.Remove(listner); }
// Listeners can register and unregister to receive callback events on collisions that result in a movement resolution public void RegisterCollisionListener(CollisionCallback listner) { collisionListeners.Add(listner); }
public void Invoke(CollisionCallback callback, Collision collision) { callback?.Invoke(collision); }
/// <summary> /// Adds a collision callback function. You need to set the CollisionPair.PhysicsObject1 /// and CollisionPair.PhysicsObject2, but you shouldn't set other properties of CollisionPair. /// Other properties of CollisionPair are set automatically when it's returned from the /// CollisionCallback delegate/callback function. /// </summary> /// <remarks> /// You can't add more than one collision callback function for the same collision pair. /// </remarks> /// <param name="pair">A pair of IPhysicsObject to detect collisions</param> /// <param name="handler">The callback function to be called when the pair collides</param> public void AddCollisionCallback(CollisionPair pair, CollisionCallback handler) { if (!collisionCallbacks.ContainsKey(pair)) { collisionCallbacks.Add(pair, handler); } }
public CollisionListener OnEnter(CollisionCallback onEnter) { this.onEnter = onEnter; return(this); }
static extern void DiscreteDynamicsWorld_checkCollidingObjects(IntPtr a_ptr, CollisionCallback a_callback);
public void AddOnCollisionListener(string eventKey, CollisionCallback collisionCallback) { this.onCollisionCallbacks.Add(eventKey, collisionCallback); }
public void addCallback(GameObject.Type typeA, GameObject.Type typeB, CollisionCallback callback, CallbackType callbackType) { switch (callbackType) { case CallbackType.BEGIN: callbacksBegin[new KeyValuePair<GameObject.Type, GameObject.Type>(typeA, typeB)] = callback; callbacksBegin[new KeyValuePair<GameObject.Type, GameObject.Type>(typeB, typeA)] = callback; break; case CallbackType.DURING: callbacksDuring[new KeyValuePair<GameObject.Type, GameObject.Type>(typeA, typeB)] = callback; callbacksDuring[new KeyValuePair<GameObject.Type, GameObject.Type>(typeB, typeA)] = callback; break; case CallbackType.END: callbacksEnd[new KeyValuePair<GameObject.Type, GameObject.Type>(typeA, typeB)] = callback; callbacksEnd[new KeyValuePair<GameObject.Type, GameObject.Type>(typeB, typeA)] = callback; break; } }