protected override async Task OnInteractiveControlUsed(UserViewModel user, InteractiveGiveInputModel input, InteractiveConnectedControlCommand command) { try { if (input.input.controlID.Equals("position") && user != null && input.input.meta.ContainsKey("x") && input.input.meta.ContainsKey("y")) { if (this.scene != null && this.positionButton != null && input.input.meta["x"] != null && input.input.meta["y"] != null) { Point point = new Point() { X = (double)input.input.meta["x"], Y = (double)input.input.meta["y"] }; this.userPoints[user.ID] = point; InteractiveConnectedButtonControlModel control = new InteractiveConnectedButtonControlModel() { controlID = this.positionButton.controlID }; control.meta["userID"] = user.ID; control.meta["x"] = point.X; control.meta["y"] = point.Y; await ChannelSession.Interactive.UpdateControls(this.scene, new List <InteractiveControlModel>() { control }); await this.Dispatcher.InvokeAsync(async() => { if (!this.userAvatars.ContainsKey(user.ID)) { UserProfileAvatarControl avatarControl = new UserProfileAvatarControl(); await avatarControl.SetUserAvatarUrl(user); avatarControl.SetSize(20); this.userAvatars[user.ID] = avatarControl; this.canvas.Children.Add(avatarControl); } this.PositionUserPointOnCanvas(user, point); }); } } } catch (Exception ex) { Logger.Log(ex); } }
protected override async Task OnInteractiveControlUsed(UserViewModel user, InteractiveGiveInputModel input, InteractiveConnectedControlCommand command) { if (user != null && !user.IsAnonymous && (input.input.controlID.Equals("gameEnd") || input.input.controlID.Equals("flyHit")) && input.input.meta.TryGetValue("total", out JToken totalToken)) { int total = totalToken.ToObject <int>(); await this.inputLock.WaitAndRelease(async() => { if (!userTotals.ContainsKey(user)) { userTotals[user] = new PlayerData(user, total); await this.Dispatcher.InvokeAsync(() => { this.userCollection.Add(userTotals[user]); }); } }); userTotals[user].Total = total; } }
protected override async Task OnInteractiveControlUsed(UserViewModel user, InteractiveGiveInputModel input, InteractiveConnectedControlCommand command) { if (user != null && !user.IsAnonymous && input.input.meta.ContainsKey("image")) { if (this.userDrawings.ContainsKey(user)) { await this.Dispatcher.InvokeAsync(() => { this.userSubmittedImages.Remove(this.userDrawings[user]); return(Task.FromResult(0)); }); } this.userDrawings[user] = new UserSubmittedImage(user, input.input.meta["image"].ToString()); await this.Dispatcher.InvokeAsync(() => { this.userSubmittedImages.Add(this.userDrawings[user]); return(Task.FromResult(0)); }); } }
protected virtual Task OnInteractiveControlUsed(UserViewModel user, InteractiveGiveInputModel input, InteractiveConnectedControlCommand command) { return(Task.FromResult(0)); }