I described in my previous post about ScriptableObjects in Unity, how you can use ScriptableObjects for various cases, specifically as a replacement for enums. I also like to use ScriptableObjects for implementing conditional triggering of effects in the game. For example you want an effect to only apply when an enemy is killed, or when the player takes damage or if the player took damage from an enemy with Fire resistance. Using enums here would lead to too many cases or a lot of hardcoded ifs.
By combining the serialized fields of the ScriptableObjects and methods that have access to the game state, you can implement basic conditions for your game to replace all those nasty hardcoded cases.
The Unity editor allows you to visualize all these properties (the data) while the ScriptableObject code defines how it uses that data. This enables non-programmers to change the behavior of your game entities (cards, magic effects, enemies) by adding triggers based on conditions that are created in the editor rather than in code, following the template behaviors that you created in code with only a few lines of code.
Dynamic Values
On top of Conditional Triggers for your game, you can also create Dynamic Values ScriptableObjects which uses their methods, serialized fields and the passed-in game state to compute and return an int value that other game systems can consume.
For example, you could create a dynamic value that gives the player an attack value based on the number of enemies they are facing, or based on the number of wounds they have taken or blocked, etc.
This follows the same concept as conditional triggers, where a few lines of code allows the ScriptableObject to inspect the game state to count the number of entities matching the condition and returning it.
You can also easily compose those values for example by giving the player an attack value equal to the number of enemies defeated multiplied by the number of wounds taken.
These are very powerful concept that can make configuring your game behavior and data extremely easy for programmers and non-programmers alike.
As usual, I have published a short deep dive video on the topic, sharing demo and code snippet.
Please have a look, like and subscribe and I hope you enjoy the content!