public void CheckCheckUpPurchaseStatus(PurchaseItemUI purchaseItemUi)
 {
     if (GameManager.Instance.Risk <= 0)
     {
         purchaseItemUi.Disable();
     }
 }
 public void CheckCondomPurchaseStatus(PurchaseItemUI purchaseItemUi)
 {
     if (GameManager.Instance.HasCondom)
     {
         purchaseItemUi.Disable();
     }
 }
Beispiel #3
0
        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();
        }
Beispiel #4
0
        // 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();
        }
Beispiel #5
0
    public void Show(PurchaseItemSet purchaseItemSet)
    {
        TitleText.text       = purchaseItemSet.title;
        DescriptionText.text = purchaseItemSet.description;

        for (int i = 0; i < PurchaseItemsHolder.transform.childCount; i++)
        {
            Destroy(PurchaseItemsHolder.transform.GetChild(i).gameObject);
        }

        for (int i = 0; i < purchaseItemSet.purchaseItems.Count; i++)
        {
            PurchaseItem purchaseItem = purchaseItemSet.purchaseItems[i];

            GameObject purchaseItemUIGameObject = Instantiate(PurchaseItemUiPrefab, PurchaseItemsHolder.transform);

            PurchaseItemUI purchaseItemUi = purchaseItemUIGameObject.GetComponent <PurchaseItemUI>();
            purchaseItemUi.ItemNameText.text = purchaseItem.ItemName;
            purchaseItemUi.PurchaseButton.GetComponentInChildren <Text>().text = "$" + purchaseItem.Cost;

            purchaseItem.CheckPurchaseItemStatus.Invoke(purchaseItemUi);

            if (purchaseItem.Cost > GameManager.Instance.Money)
            {
                purchaseItemUi.Disable();
            }

            purchaseItemUi.PurchaseButton.onClick.AddListener(() =>
            {
                GameManager.Instance.OnMoneySpent(purchaseItem.Cost);
                purchaseItem.OnItemPurchased.Invoke();
                Close();
            });
        }

        GameManager.Instance.PauseTime();
        gameObject.SetActive(true);
    }