private void MapComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if (this.MapComboBox.SelectedIndex >= 0) { string mapImagePath = "/Assets/Images/PUBGDropMap/"; PUBGMap map = (PUBGMap)this.MapComboBox.SelectedItem; if (map.Name.Equals(ErangelMapName)) { mapImagePath += "map1.png"; } else if (map.Name.Equals(MiramarMapName)) { mapImagePath += "map2.png"; } else if (map.Name.Equals(SanhokMapName)) { mapImagePath += "map3.png"; } else if (map.Name.Equals(VikendiMapName)) { mapImagePath += "map4.png"; } JObject settings = this.GetCustomSettings(); settings[MapSelectionSettingProperty] = this.MapComboBox.SelectedIndex; this.SaveCustomSettings(settings); this.ChangeMapImage(mapImagePath); } }
private void MapComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if (this.MapComboBox.SelectedIndex >= 0) { this.ErangelMap.Visibility = Visibility.Collapsed; this.MiramarMap.Visibility = Visibility.Collapsed; this.SanhokMap.Visibility = Visibility.Collapsed; PUBGMap map = (PUBGMap)this.MapComboBox.SelectedItem; if (map.Name.Equals(ErangelMapName)) { this.ErangelMap.Visibility = Visibility.Visible; } else if (map.Name.Equals(MiramarMapName)) { this.MiramarMap.Visibility = Visibility.Visible; } else if (map.Name.Equals(SanhokMapName)) { this.SanhokMap.Visibility = Visibility.Visible; } JObject settings = this.GetCustomSettings(); settings[MapSelectionSettingProperty] = this.MapComboBox.SelectedIndex; this.SaveCustomSettings(settings); } }
protected override async Task GameConnectedInternal() { this.Dispatcher.Invoke(() => { this.MapComboBox.IsEnabled = false; this.MaxTimeTextBox.IsEnabled = false; this.SparkCostTextBox.IsEnabled = false; this.TimerStackPanel.Visibility = Visibility.Collapsed; this.DropLocationStackPanel.Visibility = Visibility.Collapsed; this.WinnerStackPanel.Visibility = Visibility.Collapsed; this.TimerTextBlock.Text = string.Empty; this.DropLocationTextBlock.Text = string.Empty; this.WinnerAvatar.SetSize(80); this.WinnerTextBlock.Text = string.Empty; }); JObject settings = this.GetCustomSettings(); settings[MapSelectionSettingProperty] = this.MapComboBox.SelectedIndex; this.SaveCustomSettings(settings); await base.GameConnectedInternal(); PUBGMap map = (PUBGMap)this.MapComboBox.SelectedItem; InteractiveConnectedButtonControlModel control = new InteractiveConnectedButtonControlModel() { controlID = this.positionButton.controlID }; control.meta["map"] = map.Map; await ChannelSession.Interactive.UpdateControls(this.scene, new List <InteractiveControlModel>() { control }); }
protected override async Task <bool> GameConnectedInternal() { this.Dispatcher.Invoke(() => { this.MapComboBox.IsEnabled = false; this.MaxTimeTextBox.IsEnabled = false; this.SparkCostTextBox.IsEnabled = false; this.TimerStackPanel.Visibility = Visibility.Hidden; this.DropLocationStackPanel.Visibility = Visibility.Hidden; this.WinnerStackPanel.Visibility = Visibility.Hidden; this.TimerTextBlock.Text = string.Empty; this.DropLocationTextBlock.Text = string.Empty; this.WinnerAvatar.SetSize(80); this.WinnerTextBlock.Text = string.Empty; }); this.SaveSettings(); InteractiveConnectedSceneGroupCollectionModel sceneGroups = await ChannelSession.Interactive.GetScenes(); if (sceneGroups != null) { this.scene = sceneGroups.scenes.FirstOrDefault(); if (this.scene != null) { this.positionButton = this.scene.buttons.FirstOrDefault(c => c.controlID.Equals("position")); this.winnerButton = this.scene.buttons.FirstOrDefault(c => c.controlID.Equals("winner")); } } if (this.positionButton == null || this.winnerButton == null) { Logger.Log("Could not get position or winner buttons"); return(false); } if (this.sparkCost > 0) { this.positionButton.cost = this.sparkCost; await ChannelSession.Interactive.UpdateControls(this.scene, new List <InteractiveControlModel>() { this.positionButton }); await ChannelSession.Interactive.RefreshCachedControls(); } if (this.dropMapType == DropMapTypeEnum.PUBG) { JObject settings = this.GetCustomSettings(); settings[MapSelectionSettingProperty] = this.MapComboBox.SelectedIndex; this.SaveCustomSettings(settings); PUBGMap map = (PUBGMap)this.MapComboBox.SelectedItem; InteractiveConnectedButtonControlModel control = new InteractiveConnectedButtonControlModel() { controlID = this.positionButton.controlID }; control.meta["map"] = map.Map; await ChannelSession.Interactive.UpdateControls(this.scene, new List <InteractiveControlModel>() { control }); } this.userAvatars.Clear(); this.userPoints.Clear(); if (this.canvas != null) { this.canvas.Children.Clear(); } #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed Task.Run(async() => { if (this.scene != null && this.winnerButton != null) { InteractiveConnectedButtonControlModel control = null; for (int i = 0; i < (maxTime + 1); i++) { await Task.Delay(1000); int timeLeft = maxTime - i; this.Dispatcher.Invoke(() => { this.UpdateTimerUI(timeLeft); }); control = new InteractiveConnectedButtonControlModel() { controlID = this.winnerButton.controlID }; control.meta["timeleft"] = timeLeft; await ChannelSession.Interactive.UpdateControls(this.scene, new List <InteractiveControlModel>() { control }); } if (this.userPoints.Count > 0) { var users = this.userPoints.Keys.ToList(); int index = RandomHelper.GenerateRandomNumber(users.Count); uint winner = users[index]; Point point = this.userPoints[winner]; UserProfileAvatarControl avatar = this.userAvatars[winner]; UserModel user = await ChannelSession.Connection.GetUser(winner); string username = (user != null) ? user.username : "******"; string location = this.ComputeLocation(point); this.Dispatcher.InvokeAsync(async() => { await this.UpdateWinnerUI(winner, username, location); this.canvas.Children.Clear(); this.canvas.Children.Add(avatar); }); control = new InteractiveConnectedButtonControlModel() { controlID = this.winnerButton.controlID }; control.meta["userID"] = winner; control.meta["username"] = username; control.meta["location"] = location; await ChannelSession.Interactive.UpdateControls(this.scene, new List <InteractiveControlModel>() { control }); await ChannelSession.Chat.SendMessage(string.Format("Winner: @{0}, Drop Location: {1}", username, location)); } } }); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed return(await base.GameConnectedInternal()); }