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:

  • exitAt field: (String) determines column and row coordinates to the exit node.
  • availableCostumes field: (Int) determines which costumes are available.
  • levelLink field: (String) determines the next scene to display after this scene ends.
  • startingCostume field: (String) determines which costume the player starts with.
  • requisite_COL_ROW field(s): (String) determines what outputs require certain inputs.

These fields are not required but can be added to extend the configuration:

  • achievementTrigger field: (String) determines the achievement to trigger when passing through an achievement trigger.
  • timer field: (Int) determines how long a timer in the level will last. Defaults to 3 seconds.
  • disallowCostume field: (String) determines which costume cannot be used in this level.
  • trackName field: (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

    costumeID

    The costume ID that determines what costumes are available.

    nextScene

    The SKScene name that will load after the scene attached to this configuration.

    costume

    The type of costume the player starts with.

    requisites

    The requisites list for all inputs and and outputs.

    exit

    The matrix location of the exit.

    delay

    The default number of seconds for a timer to be active for.

    achievement

    The game achievement to earn when passing through an achievement trigger.

  • Initialize a level configuration.

    Declaration

    Swift

    public init(from userData: NSMutableDictionary)

    Parameters

    userData

    The 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;", where METHOD can be AND or OR, and every predicate afterwards is the coordinate to a corresponding input. For example: setting the key requisite_1_1 to AND;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 an AND connection where both inputs must be active to activate the output.

    Declaration

    Swift

    static func parseRequisites(from dictionary: NSMutableDictionary) -> [SwitchRequisite]

    Parameters

    dictionary

    The dictionary to read from.

    Return Value

    A list of requisites for switches and outputs.