This project is read-only.
See also: MakeNewBoard

Overview

The TruckWars engine is designed to be flexible enough that you can easily create your own creatues.

All creatures are currently defined in Tank.Core. They inherit from CreatureBase. The actual instances of are stored in the "Creatures" folder.

Perhaps the best way to create a new creature is to just find an existing one, copy it, and then modify that. Although CreatureBase has many methods, there are only a few main relevant ones:
  • Update - The main method to update the creature's position, attributes, and attempted actions. The Update method call call the "TryAttack" method, which indirecly calls the AttackDo.
  • AttackDo - The unit's attack method- such as firing a projectile (for the tank), or healing other units (for the ambulance)
  • GotHit - What happens when the unit gets hit?

Additional Attributes via Interfaces

There are also certain attributes that creatures can implement via interfaces (stored in "Interfaces.cs").
  • IProjectile - is this a projectile?
  • INotAttackable - can you not attack this? For example, certain things (like a sign post) are neutral, and there's no benefit to attacking them.
  • IFiresProjectile - indicates that this unit is a ranged unit, like a tank
  • ICanHoldItem - indicates that this unit can pickup items (like keys). For example, the pickup truck implements ICanHoldItem.
While several of these interfaces have no extra methods, they are useful simply to detect (via polymorphism) if a creature has certain abilities.

Creature Hierachy

While all creatures ultimately inherit from CreatureBase, there is a hierarchy:
  • CreatureBase
    • PowerupBase - all powerups
    • PushButtonBase - all pushButtons
    • HoldableItemBase - all holdable items (like a key)

Adding your creature to a board

There are two ways to actually get your creature to show up on a board.
Method 1: If the engine is reading xml files (for release mode), modify one of the xml files, like "Tank.Gui\Levels\1.xml". (i.e. if in Tank.Gui\DevConfig.cs, constant "UseHttpXmlBoards" = true)

Method 2: If the engine is not using xml files (for developer mode), goto "Tank\Tank.Test\Tank.Core\Level.cs" and modify the method "CreateTest()". You can either add a creature by instantiating it, or using the AddCreature method.

Last edited Nov 17, 2007 at 1:10 PM by timstall, version 3

Comments

No comments yet.