private IEnumerator DoUpgrade(float time)
    {
        EventManager.Instance.BuildingUpgradeStarted(this);
        upgradeCooldown.SetCooldown(upgradeTime);
        isUpgrading = true;
        yield return(new WaitForSeconds(time));

        isUpgrading = false;
        currentLevel++;
        Sound.Instance.PlaySoundClipWithSource(upgradeCompleteSoundHolder, audioSource, 0);
        behaviour.LevelUp();
        base.LevelUp();
        DispenseAllSettlers();
        EventLog.Instance.AddAction(LogType.Upgraded, objectName.ToString() + " leveled from " + (currentLevel - 1) + " to " + currentLevel, transform.position);
    }
示例#2
0
    public void Setup(BuildingLevel buildingLevel)
    {
        oldProduction.text       = "" + buildingLevel.ressourceGenTransaction.delta;
        oldCapacity.text         = "" + buildingLevel.ressourceGenTransaction.ressourceType.maxValueReference.Value;
        oldProductionIcon.sprite = buildingLevel.ressourceGenTransaction.ressourceType.icon;
        oldCapacityIcon.sprite   = buildingLevel.ressourceGenTransaction.ressourceType.icon;

        newProductionIcon.sprite = buildingLevel.nextLevel.ressourceGenTransaction.ressourceType.icon;
        newCapacityIcon.sprite   = buildingLevel.ressourceGenTransaction.ressourceType.icon;

        if (!buildingLevel.isLastLevel)
        {
            goldCost.text  = "" + buildingLevel.upgradeCosts[0].delta;
            stoneCost.text = "" + buildingLevel.upgradeCosts[1].delta;
            woodCost.text  = "" + buildingLevel.upgradeCosts[2].delta;

            newProduction.text = "" + buildingLevel.nextLevel.ressourceGenTransaction.delta;
            newCapacity.text   = "" + (buildingLevel.ressourceGenTransaction.ressourceType.maxValueReference.Value +
                                       buildingLevel.maxStorageIncrement);
        }
        else
        {
            goldCost.text  = "---";
            stoneCost.text = "---";
            woodCost.text  = "---";

            newProduction.text = "---";
            newCapacity.text   = "---";
        }

        upgradeButton.interactable = behavior.canLevelUp();
        upgradeButton.onClick.AddListener(delegate
        {
            behavior.LevelUp();
            gameObject.GetComponentInParent <BuildingBehaviour>().gameObject.GetComponentInChildren <InteractableBuilding>().currentLevel = behavior.currentLevel;
            HideForm();
        });
        cancelButton.onClick.AddListener(delegate { HideForm(); });

        hasBeenSetup = true;
    }