- Home /
Class design: puzzles that have to be solved.
I'm stuck at designing the architecture of a student's project game where the player solves puzzle to advance. For easy explanation, I'm simplifying the system.
Things get created:
GameController loads current state.
Current state spawns saved objects and puzzle which needs to be solved.
Puzzle checks when it is solved.
This works fine and I have everything working with ScriptableObjects, SaveGames files etc and it seems to be robust and flexible.
Here is the problem:
How can I best notify my GameController, that the current phase is done and the next should be loaded? How can my puzzle notify the current phase, that the puzzle is solved and therefore, the phase is also solved?
I have been trying:
Puzzle recognizes that its solved and calls the WasSolved delegate event on itself.
Phase has subscribed to said event and recognizes that the puzzle is over.
Phase calls another event on itself.
GameController has subscribed to phase event and so on...
This already is nothing but Lasagna Code moving from one level to the next. However, I can't have the end of the chain call anything on the GameController, because there are or might be other things in between the chain, which all need to be updated. Say, if I want different puzzle aspects contributing to one puzzle and so on.
Any design pattern or advice on how to make this class creation and communication works? Create: GameController > Phase > Puzzle > PuzzleAspects Notify: PuzzleAspect > Puzzle > Phase > GameController > MoveToNextCreate
Thanks a lot!
Your answer
![](https://koobas.hobune.stream/wayback/20220611230837im_/https://answers.unity.com/themes/thub/images/avi.jpg)