WinGrid Demo

This demo comes with the SDK for the MMO Application and illustrates the basics discussed here.

Photon Server: WinGrid Demo
Photon Server: WinGrid Demo

  • 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:

  1. Open "MmoSolution": "src-server\Mmo\Photon.Mmo.sln".
  2. Select the project "Photon.MmoDemo.Server" and build it.
  3. Copy server app binaries (all files) from "src-server\Mmo\Photon.MmoDemo.Server\bin" to "deploy\MmoDemo\bin".
  4. Start "PhotonControl" from "deploy\bin_WinXX\PhotonControl.exe".
  5. Start "MmoDemo" Instance from "PhotonControl". (you can find it in tray icon)
You can automate the 3rd step by adding a build event to "Photon.MmoDemo.Server" VisualStudio project to auto copy files on every build. This is optional but productive if you are going to change MMO sever app code.

Now you can start any of the clients.

Start Client

  1. Open the solution "\src-server\Mmo\Photon.Mmo.sln".
  2. Select the project "Photon.MmoDemo.Client.WinGrid".
  3. Build it and run it.

Examples

  1. Client with bots

Photon Server: WinGrid Demo Client with Bots
Photon Server: WinGrid Demo Client with Bots

Bots do not have an interest area.

  1. Multiple Clients

Photon Server: WinGrid Demo Multiple Clients
Photon Server: WinGrid Demo 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

Photon Server: WinGrid Demo Settings
Photon Server: WinGrid Demo 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.

Photon Server: WinGrid Demo Radar
Photon Server: WinGrid Demo Radar

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.

Photon Server: WinGrid Demo Counter
Photon Server: WinGrid Demo Counter

If the player stops moving the operations/sec drops to zero:

Photon Server: WinGrid Demo Counter
Photon Server: WinGrid Demo Counter

If auto-move is enabled each running bot will increase the operations/sec and disabling it will stop sending operations:

Photon Server: WinGrid Demo Counter
Photon Server: WinGrid Demo Counter

Increasing the interest area will send the bot positions initially but with auto-move disabled no other position updates are sent:

Photon Server: WinGrid Demo Counter
Photon Server: WinGrid Demo Counter
Photon Server: WinGrid Demo Counter
Photon Server: WinGrid Demo Counter

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:

Photon Server: WinGrid Demo Counter
Photon Server: WinGrid Demo Counter

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.

Photon Server: WinGrid Demo Counter
Photon Server: WinGrid Demo Counter

Configuration

The following settings are available in app.config to change the world parameter:

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

 To Document Top