I’m new to java.
I have game levellogic implemented with timer.
In my game i’m checking on which second of a level we are and then spawn enemies and do more things
switch(pSecond){
case 1:
xDestroyer.ClearPaths();
xDestroyer.AddPathPredefined(1);
xDestroyer.AddPathPredefined(2);
xDestroyer.AddPathPredefined(3);
xDestroyer.AddPathPredefined(4);
xDestroyer.AddPathPredefined(5);
xDestroyer.EnemyStart(14f, 5, 5, 0.0001f);
xShuttle0.EnemyStartByPath(1,5f,8,2,0.2f);
xShuttle0.EnemyStartByPath(5,5f,8,2,0.2f);
break;
case 17:
xShuttle0.EnemyStartByPath(1, 4f, 8, 2, 0.3f);
xShuttle1.EnemyStartByPath(5, 4f, 8, 2, 0.3f);
break;
}
and so on.
I would like to know how can i transfer this logic to XML file. What is the best way to do it ?
You might be able to do something like this:
The actions could then be applied to the targets using reflection.
An alternative would be to predefine a library of targets and verbs and reference them in the XML by key word or index. A useful technique here is to define an object type for each action (method name). You can then put them in an array or hash table and reference them by key word or index from the XML. They might be implemented something like this:
You’d obviously want to do some error checking and handling at some point in this process. 🙂