when selecting a character, I currently have a base class
abstract class CharacterClass { public abstract void AbilityOne(); public abstract void AbilityTwo(); }
And my characters come from this class
class Warrior : CharacterClass { public override void AbilityOne() {
Finally, I use this code to select Warrior
CharacterClass selectedClass = new Warrior();
Thus, this method works very well. But when it comes to cooldowns, etc., I want to stay with clean code, so I thought about creating an Ability class.
My abstract parent class
abstract class CharacterClass { public Ability AbilityOne { get; set; } public Ability AbilityTwo { get; set; } }
Warrior class
class Warrior : CharacterClass { public Warrior() {
And my skill class
class Ability { public Ability(int cooldown, [the ability method here]) { CoolDown = cooldown; TheAbility = ? the ability parameter ? } public int CoolDown { get; set; } public void TheAbility(){} }
Thus, the warrior will transfer his two skills and create two objects of ability. In the game I could write
CharacterClass selectedClass = new Warrior(); selectedClass.AbilityOne();
and this will lead to a break with the cooldown in 3 seconds. Is it possible to implement .. somehow ..?
source share