Class UpgradeShopAsset

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

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.

[CreateAssetMenu(menuName = "2D Tower Defense Maker/Upgrade Shop", fileName = "UpgradeShop", order = 3)]
public sealed class UpgradeShopAsset : ScriptableObject
Inheritance
Object
ScriptableObject
UpgradeShopAsset
Inherited Members
ScriptableObject.SetDirty()
ScriptableObject.CreateInstance<T>()
Object.GetEntityId()
Object.GetInstanceID()
Object.GetHashCode()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Scene)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.Instantiate(Object, Transform)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Destroy(Object)
Object.DestroyImmediate(Object)
Object.DontDestroyOnLoad(Object)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Object.FindObjectsByType<T>()
Object.FindObjectsByType<T>(FindObjectsInactive)
Object.ToString()
Object.name
Object.hideFlags

Constructors

UpgradeShopAsset()

public UpgradeShopAsset()

Fields

tracks

Tracks in shop and application order.

public List<UpgradeTrackData> tracks

Field Value

List<UpgradeTrackData>

Properties

Count

Number of tracks.

public int Count { get; }

Property Value

int

FullCost

Sum of every rank's price (what buying everything costs).

public int FullCost { get; }

Property Value

int

Methods

BakeTracks()

Bakes every track into core definitions (throws with the track and rank on invalid data).

public UpgradeTrackDef[] BakeTracks()

Returns

UpgradeTrackDef[]

CollectProjectiles(List<ProjectileAsset>)

Projectiles fired by added mechanics (so the battle view knows how to draw them).

public void CollectProjectiles(List<ProjectileAsset> output)

Parameters

output List<ProjectileAsset>

CollectReferences(List<EntityAssetBase>)

Units the effects bring into a battle (swap replacements, units summoned by added mechanics), for the level bake.

public void CollectReferences(List<EntityAssetBase> output)

Parameters

output List<EntityAssetBase>

CreateSnapshot(Func<string, int>, int?)

The battle snapshot: every track with the rank purchasedRank returns for its key (clamped to the track; null means none bought), and an optional rank forced on every track (challenge modes; it never changes the purchases).

public UpgradeSnapshot CreateSnapshot(Func<string, int> purchasedRank, int? forcedRank = null)

Parameters

purchasedRank Func<string, int>
forcedRank int?

Returns

UpgradeSnapshot

CreateSnapshot(CampaignProgress, int?)

The battle snapshot of a save slot's purchases.

public UpgradeSnapshot CreateSnapshot(CampaignProgress progress, int? forcedRank = null)

Parameters

progress CampaignProgress
forcedRank int?

Returns

UpgradeSnapshot

HasEffect(UpgradeSnapshot)

Whether a snapshot applies anything (some applied rank above zero).

public static bool HasEffect(UpgradeSnapshot snapshot)

Parameters

snapshot UpgradeSnapshot

Returns

bool

IndexOf(string)

Index of the track with key, or -1.

public int IndexOf(string key)

Parameters

key string

Returns

int

Validate(IReadOnlyList<BakedLevel>)

Authoring problems: no tracks, empty or duplicate keys, tracks without ranks, negative prices, effects without a valid payload or without any filter, swaps without units, and data the core rejects. levels (optional) also reports effects that select nothing in any of those baked levels.

public List<CampaignIssue> Validate(IReadOnlyList<BakedLevel> levels = null)

Parameters

levels IReadOnlyList<BakedLevel>

Returns

List<CampaignIssue>