Player.IO is the next version of the Nonoba Developer Tools.
More Features, No Branding, Integrates with Everything. Read more »
Class GameSetup
Namespace: Nonoba.GameLibrary
Language: C# / (.NET)
The GameSetup class and supporting methods are used to allow players to customize each instance your game. For instance, you might use GameSetup to allow the user to select the level to play on.
Using GameSetup is straight forward:
- Add GameSetup attributes to your Game class
- Use the Setup property of your Game to access the chosen setup
For example, if want your players to have the option of including bots in their games:
[GameSetup.Boolean("usebots", "Use Bots", "Should there be bots in the game?", false)]
public class Game : NonobaGame<Player> {
public override void GameStarted() {
bool useBots = Setup.GetBoolean("usebots");
}
...
}
You can add as many GameSetup attributes to your game as you want. Currently we support the following 4 GameSetup types: Boolean, String, Integer and Options.
Here is an example of how the GameSetup options are presented to the player in the game lobby
Development mode
When you're developing your game, you can control the setup of new game instances straight from the development serverIf your game has any GameSetup attributes, the development server will feature a new section on the right site of the status tab called "New Game Configuration"
This section mirrors the functionality of the lobby, and allows you to configure the values of each setting. The values are saved between different runs of the server, so you don't have to set them every time.
GameSetup Attributes
[GameSetup.Boolean(string id, string name, string description, bool defaultValue)]
True/false values. Presented as a checkbox.
[GameSetup.String(string id, string name, string description, string defaultValue)]
String values. Presented as a singleline inputfield.
[GameSetup.Integer(string id, string name, string description, int minValue, int maxValue, int defaultValue)]
Integer values in a specified interval. Presented as a dropdown, so don't use large intervals.
[GameSetup.Options(string id, string name, string description, string[] options, string[] values)]
A value from a list of options. Presented as a dropdown.
GameSetup.Boolean
GameSetup.Boolean(string id, string name, string description, bool defaultValue)
True or false value, presented as a checkbox. To receive the chosen value, call Setup.GetBoolean(id), from inside your game.
Example
[GameSetup.Boolean("usebots", "Use Bots", "Should there be bots in the game?", false)]
public class Game : NonobaGame<Player> {
public override void GameStarted() {
bool useBots = Setup.GetBoolean("usebots");
}
...
}
GameSetup.String
GameSetup.String(string id, string name, string description, string defaultValue)
String value, presented as a inputfield. To receive the chosen value, call Setup.GetString(id), from inside your game.
Example
[GameSetup.String("taunt", "Winner Taunt", "A message to show to the loser", "You lost!")]
public class Game : NonobaGame<Player> {
public override void GameStarted() {
string taunt = Setup.GetString("taunt");
}
...
}
GameSetup.Integer
GameSetup.Integer(string id, string name, string description, int minValue, int maxValue, int defaultValue)
Integer value, presented as a dropdown so don't use large values. To receive the chosen value, call Setup.GetInteger(id), from inside your game.
The value is guaranteed to be at least minValue, and at most maxValue.
Example
[GameSetup.Integer("runtime", "Round time", "How many minutes should a round take?", 2, 10, 4)]
public class Game : NonobaGame<Player> {
public override void GameStarted() {
int roundTime = Setup.GetInteger("runtime");
}
...
}
GameSetup.Options
GameSetup.Options(string id, string name, string description, params string[] options)
GameSetup.Options(string id, string name, string description, string[] options, string[] values)
A value from a list of options. Presented as a dropdown. To receive the chosen value, call Setup.GetOption(id), from inside your game.
If you're only specifying the options array, the values returned from Setup.GetOption(id) will be the exact ones in the options array. Otherwise, specify a values array of exactly the same length as the options array.
Example
[GameSetup.Options("level", "Level", "Which level to race on?",
new string[] { "Copenhagen", "Figure 8", "Zig Zag" },
new string[] { "cph", "f8", "zigzag" }
)]
[GameSetup.Options("difficulty", "Difficulty", "How hard should the AI be?",
"Easy", "Sorta-Easy", "Medium", "Hard" )]
public class Game : NonobaGame<Player> {
public override void GameStarted() {
string level = Setup.GetOption("level") // "cph" or "f8" or "zigzag"
string difficulty = Setup.GetOption("difficulty") // "Easy" or "Sorta-Easy
// or "Medium" or "Hard"
}
...
}