IEnumerator UpdateUi()
    {
        // Update while visible
        while (VisibleObject.activeSelf)
        {
            // Add view on change
            if (_scrollView.childCount < _storageContainer.EmittedProductList().Count)
            {
                List <ProductData> copy = _storageContainer.EmittedProductList();
                // Remove entries from the copy
                for (int i = 0; i < _scrollView.childCount; i++)
                {
                    AmountProductView amountProductView =
                        _scrollView.GetChild(i).gameObject.GetComponent <AmountProductView>();
                    copy.Remove(amountProductView.ProductData);
                }
                // Instantiate all entries of the copy
                foreach (ProductData productData in copy)
                {
                    AmountProductView amountProductView = Instantiate(_storedProductView, _scrollView);
                    amountProductView.ProductData = productData;
                    amountProductView.Text(_storageContainer.EmitterStorage(productData));
                }
            }

            // Update existing views
            for (int i = 0; i < _scrollView.childCount; i++)
            {
                AmountProductView amountProductView = _scrollView.GetChild(i).gameObject.GetComponent <AmountProductView>();
                amountProductView.Text(_storageContainer.EmitterStorage(amountProductView.ProductData));
            }
            yield return(new WaitForSeconds(0.1f));
        }
        _updateUiCoroutine = null;
    }
Пример #2
0
    private void ShowVehicleInformation(TransportVehicle transportVehicle)
    {
        // Set text displays
        _vehicleImage.sprite  = transportVehicle != null ? transportVehicle.Sprite : null;
        _initialCostText.text = transportVehicle != null ? "-" : "/";
        _dailyCostText.text   = transportVehicle != null ? "-" : "/";
        _strengthText.text    = transportVehicle != null ? "-" : "/";
        _topSpeedText.text    = transportVehicle != null?transportVehicle.MaxSpeed.ToString() : "-";

        _capacityText.text = transportVehicle != null?transportVehicle.MaxCapacity.ToString() : "-";

        _transferTimeText.text = transportVehicle != null?transportVehicle.TransferTime.ToString() : "-";

        // Set loaded products view
        if (transportVehicle != null)
        {
            foreach (ProductData productData in transportVehicle.LoadedProducts)
            {
                AmountProductView amountProductView = Object.Instantiate(_scrollViewElementPrefab, _scrollView);
                amountProductView.ProductData = productData;
                amountProductView.Text(transportVehicle.TransportStorage(productData));
            }
        }
        else
        {
            // remove loaded products
            for (int i = 0; i < _scrollView.childCount; i++)
            {
                Object.Destroy(_scrollView.GetChild(i).gameObject);
            }
        }
    }
Пример #3
0
    private IEnumerator UpdateUI()
    {
        ProductStorage emitterStorage = _productProcessorBehaviour.EmitterStorage();
        Dictionary <ProductData, AmountProductView> _amountProductViewDict =
            new Dictionary <ProductData, AmountProductView>();

        for (int i = 0; i < _factoryNeededProductView.ScrollView.childCount; i++)
        {
            AmountProductView productView = _factoryNeededProductView.ScrollView.GetChild(i).gameObject
                                            .GetComponent <AmountProductView>();

            ProductStorage receiverStorage = _productProcessorBehaviour.ReceiverStorage(productView.ProductData);
            if (receiverStorage == null)
            {
                continue;
            }
            productView.Text(receiverStorage);
        }

        _amountLabel.text    = emitterStorage.Amount + "/" + emitterStorage.MaxAmount;
        _productImage.sprite = emitterStorage.StoredProductData.ProductSprite;

        while (_productProcessorBehaviour && VisibleObject.activeSelf)
        {
//            _productionTimeSlider.value = _factory.ProductionProgress;
            yield return(null);
        }

        _amountLabel.text           = "Factory View";
        _productImage.sprite        = _defaultProductSprite;
        _productionTimeSlider.value = 0;
        yield return(null);
    }
Пример #4
0
 private IEnumerator UpdateUi()
 {
     while (_transportVehicle != null)
     {
         for (int i = 0; i < _scrollView.childCount; i++)
         {
             AmountProductView productView    = _scrollView.GetChild(i).gameObject.GetComponent <AmountProductView>();
             ProductStorage    productStorage = _transportVehicle.TransportStorage(productView.ProductData);
             productView.Text(productStorage);
         }
         yield return(new WaitForSeconds(1));
     }
     _coroutine = null;
 }