XNA Game Trigger Editor

September 17, 2008 at 8:48 pm (Uncategorized)

The XNA Game Trigger Editor is a tool i built specifically for SBARG but feel it would be very useful for other games too so here is a little bit of info about it.

It allows me to visually configure actions to perform in the game based on some conditions. For example in the first level of SBARG, Dr Strobo appears to encourage the player with some motivational text when the player has defeated 1 Weed Monster. The condition is Kills 1 Weed Monster, and the action is Show Dr Strobo with text “ATTACK!!”. In the main update loop i always call TriggerEngine.Update(elapsed) which checks all triggers configured and if all their conditions return true, it performs the action.

In the first tab i can select which players to check this trigger against. In SBARG i can currently select Player 1 or the Computer AI.

The second Tab Lists the conditions.

And the third tab lists the actions

If we now take a look at adding a new condition we can see how these are constructed.

The drop list contains all the available conditions i can choose from. This list is generated by the Editor using Reflection to read my game assemblies and find anything that inherits TriggerCondition. A custom condition then adds properties of a finite number of types which are listed in the list on the form.

Depending on the type of property depends on what editor is shown when double clicking that value in the list. The number is a QualifiedNumber which has a number property and a Modifier of OrLess or OrMore.

The baddytype property is a SceneItemLookup property which is quite specific to SBARG but it basically looks inside the level xml file for anything that is a sceneitem and lists it in a drop down box for selection.

So we can use this like if Kills 1 OrMore WeedMonsterBasic.

The Actions are much the same with a set of actions to choose from, but they use the same property types as conditions so the editor remains the same.

The Actions and Conditions i have available for my game are.

Conditions

Actions

Each one with its own set of lovely properties to choose from.

There is no limit to the amount of conditions to check or actions to perform for a paticular Trigeer. And the flexibility is endless as adding a new condition or action type is a trivial task which usually involves inheriting a class and adding 1 line of code for the condition or action. some are more complex but they are a minority.

Here is a shot of my level 1 triggers. It’s not pretty, but it sure is useful.

I’ll talk about the code more in a future post along with a release of the core of this Engine and Editor with source code.

It was so simple to knock up yet it totally changed the direction and possibilities of my game.

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

%d bloggers like this: