WinGrid Demo
This demo comes with the SDK for the MMO Application and illustrates the basics discussed here.
- Each cell is one interest region.
- The red dot is the avatar item.
- The red inner square is the inner interest area radius (default:
size of 1 cell) - The red outer square is the outer interest area radius (default:
size of 3 cells)
Mouse input:
- Left button drag: Move avatar
- Wheel: Increase or decrease interest area
- Middle button click: Reset interest area to default
- Right click: Toggle interest area avatar attached/detached
Keyboard input:
- M: Toggle auto-move on/off
- Num-Pad 5: Move avatar to center
- WASD and other Num-Pad Keys: Move avatar
- +: Open new tab and connect new client
- -: Close tab and disconnect client
- Insert: Start bot (additional item on same connection that moves
like an avatar) - Delete: Stop bot
- Space: Go to Settings tab (2nd tab from the left)
Start Server
Before you try to run any of the clients, make sure to start the Photon Server.
What you need to do to make it work:
- Open "MmoSolution": "src-server\Mmo\Photon.Mmo.sln".
- Select the project "Photon.MmoDemo.Server" and build it.
- Copy server app binaries (all files) from "src-server\Mmo\Photon.MmoDemo.Server\bin" to "deploy\MmoDemo\bin".
- Start "PhotonControl" from "deploy\bin_WinXX\PhotonControl.exe".
- Start "MmoDemo" Instance from "PhotonControl". (you can find it in tray icon)
Start Client
- Open the solution "\src-server\Mmo\Photon.Mmo.sln".
- Select the project "Photon.MmoDemo.Client.WinGrid".
- Build it and run it.
Examples
- Client with bots
Bots do not have an interest area.
- Multiple Clients
Other avatars are displayed with interest area. This information is
exchanged via item properties; other clients will always display the
newest chosen interest area size even if they are out of range when this
change happens.
Note that detached interest areas are still displayed as if they were
attached: interest areas are not items and cannot be “seen” if moved
around freely.
Settings
The settings tab is always the second from the far left.
- Player Text: A text that is shown as avatar name. It’s an item
property. - Player Color: The color of the player’s avatar. This is an item
property as well. - Send movement interval: The interval how often manual position
updates are sent and/or how often auto movement happens. Note that
position updates are only sent if the avatar (the item) moves. - Send reliable: Enable to test reliable sending of position updates.
- Auto Move Interval: The time the avatar is moving in one direction.
- Auto Move Velocity: The distance an avatar moves per movement
interval (“Send movement interval”. - Auto Move: If auto-move is disabled the bots stop moving as well.
Setting changes apply to the tab with the same title only.
‘Space’ is the shortcut to jump between the settings and the game tab.
Radar
The radar shows position changes of all items in the world every few
seconds.
This feature has been included with the demo to give the user a better
impression about what’s happening in the virtual world. Global radars are
no typical MMO features, that’s why it’s just part of the sample and not
of the interest management framework.
Counter
The server counter tab is updated every 5 seconds.
The picture shows the values of one connected client with one moving
player.
The received events peek every 5 seconds: They contain just counter
data, no other events are received.
If the player stops moving the operations/sec drops to zero:
If auto-move is enabled each running bot will increase the operations/sec and disabling it will stop sending operations:
Increasing the interest area will send the bot positions initially but with auto-move disabled no other position updates are sent:
Interpretation:
• Operations: 40 = 20SetViewDistance + 20SetProperties -> interest area was in-creased about 20 times
• Events: 10 = 10*ItemSubscribed -> 10 bots became visible
Moving these 10 bots with maximized interest area results in the following:
Events/sec and Operations/sec are almost identical (not receiving movement updates of avatar).
Sent and received position updates are identical when the maximized interest area is detached. The counters show a minimal because of the received counter events.
Configuration
The following settings are available in app.config to change the world parameter:
XML
<add key="WorldName" value="Unity3d-Island"/>
<add key="GridTilesVertical" value="20"/>
<add key="GridTilesHorizontal" value="20"/>
<add key="GridTileHeight" value="1000"/>
<add key="GridTileWidth" value="1000"/>
A non-existing world is created on demand with these configuration values, but already existing worlds will override these settings.
- WorldName: The name of the world to enter
- GridTilesVertical: Number of cells the grid world counts from top to bottom
- GridTilesHorizontal: Number of cells the grid world counts from left to right
- GridTileHeight: Unit-count of one cell top to bottom
- GridTileWidth: Unit-count of one cell left to right