예제 #1
0
    public bool BuyUpgrade()
    {
        PlayerMoney playerMoney = PlayerMoney.Instance;

        if (!playerMoney.CheckCash(playerMoney.GetPlayerCash() - buyPrice))
        {
            Debug.Log("Purchase Failed");
            return(false);
        }

        playerMoney.IncrementPlayerCash(-buyPrice);
        PlayerCargo.Instance.UpgradeCurrentEngine(upgrade);
        Debug.Log("Bought " + Defs.Instance.engineUpgradesNames[upgrade] + " for $" + buyPrice);
        updateUI();
        TimeCounter.Instance.StepEconomy(1);
        return(true);
    }
예제 #2
0
    public bool BuyGood(int quantity)
    {
        if (!(myGoodType == Defs.TradeGoodTypes.TRADEGOODTYPE_BUY || myGoodType == Defs.TradeGoodTypes.TRADEGOODTYPE_BOTH))
        {
            Debug.LogError("Tried to buy " + Defs.Instance.goodNames[myGood] + " but this Good is " + myGoodType);
            return(false);
        }

        PlayerMoney playerMoney = PlayerMoney.Instance;

        if (!playerMoney.CheckCash(playerMoney.GetPlayerCash() - quantity * buyPrice))
        {
            Debug.Log("Purchase Failed");
            return(false);
        }

        if (!PlayerCargo.Instance.IsCargoFull() && incrementBuyQuantity(-quantity))
        {
            playerMoney.IncrementPlayerCash(-buyPrice);
            PlayerCargo.Instance.AddSingleCargo(myGood);
            Debug.Log("Bought " + quantity + " " + Defs.Instance.goodNames[myGood] + " for $" + buyPrice * quantity);
            setBuyPrice(buyPrice + (int)((float)buyPrice / 100f * 10f));

            // Pass time for each unit bought
            TimeCounter.Instance.PassTime(quantity);

            // Disable any outlines to avoid player confusion
            foreach (var goodScript in ObjectManager.Instance.globalGoodList)
            {
                goodScript.SetSellButtonHilight(false);
            }
            return(true);
        }
        else
        {
            Debug.Log("Not enough goods to purchase");
            return(false);
        }
    }