private IDisposable SetScores(QBClient client, int lane) { var playerresult = lane == 0 ? P1Result : lane == 1 ? P2Result : lane == 2 ? P3Result : P4Result; var timeWindow = lane == 0 ? P1TimeWindow : lane == 1 ? P2TimeWindow : lane == 2 ? P3TimeWindow : P4TimeWindow; return (CurrentRound .Take(1) .Subscribe(round => { playerresult.Take(1) .Subscribe(result => { switch (round) { case Rounds.R1_Hike: client.SetR1Score(result.Item2, result.Item1[0]); if (timeWindow.Value) { timeWindow.Value = false; } break; case Rounds.R2_Hike: client.SetR2Score(result.Item2, result.Item1[0]); if (timeWindow.Value) { timeWindow.Value = false; } break; case Rounds.R3_Hike: client.SetR3Score(result.Item2, result.Item1[0]); if (timeWindow.Value) { timeWindow.Value = false; } break; } }).AddTo(this); }) .AddTo(this)); }
private IDisposable AddingClient() { return (ComReceivingStream .Subscribe(e => { var json = JSON.Parse(e.message); var state = json["state"].AsInt; var lane = json["station_id"].AsInt; var team = json["team"].AsInt; var isIntheList = false; if (state != 10) { return; } foreach (var qbClient in ClientsList) { isIntheList = qbClient.Lane == lane; } if (isIntheList) { Debug.Log("Player already joined"); } else { var playerDataStrings = _teamManager.GetPlayerData(team); var x = new QBClient(e.clientID, lane, team, playerDataStrings[0], playerDataStrings[1]); ClientsList.Add(x); if (Verbose) { Debug.LogFormat("[{0}] Client Added(+) \n id - {1} : lane -{2} : team - {3}", name, x.ClientId, x.Lane, (TeamType)x.Team); } } })); }