/// <summary> /// Returns the object's colliding object /// </summary> /// <param name="o">The object to check</param> /// <returns>Returns the object colliding with the specified object; otherwise, null</returns> public GameObject getObjectCollision(GameObject o) { foreach (GameObject g in level.getObjects()) { if (g != o && o.getDestinationBounds().Intersects(g.getDestinationBounds())) { return(g); } } foreach (Wall w in level.getWalls()) { if (w != o && o.getDestinationBounds().Intersects(w.getDestinationBounds())) { return(w); } } foreach (Door d in level.getDoors()) { if (d != o && o.getDestinationBounds().Intersects(d.getDestinationBounds())) { return(d); } } foreach (Barrier b in level.getBarriers()) { if (b != o && o.getDestinationBounds().Intersects(b.getDestinationBounds()) && !b.isOpen()) { return(b); } } return(null); }
/// <summary> /// Returns the object's colliding entity /// </summary> /// <param name="o">The object to check</param> /// <returns>Returns the entity colliding with the object; otherwise, null</returns> public Entity getEntityCollision(GameObject o) { foreach (Npc n in level.getNpcs()) { if (o.getDestinationBounds().Intersects(n.getDestinationBounds())) { return n; } } return o.getDestinationBounds().Intersects(player.getDestinationBounds()) ? player : null; }
/// <summary> /// Returns the object's colliding entity /// </summary> /// <param name="o">The object to check</param> /// <returns>Returns the entity colliding with the object; otherwise, null</returns> public Entity getEntityCollision(GameObject o) { foreach (Npc n in level.getNpcs()) { if (o.getDestinationBounds().Intersects(n.getDestinationBounds())) { return(n); } } return(o.getDestinationBounds().Intersects(player.getDestinationBounds()) ? player : null); }
/// <summary> /// Returns the object's colliding object /// </summary> /// <param name="o">The object to check</param> /// <returns>Returns the object colliding with the specified object; otherwise, null</returns> public GameObject getObjectCollision(GameObject o) { foreach (GameObject g in level.getObjects()) { if (g != o && o.getDestinationBounds().Intersects(g.getDestinationBounds())) { return g; } } foreach (Wall w in level.getWalls()) { if (w != o && o.getDestinationBounds().Intersects(w.getDestinationBounds())) { return w; } } foreach (Door d in level.getDoors()) { if (d != o && o.getDestinationBounds().Intersects(d.getDestinationBounds())) { return d; } } foreach (Barrier b in level.getBarriers()) { if (b != o && o.getDestinationBounds().Intersects(b.getDestinationBounds()) && !b.isOpen()) { return b; } } return null; }