Padlocks
Padlocks are one of the core concept of EscapeGameKit. It allows you to prevent the player from doing something until he finds the correct code. Currently, you can use them in only one place : in onTap
actions of interactables.
You can create custom padlocks, but you can also use one of the already created padlocks :
-
CredentialsPadlock
that can be unlocked by entering the correct username / password combination. -
DigitsPadlock
that can be unlocked by entering the correct digits. -
PatternPadlock
that can be unlocked with the correct pattern. -
PadlockSequence
that is unlocked only once its children are unlocked.
Let's take an example. Suppose that you want to do a custom action only if a padlock named padlock
has been unlocked.
Interactable(
id: 'interactable',
renderSettings: InteractableRenderSettings(
top: 100,
right: 50,
height: 100,
width: 100,
),
onTap: (escapeGame) {
if (padlock.isLocked) {
return ActionResult.needAction(object: padlock);
}
// TODO: Implement custom code when `padlock` is unlocked.
},
);
But it's even easier if you use one of the already created interactables ! Suppose that you have a Door
that you want to protect using a code. You want to use something like that :
Door(
id: 'my-door',
roomId: 'target-room',
renderSettings: InteractableRenderSettings(
asset: 'assets/interactables/door.svg',
top: 200,
right: 20,
height: 80,
width: 80,
),
padlock: DigitsPadlock(
digits: '2018',
title: 'Oh no !',
unlockMessage: 'There is a padlock on this door... There must be a clue about it somewhere in the room.',
),
);
The player will have to enter 2018
in order to go through this door.
Just extend the Padlock
class and implement the tryCode(code)
method (which is triggered when the user enters the code
). To provide a dialog prompting the user to unlock your padlock, you have to register it using PadlockDialogs.registerBuilderFor(type, builder)
(see example here).
EscapeGameKit has been created by Skyost.