Small explenation of my issue
i have enemies who spawn on my world threw the map class (sub of World)
There i make a array list with the enemies as they spawn adding them one by another.
i have method here to send threw the latest list.
Then i have my towers class where my enemies around my tower go in the list from getObjectsInRange
Then i want to go about getting a check for wich enemies was spawnd first and if that one is in my Range. If not check if the 2nd one that spawnd is in the range and so on and forth. Until i have a enemie to shoot at.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | List<Enemies> enemies = getObjectsInRange( 200 , Enemies. class ); // Als enmies niet leeg is. if (!enemies.isEmpty()) { emptyList = false ; for ( int i = 0 ; i < myEnemies.size(); i++) { for ( int j = 0 ; j < enemies.size(); j++) { if (myEnemies.get(i) == enemies.get(j)) { enemie = enemies.get(j); } } } turnTowards(enemie.getX(), enemie.getY()); } else { emptyList = true ; } |