Skip to content

UiWalkthrough

The UiWalkthrough class manages the new-player tutorial walkthrough. It guides players through 4 sequential steps using hint popups, tracking completion and persisting progress via localStorage.

UiWalkthrough private

Extends UiComponent.

Properties

NameTypeDescription
uiUiCurrent Ui instance. Inherited from UiComponent.
hasCompletedRecord<number, boolean>Map of step numbers to their completion status.
stepPopupIdsRecord<number, number>Map of step numbers to their active popup IDs.
currentStepnumberThe currently active step number. Starts at 1.
inWalkthroughbooleanWhether the walkthrough is currently active.
stepsRecord<string, { message: string, icon: string }>The four tutorial steps with their messages and icon paths.

Walkthrough Steps

StepMessageIcon
1Gather 10 wood and stone using WASD + Left Click.entities-tree.svg
2Place your Gold Stash — zombies will spawn at night.entities-gold-stash.svg
3Build an Arrow Tower from the toolbar.entities-arrow-tower.svg
4Build a Gold Mine to generate gold passively.entities-gold-mine.svg

Methods

constructor()

ts
function constructor(ui: Ui): void

Initializes the walkthrough with step definitions and registers the enterWorld network handler.

restart()

ts
function restart(): void

Clears localStorage completion flag, resets to step 1, sets inWalkthrough to true, and shows the first step's hint popup (30-second timeout).

markStepAsCompleted()

ts
function markStepAsCompleted(step: number): void

Marks a step as completed. If it's the current step, removes its popup and advances to the next uncompleted step (showing its hint). If all steps are completed, sets walkthroughCompleted in localStorage.

onEnterWorld()

ts
function onEnterWorld(data: { allowed: boolean }): void

Handles the enter world response. If allowed and localStorage doesn't have walkthroughCompleted set, calls restart() to begin the tutorial.