Hi, all. I’m working on an RPG-style game. In the game, I have classes (like Warrior or Mage) and abilities (like Slash or Fireball or Heal). I’ve set up a factory-style implementation for ability creation, and something similar to it for class creation. Here’s an example of each:
Ability factory:
public class AbilityFactory {
///
/// The Warrior’s basic slash ability.
///
public static AttackAndHealAbilities Slash() {
setName = “Slash”; //ability name
string setDescription = “A simple cutting attack.”; //ability description
string iconName = “SlashAbility”; //ability thumbnail
int damage = 1; //Damage the ability does. Use a negative number for healing.
//Do not edit this. Edit the corresponding variables above instead.
return new AttackAndHealAbilities(setName, setDescription, iconName, damage); }
Class creation:
public class Warrior {
///
/// Creates a Warrior-class unit.
///
public static BaseCombatClass WarriorClass() {
string setName = “Warrior”; //String to be used as the class name.
string setDescription = “A skilled fighter.”; //Description of the class.
string iconName = “WarriorClassArt”; //class thumbnail
int setMaxHP = 10; //Maximum HP
int setCurrentHP = 10; //Current HP
int setDef = 0; //Unit’s defense value
//Do not edit this. Change the corresponding variable above instead.
return new BaseCombatClass(setName,setDescription,iconName,setMaxHP,setCurrentHP,setDef); } }
Obviously there’s more variables than that, but you should get the idea of what my implementation is like. However, this is about as much as I know about OOP. What I’m wondering is, how do I make my game know that the WarriorClass stuff applies to a specific unit/Game Object, and how do I make an ability know who used it and who it was used on, so that it knows whose health to modify when used?