private void ShopClick(object sender, EventArgs e) { string id = ((Control)sender).Name; RobotEquipment bought = gameController.toBuy.Find(t => t.id == id); if (bought.price <= gameController.player.money) { gameController.player.money -= bought.price; gameController.toBuy.Remove(bought); //if upgrade RobotEquipment item = gameController.activeEquipment.Find(r => r.upgrade != null && r.upgrade.id == bought.id); if (item != null) { //Remove old version gameController.activeEquipment.Remove(item); gameController.robot.equipment.Remove(item); } //Add to lists gameController.activeEquipment.Add(bought); gameController.robot.equipment.Add(bought); } else { MessageBox.Show($"You do not have enough money! This costs {bought.price}"); } //Refresh bought.SettupRobot(); gameController.robot.updateImage = true; gameController.robot.updated = true; UpdatePlayerUI(); ShowRobotEquipment(); gameController.renderer.Update(); }
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); }