I'm trying to create a 'scripting' engine for my program. As the scripting needs to be cross-platform compatible (it is in VB for now and needs to ported to XNA later). I have sample data posted below.
Anyway, within a script you can add graphical objects, play sounds, or perform other actions. Graphical objects have a time, duration, and name for prior reference among other attributes. Sounds and other actions are based solely off of time.
I currently have code that will go through these objects once created. It's not a matter of actually displaying and scripting stuff - it is getting this information from the XML file into the respective classes. The majority of my code right now is precedural based and it is really-really-messy.
Special Situations
An object can be positioned one of three ways. It can be hard-coded in from the script file, based off of the location of another object, or placed in the center of the screen. So there's three different Position tags to store this information.
Nothing can really be hardcoded. An animation needs to be re-used, and be based off of the particular person and selected weapon. In addition, the animation needs to work if there are five characters being attacked to just one. Hence, the 'forloop' that I have included in with this code.
Like I said, I'm not sure how to load this information, parse it through, and place it into the right classes. It's not a matter of finding what script I need to find, its just reading in this XML and parsing it approperately.
Ideas?
<script name="SlicerAttack" duration="5" id="2">
<player>
<hideplayers time="0" />
<addgraphic time="0" duration="5" name="playerSlicerGraphic">
<graphicType>static</graphicType>
<layer>4</layer>
<base>pCharacter</base>
<animation>BattleSlicer</animation>
<posFlowLayout/>
</addgraphic>
<addgraphic time="0" duration=".25" name="slicerStatic">
<graphicType>static</graphicType>
<layer>5</layer>
<base>pCharacterWeapon</base>
<animation>SlicerDefault</animation>
<posFromScriptObject>playerSlicerGraphic</posFromScriptObject>
<offsetX>10</offsetX>
<offsetY>30</offsetY>
</addgraphic>
<!---
<changeAnimation time=".25">
<target>playerSlicerGraphic</target>
<animation>
</changeGraphic> -->
<addgraphic time=".25" duration="2" name="slicerMoveRight">
<graphicType>linear</graphicType>
<layer>3</layer>
<base>pCharacterWeapon</base>
<animation>SlicerThrown</animation>
<posX from="graphicObject">playerSlicerGraphic</posX>
<posY from="graphicObject">playerSlicerGraphic</posY>
<offsetX>94</offsetX>
<offsetY>30</offsetY>
<speedX>250</speedX>
<speedY>0</speedY>
</addgraphic>
<addgraphic time="1" duration="2" name="slicerMoveLeft">
<graphicType>linear</graphicType>
<layer>3</layer>
<collidable>1</collidable>
<base>pCharacterWeapon</base>
<animation>SlicerThrown</animation>
<posX from="global">1280</posX>
<posY from="global">340</posY>
<offsetX>0</offsetX>
<offsetY>0</offsetY>
<speedX>-250</speedX>
<speedY>0</speedY>
<soundHit>beep</soundHit>
<soundMiss>beep</soundMiss>
</addgraphic>
<foreachcharacter time="3" >
<type>CPU</type>
<coloring>red</coloring>
</foreach>
<showplayers time="5" />
</player>
<cpu>
</cpu>
</script>