Skip to content

Fighting Units

Today the game got to the point where units actually are fighting against each other. But since there no visual effects for the attacks (animation, particles etc.) or even sound, I added simple health status bars so I can see what happens.

Further more all types of units can now be defined through XML files, which allows for very flexible management of all the different unit types and of course easy adjustments. For example, the tank that can be seen on the screenshot is defined as follows:

<?xml version="1.0" encoding="utf-8"?>
<UnitType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Cost>300</Cost>
<Name>Panzer</Name>
<Description>Ein futuristischer Panzer mit zwei Kanonen</Description>
<ModelName>Models/panzer_rotation</ModelName>
<Race>Menschen</Race>
<Properties>
<Hitpoints>400</Hitpoints>
<PrimaryAttack>
<Damage>100</Damage>
<Precision>90</Precision>
<Range>30</Range>
<Speed>0.5</Speed>
<Type>Projectile</Type>
</PrimaryAttack>
<Armor>
<Type>Heavy</Type>
<Class>1</Class>
</Armor>
<Vision>80</Vision>
<Visibility>1</Visibility>
<MotionSpeed>20</MotionSpeed>
</Properties>
<Behavior xsi:type="AggressorUnitBehavior" />
<IsBuilding>false</IsBuilding>
<IsAnimated>false</IsAnimated>
</UnitType>

Thanks to the Serialization API of C# loading and storing unit types that way is as easy as pie.
The ModelName simply refers to an asset of the standard content project. The armor and attack types are simply to enums. Only the behavior can refer to a whole new class, which defines the behavior of the unit. Basically it’s the AI implementation which thinks for the unit and makes it move, attack and so on.
The game does also already support abilities, even though right now there is only one ability defined, which is the spawn ability to spawn new units. The building which spawns the tanks, for example, is defined as follows:
<?xml version="1.0" encoding="utf-8"?>
<UnitType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Cost>300</Cost>
  <Name>Waffenfabrik</Name>
  <Description>Fabrik zur Herstellung von Panzern</Description>
  <ModelName>Models/spaceship</ModelName>
  <Race>Menschen</Race>
  <Properties>
    <Hitpoints>5000</Hitpoints>
    <Armor>
      <Type>Building</Type>
      <Class>10</Class>
    </Armor>
    <Vision>500</Vision>
    <Visibility>1</Visibility>
    <MotionSpeed>0</MotionSpeed>
  </Properties>
  <Abilities>
    <Ability xsi:type="SpawnAbility">
      <Cooldown>15</Cooldown>
      <Name>Spawn</Name>
      <SpawnUnitName>Panzer</SpawnUnitName>
    </Ability>
  </Abilities>
  <Behavior xsi:type="SpawnBuildingBehavior" />
  <IsBuilding>true</IsBuilding>
  <IsAnimated>false</IsAnimated>
</UnitType>

There in the abilities collection is the only ability of type SpawnAbility defined with a cooldown of 15 seconds. The name is purely for in-game info later on. The spawn unit name refers to any unit that was defined through XML.

With these capabilities I can easily extend the game with more units and buildings at any point without touching any code, which makes it a lot more comfortable.

I’m positive that within the next weeks the first playable version, even though very limited, will be done.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Bunkerbewohner1

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

My Del.icio.us

%d bloggers like this: