Game Development Reference
In-Depth Information
Exercises
Now that we've reviewed the code for __Defense , here are some ideas on what
could be done to improve the game.
1. Add More Waves/Rebalance the Game
One idea would be to add more waves and make the game more challen-
ging. All of the data related to the game's balance is in Balance.cs. The in-
formation about the number and difficulty of waves is stored in the
Waves array. Adding more waves is just a matter of adding more ele-
ments to the array and increasing the TotalWaves variable. To change
the difficulty or add more levels of enemies, modify the Enemies array.
2. Add a New Tower
Add a new “lightning” tower that chains between multiple targets, de-
creasing the damage as it jumps between chains. To get a new tower func-
tioning on a basic level will require touching several files. First, you need
to add a new LightningTower class and add an entry to the eTower-
Type enum. The chain effect requires finding the nearest enemy within
range (much like the ProjectileTower does), but once it finds the
first enemy, it needs to continue and find the next enemy in the chain.
Then, GameState.TryBuild needs to be updated to handle the new
tower type. Finally, the grid needs to be updated in UIGameplay so that
it's possible to build the new tower (it would also be a good idea to add a
keybind for this, as well).
Once the new tower is functional, there are a few things left to make it
pretty. You'll want to add new custom tooltip text in en_us.xml, and also
create a couple of new textures. Take a look at the textures in XNACon-
tent/Buildings and XNAContent/UI to get an idea of what the textures
should look like. You need to reference these new textures in Lightin-
gTower and UIGameplay , respectively. Remember that if you do make
new textures, only the XNA project will actually build them. So even if
you want to use them in a MonoGame project, they first must be built in
the XNA one.
3. Create an External Balance File
Although the Balance.cs file works, it would be better if all of that data
was stored in an external file. Create a JSON file that stores all of the bal-
Search WWH ::




Custom Search