I'm trying to learn how to use Unity for my class composition, and I was wondering if you could help me.
I'm trying to create a simple game where the player is trying to pop a bunch of balloons. However, any given balloon can only be popped if all of its conditions are met. Example conditions are:
- The player color must match the balloon color
- The balloon must be popped in sequence (balloon A must be popped before balloon C)
- The balloon is only pop-able during a certain time window
And I'm sure you could think of more.
Balloons can have 0 to many conditions associated with them, but they follow the 80/20 principle where 80% will fall into a specific category (e.g. color-match-only, or color-and-sequence-only).
My Initial Solution
I created a "Balloon" class that contains a list of "ICondition" interfaces. When a collision occurs, the balloon loops through each condition to determine whether the balloon is pop-able or not. I populate this list within a "BalloonFactory" class. For 80% scenarios I can just pass in the name of the balloon type I want. For 20% scenarios I can pass a list of conditions. This solution works, except for each new combination I need to change the factory code to include the new condition.
What I'd Like to Do
Instead of storing the balloon definitions in code, I'd prefer to create prefabs in Unity and use the editor to assign condition implementations to each balloon. My problem so far is that the Unity editor doesn't seem to like displaying a list of interfaces or abstract classes.
Is there some way to do what I'm trying to do here? Or is there a third option which you would recommend?