/// <summary> /// Checks entity collision. /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool collidingWith(Mob entity) { if (getVector().X + getWidth() >= entity.getVector().X && getVector().X <= entity.getVector().X + entity.getWidth()) { if (getVector().Y + getHeight() >= entity.getVector().Y && getVector().Y <= entity.getVector().Y + entity.getHeight()) { return true; } } return false; }
/// <summary> /// Gets the chunk right of the entity /// </summary> /// <param name="creature"></param> /// <returns></returns> public Chunk getCurrentChunkRight(Mob creature) { int chunkNum = (creature.getX() + creature.getWidth()) / Chunk.CHUNKWIDTH; //InputManager.getInstance().getCurrentPlayer().getWidth(); for (int i = 0; i < rooms.Count; i++) { if (rooms.ElementAt(i).getSize() <= chunkNum) { chunkNum -= rooms.ElementAt(i).getSize(); } else { return rooms.ElementAt(i).getChunk(chunkNum); } } return new SquareChunk(-1, Int32.MaxValue); }
/// <summary> /// Checks if there is top collision of Entity from the right. /// </summary> /// <param name="creature"></param> /// <returns></returns> public bool checkRightTopCollision(Mob creature) { int boxNum = (creature.getX() + creature.getWidth()) % CHUNKWIDTH / (CHUNKWIDTH / boundingBoxes.Count); if (creature.getX() - chunkPos * CHUNKWIDTH <= 0) { boxNum = 0; } if (boxNum >= boundingBoxes.Count) return false; return boundingBoxes.ElementAt(boxNum).checkCollision(creature); }