public QueryGameState(
            Lobby lobby,
            Func <User, List <Q>, UserPrompt> queryUserPromptGenerator,
            List <Q> queryObjects,
            Action <List <Q> > queryExitListener,
            Func <UserSubForm, T> answerExtractor,
            UnityView queryUnityView,
            List <User> queriedUsers,
            TimeSpan?queryTime = null) : base(lobby)
        {
            this.PromptGenerator = queryUserPromptGenerator;
            this.ObjectList      = queryObjects;
            this.AnswerExtractor = answerExtractor;
            this.Entrance.AddExitListener(() =>
            {
                StartingTime = DateTime.UtcNow;
            });
            SelectivePromptUserState queryUserState = new SelectivePromptUserState(
                usersToPrompt: queriedUsers ?? lobby.GetAllUsers().ToList(),
                promptGenerator: this.InternalPromptGenerator,
                formSubmitHandler: this.FormSubmitHandler,
                userTimeoutHandler: this.FormTimeoutHandler,
                maxPromptDuration: queryTime,
                exit: new WaitForUsers_StateExit(lobby: lobby));

            this.Entrance.Transition(queryUserState);
            queryUserState.Transition(this.Exit);
            queryUserState.AddExitListener(() => queryExitListener(this.ObjectList));

            this.UnityView = queryUnityView;
        }
Exemple #2
0
        public VotingGameState(
            Lobby lobby,
            Func <User, List <T>, UserPrompt> votingUserPromptGenerator,
            List <T> votingObjects,
            Action <List <T>, IDictionary <User, VoteInfo> > votingExitListener,
            Legacy_UnityView votingUnityView,
            List <User> votingUsers,
            TimeSpan?votingTime = null) : base(lobby)
        {
            this.PromptGenerator = votingUserPromptGenerator;
            this.ObjectList      = votingObjects;
            this.Entrance.AddExitListener(() =>
            {
                StartingTime = DateTime.UtcNow;
            });
            SelectivePromptUserState votingUserState = new SelectivePromptUserState(
                usersToPrompt: votingUsers ?? lobby.GetAllUsers().ToList(),
                promptGenerator: this.InternalPromptGenerator,
                formSubmitHandler: this.FormSubmitHandler,
                userTimeoutHandler: this.FormTimeoutHandler,
                maxPromptDuration: votingTime,
                exit: new WaitForUsers_StateExit(lobby: lobby));

            this.Entrance.Transition(votingUserState);
            votingUserState.Transition(this.Exit);
            votingUserState.AddExitListener(() => votingExitListener(this.ObjectList, this.UserVotes));

            this.Legacy_UnityView = votingUnityView;
        }