<aside> <img src="/icons/reorder_gray.svg" alt="/icons/reorder_gray.svg" width="40px" />

Navigation

</aside>

🏠 Home Page

Getting Started

Architecture

Level System

Characters & Vehicles

Run Mechanics

World Objects

Boosters & Modifiers

Progression & Economy

UI

Save & Debugging

Modules

Publishing

Reference

💰 Monetization (Ads & IAP)

<aside> 💡 Game systems are accessed through static controllers. Most of them are created by an init module, so they are ready when the Game scene starts.

</aside>

Call the static API instead of searching for objects in the scene.

Framework controllers (Watermelon Core)

Controller Role Common calls
SaveController Loads and saves data. GetSaveObject<T>(key), MarkAsSaveIsRequired(), Save()
UIController Shows and hides UI pages. ShowPage<T>(), HidePage<T>(), GetPage<T>(), IsDisplayed<T>()
Overlay Full screen fade used between states. Overlay.Show(duration, callback), Overlay.Hide(duration)
LogManager Logging with categories. LogManager.Log(message, category)

Module controllers (Project Files / Modules)

Controller Role Common calls
CurrencyController Currency balances. Get, Add, Substract, HasAmount
AudioController Sounds and music. PlaySound, GetClip, PlayLoopingSound
ParticlesController Particle effects by name. PlayParticle(name)
UpgradesController Active upgrades of the current level. LoadUpgrades, GetUpgrade<T>
AdsManager Advertisement. See the Advertisement module doc.
Tween Tweens and delayed calls. Tween.DelayedCall, Tween.DoFloat

Game controllers (Project Files / Game)

Controller Role Common calls
GameController Runs the loop of one level. Not static. See ‣.
ProgressionController Passes upgrades of a Level to UpgradesController and exposes the multipliers. LoadLevel, LauncherPowerMultiplier, VehicleEfficiencyMultiplier, IncomeMultiplier
LevelSelectionController Saves the selected level and the highest reached level. GetSelectedLevelId, SetSelectedLevelId, MarkLevelReached
CameraController Switches the camera states. SetState, SetRunTarget, SetRunCamera, FreezeRun
BoosterController Active boosters. Activate, IsActive, DeactivateAll, OnBoosterActivated
PreRunModifierController Modifiers chosen before the run. Activate, IsActive, GetRemainingTime, GetBonusPercent
RunStateController Resets world objects that changed during a run. MarkDirty, ResetRun
RunCoinsController Coins collected during the current run. Add, AddCredited, ResetRun
LevelMusicController Level music. Play(clip)
BreakablePropController Breakable props of the level. Used by breakable props.

Controllers and init modules

A controller created by an init module is a regular class with a static instance. The module creates it in InitAsync and releases it in Unload. See the BoosterInitModule code:

public override IEnumerator InitAsync(GameObject owner)
{
    boosterController = new BoosterController(boosterDatabase);
    yield break;
}

Standard pattern for a new feature

  1. Create the folder Scripts/FeatureName/.
  2. Create FeatureNameController with a static public API.
  3. Create FeatureNameInitModule and register it with [RegisterModule("Name")].
  4. Create FeatureNameSave : ISaveObject when the feature needs persistence.
  5. Create FeatureNameDatabase : ScriptableObject when the feature needs configuration data.
  6. Add the module to Project Init Settings below the modules that it depends on.

Run state and save objects

Objects of a level scene use three interfaces to take part in the run:

Interface Purpose
IRunStateObject The object calls RunStateController.MarkDirty when its state changes and returns to the initial state in ResetState(). The reset runs without a scene reload.
IChunkActivatable The object is enabled only while the character is near it. See World Objects.
ISceneSaveObject The object stores save data that belongs to one Level, for example a collected pickup or the record wall. InitSave(levelId) is called once per level load with the id of the Level, because one scene can be reused by several Level assets.