Assigning player IDs
Another feature required by nearly all multiplayer games, is the ability to track players by player ID. We need some kind of lightweight data, which uniquely identifies a specific player, such as a number (for instance, an object might store this number as a reference to the player who owns it). So, let's modify our server to assign player IDs to peers as they connect. It will also notify the client of its player ID upon connecting.
We'll use a long integer for the purpose.
A static long variable is initialized with the smallest value possible (long.MinValue), the last assigned player ID. When a player joins, we copy the static variable as their ID, and then increment the static variable.using Photon.SocketServer; using PhotonHostRuntimeInterfaces; using System.Collections.Generic; class PhotonAckPeer : PeerBase { // note that we use long.MinValue rather than zero. Signed integer values have a negative minimum and positive maximum. Starting at zero divides the possible...