/// <summary> /// Get back the string id when you have a collision; /// </summary> /// <param name="box"></param> /// <returns></returns> public static string CollisionDetection(CollisionComponent caller) { foreach (CollisionComponent a in colliders) { if (a.bounds.Intersects(caller.bounds) && caller.bounds != a.bounds) return a.id; } return ""; }
/// <summary> /// Get back the string id when you have a collision; /// </summary> /// <param name="box"></param> /// <returns></returns> public static string CollisionDetection(CollisionComponent caller) { foreach (CollisionComponent a in colliders) { if (a.bounds.Intersects(caller.bounds) && caller.bounds != a.bounds) { return(a.id); } } return(""); }
/// <summary> /// Get back the string id when you enter a trigger; /// </summary> /// <param name="box"></param> /// <returns></returns> public static string TriggerDetection(CollisionComponent caller) { foreach (CollisionComponent a in triggers) { if (a.bounds.Intersects(caller.bounds) && caller.bounds != a.bounds) { if (caller.triggerEntered && a.id != caller.lastEntered) return ""; caller.triggerEntered = true; caller.lastEntered = a.id; return a.id; } } caller.triggerEntered = false; return ""; }
/// <summary> /// Get back the string id when you enter a trigger; /// </summary> /// <param name="box"></param> /// <returns></returns> public static string TriggerDetection(CollisionComponent caller) { foreach (CollisionComponent a in triggers) { if (a.bounds.Intersects(caller.bounds) && caller.bounds != a.bounds) { if (caller.triggerEntered && a.id != caller.lastEntered) { return(""); } caller.triggerEntered = true; caller.lastEntered = a.id; return(a.id); } } caller.triggerEntered = false; return(""); }