Tutorials #

Read more about the Tutorials system in Hiro here.

Initializing the tutorials system #

The tutorials system relies on the Nakama System which must be passed in as a dependency via the constructor.

1
2
var tutorialsSystem = new TutorialsSystem(logger, nakamaSystem);
systems.Add(tutorialsSystem);

Subscribing to changes in the tutorials system #

You can listen for changes in the tutorials system so that you can respond appropriately, such as updating the UI, by implementing the appropriate interface.

1
2
3
4
5
var disposer = SystemObserver<TutorialsSystem>.Create(tutorialsSystem, system => {
  Instance.Logger.Info($"System updated.");

  // Update UI elements etc as necessary here...
});

Refreshing the tutorials system #

To ensure the tutorials system has the latest information from Nakama you can refresh it.

1
await tutorialsSystem.RefreshAsync();

Getting all tutorials #

You can get all tutorials.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
var tutorials = tutorialsSystem.GetAllTutorials();
foreach (var tutorial in tutorials)
{
    Debug.Log($"Tutorial {tutorial.Id}");
    Debug.Log($"Step {tutorial.Current} of {tutorial.Max}");

    if (tutorial.Completed)
    {
        var completedAt = DateTimeOffset.FromUnixTimeMilliseconds(tutorial.CompleteTime).DateTime;
        Debug.Log($"Completed at {completedAt.ToShortDateString()}");
    }
}

Get an individual tutorial #

You can get an individual tutorial.

1
var tutorial = tutorialsSystem.GetTutorial("<tutorialId>");

Accepting a tutorial #

You can accept an offered tutorial.

1
await tutorialsSystem.AcceptTutorialAsync("<tutorialId>");

Declining a tutorial #

You can decline an offered tutorial.

1
await tutorialsSystem.DeclineTutorialAsync("<tutorialId>");

Abandoning a tutorial #

You can abandon a tutorial.

1
await tutorialsSystem.AbandonTutorialAsync("<tutorialId>");

Updating a tutorial #

You can update the current step of a tutorial.

1
await tutorialSystem.UpdateTutorialAsync(tutorial.Id, 3);