本文整理汇总了C#中Image.SetHoverInfoText方法的典型用法代码示例。如果您正苦于以下问题:C# Image.SetHoverInfoText方法的具体用法?C# Image.SetHoverInfoText怎么用?C# Image.SetHoverInfoText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image.SetHoverInfoText方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddImage
public void AddImage(GameObject gameObject)
{
// If the object is large enough, just add a smaller copy to the sensors screen
if (gameObject.Bounds.Width > 80 || gameObject.Bounds.Height > 150)
{
Image sensorImage;
if (gameObject.Data != null)
{
sensorImage = new Image(
gameObject.Data.TextureAsset,
gameObject.Position / (Camera2D.BackgroundMultiplier),
new Vector2(1 / Camera2D.BackgroundMultiplier, 1 / Camera2D.BackgroundMultiplier),
gameObject.Data.Name,
gameObject.Rotation);
sensorImage.SetHoverInfoText(sensorImage.Name);
}
else
{
string[] strings = gameObject.DataAsset.Split('/');
sensorImage = new Image(
gameObject.DataAsset,
gameObject.Position / (Camera2D.BackgroundMultiplier),
new Vector2(1 / Camera2D.BackgroundMultiplier, 1 / Camera2D.BackgroundMultiplier),
strings.Last(),
gameObject.Rotation);
}
sensorImage.SetTexture(gameObject.Texture);
SensorImages.Add(gameObject, sensorImage);
AddScreenUIElement(sensorImage);
}
else
{
string imageAsset = "Object";
if (gameObject as EnemyShip != null)
{
imageAsset = "Enemy";
}
else if (gameObject as PlayerShip != null)
{
imageAsset = "Player";
}
Image sensorImage = new Image(
"",
ScreenManager.ScreenCentre + gameObject.Position / (Camera2D.BackgroundMultiplier),
"Sensor Image");
if (gameObject.Data != null) { sensorImage.SetHoverInfoText(gameObject.Data.Name); }
sensorImage.SetTexture(Thumbnails[imageAsset]);
AddScreenUIElement(sensorImage);
SensorImages.Add(gameObject, sensorImage);
}
}
示例2: DisplayShieldInformation
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,
//.........这里部分代码省略.........
示例3: DisplayShipInformation
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;
//.........这里部分代码省略.........
示例4: DisplaySensorInformation
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);
}
}
示例5: DisplayEngineInformation
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);
}
}
示例6: CreateAndPopulatePanel
private void CreateAndPopulatePanel(string panelName, Vector2 buttonPosition, bool createSwitchButton = true)
{
Panel panel = new Panel(
"Sprites/UI/Panels/MenuPanelBackground",
new Vector2(ScreenManager.Viewport.Width / 3, 21 * ScreenManager.Viewport.Height / 40),
new Vector2(3 * ScreenManager.Viewport.Width / 5, 17 * ScreenManager.Viewport.Height / 20),
Color.White,
panelName + " Panel");
UpgradePanels.Add(panelName, panel);
// Populate panel here
DirectoryInfo directory = new DirectoryInfo(ScreenManager.Content.RootDirectory + "/XML/" + panelName);
if (directory.Exists)
{
FileInfo[] files = directory.GetFiles("*.xnb*");
int yDimensions = 4;
int xDimensions = 8;
for (int y = 0; y < yDimensions; y++)
{
for (int x = 0; x < xDimensions; x++)
{
if (y * xDimensions + x < files.Length)
{
string key = Path.GetFileNameWithoutExtension(files[y * xDimensions + x].Name);
if (panelName != "Shields")
{
GameObjectData gameObjectData = ScreenManager.Content.Load<GameObjectData>("XML/" + panelName + "/" + key);
Image objectImage = new Image(
gameObjectData.TextureAsset,
new Vector2(-2 * panel.Dimensions.X / 5 + x * panel.Dimensions.X / (xDimensions + 1), -2 * panel.Dimensions.Y / 5 + y * panel.Dimensions.Y / yDimensions),
panel.Dimensions.X / (2 * xDimensions + 1),
panel.Dimensions.Y / (2 * yDimensions),
panelName + "/" + key);
objectImage.InteractEvent += DisplayShopObjectInformation;
panel.LoadAndAddUIElement(objectImage);
objectImage.SetHoverInfoText(gameObjectData.Name);
}
else
{
ShieldData shieldData = ScreenManager.Content.Load<ShieldData>("XML/" + panelName + "/" + key);
Image objectImage = new Image(
shieldData.TextureAsset,
new Vector2(-2 * panel.Dimensions.X / 5 + x * panel.Dimensions.X / xDimensions, -2 * panel.Dimensions.Y / 5 + y * panel.Dimensions.Y / yDimensions),
panel.Dimensions.X / (2 * xDimensions),
panel.Dimensions.Y / (2 * yDimensions),
new Color(shieldData.Colour),
panelName + "/" + key);
objectImage.InteractEvent += DisplayShopObjectInformation;
panel.LoadAndAddUIElement(objectImage);
objectImage.SetHoverInfoText(shieldData.Name);
}
}
}
}
}
if (createSwitchButton)
{
CreatePanelSwitchButton(panelName, buttonPosition);
}
AddScreenUIElement(panel);
}
示例7: SetUpUI
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();
}
示例8: DisplayWeaponInformation
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");
//.........这里部分代码省略.........