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:

/// <summary>
/// The function that is triggered whenever the player has solved the puzzle.
/// </summary>
protected virtual void OnSolution() { }

​/// <summary>
/// The function that is triggered whenever the player makes a mistake in solving the puzzle.
/// </summary>
protected virtual void OnFailure() { }​

For example,

public class CustomPuzzleHandler : CorePuzzleHandler
{    
    protected override void OnSolution()    
    {        
        // Insert custom event        
        Debug.Log("Puzzle is solved!");    
    }
​}

See more about:

Last updated