Example #1
0
    private UniRx.IObservable <Rounds> CheckRoundsDone(Rounds checkState, int round, params Action[] toInvoke)
    {
        var toDispose = new Subject <Unit>();

        CurrentRound.Where(x => x == checkState)
        .Take(1)
        .Subscribe(_ =>
        {
            Observable
            .Timer(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1))
            .TakeWhile(condition => ClientsList.All(x =>
            {
                var b = false;
                switch (round)
                {
                case 1: b = x.R1Done; break;

                case 2: b = x.R2Done; break;

                case 3: b = x.R3Done; break;
                }
                if (Verbose)
                {
                    Debug.LogFormat("[{0}] Client status Round{4} :\n lane = {1} team ={2} Result = {3}"
                                    , name, x.Lane, x.Team, x.Result1, round);
                }
                return(b);
            }) != true)
            .DoOnCompleted(() =>
            {
//                        ClientsList.ToList().ForEach(x =>
//                        {
//                            switch (round)
//                            {
//                                case 1:
//                                    ComOutGoingStream.OnNext(CommunicationModule.BuildRound1Msg(x.Lane, x.Result1, x.Results[0].Hit));
//                                    break;
//                                case 2:
//                                    ComOutGoingStream.OnNext(
//                                        CommunicationModule.BuildRound2Msg(x.Lane, x.Result1,x.Results[0].Hit, x.Result2,x.Results[1].Hit));
//                                    break;
//                                case 3:
//                                    ComOutGoingStream
//                                        .OnNext(CommunicationModule
//                                            .BuildRound3Msg(x.Lane, x.Result1,x.Results[0].Hit, x.Result2,x.Results[1].Hit,x.Result3,x.Results[2].Hit,x.PlayerName,x.PlayerPercentage));
//                                    break;
//                            }
//                        });
                toDispose.OnCompleted();

                toInvoke.ToList().ForEach(x => x.Invoke());
            }).Subscribe();
        });
        return(toDispose.Select(_ => checkState));
    }
Example #2
0
 bool AllPlayersReady()
 {
     return(playerSelections.All(playerSelection => playerSelection.confirmed.Value) && playerSelections.Count > 0);
 }