/// <summary> /// Returns the entity's colliding entity /// </summary> /// <param name="e">The entity to check</param> /// <returns>Returns the entity colliding with the specified entity; otherwise, null</returns> public Entity getEntityCollision(Entity e) { foreach (Npc n in level.getNpcs()) { if (n != e && e.getDestinationBounds().Intersects(n.getDestinationBounds())) { return n; } } return e != player && e.getDestinationBounds().Intersects(player.getDestinationBounds()) ? player : null; }
/// <summary> /// Returns the entity's colliding entity /// </summary> /// <param name="e">The entity to check</param> /// <returns>Returns the entity colliding with the specified entity; otherwise, null</returns> public Entity getEntityCollision(Entity e) { foreach (Npc n in level.getNpcs()) { if (n != e && e.getDestinationBounds().Intersects(n.getDestinationBounds())) { return(n); } } return(e != player && e.getDestinationBounds().Intersects(player.getDestinationBounds()) ? player : null); }
/// <summary> /// Updates pressable buttons /// </summary> /// <param name="e">The entity which is pressing the button</param> public void updatePressButtons(Entity e) { foreach (PressButton p in level.getPressButtons()) { bool pushed = false; if (!p.isDeactivated()) { foreach (GameObject g in level.getObjects()) { if (p != g && g.getDestinationBounds().Intersects(p.getBounds())) { pushed = true; } } foreach (Npc n in level.getNpcs()) { if (n.getDestinationBounds().Intersects(p.getBounds())) { pushed = true; } } if (e.getDestinationBounds().Intersects(p.getBounds())) { pushed = true; } } p.setPushed(pushed); } }
/// <summary> /// Returns the entity's colliding object /// </summary> /// <param name="e">The entity to check</param> /// <returns>Returns the object colliding with the entity; otherwise, null</returns> public GameObject getObjectCollision(Entity e, bool collectibles) { foreach (GameObject g in level.getObjects()) { if (e.getDestinationBounds().Intersects(g.getDestinationBounds())) { return(g); } } foreach (Wall w in level.getWalls()) { if (e.getDestinationBounds().Intersects(w.getDestinationBounds())) { return(w); } } foreach (Door d in level.getDoors()) { if (e.getDestinationBounds().Intersects(d.getDestinationBounds())) { return(d); } } foreach (Barrier b in level.getBarriers()) { if (e.getDestinationBounds().Intersects(b.getDestinationBounds()) && !b.isOpen()) { return(b); } } foreach (Pit pi in level.getPits()) { if (e.getDestinationBounds().Intersects(pi.getDestinationBounds())) { return(pi); } } if (e == player && collectibles) { foreach (Token t in level.getTokens()) { if (e.getDestinationBounds().Intersects(t.getBounds()) && !t.isCollected()) { return(t); } } foreach (Key k in level.getKeys()) { if (e.getDestinationBounds().Intersects(k.getBounds()) && !k.isCollected()) { return(k); } } } return(null); }
/// <summary> /// Returns the entity's colliding object /// </summary> /// <param name="e">The entity to check</param> /// <returns>Returns the object colliding with the entity; otherwise, null</returns> public GameObject getObjectCollision(Entity e, bool collectibles) { foreach (GameObject g in level.getObjects()) { if (e.getDestinationBounds().Intersects(g.getDestinationBounds())) { return g; } } foreach (Wall w in level.getWalls()) { if (e.getDestinationBounds().Intersects(w.getDestinationBounds())) { return w; } } foreach (Door d in level.getDoors()) { if (e.getDestinationBounds().Intersects(d.getDestinationBounds())) { return d; } } foreach (Barrier b in level.getBarriers()) { if (e.getDestinationBounds().Intersects(b.getDestinationBounds()) && !b.isOpen()) { return b; } } foreach (Pit pi in level.getPits()) { if (e.getDestinationBounds().Intersects(pi.getDestinationBounds())) return pi; } if (e == player && collectibles) { foreach (Token t in level.getTokens()) { if (e.getDestinationBounds().Intersects(t.getBounds()) && !t.isCollected()) { return t; } } foreach (Key k in level.getKeys()) { if (e.getDestinationBounds().Intersects(k.getBounds()) && !k.isCollected()) { return k; } } } return null; }