MSW-
I see what you are saying...a "unit" in an RTS game may be an abstraction of a combination of things...say an infantry icon may represent 28 rifle men, 2 squad gunners, a LMG team, and a medic. All of these individuals are then abstracted into a base value representing it''s overall capabilties.
I want to go one step further than...making it a little less abstract and a little more concrete.
This is what I want to do in a nutshell...and please excuse my pseudo programming syntax code....I''m still learning
class Unit
{
int * pUnit= new UnitStats[10,10] //pointer to a array to hold unit stats
int * pOfficer = OfficerAssignment(void) //pointer that tells what Officer leads unit
bool Detachable; //is unit detachable?
bool setDetachable(bool) {Detachable = true} //accessor function
//fill in all your other code here that ALl units have, like DisplayObject(), a handle to AI, etc.
};
Okay, so we have a VERY simple Unit class skeleton here. So now what you can do is something like this:
class AntiAirTeam: Unit //AA team that extends Unit class
{
protected;
int AntiAirAttack(int) //provides an anti-air function
AntiAirAttack(int)* pOfficerFunction//not sure how to code this, but a pointer to a function that only certain officers can use
};
class RifleTeam: Unit
{
protected;
int RangedAttack(int);
// put code here that adds 8 to the array that holds the stats for how many men in unit, i.e UnitStat[3] = UnitStat[3] + RifleTeamMembers
}
Okay, lots of useless pseudo code here...so what you say. Well, because you have all these subclasses but now you add these constituent subclasses into a bigger class like
class StandardPlatoon = 3x RifleTeam + AntiAirTeam + LightMachineGunTeam. Since you will be able to create your own units and chains of command, everything will have to be drag and drop and object oriented is an absolute necessity. Unit objects will have plugins...the plugins being other class objects (other unit types), and interface methods (so that officers can give them orders).
What''s the difference between this and just abstracting everything? Two important things. One, certain constituent components are detachable, and thereby you can seperate them from the main unit. Secondly and perhaps more importantly, certain ranks of officers are the only ones with accessors to certain functions. So if you tell 2nd Lieutenant to order an Artillery support or to move a platoon not his own somewhere else...he won''t know what to do.
The world has achieved brilliance without wisdom, power without conscience. Ours is a world of nuclear giants and ethical infants. We know more about war than we know about peace, more about killing than we know about living. We have grasped the mystery of the atom and rejected the Sermon on the Mount." - General Omar Bradley