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 SetUpBars(ContentManager content) { ArmourBar = new Bar( ParentShip.Armour, "Sprites/UI/Bars/ArmourBar", ParentShip.Position - new Vector2(0, ParentShip.Bounds.Height / 2 + 12), new Vector2((float)ParentShip.Bounds.Width / 180, 0.5f), "Armour Bar"); ArmourBar.LoadContent(content); ArmourBar.EnableAndDisableEvent += MouseOverActivationEvent; HullBar = new Bar( ParentShip.Hull, "Sprites/UI/Bars/HullBar", ParentShip.Position - new Vector2(0, ParentShip.Bounds.Height / 2 + 5), new Vector2((float)ParentShip.Bounds.Width / 180, 0.5f), "Hull Bar"); HullBar.LoadContent(content); HullBar.EnableAndDisableEvent += MouseOverActivationEvent; if (ParentShip.Shield != null) { ShieldBar = new Bar( ParentShip.Shield.ShieldData.Strength, "Sprites/UI/Bars/ShieldBar", ParentShip.Position - new Vector2(0, ParentShip.Bounds.Height / 2 + 19), new Vector2((float)ParentShip.Bounds.Width / 180, 0.5f), "Shield Bar"); ShieldBar.LoadContent(content); ShieldBar.EnableAndDisableEvent += MouseOverActivationEvent; } DestinationMarker = new CommandMarker( "Sprites/UI/Command Markers/MoveMarker", ParentShip.Destination, "Destination Marker"); DestinationMarker.LoadContent(content); DestinationMarker.EnableAndDisableEvent += MouseOverActivationEvent; foreach (Turret turret in ParentShip.Turrets) { Vector2 targetPosition = turret.Target != null ? turret.Target.Position : ParentShip.Position; Image attackTargetMarker = new Image( "Sprites/UI/Command Markers/AttackMarker", targetPosition, "Turret Target Marker"); attackTargetMarker.LoadContent(content); attackTargetMarker.EnableAndDisableEvent += MouseOverActivationEvent; AttackTargetMarkers.Add(attackTargetMarker); } }