public void CreateLobby(LobbyInfo lobbyInfo) { Dispatcher.Invoke(() => { currentLobby = lobbyInfo; }); }
public Lobby(LobbyInfo info) { Points = new Dictionary <Team, int>(); Info = info; State = new WaitingState(this); State.Initialize(); }
/// <see cref="ILobbyLocator.LobbyFound"/> public void LobbyFound(LobbyInfo foundLobby) { if (this.InvokeRequired) { /// Invoke this function from the UI thread. this.Invoke(new LobbyFoundCallback(this.LobbyFound), new object[1] { foundLobby }); } else { /// Normal invoke. foreach (object item in this.lstLobbies.Items) { LobbyInfo infoItem = (LobbyInfo)item; if (infoItem.ID == foundLobby.ID) { /// Already in the list. return; } } this.lstLobbies.Items.Add(foundLobby); UpdateControls(); } }
/// <see cref="ILobbyLocator.LobbyChanged"/> public void LobbyChanged(LobbyInfo changedLobby) { if (this.InvokeRequired) { /// Invoke this function from the UI thread. this.Invoke(new LobbyChangedCallback(this.LobbyChanged), new object[1] { changedLobby }); } else { /// Normal invoke. foreach (object item in this.lstLobbies.Items) { LobbyInfo infoItem = (LobbyInfo)item; if (infoItem.ID == changedLobby.ID) { this.lstLobbies.Items.Remove(item); this.lstLobbies.Items.Add(changedLobby); UpdateControls(); return; } } } }
// method to get the current lobby from the API private LobbyInfo GetLobby(int LobbyID) { JSONParser JSONParser = new JSONParser(); this.curLobby = JSONParser.GetLobby(LobbyID); return(curLobby); }
public Lobby(string name) { Points = new Dictionary <Team, int>(); Info = new LobbyInfo(name); State = new WaitingState(this); State.Initialize(); }
public async Task DeleteLobby(TempSessionWithSecrets userSession, LobbyInfo lobby) { var lobbyApi = new LobbyApi(); lobbyApi.Configuration.ApiKey["api_key"] = userSession.ApiKey; await lobbyApi.LobbyDeleteAsync(lobby.Id); }
public void OnJoinMessage(NetworkMessage netMsg) { LobbyInfo info = netMsg.ReadMessage <LobbyInfo>(); if (isServer && !info.PassForServer) { info.PassForServer = true; //Send to all clients NetworkServer.SendToAll(MyMsgType.JoinMsg, info); } else if (client.isConnected) { List <string> temp = new List <string>(); foreach (string s in lobbyUI.lobbyPlayers) { temp.Add(s); } temp.Add(info.sender); lobbyUI.lobbyPlayers.Clear(); for (int i = 0; i < temp.Count; i++) { lobbyUI.lobbyPlayers.Add(temp[i]); } lobbyUI.AddPlayer(); lobbyUI.SetLobbyInfo(info); } }
private void CreateLobbyCard(Vector3 pos, Vector3 scale, Quaternion rot, LobbyInfo lobby) { if (ItemPrefab != null) { SelectorActor sa = Instantiate(ItemPrefab); sa.transform.SetParent(transform); sa.transform.position = pos; sa.transform.localScale = scale; sa.transform.rotation = rot; Step ph = sa.gameObject.GetComponent <Step>(); ph.NextPhase = JoinLobbyPhase; Card card = sa.GetComponentInChildren <Card>(); if (card != null) { //\nLast Activity:{4}minutes ago //(DateTime.Now - lobby.last_activity).TotalMinutes) // Anzeige ist nicht korrekt, lobby.last_activity überprüfen card.CardText = String.Format("Name:\n{0}\n\nPlayers:{1}/{2}\nTarget Score:{3}", lobby.game_name, lobby.user_count, lobby.max_players, lobby.target_score); } CreatedItems.Add(sa); base.AddActor(sa); onScreenShownLobbys.Add(lobby); } }
public void LobbySearchFinished(LobbyMatchList_t pLobbyMatchList) { lobbies.Clear(); int numberOfResults = (int)pLobbyMatchList.m_nLobbiesMatching; int numberOfLobbies = 0; for (int i = 0; i < numberOfResults; i++) { CSteamID lobby = SteamMatchmaking.GetLobbyByIndex(i); LobbyInfo info = new LobbyInfo(lobby); if (info.UpdateLobbyInfo(lobby)) { lobbies.Add(info); numberOfLobbies++; } } searching = false; { patch_ProcessManager patchPM = ((patch_ProcessManager)Patches.patch_Rainworld.mainRW.processManager); if ((patchPM.currentMainLoop is LobbyFinderMenu)) { (patchPM.currentMainLoop as LobbyFinderMenu).searchFinished(numberOfLobbies); } } }
public bool TryJoinLobby(int id, string password) { var request = new WithoutLobbyRequest(); var message = new JoinLobbyRequest(); message.Password = password; message.LobbyId = id; request.JoinLobbyRequest = message; System.Console.WriteLine($"Joining lobby {id}"); request.WriteDelimitedTo(stream); var response = JoinLobbyResponse.Parser.ParseDelimitedFrom(stream); if (response.LobbyInfo != null) { System.Console.WriteLine($"Successfully joined lobby: {response.LobbyInfo}"); this.state = Tcp_State.PeerWithinLobby; this.joined_lobby = response.LobbyInfo; return(true); } this.state = Tcp_State.WithoutLobby; return(false); }
public bool TryCreateLobby(string password) { var request = new WithoutLobbyRequest(); var message = new CreateLobbyRequest(); message.Password = password; message.Capacity = 2; request.CreateLobbyRequest = message; System.Console.WriteLine($"Creating lobby {id}"); request.WriteDelimitedTo(stream); var response = CreateLobbyResponse.Parser.ParseDelimitedFrom(stream); if (response.LobbyId != 0) { System.Console.WriteLine($"Successfully created lobby {response.LobbyId}"); this.state = Tcp_State.HostWithinLobby; this.joined_lobby = new LobbyInfo { HostId = id, LobbyId = response.LobbyId, Capacity = message.Capacity }; return(true); } this.state = Tcp_State.WithoutLobby; return(false); }
public void LobbyEntered(LobbyEnter_t enterLobby) { connectedPlayers.Clear(); otherPlayers.Clear(); ResetManagers(); { if (!(RainWorldHK.mainRW.processManager.currentMainLoop is SteamMultiplayerMenu)) { ProcessManagerHK.ImmediateSwitchCustom(RainWorldHK.mainRW.processManager, new SteamMultiplayerMenu(RainWorldHK.mainRW.processManager)); } } joining = false; lobbyID = (CSteamID)enterLobby.m_ulSteamIDLobby; int playerCount = SteamMatchmaking.GetNumLobbyMembers((CSteamID)enterLobby.m_ulSteamIDLobby); MultiplayerChat.AddChat("Entered Lobby!"); //Send packets to all players, to establish P2P connections with them if (playerCount > 1) { for (int i = 0; i < playerCount; i++) { CSteamID lobbyMember = SteamMatchmaking.GetLobbyMemberByIndex(lobbyID, i); SteamNetworking.SendP2PPacket(lobbyMember, new byte[] { 255 }, 1, EP2PSend.k_EP2PSendReliable, 0); SteamNetworking.SendP2PPacket(lobbyMember, new byte[] { 255 }, 1, EP2PSend.k_EP2PSendReliable, 1); SteamNetworking.SendP2PPacket(lobbyMember, new byte[] { 255 }, 1, EP2PSend.k_EP2PSendReliable, 2); if (!connectedPlayers.Contains(lobbyMember.m_SteamID)) { connectedPlayers.Add(lobbyMember.m_SteamID); PlayerJoinedManagers(lobbyMember.m_SteamID); } if (lobbyMember != SteamUser.GetSteamID()) { otherPlayers.Add(lobbyMember.m_SteamID); } } } //Set up network data NetworkGameManager.managerID = ulong.Parse(SteamMatchmaking.GetLobbyData(lobbyID, MANAGER_ID)); NetworkGameManager.playerID = SteamUser.GetSteamID().m_SteamID; if (NetworkGameManager.managerID != NetworkGameManager.playerID) { lobbyInfo = new LobbyInfo((CSteamID)enterLobby.m_ulSteamIDLobby); lobbyInfo.UpdateLobbyInfo((CSteamID)enterLobby.m_ulSteamIDLobby); lobbyInfo.owner = new CSteamID(NetworkGameManager.managerID); } if (!connectedPlayers.Contains(SteamUser.GetSteamID().m_SteamID)) { connectedPlayers.Add(SteamUser.GetSteamID().m_SteamID); PlayerJoinedManagers(SteamUser.GetSteamID().m_SteamID); } MultiplayerChat.AddChat("This game's manager is " + SteamFriends.GetFriendPersonaName((CSteamID)NetworkGameManager.managerID)); isInGame = true; Log("Entered Lobby! \nThis game's manager is " + SteamFriends.GetFriendPersonaName((CSteamID)NetworkGameManager.managerID)); }
public void SetLobbyInfo(LobbyInfo info) { lobbyNameText.text = "Lobby Name: " + info.lobbyName; maxPlayersText.text = "Max Players: " + info.amountOfPlayers; amountOfRoundsText.text = "Amount of rounds: " + info.amountOfRounds; mapText.text = "Map: " + info.mapName; passwordProtectedText.text = "Password Protected:" + (string.IsNullOrEmpty(info.lobbyPassword)? "NO":"YES"); }
public void ChangeTeam() { var parameters = new List<SerializableType>(); var room = new LobbyInfo(Network.Instance.ClientPlayer.Id, Helper.RoomNameDisplay.text, "aurica", 6, 1); parameters.Add(room); var remoteMethod = new RemoteInvokeMethod(Command.ChangeTeam, parameters); BeginSendPackage(remoteMethod); }
public LobbyInfo WaitForFirstLobby() { TraceManager.WriteAllTrace("Waiting for first lobby!", TestConsoleTraceFilters.TEST_INFO); this.foundEvt.WaitOne(); LobbyInfo ret = this.foundLobby; TraceManager.WriteAllTrace(string.Format("Lobby found: {0}", ret.ToString()), TestConsoleTraceFilters.TEST_INFO); return(ret); }
public void StartGame() { var parameters = new List<SerializableType>(); GameFlow.Instance.RoomName = Helper.RoomNameDisplay.text; var room = new LobbyInfo(Network.Instance.ClientPlayer.Id, Helper.RoomNameDisplay.text, GameType.Fast.ToString(), 2, 2); parameters.Add(room); var remoteMethod = new RemoteInvokeMethod(Command.Start, parameters); BeginSendPackage(remoteMethod); }
public void Read(PacketReader reader) { PlayerInfo = new LobbyInfo[reader.ReadInt16()]; for (int i = 0; i < PlayerInfo.Length; i++) { PlayerInfo[i] = new LobbyInfo(); PlayerInfo[i].Read(reader); } }
// method to set lobby text and all feilds that require the lobby public void SetLobby(int LobbyID) { LobbyIDText.text = "LobbyID: " + LobbyID.ToString(); lobbyID = LobbyID; // setting curlobby field this.curLobby = GetLobby(this.lobbyID); // getting the current players in lobby this.curPlayers = GetLobby(lobbyID).CurrentPlayers; }
public void Create() { var parameters = new List<SerializableType>(); GameFlow.Instance.RoomName = Helper.RoomName.text; var room = new LobbyInfo( Network.Instance.ClientPlayer.Id, Helper.RoomName.text, "Fast", 2, 1); parameters.Add(room); var remoteMethod = new RemoteInvokeMethod(Command.Create, parameters); BeginSendPackage(remoteMethod); Helper.StartButton.SetActive(true); }
static void Client() { /// Wait for the server to create a DSS-lobby network.StartLocatingLobbies(locator); LobbyInfo foundLobby = locator.WaitForFirstLobby(); network.StopLocatingLobbies(); DssServiceAccess.ConnectDSS(foundLobby, network, guest, guest); }
public void Join(string roomName) { var parameters = new List<SerializableType>(); var room = new LobbyInfo(Network.Instance.ClientPlayer.Id, roomName, "aurica", 6, 1); GameFlow.Instance.RoomName = roomName; parameters.Add(room); var remoteMethod = new RemoteInvokeMethod(Command.Join, parameters); BeginSendPackage(remoteMethod); Helper.StartButton.SetActive(false); }
/// <summary> /// 添加大厅 /// </summary> /// <param name="lobby">大厅类型标识</param> /// <param name="name">大厅名字:如初级场</param> /// <param name="userCount">大厅最大人数</param> /// <param name="roomCount">房间个数</param> /// <param name="roomUserCount">房间人数限制</param> public void AddLobby(string strKey, string lobbyName, int userCount, int roomCount) { var lobby = new LobbyInfo(); lobby.lobbyName = lobbyName; lobby.userCount = userCount; lobby.roomCount = roomCount; lobby.InitRooms(); lobbys.Add(strKey, lobby); }
public void OpenNewLobby() { // Setup the networker LobbyInfo thisLobby = new LobbyInfo(); thisLobby.connectedClients = 1; thisLobby.maxClients = 1000; thisLobby.port = 8081; thisLobby.name = "MMO Duel Simulation"; LobbyConnector.HostLobby(thisLobby); }
public LobbyInfo GetInfo() { var info = new LobbyInfo { LobbyId = id, HostId = host_id, Capacity = capacity }; info.PeerIds.AddRange(GetNonHostPeerIds()); return(info); }
public void SyncLobbyInfo() { if (State == ServerState.WaitingPlayers) // Don't do this while the game is running, it breaks things! { DispatchOrders(null, 0, new ServerOrderDefault("SyncInfo", LobbyInfo.Serialize()).Serialize()); } foreach (var t in serverTraits.WithInterface <INotifySyncLobbyInfo <ClientDefault, ClientPingDefault> >()) { t.LobbyInfoSynced(this); } }
private void OnGUI() { if (isConnecting) { if (GUILayout.Button("Cancel Connection")) { this.isConnected = false; this.isConnecting = false; LobbyConnector.CancelConnection(); } } else if (isConnected) { if (GUILayout.Button("Disconnect")) { LobbyConnector.Disconnect(); } } else { if (GUILayout.Button("Start Host")) { this.isConnecting = true; LobbyInfo thisLobby = new LobbyInfo(); thisLobby.ip = "localhost"; thisLobby.port = 8080; thisLobby.isServer = false; LobbyConnector.HostLobby(thisLobby); } if (GUILayout.Button("Start Dedicated Server")) { this.isConnecting = true; LobbyInfo thisLobby = new LobbyInfo(); thisLobby.ip = "localhost"; thisLobby.port = 8080; thisLobby.isServer = true; LobbyConnector.HostLobby(thisLobby); } if (GUILayout.Button("Connect To Host")) { this.isConnecting = true; LobbyConnector.ConnectToLobby(textFieldString); } textFieldString = GUI.TextField(new Rect(0, 100, 100, 20), textFieldString); } }
private void OnConnected(NetworkMessage netMsg) { if (client.isConnected) { lobbyController.ActivePublicLobby(); client.RegisterHandler(MyMsgType.ChatMsg, OnChatMessage); client.RegisterHandler(MyMsgType.JoinMsg, OnJoinMessage); LobbyInfo packet = new LobbyInfo(); packet.sender = MyGameManager.user.Name; packet.currentActivePlayers = NetworkServer.connections.Count; client.Send(MyMsgType.JoinMsg, packet); } }
/// <see cref="ILobbyLocator.LobbyVanished"/> public void LobbyVanished(LobbyInfo vanishedLobby) { if (RCThread.CurrentThread == MainForm.UiThread) { throw new Exception("This call is not allowed from the UI-thread!"); } LobbyLocatorUiCall uiCall = new LobbyLocatorUiCall(this.locatorObj, LobbyLocatorUiCall.LobbyLocatorMethod.LobbyVanished, vanishedLobby); this.ui.InvokeUI(uiCall); }
public void LobbyKicked(LobbyKicked_t kickResult) { lobbyID = new CSteamID(0); lobbyInfo = new LobbyInfo(lobbyID); if (RainWorldHK.mainRW.processManager.musicPlayer != null) { RainWorldHK.mainRW.processManager.musicPlayer.FadeOutAllSongs(5f); RainWorldHK.mainRW.processManager.musicPlayer.MenuRequestsSong("RW_8 - Sundown", 1.4f, 2f); } RainWorldHK.mainRW.processManager.RequestMainProcessSwitch(ProcessManager.ProcessID.MainMenu); Log("Kicked from Lobby!"); OnGameExit(); joining = false; }