Puzzle System
Search…
CorePuzzleHandler
This is the core class for the Handler elements. This means that the subclasses of this component also have all properties and methods that are present in here. Make use of it.

Default

A default class of type Puzzle Handler. See Beginning -> Puzzle Structure for more info.
As it is has been described, this class is responsible for handling critical events of the puzzle lifespan: on puzzle solved and on puzzle failed.
To make your life easier, these events are easily assignable in the inspector view. Click '+' under the desired event, then select the object that you want to affect. Afterwards, in the appeared dropdown menu, choose the action that you want to apply to the object.
For example, it is common to choose GameObject -> SetActive method in order to activate or deactivate the chosen object. So, if you have chosen OnSolutionEvent and SetActive with checked checkbox, the object will be activated as soon as the puzzle is solved.
More about Unity Events: Video Tutorial
The class also declares a boolean property "debug" that will define whether or not, this specific puzzle system -- handler, logic and triggers within one puzzle -- will debug all logs into the console.

Inheritence

In order create more complex event callbacks, you can inherit CorePuzzleHandler.
There are 2 virtual methods available that you can overridde as you wish:
1
/// <summary>
2
/// The function that is triggered whenever the player has solved the puzzle.
3
/// </summary>
4
protected virtual void OnSolution() { }
5
6
​/// <summary>
7
/// The function that is triggered whenever the player makes a mistake in solving the puzzle.
8
/// </summary>
9
protected virtual void OnFailure() { }​
Copied!
For example,
1
public class CustomPuzzleHandler : CorePuzzleHandler
2
{
3
protected override void OnSolution()
4
{
5
// Insert custom event
6
Debug.Log("Puzzle is solved!");
7
}
8
​}
Copied!
See more about:
Last modified 2yr ago
Copy link