public void ValueChangedCallback()
    {
        curCapacity = 0;
        curCost     = 0;
        canSendShip = true;
        for (int i = 0; i < itemSelectors.Length; i++)
        {
            curCapacity += itemSelectors[i].amount * itemSelectors[i].myItem.weight;
            if (isBuy)
            {
                curCost += itemSelectors[i].amount * itemSelectors[i].myItem.buyCost;
            }
            else
            {
                curCost += itemSelectors[i].amount * itemSelectors[i].myItem.sellCost;
                if (false)
                {
                    itemSelectors[i].SetAvailabilityInInventory(false);
                    canSendShip = false;
                }
                else
                {
                    itemSelectors[i].SetAvailabilityInInventory(true);
                }
            }
        }

        shipCountText.text    = "Available Ships:\n" + Player_CommsController.s.availableShipCount.ToString() + "/" + 3.ToString();
        shipCapacityText.text = "Capacity:\n" + curCapacity.ToString() + "/" + carryCapacity.ToString() + " kg";
        shipCostText.text     = "Cost:\n" + GUI_CommsController.FormatMoney(curCost);

        if (curCapacity <= carryCapacity)
        {
            shipCapacityText.color = normalColor;
        }
        else
        {
            shipCapacityText.color = unavailableColor;
            canSendShip            = false;
        }

        if (isBuy)
        {
            if (curCost <= Player_CommsController.s.money)
            {
                shipCostText.color = moneyColor;
            }
            else
            {
                shipCostText.color = unavailableColor;
                canSendShip        = false;
            }
        }
        else
        {
            shipCostText.color = moneyColor;
        }
    }
Example #2
0
    void UpdateAmountText(bool isCallback)
    {
        itemCurrentAmount.text = amount.ToString();
        itemCurrentWeight.text = (amount * myItem.weight).ToString() + "kg";
        if (isBuy)
        {
            itemCurrentCost.text = GUI_CommsController.FormatMoney(myItem.buyCost * amount);
        }
        else
        {
            itemCurrentCost.text = GUI_CommsController.FormatMoney(myItem.sellCost * amount);
        }

        if (isCallback)
        {
            master.ValueChangedCallback();
        }
    }
Example #3
0
    public void SetUp(Item item, bool _isBuy, MiniGUI_BuySellMenu _master)
    {
        myItem        = item;
        isBuy         = _isBuy;
        master        = _master;
        icon.sprite   = myItem.GetSprite();
        itemName.text = myItem.name;

        if (isBuy)
        {
            itemCost.text = GUI_CommsController.FormatMoney(myItem.buyCost);
        }
        else
        {
            itemCost.text = GUI_CommsController.FormatMoney(myItem.sellCost);
        }

        itemWeight.text = myItem.weight.ToString() + " kg";

        SetAvailabilityInInventory(true);
        UpdateAmountText(false);
    }