private void OpenShop(object sender, EventArgs e) { ClearSecondView(); //Display int c = 0; gameController.toBuy.ForEach(i => { if (i.IsUpgrade) { return; } robotPartGridSecond.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(140) }); RobotPart robotPart = new RobotPart(i.name, i.Description, i.price, i.image) { BeingSold = true, HorizontalAlignment = HorizontalAlignment.Left }; Grid.SetColumn(robotPart, 0); Grid.SetRow(robotPart, c++); robotPart.Click += ShopClick; robotPart.Name = i.id; robotPartGridSecond.Children.Add(robotPart); }); }
private void ShowRobotEquipment() { ClearSecondView(); //Setup int c = 0; foreach (RobotEquipment part in gameController.activeEquipment) { RowDefinition row = new RowDefinition { Height = new GridLength(140) }; robotPartGrid.RowDefinitions.Add(row); RobotPart robotPart = new RobotPart(part.name, part.Description, part.price, part.image) { Name = part.id }; robotPart.Click += HandleUpdate; robotPart.HorizontalAlignment = HorizontalAlignment.Left; Grid.SetColumn(robotPart, 0); Grid.SetRow(robotPart, c++); robotPartGrid.Children.Add(robotPart); } //Show button to open shop if possible if (gameController.toBuy.Count != 0) { RowDefinition eRow = new RowDefinition { Height = new GridLength(75) // Add a little for margin and border! }; Button addPart = new Button { Height = 65, Width = 300, Content = "Buy a new part!", VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(3), BorderBrush = Brushes.DarkOliveGreen, BorderThickness = new Thickness(2), Background = Brushes.DarkGray, HorizontalAlignment = HorizontalAlignment.Left }; addPart.Click += OpenShop; robotPartGrid.RowDefinitions.Add(eRow); Grid.SetColumn(addPart, 0); Grid.SetRow(addPart, c); robotPartGrid.Children.Add(addPart); } }
private void HandleUpdate(object sender, EventArgs e) { RobotPart clicked = sender as RobotPart; RobotEquipment chosen = gameController.robot.equipment.ToList().Find(p => p.id == clicked.Name); if (chosen.upgrade == null) { MessageBox.Show("There is no upgradeable version!"); } else { ShowUpgrade(chosen.upgrade); } }
private void ShowUpgrade(RobotEquipment toShow) { ClearSecondView(); //Display robotPartGridSecond.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(140) }); RobotPart robotPart = new RobotPart(toShow.name, toShow.Description, toShow.price, toShow.image) { BeingSold = true, HorizontalAlignment = HorizontalAlignment.Left }; robotPart.Name = toShow.id; Grid.SetColumn(robotPart, 0); Grid.SetRow(robotPart, 0); robotPart.Click += ShopClick; robotPartGridSecond.Children.Add(robotPart); }