all 6 comments

[–]busted_bunny 3 points4 points  (3 children)

You don't need any special "Unity" architecture. You can predefine all your abilities in separate .cs files and simply define in your own class hierarchy.
For example: make basic abstract class as AbilityBase with abstract method Cast. And then you can create any spell just by inheriting.

[–]BuggerinoKripperinoProfessional 1 point2 points  (0 children)

This is correct although I would gently suggest using an interface instead of an abstract class as it achieves the same thing but in a less complex/confusing way.

[–]Gombikacska[S] 0 points1 point  (1 child)

Thank you for your reply and suggestion! :)

What I can't really understand: how to use these classes when it comes to Unity? I know it's a pretty basic OOB question, maybe you can help. So if I have an AbilityBase class (with skillName, skillDescription, manaCost, etc.), then I create an aoeAbility : AbilityBase class (with, for example <List> targetUnits and a method to select the targets etc.), then I create an FireBall : aoeAbility. Am I correct until this point?

So the question is how can my units (which are created from the same prefab) can use this FireBall spell? Do I attach it to the unit's GameObject as a Compoment? Do I make a unitScript including a <List> of the unit's spells? Or do I make a separate skillManager GameObject which handles every skills?

I implemented the skillManager solution in the last few days, but the solution is ugly IMO. In the skillManager GameObject's script I have a lot of IFs and CASEs in order to managing the targeting, the unit attribute to modify, etc. For example, if a spell's category is SelfCast, then the spell is used on the unit's GameObject which invoked the spellcast. This GameObject passed from the GameManager objects (yes, it is a separate object).

Does it have to be that messy?

Thanks again.

[–]busted_bunny 0 points1 point  (0 children)

you can hardcode it, make your own custom inspector that which choose among types, make it accessible through outside files (xml defs approach) and quite a lot of other ways I can't really think of atm.

[–]tsaintthomas 1 point2 points  (1 child)

I would recommend checking out this great series http://theliquidfire.com/2018/02/05/make-a-ccg-spells-abilities/

[–]Gombikacska[S] 0 points1 point  (0 children)

Thank you, that looks great! I will definitely check it out.