// Send a connect command to the server with the photon client id public void ConnectToServer(bool isOfflinePlayMode) { IsOfflinePlayMode = isOfflinePlayMode; JUMPCommand_Connect c = new JUMPCommand_Connect(JUMPMultiplayer.PlayerID); SendCommandToServer(c); }
// Server Engine internal void OnPhotonEventCall(byte eventCode, object content, int senderId) { // We are the server, hence, we are only processing events for the Master Client if (IsOfflinePlayMode || PhotonNetwork.isMasterClient) { if (eventCode == JUMPCommand_Connect.JUMPCommand_Connect_EventCode) { JUMPCommand_Connect c = new JUMPCommand_Connect((object[])content); // Set the player as connected JUMPPlayer player = new JUMPPlayer(); player.PlayerID = c.PlayerID; player.IsConnected = true; Players.Add(player); int maxPlayerId = player.PlayerID; // Add bots as players if offline if (IsOfflinePlayMode) { Bots.ForEach(x => { x.PlayerID = ++maxPlayerId; x.IsConnected = true; Players.Add(x); }); } int connectedplayers = Players.Count(p => p.IsConnected); // When all the players are connected, start the game. if (connectedplayers == JUMPOptions.NumPlayers) { GameServerEngine.StartGame(Players); } } else { JUMPCommand c = GameServerEngine.CommandFromEvent(eventCode, content); if (c != null) { GameServerEngine.ProcessCommand(c); } } } }