public void CreateUI() { ShipImage = new Image( "", new Vector2(-Dimensions.X / 4, 0), Dimensions.X / 2 - Dimensions.X / 10, Dimensions.Y - Dimensions.Y / 5, "Ship Image"); LoadAndAddUIElement(ShipImage, ShipImage.Position); ShipName = new Text( "", this, new Vector2(Dimensions.X / 4, -Dimensions.Y / 3), Color.White, "Ship Name Text", "Fonts/SmallGameUIFont"); LoadAndAddUIElement(ShipName, ShipName.Position); ShieldBar = new Bar( 0, "Sprites/UI/Bars/ShieldBar", new Vector2(Dimensions.X / 4, -Dimensions.Y / 9), new Vector2(1), "Shield Bar"); LoadAndAddUIElement(ShieldBar, ShieldBar.Position); ArmourBar = new Bar( 0, "Sprites/UI/Bars/ArmourBar", new Vector2(Dimensions.X / 4, 0), new Vector2(1), "Armour Bar"); LoadAndAddUIElement(ArmourBar, ArmourBar.Position); HullBar = new Bar( 0, "Sprites/UI/Bars/HullBar", new Vector2(Dimensions.X / 4, Dimensions.Y / 9), new Vector2(1), "Hull Bar"); LoadAndAddUIElement(HullBar, HullBar.Position); ShieldStatusText = new Text( "", this, new Vector2(Dimensions.X / 6, 3 * Dimensions.Y / 10), Color.Cyan, "Shield Status Text", "Fonts/SmallGameUIFont"); LoadAndAddUIElement(ShieldStatusText, ShieldStatusText.Position); }
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 SetUpUI() { MissionImage = new Image( MissionData[CurrentLevel - 1].LevelThumbnailAsset, new Vector2(ScreenManager.Viewport.Width / 3, 2 * ScreenManager.Viewport.Height / 5), 2 * ScreenManager.Viewport.Width / 3, 2 * ScreenManager.Viewport.Height / 3, "Mission Image"); AddScreenUIElement(MissionImage); MissionDescription = new Text( MissionData[CurrentLevel - 1].Description, new Vector2(ScreenManager.Viewport.Width / 3, 5 * ScreenManager.Viewport.Height / 6), 3 * ScreenManager.Viewport.Width / 5, Color.AliceBlue, "Mission Description Text"); AddScreenUIElement(MissionDescription); for (int i = 0; i < maxLevel; i++) { Button button = new Button( "XML/UI/Buttons/MenuButton", new Vector2(5 * ScreenManager.Viewport.Width / 6, ScreenManager.Viewport.Height / 10 + i * 60), Button.defaultColour, Button.highlightedColour, i.ToString(), MissionData[i].Name); button.InteractEvent += LevelInformationEvent; MissionButtons.Add(button); AddScreenUIElement(button); } Button acceptMissionButton = new Button( "XML/UI/Buttons/MenuButton", new Vector2(5 * ScreenManager.Viewport.Width / 6, 9 * ScreenManager.Viewport.Height / 10), Button.defaultColour, Button.highlightedColour, "Accept Mission Button", "Start"); acceptMissionButton.InteractEvent += AcceptMissionEvent; AddScreenUIElement(acceptMissionButton); Button backButton = new Button( "XML/UI/Buttons/MenuButton", new Vector2(ScreenManager.Viewport.Width / 6, MissionDescription.Position.Y + MissionDescription.TextOrigin.Y + ScreenManager.Viewport.Height / 20), new Color(0.588f, 0, 0), new Color(1f, 0, 0), "Back Button", "Back"); backButton.InteractEvent += BackEvent; AddScreenUIElement(backButton); }
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 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 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 SetUpUI() { Vector2 shipPanelButtonPosition = new Vector2(120, ScreenManager.Viewport.Height / 20); Vector2 buttonSpacing = new Vector2(ScreenManager.Viewport.Width / 8, 0); CreateAndPopulatePanel("Ships", shipPanelButtonPosition); CreateAndPopulatePanel("Weapons", shipPanelButtonPosition + buttonSpacing); CreateAndPopulatePanel("Engines", shipPanelButtonPosition + 2 * buttonSpacing); CreateAndPopulatePanel("Shields", shipPanelButtonPosition + 3 * buttonSpacing); CreateAndPopulatePanel("Sensors", shipPanelButtonPosition + 4 * buttonSpacing); CreateAndPopulateShipModPanel("Ship Mods", shipPanelButtonPosition + 5 * buttonSpacing); CurrentObjectInfoPanel = new Panel( "Sprites/UI/Panels/MenuPanelBackground", new Vector2(82 * ScreenManager.Viewport.Width / 100, ScreenManager.Viewport.Height / 3), new Vector2(7 * ScreenManager.Viewport.Width / 20, 2 * ScreenManager.Viewport.Height / 5), Color.White, "Current Object Info", 0.5f); AddScreenUIElement(CurrentObjectInfoPanel); CurrentShipInfoPanel = new Panel( "Sprites/UI/Panels/MenuPanelBackground", new Vector2(82 * ScreenManager.Viewport.Width / 100, 3 * ScreenManager.Viewport.Height / 4), new Vector2(7 * ScreenManager.Viewport.Width / 20, 2 * ScreenManager.Viewport.Height / 5), Color.White, "Current Ship Info", 0.5f); AddScreenUIElement(CurrentShipInfoPanel); Text money = new Text( ExtendedScreenManager.Session.Money.ToString(), shipPanelButtonPosition + 6 * buttonSpacing, Color.White, "Current Money"); AddScreenUIElement(money); Image moneyImage = new Image( "Sprites/UI/Thumbnails/MoneyThumbnail", new Vector2(money.Position.X - money.TextOrigin.X - 20, money.Position.Y), new Vector2(1, 1), Color.Cyan, "Current Money Thumbnail"); AddScreenUIElement(moneyImage); moneyImage.SetHoverInfoText("Current Money"); CreateNextMissionButton(); ActivatePanel("Ships"); SetUpCurrentShipInformation(); DisplayCurrentShipInformation(); }
private void SetUpCurrentShipInformation() { Image shipImage = new Image( "", new Vector2(-CurrentObjectInfoPanel.Dimensions.X / 4, -CurrentObjectInfoPanel.Dimensions.Y / 10), CurrentObjectInfoPanel.Dimensions.X / 3, 2 * CurrentObjectInfoPanel.Dimensions.Y / 5, "Ship Image"); shipImage.EnableAndDisableEvent += PlayerShipDependentActivationEvent; CurrentShipInfoPanel.LoadAndAddUIElement(shipImage, shipImage.Position); Button sellAllButton = new Button( "XML/UI/Buttons/MenuButton", new Vector2(0, 2 * CurrentObjectInfoPanel.Dimensions.Y / 5), Button.defaultColour, Button.highlightedColour, "Sell All Button", "Sell All: "); sellAllButton.InteractEvent += SellAllEvent; sellAllButton.EnableAndDisableEvent += PlayerShipDependentActivationEvent; CurrentShipInfoPanel.LoadAndAddUIElementRelativeTo(sellAllButton, shipImage); Text loadoutText = new Text( "Ship Loadout", new Vector2(CurrentShipInfoPanel.Dimensions.X / 8, -CurrentObjectInfoPanel.Dimensions.Y / 3), Color.PaleVioletRed, "Ship Loadout Text"); loadoutText.EnableAndDisableEvent += PlayerShipDependentActivationEvent; CurrentShipInfoPanel.LoadAndAddNewTextEntryBelowPrevious(loadoutText); /*for (int i = 0; i < PlayerShip.ShipData.WeaponHardPoints.Count; i++) { if (i < PlayerShip.Turrets.Count) { Image weaponImage = new Image( PlayerShip.Turrets[i].TurretData.TextureAsset, PlayerShip.ShipData.WeaponHardPoints[i] * shipImage.Scale, 15 * shipImage.Scale.X, 15 * shipImage.Scale.Y, "Weapon Image " + i); weaponImage.LoadContent(ScreenManager.Content); CurrentShipInfoPanel.AddUIElementRelativeTo(weaponImage, shipImage); Text weaponText = new Text( PlayerShip.Turrets[i].TurretData.Name, new Vector2(CurrentShipInfoPanel.Dimensions.X / 8, -CurrentObjectInfoPanel.Dimensions.Y / 3), Color.White, "Weapon " + i + " Text"); CurrentShipInfoPanel.LoadAndAddNewTextEntryBelowPrevious(weaponText); Button sellButton = new Button( "XML/UI/Buttons/MenuButton", new Vector2(weaponText.TextOrigin.X, 0), Button.defaultColour, Button.highlightedColour, "Weapon " + PlayerShip.Turrets[i].TurretData.Name, "Sell: " + (PlayerShip.Turrets[i].TurretData.Cost / 2).ToString()); sellAllButton.InteractEvent += SellItemEvent; CurrentShipInfoPanel.LoadAndAddUIElementRelativeTo(sellButton, weaponText); } else { Image weaponFreeImage = new Image( "Sprites/UI/Panels/Panel", PlayerShip.ShipData.WeaponHardPoints[i] * shipImage.Scale, 5 * shipImage.Scale.X, 5 * shipImage.Scale.Y, Color.Cyan, "Weapon Free Image " + i); weaponFreeImage.SetOpacity(0.3f); CurrentShipInfoPanel.LoadAndAddUIElementRelativeTo(weaponFreeImage, shipImage); weaponFreeImage.SetHoverInfoText("Free Weapon Slot"); } }*/ /*for (int i = 0; i < PlayerShip.ShipData.EngineHardPoints.Count; i++) { if (i < PlayerShip.Engines.Count) { Image engineImage = new Image( PlayerShip.Engines[i].EngineData.TextureAsset, PlayerShip.ShipData.EngineHardPoints[i] * shipImage.Scale, 12 * shipImage.Scale.X, 12 * shipImage.Scale.Y, "Engine Image " + i); engineImage.LoadContent(ScreenManager.Content); CurrentShipInfoPanel.AddUIElementRelativeTo(engineImage, shipImage); Text engineText = new Text( PlayerShip.Engines[i].EngineData.Name, new Vector2(CurrentShipInfoPanel.Dimensions.X / 8, -CurrentObjectInfoPanel.Dimensions.Y / 3), Color.White, "Engine " + i + " Text"); CurrentShipInfoPanel.LoadAndAddNewTextEntryBelowPrevious(engineText); Button sellButton = new Button( "XML/UI/Buttons/MenuButton", new Vector2(engineText.TextOrigin.X, 0), Button.defaultColour, Button.highlightedColour, "Engine " + PlayerShip.Engines[i].EngineData.Name, "Sell: " + (PlayerShip.Engines[i].EngineData.Cost / 2).ToString()); sellAllButton.InteractEvent += SellItemEvent; CurrentShipInfoPanel.LoadAndAddUIElementRelativeTo(sellButton, engineText); } else { Image engineFreeImage = new Image( "Sprites/UI/Panels/Panel", PlayerShip.ShipData.EngineHardPoints[i] * shipImage.Scale, 7 * shipImage.Scale.X, 7 * shipImage.Scale.Y, Color.LightGreen, "Engine Free Image " + i); engineFreeImage.SetOpacity(0.3f); CurrentShipInfoPanel.LoadAndAddUIElementRelativeTo(engineFreeImage, shipImage); engineFreeImage.SetHoverInfoText("Free Engine Slot"); } }*/ Image shieldImage = new Image( "", Vector2.Zero, shipImage.Bounds.Width * 2, shipImage.Bounds.Height * 2, Color.White, "Shield Image"); shieldImage.SetOpacity(0.1f); shieldImage.EnableAndDisableEvent += PlayerShipDependentActivationEvent; CurrentShipInfoPanel.LoadAndAddUIElementRelativeTo(shieldImage, shipImage); Text shieldText = new Text( "", new Vector2(CurrentShipInfoPanel.Dimensions.X / 8, -CurrentObjectInfoPanel.Dimensions.Y / 3), CurrentShipInfoPanel.Dimensions.X / 4, Color.White, "Shield Text"); shieldText.EnableAndDisableEvent += PlayerShipDependentActivationEvent; CurrentShipInfoPanel.LoadAndAddNewTextEntryBelowPrevious(shieldText); Button sellShieldButton = new Button( "XML/UI/Buttons/MenuButton", new Vector2(shieldText.TextOrigin.X, 0), Button.defaultColour, Button.highlightedColour, "Sell Shield Button", "Sell: "); sellShieldButton.InteractEvent += SellItemEvent; sellShieldButton.EnableAndDisableEvent += PlayerShipDependentActivationEvent; // CurrentShipInfoPanel.LoadAndAddUIElementRelativeTo(sellShieldButton, shieldText); Image sensorImage = new Image( "", Vector2.Zero, 12 * shipImage.Scale.X, 12 * shipImage.Scale.Y, "Sensor Image"); sensorImage.EnableAndDisableEvent += PlayerShipDependentActivationEvent; CurrentShipInfoPanel.LoadAndAddUIElementRelativeTo(sensorImage, shipImage); Text sensorText = new Text( "", new Vector2(CurrentShipInfoPanel.Dimensions.X / 8, -CurrentObjectInfoPanel.Dimensions.Y / 3), CurrentShipInfoPanel.Dimensions.X / 4, Color.White, "Sensor Text"); sensorText.EnableAndDisableEvent += PlayerShipDependentActivationEvent; CurrentShipInfoPanel.LoadAndAddNewTextEntryBelowPrevious(sensorText); Button sellSensorButton = new Button( "XML/UI/Buttons/MenuButton", new Vector2(sensorText.TextOrigin.X, 0), Button.defaultColour, Button.highlightedColour, "Sell Sensor Button", "Sell: "); sellSensorButton.InteractEvent += SellItemEvent; sellSensorButton.EnableAndDisableEvent += PlayerShipDependentActivationEvent; // CurrentShipInfoPanel.LoadAndAddUIElementRelativeTo(sellSensorButton, sensorText); }
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); } }