Hello can I ask, is it possible to auto cast the ability on the bar whenever the cooldown is off without clicking the slot manually that also prioritize ability with longer cooldown? like for example the first slot ability have 5 sec cooldown and the last slot have 15 seconds cooldown and it will prioritize the one that have longer cooldown. I don’t know if it’s possible and how should I manage it. Can someone give me some idea and advice on how to start with it? thanks
So there are actually two requests in one here…
One is to have an ability auto fire once the cooldown is over. That one is actually fairly simple assuming that you’re using Sam’s CooldownStore as he’s using the Ability as the Key in the Dictionary for the cooldown. When the cooldown is expired, you can simply notify the AbilityStore that the cooldown has expired (perhaps using the Observer pattern), and the AbilityStore could then try to Use the ability again.
The second is a bit more complex, because by using the CooldownStore take in an Ability as the key, there are no inherent cooldown reasons why you can’t fire all 6 abilities simultaneously in the first place.
For that, some sort of Global Cooldown might be in order. In this case, in addition to the cooldown for the Ability, you would also have a specialized cooldown that fires when any ability is fired. This would be the cooldown the ActionStore would listen to. Both the Ability cooldown and the Global cooldown would be checked before an ability can be fired.
When that cooldown expired, the ActionStore would then go through the abilities and find the one with the longest Cooldown that can be used under the existing circumstance (does it have mana? Can you get a target simply through code and no action, etc).