Nice mechanic, but it's annoying that the tower prioritizes the boss while I want it to shoot the little enemies first and then shoot at the boss. Otherwise it seems to target whichever enemy is nearest. However, the player wants it to target the enemy closest to the end of the path.
You mentioned that you're not a good programmer, so here's what the code could look like:
- Determine the enemies in range.
- Sort enemies into lists (arrays) based on priority (regular enemies or boss enemy).
- Attack boss enemy if there are no regular enemies.
- Otherwise check which enemy is closest to the exit (check y pos with y pos exits). Then target the enemy closest to the exit.
Note that this only works if the exits are all at the same y position. Otherwise split the list of regular enemies into a list per exit (check if the x pos is equal to the x pos of the exit (probably use a small threshold)). Then check foreach list which enemy is closest to its exit.
I completely agree. We'll adjust the aiming system as it's still not working as intended, and this issue with the boss just makes it worse indeed. We have a similar system as you have mentioned (except in jam spaghetti code), so when we refactor it properly we'll tackle this issue too. Thank you for taking the time to break down a good direction to solve it!