Example #1
0
    void AddNewResource(ResourceId _resource)
    {
        if (selectedVehicle.Inventory.CheckForResource(_resource) || _resource == ResourceId.Fuel || _resource == ResourceId.Rations)
        {
            GameObject            newListObject = Instantiate(resourceListPrefab, resourceListGroup.transform);
            ResourceListConnector connector     = newListObject.GetComponent <ResourceListConnector>();
            resourceListItems.Add(connector);

            connector.resource              = _resource;
            connector.resourceName.text     = selectedVehicle.Inventory.GetResourceName(_resource);
            connector.resourceQuantity.text = selectedVehicle.Inventory.GetResourceAmount(_resource).ToString("F2");
            connector.resourceCapacity.text = selectedVehicle.Inventory.GetResourceCapacity(_resource).ToString("F2");
            connector.resourceValue.text    = "$" + CalculateValue(_resource).ToString("F2");
            connector.shopMain              = this;

            if (_resource == ResourceId.Fuel || _resource == ResourceId.Rations)
            {
                connector.buyOneButton.SetActive(true);
            }
        }
    }
Example #2
0
    public void RefreshResource(ResourceId _resource, ResourceListConnector _connector)
    {
        if (selectedVehicle.Inventory.CheckForResource(_resource) || _resource == ResourceId.Fuel || _resource == ResourceId.Rations)
        {
            _connector.gameObject.SetActive(true);

            _connector.resourceName.text     = selectedVehicle.Inventory.GetResourceName(_resource);
            _connector.resourceQuantity.text = selectedVehicle.Inventory.GetResourceAmount(_resource).ToString("F2");
            _connector.resourceCapacity.text = selectedVehicle.Inventory.GetResourceCapacity(_resource).ToString("F2");
            _connector.resourceValue.text    = "$" + CalculateValue(_resource);
            _connector.shopMain = this;

            if (_resource == ResourceId.Fuel || _resource == ResourceId.Rations)
            {
                _connector.buyOneButton.SetActive(true);
            }
        }
        else if (!selectedVehicle.Inventory.CheckForResource(_resource))
        {
            _connector.gameObject.SetActive(false);
        }
    }