private void LoadShipAddOns() { int otherAddOnCounter = 0, engineCounter = 0; foreach (string addOnName in EnemyShipData.ShipAddOns) { if (!string.IsNullOrEmpty(addOnName)) { ShipAddOnData addOnData = AssetManager.GetData <ShipAddOnData>(addOnName); switch (addOnData.AddOnType) { case "ShipTurret": AddTurret(ShipData.OtherHardPoints[otherAddOnCounter], addOnData); otherAddOnCounter++; break; case "ShipShield": AddShield(ShipData.OtherHardPoints[otherAddOnCounter], addOnData); otherAddOnCounter++; break; case "ShipEngine": AddEngine(ShipData.EngineHardPoints[engineCounter], addOnData); engineCounter++; break; } } } }
protected override void ShowHardPointsEvent(object sender, EventArgs e) { Image objectImage = sender as Image; if (objectImage != null) { foreach (PlayerShip ally in UnderSiegeGameplayScreen.Allies.Values) { ally.DrawOtherHardPoints = true; } ShipAddOnData dataOfObject = objectImage.StoredObject as ShipAddOnData; if (dataOfObject != null) { // This is going to need to be generalised - how are we going to store/get the ShipAddOn type name? PurchaseItemUI purchaseShipObjectUI = new PurchaseItemUI(objectImage.Texture, dataOfObject, dataOfObject.AddOnType, ScreenManager.GameMouse.InGameMouse); purchaseShipObjectUI.OnSelect += CheckForPlaceObjectEvent; HUD.GameplayScreen.AddInGameUIObject(purchaseShipObjectUI, "Purchase Object UI", false); purchaseShipObjectUI.Initialize(); previousCameraZoom = Camera.Zoom; Camera.Zoom = 1; } } ScreenManager.GameMouse.Flush(); }
public void AddTurret(Vector2 hardPoint, ShipAddOnData addOnData) { ShipTurretData turretData = addOnData as ShipTurretData; string dataAsset = AssetManager.GetKeyFromData(turretData); ShipTurret turret = null; switch (turretData.TurretType) { case "Kinetic": turret = new ShipKineticTurret(hardPoint, dataAsset, this, true); break; case "Missile": turret = new ShipMissileTurret(hardPoint, dataAsset, this, true); break; case "Beam": turret = new ShipBeamTurret(hardPoint, dataAsset, this, true); break; } ShipAddOns.AddObject(turret); DealWithHardPoint(hardPoint, false); }
public void AddEngine(Vector2 hardPoint, ShipAddOnData addOnData) { ShipEngine engine = new ShipEngine(hardPoint, AssetManager.GetKeyFromData(addOnData), this, true); ShipAddOns.AddObject(engine); DealWithHardPoint(hardPoint, true); }
public void AddShield(Vector2 hardPoint, ShipAddOnData addOnData) { ShipShield shield = new ShipShield(hardPoint, AssetManager.GetKeyFromData(addOnData), this, true); ShipAddOns.AddObject(shield); DealWithHardPoint(hardPoint, false); }
// Bit of a hack, but basically when we place the purchase object UI, the engine perceives us as "selecting" it so we just run this function when selected protected override void CheckForPlaceObjectEvent(object sender, EventArgs e) { PurchaseItemUI shipObjectToPurchase = sender as PurchaseItemUI; if (shipObjectToPurchase != null) { // This is going to need optimising foreach (PlayerShip ally in UnderSiegeGameplayScreen.Allies.Values) { if (ally.Collider.CheckCollisionWith(ScreenManager.GameMouse.InGamePosition)) { // We have clicked inside a ship foreach (HardPointUI hardPoint in ally.HardPointUI.OtherHardPointUI) { if (hardPoint.Collider.CheckCollisionWith(ScreenManager.GameMouse.InGamePosition)) { if (ScreenManager.GameMouse.IsLeftClicked) { ShipAddOnData addOnData = shipObjectToPurchase.DataAssetOfObject as ShipAddOnData; if (Session.Money >= addOnData.Price) { Session.Money -= addOnData.Price; ally.AddTurret(hardPoint.HardPoint, addOnData); } else { HUD.AddUIObject(new FlashingLabel("Insufficient Money!", new Vector2(0, -(ItemMenu.Size.Y + SpriteFont.LineSpacing) * 0.5f), Color.Red, ItemMenu, 1.5f), "Insufficient Money For Turret Label"); } } return; } } // Removes the purchase item UI from the HUD ResetPlaceObjectUI(); // We have found out which ship the mouse is over, so we can exit the loop return; } } } // Removes the purchase item UI from the HUD ResetPlaceObjectUI(); }
public BuyShipAddOnHoverInfo(ShipAddOnData shipAddOnData, Vector2 localPosition, BaseObject parent, float lifeTime = float.MaxValue) : base(localPosition, 0, 0, 0, 0, "Sprites\\UI\\Menus\\default", parent, lifeTime) { }