package zero1hd.polyjet.entity;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.Array;

public class CollisionDetector {
	Array<Entity> firstGroup;
	Array<Entity> secondGroup;
	
	public CollisionDetector(Array<Entity> firstGroup, Array<Entity> secondGroup) {
		this.firstGroup = firstGroup;
		this.secondGroup = secondGroup;
	}
	
	public void collisionCheck() {
		if ((firstGroup.size != 0) && (secondGroup.size != 0)) {
			for (int f = 0; f < firstGroup.size; f++) {
				Entity fe = firstGroup.get(f);
				for (int s = 0; s < secondGroup.size; s++) {
					Entity se = secondGroup.get(s);
					
					if (fe.getHitZone().overlaps(se.getHitZone())) {
						Gdx.app.debug("Collision Detector", "Collision between entities: " + fe.getEntityType() + " and " + se.getEntityType());
						
						fe.collided(se);
						se.collided(fe);
						break;
					}
				}
			}
		}
	}
}
