Exemplo n.º 1
0
        /// <summary>
        /// Returns the unity view that needs to be potentially sent to the clients.
        /// </summary>
        /// <returns>The active unity view</returns>
        public UnityView GetActiveUnityView(bool returnNullIfNoChange)
        {
            UnityView        currentView       = this.CurrentGameState?.GetActiveUnityView();
            Legacy_UnityView currentLegacyView = this.CurrentGameState?.GetActiveLegacyUnityView();

            /*if (currentView != null && currentLegacyView != null)
             * {
             *  throw new Exception("Gamestate did not properly setup views");
             * }*/

            if (currentLegacyView != null)
            {
                if (!returnNullIfNoChange || currentLegacyView.Refresh())
                {
                    return(new UnityView(currentLegacyView));
                }
            }
            else if (currentView != null)
            {
                if (!returnNullIfNoChange)
                {
                    return(currentView);
                }
                else if (this.CurrentGameState?.UnityViewDirty ?? false)
                {
                    this.CurrentGameState.UnityViewDirty = false;
                    return(currentView);
                }
            }

            return(null);
        }
Exemplo n.º 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;
        }
Exemplo n.º 3
0
        public override Legacy_UnityView VotingUnityViewGenerator()
        {
            Legacy_UnityView view = base.VotingUnityViewGenerator();

            view.Options = new StaticAccessor <Legacy_UnityViewOptions>
            {
                Value = new Legacy_UnityViewOptions()
                {
                    BlurAnimate = new StaticAccessor <Legacy_UnityViewAnimationOptions <float?> >
                    {
                        Value = new Legacy_UnityViewAnimationOptions <float?>()
                        {
                            StartValue = new StaticAccessor <float?> {
                                Value = 1.0f
                            },
                            EndValue = new StaticAccessor <float?> {
                                Value = 0.0f
                            },
                            StartTime = new StaticAccessor <DateTime?> {
                                Value = DateTime.UtcNow.AddSeconds(BlurRevealDelay)
                            },
                            EndTime = new StaticAccessor <DateTime?> {
                                Value = DateTime.UtcNow.AddSeconds(BlurRevealDelay + BlurRevealLength)
                            }
                        }
                    }
                }
            };
            return(view);
        }
        public VoteRevealGameState(
            Lobby lobby,
            string promptTitle,
            Legacy_UnityView voteRevealUnityView) : base(
                lobby: lobby,
                exit: new WaitForPartyLeader_StateExit(
                    lobby: lobby,
                    partyLeaderPromptGenerator: Prompts.ShowScoreBreakdowns(
                        lobby: lobby,
                        promptTitle: promptTitle,
                        userPromptId: UserPromptId.PartyLeader_SkipReveal,
                        userScoreBreakdownScope: Score.Scope.Reveal,
                        showPartyLeaderSkipButton: true),

                    waitingPromptGenerator: Prompts.ShowScoreBreakdowns(
                        lobby: lobby,
                        promptTitle: promptTitle,
                        userScoreBreakdownScope: Score.Scope.Reveal)))
        {
            this.Entrance.Transition(this.Exit);
            this.Legacy_UnityView = voteRevealUnityView;
        }