Example #1
0
    private IEnumerator LoadCapacity()
    {
        yield return(new WaitForSeconds(timeToLoad));

        var spaceLeft = capacity - currentLoad;

        if (spaceLeft >= loadingContainer.CurrentCapacity)
        {
            currentLoad = loadingContainer.CurrentCapacity;
            loadingContainer.SetNewContainerCapacity(0);
            loadingContainer.SetContainerCapacityText();
        }

        if (spaceLeft < loadingContainer.CurrentCapacity)
        {
            currentLoad = capacity;
            loadingContainer.SetNewContainerCapacity(loadingContainer.CurrentCapacity - spaceLeft);
            loadingContainer.SetContainerCapacityText();
        }

        if (currentLoad == capacity)
        {
            Debug.LogWarning("Overdays Worker cant load.");
        }

        Debug.LogWarning("Overdays worker has currently loaded " + currentLoad);
        isFullyLoaded  = true;
        spriteR.sprite = workerIcon;

        StopAllCoroutines();
    }
Example #2
0
    private IEnumerator UnloadCapacity()
    {
        yield return(new WaitForSeconds(timeToUnload));

        var spaceLeftInGroundFloorContainer = groundFloorContainer.GetMaxCapacity() - groundFloorContainer.CurrentCapacity;

        if (currentLoad <= spaceLeftInGroundFloorContainer)
        {
            int groundFloorCap = groundFloorContainer.CurrentCapacity;
            groundFloorContainer.SetNewContainerCapacity(groundFloorCap + currentLoad);
            currentLoad = 0;
            groundFloorContainer.SetContainerCapacityText();
            SetElevatorWOrkerCapacityText();
            isFullyLoaded = false;
        }

        if (currentLoad > spaceLeftInGroundFloorContainer)
        {
            currentLoad -= spaceLeftInGroundFloorContainer;
            groundFloorContainer.SetNewContainerCapacity(groundFloorContainer.GetMaxCapacity());
            groundFloorContainer.SetContainerCapacityText();
            SetElevatorWOrkerCapacityText();
            isFullyLoaded = false;
        }

        if (spaceLeftInGroundFloorContainer == 0)
        {
            Debug.LogWarning("Elevator Worker cant unload");
        }

        if (!hasManager)
        {
            active = false;
        }

        spriteR.sprite  = workerIcon;
        index           = 1;
        loadingPosition = loadingPositions[index];
        StopAllCoroutines();
    }