public DisplayPeople_GS( Lobby lobby, string title, IReadOnlyList <Person> peopleList, Func <Person, Color?> backgroundColor = null, Func <Person, string> imageIdentifier = null, Func <Person, string> imageTitle = null, Func <Person, string> imageHeader = null) : base( lobby: lobby, exit: new WaitForPartyLeader_StateExit( lobby: lobby, partyLeaderPromptGenerator: Prompts.PartyLeaderSkipRevealButton(), waitingPromptGenerator: Prompts.DisplayText() ) ) { if (peopleList == null || peopleList.Count == 0) { throw new ArgumentException("PeopleList cannot be empty"); } this.Entrance.Transition(this.Exit); backgroundColor ??= (person) => null; imageIdentifier ??= (person) => null; imageTitle ??= (person) => null; imageHeader ??= (person) => null; var unityImages = new List <Legacy_UnityImage>(); foreach (Person person in peopleList) { unityImages.Add(person.GetUnityImage( backgroundColor: backgroundColor(person), imageIdentifier: imageIdentifier(person), title: imageTitle(person), header: imageHeader(person) )); } this.Legacy_UnityView = new Legacy_UnityView(this.Lobby) { ScreenId = new StaticAccessor <TVScreenId> { Value = TVScreenId.ShowDrawings }, UnityImages = new StaticAccessor <IReadOnlyList <Legacy_UnityImage> > { Value = unityImages }, Title = new StaticAccessor <string> { Value = title }, }; }
public WaitForLobbyCloseGameState(Lobby lobby) : base( lobby: lobby, exit: new WaitForTrigger_StateExit(Prompts.DisplayText(Prompts.Text.WaitingForGameToStart)) ) { Arg.NotNull(lobby, nameof(lobby)); this.Entrance.Transition(this.Exit); // I have created a monstrosity. this.Legacy_UnityView = new Legacy_UnityView(this.Lobby) { ScreenId = new StaticAccessor <TVScreenId> { Value = TVScreenId.WaitForLobbyToStart }, Title = new StaticAccessor <string> { Value = Invariant($"Lobby code: {lobby.LobbyId}") }, Instructions = new StaticAccessor <string> { Value = "Players joined so far:" }, UnityImages = new DynamicAccessor <IReadOnlyList <Legacy_UnityImage> > { DynamicBacker = () => this.Lobby.GetAllUsers().OrderBy((User user) => user.LobbyJoinTime).Select(usr => new Legacy_UnityImage(usr.Id) { Title = new StaticAccessor <string> { Value = usr.DisplayName }, Base64Pngs = new StaticAccessor <IReadOnlyList <string> > { Value = new List <string> { usr.SelfPortrait } } }).ToList() } }; }
public Setup_GS(Lobby lobby, List <Prompt> promptsToPopulate, TimeSpan?writingTimeDuration, TimeSpan?drawingTimeDuration, int numRounds, int maxPlayersPerPrompt, int numDrawingsPerUser) : base( lobby: lobby, exit: new WaitForUsers_StateExit(lobby)) { this.PromptsToPopulate = promptsToPopulate; this.WritingTimeDuration = writingTimeDuration; this.DrawingTimeDuration = drawingTimeDuration.MultipliedBy(numDrawingsPerUser); // TODO, this is incorrect in edge case where we have too many users and maxPlayersPerPrompt is exceeded. this.NumRounds = numRounds; this.MaxPlayersPerPrompt = maxPlayersPerPrompt; this.NumDrawingsPerUser = numDrawingsPerUser; State getChallenges = GetChallengesUserState(); this.Entrance.Transition(getChallenges); getChallenges.AddExitListener(() => this.AssignPrompts()); getChallenges.Transition(() => { StateExit waitForDrawings = new WaitForUsers_StateExit( lobby: this.Lobby, waitingPromptGenerator: (User user) => { return(Prompts.DisplayText("Waiting for others to draw.")(user)); }); var getDrawings = new MultiStateChain(GetDrawingsUserStateChain, exit: waitForDrawings, stateDuration: DrawingTimeDuration); getDrawings.Transition(this.Exit); return(getDrawings); }); this.Legacy_UnityView = new Legacy_UnityView(this.Lobby) { ScreenId = new StaticAccessor <TVScreenId> { Value = TVScreenId.WaitForUserInputs }, Instructions = new StaticAccessor <string> { Value = "Complete all the prompts on your devices." }, }; }
public DisplayOriginal_GS(Lobby lobby, TimeSpan?displayTimeDuration, UserDrawing displayDrawing) : base(lobby, stateTimeoutDuration: displayTimeDuration, exit: new WaitForStateTimeoutDuration_StateExit(waitingPromptGenerator: Prompts.DisplayText(Prompts.Text.LookAtTheScreen))) { this.Legacy_UnityView = new Legacy_UnityView(this.Lobby) { ScreenId = new StaticAccessor <TVScreenId> { Value = TVScreenId.ShowDrawings }, Title = new StaticAccessor <string> { Value = "Memorize this drawing" }, UnityImages = new StaticAccessor <IReadOnlyList <Legacy_UnityImage> > { Value = new List <Legacy_UnityImage>() { displayDrawing.GetUnityImage() } } }; this.Entrance.Transition(this.Exit); }
/// <summary> /// Initializes a new <see cref="WaitForTrigger_StateExit"/>. /// </summary> /// <param name="waitingPromptGenerator">The prompt generator to use while waiting for the trigger. The outlet of this state will be overwritten</param> public WaitForTrigger_StateExit(Func <User, UserPrompt> waitingPromptGenerator = null) : base() { this.WaitingState = new SimplePromptUserState(promptGenerator: waitingPromptGenerator ?? Prompts.DisplayText()); this.WaitingState.AddPerUserEntranceListener((User user) => this.InvokeEntranceListeners(user)); }
public CreateMimics_GS(Lobby lobby, RoundTracker roundTracker, TimeSpan?drawingTimeDuration = null) : base(lobby) { SelectivePromptUserState createMimics = new SelectivePromptUserState( usersToPrompt: lobby.GetAllUsers().Where((User user) => user != roundTracker.originalDrawer).ToList(), promptGenerator: (User user) => new UserPrompt() { UserPromptId = UserPromptId.Mimic_RecreateDrawing, Title = Constants.UIStrings.DrawingPromptTitle, Description = "Recreate the drawing you just saw to the best of your abilities", SubPrompts = new SubPrompt[] { new SubPrompt { Drawing = new DrawingPromptMetadata { ColorList = CommonConstants.DefaultColorPalette.ToList(), GalleryOptions = null } } }, SubmitButton = true }, formSubmitHandler: (User user, UserFormSubmission input) => { UserDrawing submission = new UserDrawing { Drawing = input.SubForms[0].Drawing, Owner = user }; roundTracker.UsersToUserDrawings.AddOrReplace(user, submission); return(true, string.Empty); }, exit: new WaitForUsers_StateExit( lobby: this.Lobby, waitingPromptGenerator: (User user) => (user == roundTracker.originalDrawer)?Prompts.DisplayText("Others are recreating your masterpiece. Enjoy the turmoil.")(user):Prompts.DisplayText("Waiting for others to finish mimicking.")(user) ), maxPromptDuration: drawingTimeDuration); this.Entrance.Transition(createMimics); createMimics.Transition(this.Exit); this.Legacy_UnityView = new Legacy_UnityView(this.Lobby) { ScreenId = new StaticAccessor <TVScreenId> { Value = TVScreenId.WaitForUserInputs }, Instructions = new StaticAccessor <string> { Value = "Recreate that drawing to the best of your abilities" }, }; }