So BattleField One has gotten a little more serious. My goal in this project is to design and build a strategy game engine. Eventually I’ll demonstrate how to modularize the interface so that the game can operate with DirectX instead of a web-based interface using SVG. My method of development is to do this in tiny chunks the way that XP programming is performed. I never want to get into a situation where I need to do months worth of work in order to get the program back into a playable position. So I’m building a feature and making the game playable, then building a feature, etc.
In this blog post I’m going to show how to incorporate the unit range feature by adding artillery. For those who have no military knowledge, artillery is nothing more than a large cannon with lots of range. Artillery positions are normally miles away from the target. But artillery and their crew cannot see very far away, so they need a spotter. There is also a movement restriction on artillery, but I’ll be ignoring that for now (most artillery need a vehicle to tow it into position).
So I drew a unit type and modified the game to include this unit in it’s case statement (see the UnitClass.cs file). Here’s what the new unit looks like:
I designed a new map to represent a beach invasion scenario. The new map looks like this:
The ocean cells will block any unit from passing. The beach cells act the same as grass. The goal of this game is to take all cities that the German units are protecting. So I modified the CheckForEndOfGameCondition() method to call a new object that can be initialized with different goal conditions. The new object is called VictoryCalculator(). It can be setup to a condition where the enemy (or allies) must defend a given number of cities instead of just destroying all enemy units. I have also designed to to be extendable to allow game conditions where German or Allied units must retain a certain number of units to win. I don’t currently have a game turn limit and (number of turns to meet objective) but it could also be added to this object in the future.
Getting the Code
You can go to my GitHub account and download the zipped up version of this project (Click Here).