I know. If id' be making something with alot of physics, complex algorythms etc, i'd of course start backwards. But in case of MOO2...
That is VERY simple and in fact already done by me in a text file. And i described it above. I can do this exact part again:
The game flow consists of parralel actions of players, where each player has initial state of the turn (colonies, ships, planets, stars, leaders) and makes changes to theese (swaps workers, recruits or fires leaders, scraps or refits ships, makes orders to colonies and fleets). When player makes a change to a colony, colony recalculates its numbers (gold outcome, prod, food, etc) or calculates turns to complete prod.
When each player pressed end turn, they all send their modified data to host. Host does AI turns to complete the sequence and he has an end turn state of each of the players. He then takes his state and strips it of everything that does not belong to him (ledaers, fleets, colonies, player info) and replaces it with the one from corresponding player (each player has actual information about his colonies, fleets, leaders and tech/stuff at the end of his turn).
Then, a "TimeShift()" happens that actually does production, spying, etc, all that happens in "one" turn. Ships fly towards destinations, etc. After that, combat possibilities are calculated. Appropriate players are given a choice to pick their fights.
If fight happens, a battle module is initialised, it holds reference to all participating ships. It calls battle engine to draw the battle action on the screen, and has two big states = "Someone is choosing his action" or "action is underway". If first, it waits for said player to make his choice and then adds his actions to the action queue and switches to playing them (for example, player wants to fire at the ship with 8 weapons, thats 8 actions queued).
When a ship is moving, it is done in same "TimeShift()" manner. For each point a ship moves it is checked wether someone wants to reaction-fire at him, or if any missile is after this ship. If so, missile is also given a chance to move and attack. If an attack happens, its added to the action queue before the ship movement and processed first
When ship is firing (or missile is hitting a ship, or fighter, etc) all the damage is calculated and sent to every player (so random numbers are same at each pc) then the animation is played, and sound. (piu piu piu, fsshshh, red beams scratching the target hull... numbers flying out...). After the animations damage is applied, ship checks if its alive, dies if not. Dying is also an action and can be "silent" or "detonation".
When ship dies or escapes its marked as such. Escaped ships are not drawn in combat, dead ships are removed from game when combat ends, with leaders who died on them, if any.
Technology - each player has a list of "achivements". They might be racial or technical. Each achivement can be one of different achivement types.
- some give bonuses to different fields, they are queried for when appropriate calcualtions are done (when i'm calculating my chance to hit, i am asking if the player has any modifiers to chance to hit and getting their sum).
- some give building options like AF
- some give ship weapons etc
- some are special and treated as such (Unification's no morale, TransDimensional's fly w/o drives, lucky etc)
Each tech has a list of benefits. When its researched it goes to "researched techs" but its only there to calculate player tech score and show in the INFO screen. The benefits of the tech are added to the player's achivements list. Those are the one that count
There is also planet achivement list. Theese are added by buildings built and include AF bonus, Holo Simulator bonus, etc. For example AF provides two achivements - flat bonus and per worker bonus. Building itself is there for show and achivement, if not permanent (soil enrichment for ex, if i remember correct, is permanent), stores a link to the bulding. When building is destroyed or scrapped, all achivements "depending" on it are also lost.
--
Well, i have all that in mind and alot in text. I dont write pseudocode as this is close enough to the code. Actually, i replace theese strings with "todo" list like:
make static class Languages. it handles all language specific strings in the game and gives them out on demand. it changes language on demand and reloads textures. strings are stored in another CurrentLanguage class instance that can FromXML itself
and todo list with verbal explanation what a class should do, like this:
public static void LoadAvailableLanguages()
{
runs at class constructor i suppose
tries to load every xml from Languages folder.If success reads language name and stores Dictionary of name-path.
as a result has Dictionary<> availableLanguages filled
This reads proxy class that has only name field, not the whole languagespecific class with all strings and stuff that would take 100x to read
}
and then this verbal explanation is commented and code is added. That way i can plan my game anywhere, in subway, at work, and then by the end of the day i have a "big TODO" list with exact instructions
I always start from the hardest and most boring parts. Because if i do the "sweet" and easy parts, the hard parts would then discourage and probably make me drop this whole thing, loosing all work that was already done.
Planning this game, i figured most of the time would be spent on making controls (buttons, text fields, stars, planets, colony screen buildings, ship/colony lists...) that interact with player in correct way, are re-usable (same class to display workers and spies, same class to display list of colonies and list of ship weapons...) and work fast. And making screens of them. Thats why i start from there.
If using windows controls (that is windows forms for all, colony list as a popup form, colony screen as another popup) i would estimate that it would take less a week to make a kinda-playable moo2 clone (strategic combat though) engine. It would let you do all the same you could in moo2, but with windows buttons, lists etc. Its just very easy to do. Then add tactical combat (with 2d net drawn with Canvas.Lineto and X instead of ships), and just fill the XML files with data (tech lists, race perk lists, bulding lists, weapon lists..) and you have a windows forms moo2. But making all those fancy graphics, colonists moving controls (where you pick 3 men and others stretch to their positions), combat action animations is what takes most time.
PS: IMHO of course. I might be 100% wrong at any of theese. And i'm open to crticism and suggestions 100% because i know i'm not a "know-it-all" nor a professional game programmer