private void DisplayShipModInformation(string shipModName) { CurrentObjectInfoPanel.Clear(); ShipModData shipModData = ScreenManager.Content.Load<ShipModData>("XML/Ship Mods/" + shipModName); if (shipModData != null) { Image shieldImage = new Image( shipModData.TextureAsset, new Vector2(-CurrentObjectInfoPanel.Dimensions.X / 3, -CurrentObjectInfoPanel.Dimensions.Y / 4), CurrentObjectInfoPanel.Dimensions.X / 6, CurrentObjectInfoPanel.Dimensions.X / 6, shipModName + " Image"); CurrentObjectInfoPanel.LoadAndAddUIElement(shieldImage); Text name = new Text( shipModData.Name, new Vector2(0, -2 * CurrentObjectInfoPanel.Dimensions.Y / 5), Color.Yellow, "Name"); CurrentObjectInfoPanel.LoadAndAddUIElement(name); name.SetHoverInfoText("Ship Mod Name"); Text activeOrPassiveText; if (shipModData.Active) { activeOrPassiveText = new Text( "Active", new Vector2(0, 4 * name.TextOrigin.Y), Color.White, "Active Or Passive Text"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(activeOrPassiveText, name); activeOrPassiveText.SetHoverInfoText("Mod Type"); Text runTimeText = new Text( shipModData.RunTime.ToString(), new Vector2(0, 4 * name.TextOrigin.Y), Color.White, "Run Time Text"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(runTimeText, activeOrPassiveText); runTimeText.SetHoverInfoText("Mod Run Time"); Text coolDownText = new Text( shipModData.Cooldown.ToString(), new Vector2(0, 4 * name.TextOrigin.Y), Color.White, "Cool Down Text"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(coolDownText, runTimeText); coolDownText.SetHoverInfoText("Mod Cool Down"); } else { activeOrPassiveText = new Text( "Passive", new Vector2(0, 4 * name.TextOrigin.Y), Color.White, "Active Or Passive Text"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(activeOrPassiveText, name); activeOrPassiveText.SetHoverInfoText("Mod Type"); } Text descriptionText = new Text( shipModData.Description, new Vector2(0, 2 * CurrentObjectInfoPanel.Dimensions.Y / 5), 4 * CurrentObjectInfoPanel.Dimensions.X / 5, Color.White, shipModName + " Description"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(descriptionText, activeOrPassiveText); Text costText = new Text( shipModData.Cost.ToString(), new Vector2(-CurrentObjectInfoPanel.Dimensions.X / 8, CurrentObjectInfoPanel.Dimensions.Y / 4), Color.White, "Cost"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(costText, descriptionText); Image moneyImage = new Image( "Sprites/UI/Thumbnails/MoneyThumbnail", new Vector2(-costText.TextOrigin.X - 20, 0), new Vector2(1, 1), Color.Cyan, "Cost Thumbnail"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(moneyImage, costText); Button buyButton = new Button( "XML/UI/Buttons/MenuButton", new Vector2(costText.TextOrigin.X + CurrentObjectInfoPanel.Dimensions.X / 3, 0), Button.defaultColour, Button.highlightedColour, shipModName + " " + shipModData.Cost, "Purchase"); buyButton.InteractEvent += BuyShipModEvent; buyButton.EnableAndDisableEvent += SameShipModPurchaseActivationEvent; CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(buyButton, costText); } }
private void DisplayShipInformation(string shipName) { CurrentObjectInfoPanel.Clear(); ShipData shipData = ScreenManager.Content.Load<ShipData>("XML/Ships/" + shipName); if (shipData != null) { Image shipImage = new Image( shipData.TextureAsset, new Vector2(-CurrentObjectInfoPanel.Dimensions.X / 3, -CurrentObjectInfoPanel.Dimensions.Y / 4), CurrentObjectInfoPanel.Dimensions.X / 3, 2 * CurrentObjectInfoPanel.Dimensions.Y / 5, shipName + " Image"); CurrentObjectInfoPanel.LoadAndAddUIElement(shipImage); Text name = new Text( shipData.Name, new Vector2(0, -2 * CurrentObjectInfoPanel.Dimensions.Y / 5), Color.LightGreen, "Name"); CurrentObjectInfoPanel.LoadAndAddUIElement(name); name.SetHoverInfoText("Ship Name"); Text armourText = new Text( shipData.Armour.ToString(), new Vector2(0, 4 * name.TextOrigin.Y), Color.White, shipName + " Armour"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(armourText, name); Image armourImage = new Image( "Sprites/UI/Thumbnails/ArmourThumbnail", new Vector2(-5 * armourText.TextOrigin.X / 2, 0), "Armour Thumbnail"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(armourImage, armourText); armourImage.SetHoverInfoText("Armour"); Text hullText = new Text( shipData.Hull.ToString(), new Vector2(0, 4 * armourText.TextOrigin.Y), Color.White, shipName + " Hull"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(hullText, armourText); Image hullImage = new Image( "Sprites/UI/Thumbnails/HullThumbnail", new Vector2(-5 * hullText.TextOrigin.X / 2, 0), new Vector2(1, 1), Color.White, "Hull Thumbnail"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(hullImage, hullText); hullImage.SetHoverInfoText("Hull"); Text massText = new Text( shipData.Mass.ToString(), new Vector2(0, 4 * hullText.TextOrigin.Y), Color.White, shipName + " Mass"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(massText, hullText); Image massImage = new Image( "Sprites/UI/Thumbnails/MassThumbnail", new Vector2(-hullText.TextOrigin.X - 35, 0), new Vector2(1, 1), Color.White, "Mass Thumbnail"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(massImage, massText); massImage.SetHoverInfoText("Mass"); Text weaponSlotsText = new Text( shipData.WeaponHardPoints.Count.ToString(), new Vector2(0, 4 * massText.TextOrigin.Y), Color.White, shipName + " Weapon Slots"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(weaponSlotsText, massText); Image weaponSlotsImage = new Image( "Sprites/UI/Thumbnails/WeaponSlotsThumbnail", new Vector2(-weaponSlotsText.TextOrigin.X - 25, 0), "Weapons Slots Thumbnail"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(weaponSlotsImage, weaponSlotsText); weaponSlotsImage.SetHoverInfoText("Weapon Slots"); Text shipModSlotsText = new Text( shipData.ShipModSlots.ToString(), new Vector2(0, 4 * massText.TextOrigin.Y), Color.White, shipName + " Ship Mods Slot"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(shipModSlotsText, weaponSlotsText); shipModSlotsText.SetHoverInfoText("Ship Mod Slots"); Text descriptionText = new Text( shipData.Description, new Vector2(0, CurrentObjectInfoPanel.Dimensions.Y / 7), 4 * CurrentObjectInfoPanel.Dimensions.X / 5, Color.White, shipName + " Description"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(descriptionText, shipModSlotsText); int cost = shipData.Cost; if (PlayerShip != null) { cost -= PlayerShip.TotalWorth / 2; } string costString = cost.ToString(); Text costText = new Text( costString, new Vector2(-CurrentObjectInfoPanel.Dimensions.X / 8, CurrentObjectInfoPanel.Dimensions.Y / 6), Color.White, "Cost"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(costText, descriptionText); Image moneyImage = new Image( "Sprites/UI/Thumbnails/MoneyThumbnail", new Vector2(-costText.TextOrigin.X - 20, 0), new Vector2(1, 1), Color.Cyan, "Cost Thumbnail"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(moneyImage, costText); Button buyButton = new Button( "XML/UI/Buttons/MenuButton", new Vector2(costText.TextOrigin.X + CurrentObjectInfoPanel.Dimensions.X / 3, 0), Button.defaultColour, Button.highlightedColour, shipName + " " + costString, "Purchase"); buyButton.InteractEvent += BuyShipEvent; buyButton.EnableAndDisableEvent += SameShipPurchaseActivationEvent; CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(buyButton, costText); } }
private void DisplayShieldInformation(string shieldName) { CurrentObjectInfoPanel.Clear(); ShieldData shieldData = ScreenManager.Content.Load<ShieldData>("XML/Shields/" + shieldName); if (shieldData != null) { Image shieldImage = new Image( shieldData.TextureAsset, new Vector2(-CurrentObjectInfoPanel.Dimensions.X / 3, -CurrentObjectInfoPanel.Dimensions.Y / 7), CurrentObjectInfoPanel.Dimensions.X / 3, 2 * CurrentObjectInfoPanel.Dimensions.Y / 5, new Color(shieldData.Colour), shieldName + " Image"); CurrentObjectInfoPanel.LoadAndAddUIElement(shieldImage); Text name = new Text( shieldData.Name, new Vector2(0, -2 * CurrentObjectInfoPanel.Dimensions.Y / 5), Color.Cyan, "Name"); CurrentObjectInfoPanel.LoadAndAddUIElement(name); name.SetHoverInfoText("Shield Name"); Text strengthText = new Text( shieldData.Strength.ToString(), new Vector2(0, 4 * name.TextOrigin.Y), Color.White, shieldName + " Strength"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(strengthText, name); strengthText.SetHoverInfoText("Strength"); Text rechargePerSecondText = new Text( shieldData.RechargePerSecond.ToString(), new Vector2(0, 4 * strengthText.TextOrigin.Y), Color.White, shieldName + " Recharge Per Second"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(rechargePerSecondText, strengthText); Image rechargePerSecondImage = new Image( "Sprites/UI/Thumbnails/RepairRateThumbnail", new Vector2(-rechargePerSecondText.TextOrigin.X - 25, 0), new Vector2(1, 1), Color.LightGreen, "Recharge Per Second Thumbnail"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(rechargePerSecondImage, rechargePerSecondText); rechargePerSecondImage.SetHoverInfoText("Recharge Per Second"); Text rechargeDelayText = new Text( shieldData.RechargeDelay.ToString(), new Vector2(0, 4 * rechargePerSecondText.TextOrigin.Y), Color.White, shieldName + " Recharge Delay"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(rechargeDelayText, rechargePerSecondText); rechargeDelayText.SetHoverInfoText("Recharge Delay"); Text depletionDelayText = new Text( shieldData.DepletionDelay.ToString(), new Vector2(0, 4 * rechargeDelayText.TextOrigin.Y), Color.White, shieldName + " Depletion Delay"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(depletionDelayText, rechargeDelayText); depletionDelayText.SetHoverInfoText("Depletion Delay"); Text descriptionText = new Text( shieldData.Description, new Vector2(0, CurrentObjectInfoPanel.Dimensions.Y / 6), 4 * CurrentObjectInfoPanel.Dimensions.X / 5, Color.White, shieldName + " Description"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(descriptionText, depletionDelayText); int cost = shieldData.Cost; if (PlayerShip.Shield != null) { cost -= PlayerShip.Shield.ShieldData.Cost / 2; } string costString = cost.ToString(); Text costText = new Text( costString, new Vector2(-CurrentObjectInfoPanel.Dimensions.X / 8, CurrentObjectInfoPanel.Dimensions.Y / 5), Color.White, "Cost"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(costText, descriptionText); Image moneyImage = new Image( "Sprites/UI/Thumbnails/MoneyThumbnail", new Vector2(-costText.TextOrigin.X - 20, 0), new Vector2(1, 1), Color.Cyan, "Cost Thumbnail"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(moneyImage, costText); Button buyButton = new Button( "XML/UI/Buttons/MenuButton", new Vector2(costText.TextOrigin.X + CurrentObjectInfoPanel.Dimensions.X / 3, 0), Button.defaultColour, Button.highlightedColour, shieldName + " " + costString, "Purchase"); buyButton.InteractEvent += BuyShieldEvent; buyButton.EnableAndDisableEvent += SameShieldPurchaseActivationEvent; CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(buyButton, costText); } }
private void DisplaySensorInformation(string sensorName) { CurrentObjectInfoPanel.Clear(); SensorData sensorData = ScreenManager.Content.Load<SensorData>("XML/Sensors/" + sensorName); if (sensorData != null) { Image shieldImage = new Image( sensorData.TextureAsset, new Vector2(-CurrentObjectInfoPanel.Dimensions.X / 3, -CurrentObjectInfoPanel.Dimensions.Y / 7), CurrentObjectInfoPanel.Dimensions.X / 3, 2 * CurrentObjectInfoPanel.Dimensions.Y / 5, sensorName + " Image"); CurrentObjectInfoPanel.LoadAndAddUIElement(shieldImage); Text name = new Text( sensorData.Name, new Vector2(0, -2 * CurrentObjectInfoPanel.Dimensions.Y / 5), Color.Yellow, "Name"); CurrentObjectInfoPanel.LoadAndAddUIElement(name); name.SetHoverInfoText("Sensor Name"); Text sensorRangeText = new Text( sensorData.Range.ToString(), new Vector2(0, 4 * name.TextOrigin.Y), Color.White, sensorName + " Range"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(sensorRangeText, name); Image sensorRangeImage = new Image( "Sprites/UI/Thumbnails/SensorRangeThumbnail", new Vector2(-2 * sensorRangeText.TextOrigin.X, 0), new Vector2(1, 1), Color.LightGreen, "Range Image"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(sensorRangeImage, sensorRangeText); sensorRangeImage.SetHoverInfoText("Range"); Text descriptionText = new Text( sensorData.Description, new Vector2(0, CurrentObjectInfoPanel.Dimensions.Y / 2), 4 * CurrentObjectInfoPanel.Dimensions.X / 5, Color.White, sensorName + " Description"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(descriptionText, sensorRangeText); int cost = sensorData.Cost; if (PlayerShip.Sensors != null) { cost -= PlayerShip.Sensors.SensorData.Cost / 2; } string costString = cost.ToString(); Text costText = new Text( costString, new Vector2(-CurrentObjectInfoPanel.Dimensions.X / 8, CurrentObjectInfoPanel.Dimensions.Y / 5), Color.White, "Cost"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(costText, descriptionText); Image moneyImage = new Image( "Sprites/UI/Thumbnails/MoneyThumbnail", new Vector2(-costText.TextOrigin.X - 20, 0), new Vector2(1, 1), Color.Cyan, "Cost Thumbnail"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(moneyImage, costText); Button buyButton = new Button( "XML/UI/Buttons/MenuButton", new Vector2(costText.TextOrigin.X + CurrentObjectInfoPanel.Dimensions.X / 3, 0), Button.defaultColour, Button.highlightedColour, sensorName + " " + costString, "Purchase"); buyButton.InteractEvent += BuySensorEvent; buyButton.EnableAndDisableEvent += SameSensorPurchaseActivationEvent; CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(buyButton, costText); } }
private void DisplayEngineInformation(string engineName) { CurrentObjectInfoPanel.Clear(); EngineData engineData = ScreenManager.Content.Load<EngineData>("XML/Engines/" + engineName); if (engineData != null) { Image shieldImage = new Image( engineData.TextureAsset, new Vector2(-CurrentObjectInfoPanel.Dimensions.X / 3, -CurrentObjectInfoPanel.Dimensions.Y / 7), CurrentObjectInfoPanel.Dimensions.X / 3, 2 * CurrentObjectInfoPanel.Dimensions.Y / 5, engineName + " Image"); CurrentObjectInfoPanel.LoadAndAddUIElement(shieldImage); Text name = new Text( engineData.Name, new Vector2(0, -2 * CurrentObjectInfoPanel.Dimensions.Y / 5), Color.Yellow, "Name"); CurrentObjectInfoPanel.LoadAndAddUIElement(name); name.SetHoverInfoText("Engine Name"); Text speedText = new Text( engineData.EngineSpeed.ToString(), new Vector2(0, 4 * name.TextOrigin.Y), Color.White, engineName + " Speed"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(speedText, name); speedText.SetHoverInfoText("Thrust"); string rotateValueString = MathHelper.ToDegrees(engineData.EngineRotateSpeed).ToString(); string trimmedRotateValue = rotateValueString.Length > 3 ? rotateValueString.Substring(0, 4) : rotateValueString; Text rotateSpeedText = new Text( trimmedRotateValue, new Vector2(0, 4 * speedText.TextOrigin.Y), Color.White, engineData + " RotateSpeed"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(rotateSpeedText, speedText); Image rotateSpeedImage = new Image( "Sprites/UI/Thumbnails/RotateSpeedThumbnail", new Vector2(-rotateSpeedText.TextOrigin.X - 25, 0), "Rotate Speed Image"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(rotateSpeedImage, rotateSpeedText); rotateSpeedImage.SetHoverInfoText("Rotate Degrees Per Second"); Text descriptionText = new Text( engineData.Description, new Vector2(0, 2 * CurrentObjectInfoPanel.Dimensions.Y / 5), 4 * CurrentObjectInfoPanel.Dimensions.X / 5, Color.White, engineName + " Description"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(descriptionText, rotateSpeedText); Text costText = new Text( engineData.Cost.ToString(), new Vector2(-CurrentObjectInfoPanel.Dimensions.X / 8, CurrentObjectInfoPanel.Dimensions.Y / 5), Color.White, "Cost"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(costText, descriptionText); Image moneyImage = new Image( "Sprites/UI/Thumbnails/MoneyThumbnail", new Vector2(-costText.TextOrigin.X - 20, 0), new Vector2(1, 1), Color.Cyan, "Cost Thumbnail"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(moneyImage, costText); Button buyButton = new Button( "XML/UI/Buttons/MenuButton", new Vector2(costText.TextOrigin.X + CurrentObjectInfoPanel.Dimensions.X / 3, 0), Button.defaultColour, Button.highlightedColour, engineName + " " + engineData.Cost, "Purchase"); buyButton.InteractEvent += BuyEngineEvent; buyButton.EnableAndDisableEvent += EnginePurchaseActivationEvent; CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(buyButton, costText); } }
private void DisplayWeaponInformation(string weaponName) { CurrentObjectInfoPanel.Clear(); TurretData turretData = ScreenManager.Content.Load<TurretData>("XML/Weapons/" + weaponName); if (turretData != null) { Image weaponImage = new Image( turretData.TextureAsset, new Vector2(-CurrentObjectInfoPanel.Dimensions.X / 3, -CurrentObjectInfoPanel.Dimensions.Y / 4), CurrentObjectInfoPanel.Dimensions.X / 4, CurrentObjectInfoPanel.Dimensions.Y / 5, weaponName + " Image"); CurrentObjectInfoPanel.LoadAndAddUIElement(weaponImage); Text name = new Text( turretData.Name, new Vector2(0, -2 * CurrentObjectInfoPanel.Dimensions.Y / 5), new Color(1, 0, 0.17f, 1), "Name"); CurrentObjectInfoPanel.LoadAndAddUIElement(name); name.SetHoverInfoText("Weapon Name"); Text weaponType = new Text( turretData.Type, new Vector2(0, 4 * name.TextOrigin.Y), Color.White, weaponName + " Type"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(weaponType, name); Image weaponTypeImage = new Image( "Sprites/UI/Thumbnails/WeaponType" + turretData.Type, new Vector2(-3 * weaponType.TextOrigin.X / 2, 0), "Weapon Type Thumbnail"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(weaponTypeImage, weaponType); weaponTypeImage.SetHoverInfoText("Weapon Type"); int lengthOfString = (1 / turretData.FireTimer).ToString().Length > 4 ? 4 : (1 / turretData.FireTimer).ToString().Length; Text weaponFireSpeed = new Text( (1 / turretData.FireTimer).ToString().Substring(0, lengthOfString), new Vector2(0, 4 * weaponType.TextOrigin.Y), Color.White, weaponName + " Fire Speed"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(weaponFireSpeed, weaponType); weaponFireSpeed.SetHoverInfoText("Shot Per Second"); Text weaponRange = new Text( turretData.Range.ToString(), new Vector2(0, 4 * weaponFireSpeed.TextOrigin.Y), Color.White, weaponName + " Range"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(weaponRange, weaponFireSpeed); weaponRange.SetHoverInfoText("Range"); Text weaponDamage = new Text( turretData.BulletDamage.ToString(), new Vector2(0, 4 * weaponRange.TextOrigin.Y), Color.White, weaponName + " Damage"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(weaponDamage, weaponRange); Image weaponDamageImage = new Image( "Sprites/UI/Thumbnails/DamageThumbnail", new Vector2(-weaponDamage.TextOrigin.X - 25, 0), new Vector2(1, 1), Color.OrangeRed, "Weapon Damage Thumbnail"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(weaponDamageImage, weaponDamage); weaponDamageImage.SetHoverInfoText("Damage"); Text descriptionText = new Text( turretData.Description, new Vector2(0, CurrentObjectInfoPanel.Dimensions.Y / 6), 4 * CurrentObjectInfoPanel.Dimensions.X / 5, Color.White, weaponName + " Description"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(descriptionText, weaponDamage); Text costText = new Text( turretData.Cost.ToString(), new Vector2(-CurrentObjectInfoPanel.Dimensions.X / 8, CurrentObjectInfoPanel.Dimensions.Y / 5), Color.White, "Cost"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(costText, descriptionText); Image moneyImage = new Image( "Sprites/UI/Thumbnails/MoneyThumbnail", new Vector2(-costText.TextOrigin.X - 20, 0), new Vector2(1, 1), Color.Cyan, "Cost Thumbnail"); CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(moneyImage, costText); Button buyButton = new Button( "XML/UI/Buttons/MenuButton", new Vector2(costText.TextOrigin.X + CurrentObjectInfoPanel.Dimensions.X / 3, 0), Button.defaultColour, Button.highlightedColour, weaponName + " " + turretData.Cost, "Purchase"); buyButton.InteractEvent += BuyWeaponEvent; buyButton.EnableAndDisableEvent += WeaponPurchaseActivationEvent; CurrentObjectInfoPanel.LoadAndAddUIElementRelativeTo(buyButton, costText); } }