public void InitOnlineMatch(Lidgren.Network.NetClient client, MatchState matchState) { //Create existing clients foreach (var clientInfo in matchState.Clients) { clients.Add(new MatchClient(clientInfo.Guid, clientInfo.Name)); } //Create existing players foreach (var playerInfo in matchState.Players) { MatchPlayer p = new MatchPlayer(playerInfo.ClientGuid, playerInfo.CtrlType, playerInfo.CharacterId); p.ReadyToRace = playerInfo.ReadyToRace; players.Add(p); if (inLobby) { SpawnLobbyBall(p); } } //Set settings currentSettings = matchState.Settings; //Set auto start timer //TODO Get and apply travel time autoStartTimerOn = matchState.CurAutoStartTime != 0; autoStartTimer = matchState.CurAutoStartTime; //Create messenger OnlineMatchMessenger messenger = new OnlineMatchMessenger(client); this.messenger = messenger; messenger.Disconnected += (sender, e) => { QuitMatch(e.Reason); }; messenger.OnPlayerMovement += OnlinePlayerMovement; //Create chat activeChat = Instantiate(chatPrefab); activeChat.MessageSent += LocalChatMessageSent; //Enter the lobby or stage if (matchState.InRace) { joiningRaceInProgress = true; GoToStage(); } else { //showSettingsOnLobbyLoad = true; GoToLobby(); } }
private void GetChatWindow() { lock (_lock) { if (_chat == null || !_chat.IsVisible) { if (_chat != null) { _chat.Close(); } _chat = new UI.Chat(); _chat.Closed += _chat_Closed; } } }
private void _chat_Closed(object sender, EventArgs e) { lock (_lock) { _chat.Closed -= _chat_Closed; _chat = null; } }