Hello,
I have finnished the MapLoader, UnitLoader and a BasicGui. Now that it’s time to implement a basic gamelogic i have read trough the Custom Controls section in the tutorials. At a first look everything looks straightforward but i am not sure that i understand it correctly. I am planning following design which should allow my whole game logic to work:
I want to make a commend and conquer like game. I need 4 different types of items in my game: Buildings, Units, Weapons and Projectiles.
I would like to allow each Item extendable with subItems (Tank has 1 or more Weapons which fire 1 ore more Projectiles) i implemented a Class GameUnit as container pattern.
Basically it is something like:
[java]
public class GameUnit extends Node{
ArrayList<GameUnit> SubUnits;
int UnitType;
}
[/java]
Now to the part i am not sure about. From reading the tutorial i think i will need 4 different CustomControls, lets call these BuildingControl, UnitControl, WeaponControl and ProjectileControl. Depending on what type of Unit it is, when i create a new unit i need only to ‘this.addControl(x)’ to add the specific controls for each unit. Is that right?
Afterwards in my inputEvaluator class i should be able to write something like:
[java]
Unit[10].getControl(UnitControl.class).setWayPoint(Vector3f);
[/java]
assuming in my UnitControl i have a function:
[java]
public setWayPoint(Vector3f waypoint){
}
[/java]
Is this design valid or have i misunderstood something completely?
Additionally is it possible that within my UnitControl i update the state of a different CustomControl?
Example:
[java]
public void UnitControl extends Control{
public void MoveAndFire(Vector3f waypoint, Vector3f target){
for(subUnit : currentSubUnit){
if(currentSubUnit==Weapon){
currentSubUnit.getControl(WeaponControl.class).fireAtTarget(target);
}
}
}
}
[/java]
Best regards
Michael
yeh thats fine