This task is an expansion of The Quest game from C# Lab 2 (Development Project 3). Take your game, and add a new Spell class to it. Your Spell class must be a subclass of Spell, and implement the ISpell interface (both can be found in the attached [url removed, login to view] file). To make use of these files, you will need to extract them from the attached zip file, then open your project in Visual C# 2010. Right click on the name of your project, and choose Add Existing Item... Browse to find the files you just extracted ([url removed, login to view], [url removed, login to view], and [url removed, login to view]), then add them to your project. IMPORTANT: If the namespace for the rest of your project is not TheQuest, you MUST modify these three files so that they have the same namespace as the rest of your project (see pg. 263). You can create one kind of spell, or more than one kind of spell (more on this later). So here's what you need to know about spells
Spells are magical weapons that appear along with the main weapon in Levels 4-7, and will move to a new random location once every 20 turns. This means that they have their own special Move() method which needs no parameters, and returns void. It must simply set the Spell object's location to a new random location, using the Game object's GetRandomLocation() method. When the player moves over a Spell object, it is picked up and added to his/her inventory, just like the other weapons, the attached zip file contains some icons which you can use. Clicking on a Spell's icon in the Inventory Scroll activates the spell, it requires a certain number of turns to set up a Spell, after which the Spell will damage any enemies in range. The number of turns required increases with the range and damage of the spell, from a minimum of 2 to a maximum of 5). Using a Spell also costs the player a certain number of hit points (between 1 and 5, depending on the range and damage done by the spell). To make sure this works correctly, modify your Player class to add the following method:
public bool PowerSpell(int health)
if (hitPoints >= health)
hitPoints -= health;
There is nothing random about this, using a spell always takes a specific number of hit points away from the player's own health, this means that the Spell object's Attack() method must not only call the DamageEnemy() method like a normal weapon, but must also call the Player's PowerSpell method. As you can see above, the PowerSpell() method returns a bool, so you can use it to determine whether or not the player can use the spell (if PowerSpell() returns false, then the Spell object's Attack() method does nothing, if you want, you can pop up a MessageBox to inform the user that the Player is too weak to use the spell).
The Spell object's Attack() method must force the player to wait a the required number of turns, so write the following for loop:
for (int i = 0; i < Turns; i++)
foreach (Enemy enemy in [url removed, login to view])
[url removed, login to view](random);
When creating your Spell objects, you need to follow the following rules:
Each spell in the game will be its own subclass of Spell, with its own unique properties
There are two types of spells, Unidirectional and Omnidirectional, each spell you create must have one of these two types, you've been given a SpellType enum to implement this.
Unidirectional spells will only affect enemies in the specified attack direction, if they are in range. Omnidirectional spells affect enemies in any direction, as long as they are in range.
Every Spell knows its own type, range, damage, required hit points, and the number of turns necessary to set it up. The minimum range is 50, the maximum is 300 (remember to correct for the size of the player and enemy icons in your Attack() method). The minimum damage is 10, the maximum is 35 . The provided Spell class automatically calculates the required hit points based upon the range