Class ProfileData

Namespace
TDMaker.Unity.Campaign
Assembly
TDMaker.Unity.dll

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.

public sealed class ProfileData
Inheritance
ProfileData
Inherited Members

Constructors

ProfileData()

public ProfileData()

Fields

CurrentVersion

Schema version written by this code.

public const int CurrentVersion = 1

Field Value

int

FormatName

Marker of 2D Tower Defense Maker profile files.

public const string FormatName = "TDMakerProfile"

Field Value

string

created

Creation time (UTC, round-trip format).

public string created

Field Value

string

custom

Free game-specific entries.

public List<ProfileEntry> custom

Field Value

List<ProfileEntry>

earnedStars

Earned star total when the slot was last saved (for slot pickers that do not load the campaign).

public int earnedStars

Field Value

int

format

Format marker (FormatName).

public string format

Field Value

string

levels

Opened levels (a level without a record is locked).

public List<LevelRecord> levels

Field Value

List<LevelRecord>

pendingClears

Victories waiting to be merged into the map.

public List<PendingClear> pendingClears

Field Value

List<PendingClear>

saved

Time of the last save (UTC, round-trip format).

public string saved

Field Value

string

starsSpent

Stars spent on permanent upgrades (available = earned − spent).

public int starsSpent

Field Value

int

upgradeRanks

Purchased permanent upgrade ranks by track key.

public List<UpgradeRankRecord> upgradeRanks

Field Value

List<UpgradeRankRecord>

version

Schema version of the data (see Migrate).

public int version

Field Value

int

Methods

Clone()

A deep copy (through JSON).

public ProfileData Clone()

Returns

ProfileData

CreateNew()

A new empty profile stamped with the current time.

public static ProfileData CreateNew()

Returns

ProfileData

FindLevel(string)

The record of key, or null (locked).

public LevelRecord FindLevel(string key)

Parameters

key string

Returns

LevelRecord

FindPending(string)

The pending victory of key, or null.

public PendingClear FindPending(string key)

Parameters

key string

Returns

PendingClear

GetCustom(string, string)

A game-specific value, or fallback.

public string GetCustom(string key, string fallback = null)

Parameters

key string
fallback string

Returns

string

GetUpgradeRank(string)

Purchased rank of an upgrade track (0 when never bought).

public int GetUpgradeRank(string track)

Parameters

track string

Returns

int

Normalize()

Replaces missing lists, drops empty entries and merges duplicate keys (keeping the best values). Run after loading.

public void Normalize()

OpenLevel(string, out bool)

The record of key, created (opened) when missing.

public LevelRecord OpenLevel(string key, out bool created)

Parameters

key string
created bool

Returns

LevelRecord

SetCustom(string, string)

Sets a game-specific value (null removes it).

public void SetCustom(string key, string value)

Parameters

key string
value string

SetUpgradeRank(string, int)

Sets the purchased rank of an upgrade track (0 removes the entry).

public void SetUpgradeRank(string track, int rank)

Parameters

track string
rank int