UnitType class design

Coordinator
Dec 23, 2008 at 2:24 AM
I thought I'd branch out the UnitType class discussion since it is significant in itself.  I'm trying to tweak the design a bit more before modifying the existing game code to utilize it.

One of the remaining issues for the class is how to denote a unit type's movement class (i.e. static, towed, leg, tracked, etc).  I currently have an enum (see below) and the UnitType class has a member of that enum type.

    /// <summary>
    /// Contains all the movement types for ground units.
    /// </summary>
    public enum GroundMovementClass
    {
        Static = 0, Towed, Leg, Truck, Wheeled, HalfTracked, Tracked
    }

The problem I see is that the movement types are hard-coded vs. dynamically loaded at run-time, minimizing the ability to use the xnaPanzer engine for other realms, e.g. fantasy, space, etc.  I'll probably stick with the current structure for now since it's quick and easy but the issue did raise a red flag in my noggin.  

Anyone have suggestions on the subject?  Thanks.

Troy
Coordinator
Dec 26, 2008 at 10:10 PM
I was finally able to get the Xml Reader working for the UnitType class.  The XML for a sample UnitType is as follows:

<?xml version="1.0" encoding="utf-8" ?>
<XnaContent>
  <Asset Type="XmlContentShared.UnitType">
    <AirAttack>0</AirAttack>
    <AirDefense>0</AirDefense>
    <Ammo>123</Ammo>
    <AvailabilityEnd>1945-06-01</AvailabilityEnd>
    <AvailabilityStart>1939-05-01</AvailabilityStart>
    <Characteristics>0</Characteristics>
    <CloseDefense>0</CloseDefense>
    <CombatRange>1</CombatRange>
    <Cost>200</Cost>
    <EntrenchmentRate>1</EntrenchmentRate>
    <Fuel>35</Fuel>
    <GroundDefense>5</GroundDefense>
    <HardAttack>5</HardAttack>
    <ID>0</ID>
    <Initiative>5</Initiative>
    <MovementClass>0</MovementClass>
    <Moves>5</Moves>
    <Name>Pz IIIJ</Name>
    <Nationality>0</Nationality>
    <SoftAttack>5</SoftAttack>
    <SpottingRange>5</SpottingRange>
    <SpritesheetX>0</SpritesheetX>
    <SpritesheetY>0</SpritesheetY>
  </Asset>
</XnaContent>

Dec 26, 2008 at 10:42 PM
Excellent!
Coordinator
Dec 30, 2008 at 12:29 AM
Rot roh, my attempt to tweak the project's structure in VS2008 has backfired: the run-time complains that the Maps\tacmaps_terrain_xnaPanzer.bmp file cannot be found.  It is looking for the path under C:\Shared\Projects\XNA\xnaPanzer\xnaPanzer\bin\x86\Debug\Content, which makes little sense to me.  I would think it should be looking for it under C:\Shared\Projects\XNA\xnaPanzer\xnaPanzer\Content, but obviously I am uneducated in the 'proper' XNA project structure.

In any case, I will likely have to wipe the xnaPanzer project (the primary project in the 3-project solution) and recreate it.  This will be an interesting exercise (albeit a time waster).

Troy

Coordinator
Dec 30, 2008 at 1:38 AM
Makes perfect sense now.  I am recreating the solution files and hope to commit them tomorrow night.

Troy
Coordinator
Dec 31, 2008 at 3:04 AM
I have rebuilt all 3 projects and all looks good except for three things: (1) compiler error: XML element "AirAttack" not found in UnitList.xml.  Obviously a wire is crossed because the UnitType class has the AirAttack value, not the Unit class; (2) I accidentally put the projects one level higher in the folder structure, i.e. there should be ..\xnaPanzer\xnaPanzer\.. but there isn't--causing Subversion not to like it--will have to correct; and (3) I have renamed and slightly restructured the projects, thus they no longer match the existing faulty projects--I'm hoping I can simply upload the new structures and ignore the old files/structure (doubt it).

I'll be glad when I'm back on track doing actual development instead of project maintenance (due to XNA ignorance).

Troy

Coordinator
Jan 5, 2009 at 2:18 AM
I have finally been able to re-create and commit the xnaPanzer solution (containing 3 projects).  All now works EXCEPT for one seemingly simple error: "XML element 'UnitType' not found in UnitList.xml file."  Not sure what is wrong.  Hopefully one of you gents can take a fresh look at it and immediately see the problem.  I'd be quite thankful!

Take care.

Troy

Coordinator
Jan 8, 2009 at 1:32 AM
I created a test Map class with xml reader/writer methods--works well, as expected (it displays the map name on the GUI).  This really makes me wonder what is wrong with the UnitList.xml file since it is not being accessed properly (for unknown reasons).  Anyway, I deleted the UnitList.xml file and will likely have to re-create the entire Unit schema (class, reader/writer, xml) from scratch (this time I will NOT copy from UnitType schema).