LevelDataConfiguration
public struct LevelDataConfiguration
A data structure used to determine the properties of a level based on a user data dictionary.
The user data dictionary requires the following fields:
exitAtfield: (String) determines column and row coordinates to the exit node.availableCostumesfield: (Int) determines which costumes are available.levelLinkfield: (String) determines the next scene to display after this scene ends.startingCostumefield: (String) determines which costume the player starts with.requisite_COL_ROWfield(s): (String) determines what outputs require certain inputs.
These fields are not required but can be added to extend the configuration:
achievementTriggerfield: (String) determines the achievement to trigger when passing through an achievement trigger.timerfield: (Int) determines how long a timer in the level will last. Defaults to 3 seconds.disallowCostumefield: (String) determines which costume cannot be used in this level.trackNamefield: (String) determines what music track to play.
-
The ID that determines what costumes are avaiable, with 0 indicating no costumes annd 3 indicating all costumes.
Declaration
Swift
public let costumeID: Int -
The name of the SKScene that will load after the current scene this level configuration is attached to.
Declaration
Swift
public let linksToNextScene: String -
The costume the player will start with by default.
Declaration
Swift
public let startWithCostume: PlayerCostumeType -
The matrix location of the exit door.
Declaration
Swift
public let exitLocation: CGPoint -
The default amount of time on alarm clock timers.
Declaration
Swift
public let defaultTimerDelay: Double -
A list of the requisites for switches and receivers.
Declaration
Swift
let requisites: [SwitchRequisite] -
The achievement to earn when passing through the achievement trigger, if one exists.
Declaration
Swift
let achievementTrigger: GameAchievement? -
A costume to remove from the queue.
Declaration
Swift
let disallowCostume: PlayerCostumeType? -
The track name to play as music.
Declaration
Swift
let trackName: String? -
A default level configuration with no costumes loaded and the next scene set to the main menu.
Declaration
Swift
static var `default`: LevelDataConfiguration { get } -
Initialize a level configuration.
Declaration
Swift
init( costumeID: Int, nextScene: String, startingWith costume: PlayerCostumeType, disallowing disallowedCostume: PlayerCostumeType?, under requisites: [SwitchRequisite], with exit: CGPoint, timed delay: Double, earning achievement: GameAchievement?, playing music: String? )Parameters
costumeIDThe costume ID that determines what costumes are available.
nextSceneThe SKScene name that will load after the scene attached to this configuration.
costumeThe type of costume the player starts with.
requisitesThe requisites list for all inputs and and outputs.
exitThe matrix location of the exit.
delayThe default number of seconds for a timer to be active for.
achievementThe game achievement to earn when passing through an achievement trigger.
-
Initialize a level configuration.
Declaration
Swift
public init(from userData: NSMutableDictionary)Parameters
userDataThe user data dictionary to read data from and generate a configuration.
-
Parse a given dictionary into a list of requisites.
This method will read a dictionary, filter for fields with the format
"requisite_COL_ROW", and proceed to parse t he resulting value as data about how the output is defined.The format for a requisite string is
"METHOD;COL,ROW;", whereMETHODcan beANDorOR, and every predicate afterwards is the coordinate to a corresponding input. For example: setting the keyrequisite_1_1toAND;2,1;3,1;will tell the scene to connect the output at (1, 1) to the inputs (2, 1) and (3, 1) while also making the connect anANDconnection where both inputs must be active to activate the output.Declaration
Swift
static func parseRequisites(from dictionary: NSMutableDictionary) -> [SwitchRequisite]Parameters
dictionaryThe dictionary to read from.
Return Value
A list of requisites for switches and outputs.