P3-SDK 0.9
P3 Software Development Kit
Loading...
Searching...
No Matches
Additional Platform Features

Feature Menu

P3 games can optionally enable a Feature Menu to give players access to various features to enhance their playing experience. The Feature Menu is intended to be accessible in the same way by players in any app (when enabled). That is by holding down either flipper button and hitting the start button. Alternatively, an app can bring up the Feature Menu at any time by posting "Evt_ShowFeatureMenu", though the contents are mostly relevant in AttractMode and when launch is pending in HomeMode.

The Feature Menu and many of the features it contains can be enabled/disabled through GameAttributes. App developers can choose to allow operators to control accessibility of many of the features, or they can hide any/all of these GameAttributes by setting the GameAttribute options to Hidden in the SettingsMode (attr.Options |= GameAttributeOptions.Hidden).

The entire Feature Menu can be enabled/disabled by controlling GameAttribute "FeatureMenuEnabled"

// To enable access to the feature menu
data.GetGameAttributeValue("FeatureMenuEnabled").Set(true);
// To disable access to the feature menu
data.GetGameAttributeValue("FeatureMenuEnabled").Set(false);

When enabled, the Feature Menu is available when data.ball == 0 or when gameState == GameState.LaunchPending. It's an app's responsibility to change the gameState to GameState.BallInPlay when a ball is launched (usually in HomeMode.BallStartCompleteEventHandler()) and back to GameState.LaunchPending at the start of the next ball (usually in HomeMode.StartPlaying()).

PostModeEventToModes("Evt_ChangeGameState", GameState.LaunchPending);
PostModeEventToModes("Evt_ChangeGameState", GameState.BallInPlay);

Player Profiles

Player profiles allow players to effectively log into the game and access profile-specific features, like profile-specific game settings, team games, save/restore game state, etc.

// To get the profile name for player x. Will return "PlayerNotInGame" if x >= the number of players in the game.
data.GetPlayerName(x);
// To get the profile name for player x. Will return "Player " + (x+1).ToString() if the player is not logged in as a profile. Otherwise it will return "N/A".
data.GetPlayerName(x, true);

There are a number of GameAttributes that determine how profile-related features and menus work. See the Feature Menu Configuration section for specifics.

Player-specific Settings

Certain GameAttributes can be customized per profile, allowing people to play games with settings tailored to their skill level or desired configuration. To create such a GameAttribute, include the GameAttributeOptions.ProfileOption in the options parameter of the GameAttribute.

Example from P3SASettingsMode:

InitAttr(37, "SideTargetDifficulty", "Side Target Difficulty", "Side Target Difficulty", "Service Menu/Settings/Gameplay/General", PRW, 0, 0, 2, 1, 0);

The example above sets the Option parameter to "PRW", which is a constant defined in the base SettingsMode as follows:

protected const GameAttributeOptions PRW = GameAttributeOptions.ProfileOption;

Player Profile Events

If you want to access player profiles in your game without using the Feature Menu, you can issue the following ModeToMode events:

Event Name Parameter Type Parameter Meaning Event Description
Evt_ChooseProfile bool Active profile upon choice Bring up the profile selection menu
Evt_ActivateProfile string Profile name Activate the specified profile by name
Evt_ChangeProfile string Profile name Change the active player to a new profile
Evt_DeleteProfile string Profile name Delete the specified profile
Evt_EditProfileSettings string Profile name Bring up the operator settings for the specified profile
Evt_ResetProfile string Profile name Reset the specified profile as if it were being created for the first time in this app
Evt_GetListOfProfileNames any N/A Request the names of available profiles. The results are posted as ModeToMode event "Evt_ListOfProfileNames" with a List of strings (List<string>)
Evt_AddProfile string Profile name Create a new profile with the specified name

If you want to request a new name be entered, the following code will do it:

protected void PromptForNewProfileName()
{
SetSelectorData("ProfileNameTextSelector", new TextSelectorData("Enter profile name", new List<string>(), ""));
OpenDialog("ProfileNameEditor");
AddModeEventHandler("Evt_ProfileNameEntryCompleted", NameEnteredEventHandler, Priority);
AddModeEventHandler("Evt_ProfileNameEntryCancelled", NameCancelledEventHandler, Priority);
}
private bool NameEnteredEventHandler(string evtName, object evtData)
{
string newName = (string)evtData;
newName = newName.Trim();
RemoveModeEventHandler("Evt_ProfileNameEntryCompleted", NameEnteredEventHandler, Priority);
CloseDialog("ProfileNameEditor");
return SWITCH_CONTINUE;
}
private bool NameCancelledEventHandler(string evtName, object evtData)
{
RemoveModeEventHandler("Evt_ProfileNameEntryCompleted", NameEnteredEventHandler, Priority);
RemoveModeEventHandler("Evt_ProfileNameEntryCancelled", NameCancelledEventHandler, Priority);
CloseDialog("ProfileNameEditor");
return SWITCH_CONTINUE;
}

Team Games

When enabled, team games allow multiple players (and even groups of players in the same game) to play cooperatively. All players playing under the same profile name will play on the same team. Players on the same team will share the same player data. For example, if players 1 and 3 are on the same team, data.Players[2].GetData("Score", 0L) will return the same value as data.Players[0].GetData("Score", 0L). This allows players to help each other progress through a game and/or team up against another player or team.

Team games are enabled/disabled with GameAttribute: "TeamGamesAllowed"

Save/Restore State

Saving/Restoring state can allow players to save their state and later start a new game that starts where they previously left off (relative to game progress, not the number of balls they've played). Players can restore state before launching their first ball, and they can save state before plunging subsequent balls.

Saving/Restoring state is enabled/disabled with GameAttribute: "SaveRestoreStateAllowed";

Bluetooth Connections

Bluetooth connection options are listed in the Feature Menu if the Global Setting "BluetoothEnabled" is true.

Restarts and Removing Players

Player Removal

If the "AllowPlayerRemoval" GameAttribute is true and data.ball == 1, then players can be removed from the game. If a player is currently playing, player numbers greater than the current player can be removed by holding the start button for 2s, starting with the last player added. If launch is pending (gameState == GameState.LaunchPending), then even the current player can be removed. When player removal is possible, the Feature Menu will include an option to remove a player.

Soft Restarts

When the "SoftRestartEnabled" GameAttribute is true, active games can be aborted after the first ball by either holding down the start button for 2s or by selecting the Abort Game option in the Feature Menu.