public void FindGame() { MObjects.FindGameRequest mObject = new MObjects.FindGameRequest(); mObject.alias = string.IsNullOrEmpty(input_alias.text) ? Language.GetText(10) : input_alias.text; mObject.mapId = (ushort)selectedMap; nc.Send(MTypes.FindGameRequest, mObject); loadingText.text = Language.GetText(7); panel_Loading.Open(); }
public void FindGameRequest(NetworkMessage netMsg) // Registered on UNETServer { Debug.Log("Find game request received"); /* * FIND THE CURRENT SESSION * */ MObjects.FindGameRequest mObject = netMsg.ReadMessage <MObjects.FindGameRequest>(); Callipso.GameSession _currentSession = sessions.Find(x => x.agents.Find(e => e.user != null && e.user.connectionId == netMsg.conn.connectionId)); // currently in session if (_currentSession != null) { netMsg.conn.Disconnect(); return; // kicked } string clientPrefab = playerHeroes[Random.Range(0, playerHeroes.Count)].clientPrefab; // Random hero for first connection Callipso.GameSession _gameSession = sessions.Find(x => x.map == mObject.mapId && !x.isStarted && !x.killed && x.agents.Count < MapLoader.maps [x.map].maxPlayers); JoinGame(netMsg.conn, _gameSession, mObject.alias, clientPrefab, true, mObject.mapId); }