Post by Ezeta on Nov 12, 2022 10:42:06 GMT
Hello,
I've taken the stupid crazy task to implement the architecture in the CCG Game to a turn-based tactics game like the previous tutorial because I really liked the idea of separating the game model completely from the view and going hard on unit testing and integration testing for more complex behaviours.
Now I realize the CCG architecture with game actions and reactions in different phases doesn't perfectly apply to a turn based tactics RPG, not many reactions that need a view in my idea, but so far it's working okay.
One problem I'm facing is while trying to implement more complex abilities and I think it's a problem the base CCG architecture also has for a card game and I can't manage solve it.
An ability in my game is the equivalent of a card (it's a container) and has an AbilityComponent (aspect and container) with HitRate (aspect), WeaponDamage (aspect) logic etc.. inspired from the tactics RPG tutorial. So pretty cool I have simple abilities that are not prefabs and I can test easily how they affect the game model.
The problem I'm facing is for a complex ability and it's viewer, for example Whirlwind: repeats X times, each time : swaps position with target, applies damage and the following repetitions pick a target randomly. Can hit many times same target and needs to check for target being alive.
Now, how does the viewer of the perform ability for this would work ? This ability has many sub-actions (damage, swap positions) and all needs to be animated under a common animation, an unlike the arcane missiles that picks 3 random targets before performing and doesn't care if a target dies and gets hit twice, we don't know which the next targets are gonna be and if they will be available after getting damaged since they could be death.
To help me, I added the functionality for the ActionSystem to perform instant reactions : reactions that don't wait to trigger their prepare/perform notifications until the current action they reacted to is over and cannot have a viewer :
So during the animation, an instant reaction of DamageAction and SwapAction would get added and get processed on the game model by systems. But this is the problem, if the viewer is leading the logic, picking the next target, etc. then I can easily sync the bubbling GameAction's to the animation. But if I want to extract this logic from the view, I can't wrap my head how to feed it into the viewer.
Another solution could be separating the repetitions of the ability into their own actions, each having their own viewer, then the animation would repeat with different parameters, but I lose the "main viewer" logic that orchestrates everything and the animation becomes more limited.
Another solution would be calculating the outcome of the ability before giving it into a specialized viewer to show it. But this goes against what the entire architecture was made for and I would need to delay the model application and calculate future model states since systems already react to damage etc in the view automatically.
Anyways, any help would be appreciated, other than doing less complex abilities I don't really know where to go from here.
Thanks in advance.
I've taken the stupid crazy task to implement the architecture in the CCG Game to a turn-based tactics game like the previous tutorial because I really liked the idea of separating the game model completely from the view and going hard on unit testing and integration testing for more complex behaviours.
Now I realize the CCG architecture with game actions and reactions in different phases doesn't perfectly apply to a turn based tactics RPG, not many reactions that need a view in my idea, but so far it's working okay.
One problem I'm facing is while trying to implement more complex abilities and I think it's a problem the base CCG architecture also has for a card game and I can't manage solve it.
An ability in my game is the equivalent of a card (it's a container) and has an AbilityComponent (aspect and container) with HitRate (aspect), WeaponDamage (aspect) logic etc.. inspired from the tactics RPG tutorial. So pretty cool I have simple abilities that are not prefabs and I can test easily how they affect the game model.
The problem I'm facing is for a complex ability and it's viewer, for example Whirlwind: repeats X times, each time : swaps position with target, applies damage and the following repetitions pick a target randomly. Can hit many times same target and needs to check for target being alive.
Now, how does the viewer of the perform ability for this would work ? This ability has many sub-actions (damage, swap positions) and all needs to be animated under a common animation, an unlike the arcane missiles that picks 3 random targets before performing and doesn't care if a target dies and gets hit twice, we don't know which the next targets are gonna be and if they will be available after getting damaged since they could be death.
To help me, I added the functionality for the ActionSystem to perform instant reactions : reactions that don't wait to trigger their prepare/perform notifications until the current action they reacted to is over and cannot have a viewer :
var instant = instantReactions = new List<GameAction>();
var flow = phase.Flow(container);
while (flow.MoveNext())
{
if(instant.Count > 0)
{
var instantFlow = ReactPhase(instant);
while (instantFlow.MoveNext()) { yield return null; }
instant = instantReactions = new List<GameAction>();
}
yield return null;
}
So during the animation, an instant reaction of DamageAction and SwapAction would get added and get processed on the game model by systems. But this is the problem, if the viewer is leading the logic, picking the next target, etc. then I can easily sync the bubbling GameAction's to the animation. But if I want to extract this logic from the view, I can't wrap my head how to feed it into the viewer.
Another solution could be separating the repetitions of the ability into their own actions, each having their own viewer, then the animation would repeat with different parameters, but I lose the "main viewer" logic that orchestrates everything and the animation becomes more limited.
Another solution would be calculating the outcome of the ability before giving it into a specialized viewer to show it. But this goes against what the entire architecture was made for and I would need to delay the model application and calculate future model states since systems already react to damage etc in the view automatically.
Anyways, any help would be appreciated, other than doing less complex abilities I don't really know where to go from here.
Thanks in advance.