예제 #1
0
    private void Start()
    {
        if (isFirstMineshaft)
        {
            upgradeButton.SetNewUpgradeCost(Mathf.RoundToInt(GameCore.Instance.Data.BasicMineshaftUpgradeCost));
        }

        upgradeButton.OnUpgraded        += HandleUpgrade;
        mineShaftWorkers                 = GetComponentsInChildren <Miner>();
        shaftManager.OnManagerBought    += HandleManagerBought;
        shaftManager.OnManagerActivated += HandleManagerActivated;
        multiplier     = GameCore.Instance.Data.BoughtUpgradeMultiplier;
        mineshaftFloor = GameCore.Instance.GetAmountOfMineshafts();
        shaftManager.SetManagerCost(GameCore.Instance.Data.GetManagerCost(mineshaftFloor));
        elevatorShaft.SetNewMaxCapacity(elevatorShaft.GetMaxCapacity() * mineshaftFloor);
        shaftManager.SetManagerBonusTime(((mineshaftFloor * 6) / 2) + 7);
        elevatorShaft.SetContainerCapacityText();
    }
예제 #2
0
    private IEnumerator UnloadCapacity()
    {
        yield return(new WaitForSeconds(timeToUnload));

        var spaceInContainer = shaftContainer.GetMaxCapacity() - shaftContainer.CurrentCapacity;

        if (spaceInContainer == 0)
        {
            Debug.LogWarning("Miner cant unload.");
        }

        if (spaceInContainer >= currentLoad)
        {
            int containerCap = shaftContainer.CurrentCapacity;
            shaftContainer.SetNewContainerCapacity(containerCap + currentLoad);
            currentLoad = 0;
            shaftContainer.SetContainerCapacityText();
            isFullyLoaded = false;
        }
        else
        {
            var loadToStore = currentLoad - spaceInContainer;
            currentLoad -= loadToStore;
            shaftContainer.SetNewContainerCapacity(shaftContainer.GetMaxCapacity());
            shaftContainer.SetContainerCapacityText();
            shaftContainer.isFullyLoaded = true;
            isFullyLoaded = false;
        }

        spriteRenderer.sprite = workerIcon;
        if (!hasManager)
        {
            active = false;
        }

        StopAllCoroutines();
    }