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
FormatName
Marker of 2D Tower Defense Maker profile files.
public const string FormatName = "TDMakerProfile"
Field Value
created
Creation time (UTC, round-trip format).
public string created
Field Value
custom
Free game-specific entries.
public List<ProfileEntry> custom
Field Value
earnedStars
Earned star total when the slot was last saved (for slot pickers that do not load the campaign).
public int earnedStars
Field Value
format
Format marker (FormatName).
public string format
Field Value
levels
Opened levels (a level without a record is locked).
public List<LevelRecord> levels
Field Value
pendingClears
Victories waiting to be merged into the map.
public List<PendingClear> pendingClears
Field Value
saved
Time of the last save (UTC, round-trip format).
public string saved
Field Value
starsSpent
Stars spent on permanent upgrades (available = earned − spent).
public int starsSpent
Field Value
upgradeRanks
Purchased permanent upgrade ranks by track key.
public List<UpgradeRankRecord> upgradeRanks
Field Value
version
Schema version of the data (see Migrate).
public int version
Field Value
Methods
Clone()
A deep copy (through JSON).
public ProfileData Clone()
Returns
CreateNew()
A new empty profile stamped with the current time.
public static ProfileData CreateNew()
Returns
FindLevel(string)
The record of key, or null (locked).
public LevelRecord FindLevel(string key)
Parameters
keystring
Returns
FindPending(string)
The pending victory of key, or null.
public PendingClear FindPending(string key)
Parameters
keystring
Returns
GetCustom(string, string)
A game-specific value, or fallback.
public string GetCustom(string key, string fallback = null)
Parameters
Returns
GetUpgradeRank(string)
Purchased rank of an upgrade track (0 when never bought).
public int GetUpgradeRank(string track)
Parameters
trackstring
Returns
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
Returns
SetCustom(string, string)
Sets a game-specific value (null removes it).
public void SetCustom(string key, string value)
Parameters
SetUpgradeRank(string, int)
Sets the purchased rank of an upgrade track (0 removes the entry).
public void SetUpgradeRank(string track, int rank)