So with my current targeting system, It finds nearest unit.class and spawns the bullets in the direction of the units using lists, but how would I change my current code to apply to multiple targets in the list like Heavyunit.class and Fastunit.class
public void findClosestInRange()
{
List<unit> units = getObjectsInRange(maxRange, unit.class);
if(units.size() != 0)
{
int unitX = units.get(0).getX();
int unitY = units.get(0).getY();
turnTowards(unitX, unitY);
}
}
public void addBullet()
{
List<unit> ListOfTargets = getObjectsInRange(maxRange, unit.class);
if(ListOfTargets.size() != 0 && reload >= 0)
{
LazerAmmo bullet = new LazerAmmo();
getWorld().addObject(bullet, getX(),getY());
bullet.setRotation(getRotation());
bullet.move(95);
reload -=reloadtimer;
}
if (reload < 0)
{
reload +=1;
}
}

