Class CampaignAsset

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

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.

[CreateAssetMenu(menuName = "2D Tower Defense Maker/Campaign", fileName = "Campaign", order = 2)]
public sealed class CampaignAsset : ScriptableObject
Inheritance
Object
ScriptableObject
CampaignAsset
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

CampaignAsset()

public CampaignAsset()

Fields

drawConnections

Draws the connections between levels and their prerequisites on the map.

[Header("Map drawing")]
public bool drawConnections

Field Value

bool

levels

Levels in campaign order (the main path follows this order; branches can sit anywhere).

public List<CampaignLevel> levels

Field Value

List<CampaignLevel>

lockedPathColor

Colour of a connection whose destination is still locked.

public Color lockedPathColor

Field Value

Color

mapImage

World map picture (any size; level points use 0..1 coordinates on it). Empty draws a plain panel.

[Tooltip("World map picture. Level points use 0..1 coordinates on it, so any resolution works.")]
public Sprite mapImage

Field Value

Sprite

maxStarsPerLevel

Most stars one level can give (the star rating tiers, normally 3).

[Min(1)]
public int maxStarsPerLevel

Field Value

int

openPathColor

Colour of a connection whose destination is open.

public Color openPathColor

Field Value

Color

pathDash

Length of the dashes of the connections in canvas units (0 = solid).

[Min(0)]
public float pathDash

Field Value

float

pathWidth

Connection thickness in canvas units.

[Min(1)]
public float pathWidth

Field Value

float

pointSize

Diameter of a level point in canvas units.

[Min(20)]
public float pointSize

Field Value

float

upgradeShop

Optional permanent star-upgrade shop. The world map then shows a Shop button, and battles started while a slot of this campaign is open apply its purchased ranks.

[Tooltip("Optional star-upgrade shop: the world map shows a Shop button and battles apply the slot's purchased ranks.")]
public UpgradeShopAsset upgradeShop

Field Value

UpgradeShopAsset

Properties

Count

Number of levels.

public int Count { get; }

Property Value

int

MaxStars

Highest possible star total (levels that count toward the total × maxStarsPerLevel).

public int MaxStars { get; }

Property Value

int

Methods

Find(string)

The level with key, or null.

public CampaignLevel Find(string key)

Parameters

key string

Returns

CampaignLevel

GetPrerequisites(int, List<int>)

Adds the indices of the levels that must be won before level index opens (the star gate aside). Unknown keys add -1 so callers can tell a missing prerequisite from none.

public void GetPrerequisites(int index, List<int> into)

Parameters

index int
into List<int>

IndexOf(string)

Index of the level with key, or -1.

public int IndexOf(string key)

Parameters

key string

Returns

int

IndexOf(LevelAsset)

Index of the entry playing level, or -1.

public int IndexOf(LevelAsset level)

Parameters

level LevelAsset

Returns

int

PreviousMainLevel(int)

Index of the main-path level PreviousLevel refers to for level index: the nearest earlier level that is not a branch, or -1 when there is none (open from the start).

public int PreviousMainLevel(int index)

Parameters

index int

Returns

int

Validate()

Checks the campaign: missing level assets, empty or duplicate keys, unknown required keys, cycles, levels that can never open (also counting the star gates against the stars reachable without them), no level open at the start and points off the map.

public List<CampaignIssue> Validate()

Returns

List<CampaignIssue>