forked from MagicBane/Server
FatBoy-DOTC
12 months ago
4 changed files with 36 additions and 28 deletions
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
package engine.gameManager; |
||||
|
||||
import engine.collision.Mesh; |
||||
import engine.objects.Building; |
||||
|
||||
import java.awt.*; |
||||
import java.awt.geom.Line2D; |
||||
|
||||
public class CollisionManager { |
||||
public static boolean CollisionDetected(Building building, Line2D travelLine, float charHeight){ |
||||
Rectangle.Float boundsRect = new Rectangle.Float(); |
||||
float rectCenterX = building.loc.x + building.getBounds().getHalfExtents().x; |
||||
float rectCenterZ = building.loc.z + building.getBounds().getHalfExtents().y; |
||||
boundsRect.setRect(rectCenterX, rectCenterZ, building.getBounds().getHalfExtents().x * 2,building.getBounds().getHalfExtents().y * 2); |
||||
if(travelLine.intersects(boundsRect)){ |
||||
//collided with building
|
||||
for(Mesh mesh : building.buildingMeshes) { |
||||
if (mesh.MeshCollides(travelLine,charHeight)) { |
||||
//ChatManager.chatSystemInfo(pc, "Collision Detected");
|
||||
//MovementManager.movement(msg, pc);
|
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
} |
Loading…
Reference in new issue