Bowling Level Setup
From Blue Mars Developer Guidebook
Overview of Level Setup
This page details how the Bowling game is setup for one lane. Bowling assets, scripts and triggers are setup in the Beach City level and organized in a separate level layer.
The following entities are placed in the level.
Number (1) in the image above, an ARAvatarTrigger is placed at the beginning of a lane near the ball rack; Property settings are pictured below.
The Popup dialogs section explains what happens upon entering this trigger.
Number (2) in the image above, TagPoints (RollupBar>AI>TagPoint) are placed to mark these locations:
- (2a) Starting Position, named TagPoint_startpos_<lane#> - position is used for the avatar's position at the start of a turn
- (2b) Ball return, named TagPoint_ballreturn_<lane#> - position & direction is used for setting the position of a returned ball, and adding impulse to roll in the forward direction of the TagPoint
- (2c) Pin 1 position, named TagPoint_pin_<lane#> - position & direction is used to align the pins and the pin resetter machine, and this direction is used as the lane's forward direction
Number (3) in the image above, four bowling balls are placed on the ball return rack
- The balls are instances of the Entity Archetype "ball" found in the DataBase View (View>Open View Pane> DataBase View), and are loaded from the Game/Levels/AR/Common/Libs/EntityArchetypes/Bowling.xml file
- Entity Archetypes allow the model, physics settings, etc. to be defined once for an entity
- They are named ball_lane<lane#>_p<plyr#> (e.g., ball_lane3_p1) and referenced by name in script (System.GetEntityByName by name in scripts)
Number (4) in the image above, chair entities are placed in the couch and are marked as "HiddenInGame" in EntityParams, used to seat players during multiplayer games. Four chairs are linked to the Supervisor entity with Link Names "chair1"-"chair4", as shown below.
These reserved seats (the first two spots on the couch) are only accessed within the game. The third spot is accessible by any player since the couch is an ARChair entity - upon clicking the couch, a player is seated on the third cushion. There are also a number of ARChair entities in the level used for the stools and booths in the back of the alley.
Pins are Entity Archetypes, similar to the bowling balls.
- Ten pins are placed in the level (Entity Archetype "pin" from DataBaseView) and linked to the Supervisor entity with Link Names "pin"
- The supervisor script uses these links to access the pins, so their object names don't matter
- Pictured below, pins are setup by the supervisor according to the Pin TagPoint location (2c above, grayed out here because it is frozen)
ARConfirmTeleport entity - enter/exit the alley
Two ARConfirmTeleport entities are placed in the level to handle entering and exiting the bowling alley.
See the ARConfirmTeleport page for more details about this setup, which includes an ARAvatarTrigger, a destination TagPoint, and a simple FlowGraph.
ARConfirm entity - choose game mode
In the FlowGraph, the avatar trigger is connected to the lane's updater to check if the lane is available ("not owned"); if so the ARConfirm entity starts, bringing up a popup dialog. The player's choice (single player or multiplayer button) is passed on to the supervisor which spawns the corresponding mode's script. This FlowGraph, shown below, is a bit ugly--it's a working solution until the next implementation of matchmaking.
Bowling game entity setup
The game entities are placed in the level (in the AR_BeachCity level, these entities appear in the RollupBar Entity Browser under AR>Common>Minigames>Bowling) and Properties, links and FlowGraph nodes are setup. These entities - ARBowlingUpdater and ARBowlingSupervisor - are represented by yellow "AR" icons in the image at the top of the page. The ARBowlingStatsDisplay script controls the leaderboard using web utilities and Flash Material, the same way the golf display is controlled by the ARGolfStatsDisplay.
"Updater" entity communicates game events to spectators
The ARBowlingUpdater's syncPeriod Property is set to 333, meaning spectators receive game events every 333ms or 3 times per second. One ARAvatarTrigger encompasses the alley and uses a ScriptCommand to initialize all lanes for spectators.
- The Enabled and OnlyLocalAvatar and checked, but StopOnEnter is not checked; DimX,Y,Z are set to 36, 40, 5.
- The ScriptCommand contains calls to launch each lane's updater as well as the leaderboard.
EntityNamed("ARBowlingUpdater1"):GameStart();EntityNamed("ARBowlingUpdater2"):GameStart(); ... EntityNamed("ARBowlingUpdater6"):GameStart(); EntityNamed("ARBowlingStatsDisplay1"):Start();
- The ScriptCommandLeave stops the leaderboard from refreshing every minute.
"Supervisor" entity launches game
ARBowlingSupervisor is placed in the level with Properties pictured below, including a GameClass unique to this lane and area id's matching the gutter, pin and pit areas below.
- ARBowlingSupervisor links to the pins and chairs, as described in the Bowling page's game entity targets objects section.
- Shape areas are placed to delimit the gutters, pit, and pins areas. These Shape areas target the Supervisor entity, as described in the Bowling page's shape areas target game entity section.
- Lane, gutter and pit models have collision proxies which interact with the ball and pins.
- Solids (RollupBar>Objects tab>Solid) are placed as borders to prevent avatars from walking down the lanes or beyond the boundary of the alley
- the solid's material is assigned a special SurfaceType, mat_ar_forbidden, which prevents an avatar from walking over the solid
- Building interior and exterior geometry, decals, a VisArea and a few lights complete the alley setup
The sound effects are triggered by surface types coming in contact as described on the Material Effects page. Three bowling-specific surface types are used to define Material Effects: mat_bowlingBall, mat_bowlingPin, and mat_bowlingLane (floor). The four types of collisions are listed in the row/column intersections in the Material Effects spreadsheet, which point to sound effects defined in the collisions.xml.
User Interface files
UI Flash Movie files can be found in Game/Levels/AR/Common/Libs/UI/Bowling. These are referenced in the Hud table of the single and multiplayer scripts.