CorePuzzleLogic
Last updated
Last updated
This is the core class for the Logic elements. This means that the subclasses of this component also have all properties and methods that are present in here. Make use of it.
As soon as you add the component to the game object, you will need to assign a few fields in the inspector view.
The first field is an array of all triggers that are related to the system.
Make sure to manually assign all triggers related to the puzzle to this array, unless you created the system using the editor utility tool.
Two other properties define the auto resets of the system when the puzzle is solved or failed. In other words, whether or not the puzzle needs to reset all triggers and the logic system in these cases.
There are a few public readonly properties that can be accessed from outside of the component/system:
bool IsSolved -- is the puzzle in the solved state?
bool IsFailed -- is the puzzle in the failed state?
bool IsAutoResetSolution -- will the puzzle be auto reset on solved?
bool IsAutoResetFailure -- will the puzzle be auto reset on failure?
There are a few public methods that you can also makes use of:
Unlike the CorePuzzleHandler, this class more likely needs to be extended. By default, it has a very simple logic. In order to solve it, the player must just activate all triggers.
By inheriting this class, you will get access to a few useful protected fields:
CorePuzzleHandler handler -- the reference to the handler entity.
int completedSteps -- the count of the successfuly completed steps. It might be used for comparing it to a total number of triggers, and if they are equal, the puzzle is solved.
There are multiple methods that can be overridden:
It is highly recommeded to see what the default logic is present in all given methods.
Note that Reset defines the actions that must be taken to reset the puzzle; such as reset the count of completed steps, reset isSolved field, and more importantly UnTriggers all activated triggers.
As up to TriggerPuzzle, it provides the logic of puzzle, and when it thinks that the puzzle is solved, calls out AcceptSolution. It also may call out the failure method of the Puzzle Handler.
It is not recommended to change AcceptSolution or Awake; or at least, make sure to include the base implementation of both. Overriding these methods without including base implementation may lead to unexpected issues, unless you really know what you are doing.
Example on how to safely override Awake: