Warning: TL;DR Post with a lot of Programming Mumbo-Jumbo
If I can provide a recommendation, why not try having units move into SZs containing Transports, rather than having Transports need to click units to load them.
Implementing the logic would be a bit trickier, sure, but it’d probably go something like (pseudo-coded out the wazoo):
landunit{
…
move(){
…
if(destinationTile.type() == “Sea”){
if(destinationTile.canLoad(this){
//Prompt the player to select a Transport to be loaded.
}
else{
//Prevent the unit from moving.
}
}
}
…
}
And, in a separate area that handles the logic for individual tiles on the map:
seaTile extends Tile{
…
canLoad(LandUnit unit){
result = false;
List<Units> units = this.getUnits();
for(i = 0; i < units.size(); i++){
if(units.get(i).getType() == “Transport”){
if(((transport) units.get(i)).canLoad(unit)){
result = true;
}
}
}
return result;
}
…
}
And later, in the area that handles the Transport:
Transport extends NavalUnit{
…
canLoad(LandUnit unit){
if(unit.getType() == “Infantry”){
if(this.getCargo.size() < 2){
return true;
}
else{
return false;
}
}
//Unit attempting to be loaded is ART/TANK/AA Gun
else{
if(this.getCargo.size() < 2 && !(this.getCargo().contains(“ART”) || this.getCargo().contains(“TANK”) || this.getCargo().contains(“AA Gun”))){
return true;
}
else{
return false;
}
}
}
…
}
Wow, the formatting is terrible for code-blocks on here. I guess the forum software likes cutting leading spaces.