Namespace TDMaker.Unity.Campaign

Classes

CampaignAsset

A campaign: ordered levels on a world map with unlock rules (previous level, a list of required levels, an optional star gate, side branches that never block the main path) and the map picture. Progress lives in a save slot (ProfileData, read through CampaignProgress); this asset only describes the campaign. Edit it in the inspector: click in the map view to place level points, and the inspector lists validation problems.

CampaignLevel

One level of a CampaignAsset: what to play, where its point sits on the world map and when it opens.

CampaignMapScreen

World map screen built from code (uGUI + TextMesh Pro, styled by a HudTheme): the campaign's map picture with a point per level (locked with a lock, open with its number, completed with its best stars), dashed roads from each level's prerequisites, the star total, and a level info panel (title, summary, best stars, unlock requirements, Play). Call Show(CampaignProgress, CampaignMapUpdate) with the slot's progress and the update returned by ApplyPending() to highlight new stars and newly opened levels. PlayRequested and BackRequested leave the screen to the caller. Keys: 1-9 select a level, Enter plays it, Esc closes the panel and then goes back. Texts use HudTexts keys and relabel when the language changes. When the campaign has an upgradeShop, a Shop button (with the unspent stars as a badge) opens the UpgradeShopScreen over the map.

CampaignMapUpdate

Everything a map should show after merging victories: new stars, first clears and newly opened levels.

CampaignProgress

Campaign rules over one save slot's ProfileData. A level is locked until its record exists; records are created when the unlock rule holds (Refresh()), and an opened level never locks again. A victory is first recorded as a pending clear (RecordVictory(string, int), at the end of the battle) and merged into the map once by ApplyPending() (on map entry): best stars keep the maximum, re-wins never grant stars twice, the first win raises FirstCleared, and the next levels open. Several victories before a merge keep the best rating, and a later defeat does not discard it. Earned stars = sum of best stars of the levels that count; available = earned − spent.

CampaignSaveSlots

Save slots of one campaign over an ISaveStore: summaries for the slot picker, opening a slot (creating a fresh profile for an empty or unreadable one), saving the active slot and deleting slots. App settings are not stored here.

CampaignSession

The save slots whose slot is open right now (set by Open(int)). A SimulationRunner reads the open slot's purchased upgrade ranks and its campaign's upgradeShop from here when a battle starts, and the upgrade shop saves through it, so a flow script needs no extra wiring. Cleared when play mode starts.

CampaignUi

Helpers shared by the campaign screens (built from code with a HudTheme, like the HUD).

JsonFileSaveStore

Default store: one JSON file per slot under UnityEngine.Application.persistentDataPath (folder TDMakerSaves, files slot1.json, slot2.json, ...). Writes go to a temporary file that then replaces the slot file, so a crash mid-write leaves the previous save intact. An unreadable file is renamed to slotN.json.bak (or .bak2, ...) and kept. Not for WebGL (use PlayerPrefsSaveStore, or CreateDefault(int, string)).

LevelRecord

Saved progress of one campaign level. A record exists once the level is open.

MemorySaveStore

In-memory store (nothing persists): for tests, previews and tools.

PendingClear

A victory recorded at the end of a battle and not yet merged into the map (see ApplyPending()).

PlayerPrefsSaveStore

Store in UnityEngine.PlayerPrefs (browser storage in WebGL builds): one string per slot under prefix + slot number. Unreadable content is copied to key.bak before the slot is cleared. Flushes with UnityEngine.PlayerPrefs.Save() on every write.

ProfileData

Everything one save slot stores: opened levels with best stars, victories not yet merged into the map, purchased permanent upgrade ranks per track, stars spent on them, and free game-specific entries. App settings (volumes, language) are not part of a slot; they stay in TDGameSettings. Serialized with UnityEngine.JsonUtility by ProfileSerializer; version drives migrations.

ProfileEntry

A game-specific value kept in the save slot (tutorial flags, selected hero, ...).

ProfileSerializer

JSON form of ProfileData with schema versions. Reading runs the built-in migration steps and then every registered Migrate step from the file's version up to CurrentVersion (JsonUtility leaves fields a file does not have at their defaults, so a step only fixes meaning, not shape).

SaveSlotScreen

Save slot picker built from code (styled by a HudTheme): one row per slot of a CampaignSaveSlots with its stars, levels won and last play time, a Continue / New Campaign button and Delete (with a confirmation dialog: Delete, Cancel). One click on a slot opens it (SlotChosen); a new slot needs no name or extra confirmation. Keys: 1-9 choose a slot, Esc cancels the dialog and then goes back. Texts use HudTexts keys.

SaveStoreFactory

Picks the store for the running platform.

TextSaveStore

Shared logic of the text-based stores: JSON through ProfileSerializer, unreadable or newer content moved to a backup before the slot is treated as empty, and exceptions turned into results with a warning.

UpgradeEffectData

One effect of an upgrade rank. Maps one to one to a core UpgradeEffectDef.

UpgradeRankData

One purchasable rank of a track: its star price and its effects (added on top of the lower ranks).

UpgradeRankRecord

Purchased rank of one permanent upgrade track (ranks below it count as owned).

UpgradeShopAsset

The permanent star-upgrade shop of a campaign: ordered tracks (columns) of ranks bought in order with earned stars. Purchases live in the save slot (GetUpgradeRank(string) by track key); a battle bakes the shop and the purchased ranks into a core UpgradeSnapshot (CreateSnapshot(Func<string, int>, int?)) that the simulation applies before anything spawns. Assign it to upgradeShop (the world map then shows a Shop button and every battle started while that campaign's slot is open applies it) or to a SimulationRunner directly. Edit it in Tools > 2D Tower Defense Maker > Upgrade Shop.

UpgradeShopScreen

The permanent star-upgrade shop, built from code (uGUI + TextMesh Pro, styled by a HudTheme) over the world map: one column per track with its rank nodes, the stars to spend, a tooltip on hover (price, state and an effect summary generated from the data), one click on the next affordable rank buys it at once (no confirmation), Undo Changes returns to the purchases the shop opened with, Reset All clears every purchase (no confirmation) and Done or Esc closes it. Every change is saved immediately (UpgradeShopSession). CampaignMapScreen opens it from its Shop button.

UpgradeShopSession

One visit of the star-upgrade shop over a save slot. Every rule comes from the core UpgradeShopRules: only the next rank of a track can be bought and only with enough stars (Available = EarnedTotal − Spent); opening the session copies the purchases as the revert baseline; Revert() returns to that baseline (not one step back); ResetAll() clears every purchase and makes the cleared state the new baseline. Each change is written into the slot's ProfileData (ranks per track key and stars spent) and saved at once through Save.

UpgradeShopText

Texts of the upgrade shop in the current language: track names and summaries (shop.track.<key>.name|summary, then the authored English), rank lines (shop.track.<key>.rank<N>) and effect summaries generated from the effect data ("Range +10%", "Cooldown -2s", "New: Shell Burst", "Conscript becomes Veteran").

UpgradeTargetData

Which templates or spells an effect changes. Filters combine with AND; inside the asset list and inside the kind mask they are alternatives. Empty filters do not restrict (an effect with no filter at all changes everything of the field's kind).

UpgradeTrackData

One shop column: a chain of ranks bought in order.

Structs

CampaignIssue

One problem found by Validate().

CampaignLevelChange

What one ApplyPending() changed on a level.

SaveSlotSummary

What a slot picker shows for one slot without opening it.

Interfaces

ISaveStore

Where save slots live. Implementations never throw from these calls: failures are reported through the return values (and a console warning). Slot numbers start at 0. Unreadable content is never deleted silently: it is kept as a backup.

Enums

CampaignIssueSeverity

Severity of a CampaignIssue.

CampaignLevelState

Map state of a campaign level.

CampaignUnlock

How a campaign level opens on the world map.

SaveLoadStatus

Outcome of reading a save slot.

UpgradeEffectKind

What one authored permanent-upgrade effect does.

UpgradeRankState

What a rank node of the shop shows.

Delegates

ProfileMigration

One migration step: upgrades data read with schema fromVersion to fromVersion + 1.