Exemple #1
0
    private void tryPlacing(GameObject tryObj)
    {
        var ph = tryObj.GetComponent <BuildingPlaceHolder>();

        if (!ResourceHolder.CanAfford(ph.costs))
        {
            PopupWindow.ShowPopup("You cannot afford this.");
            SetNotPlacable(tryObj);
            return;
        }

        BuildingPlaceHolder.State state = ph.state;
        if (state == BuildingPlaceHolder.State.NONE)
        {
            return;
        }
        else if (state == BuildingPlaceHolder.State.PLACING_NOT_POSSIBLE)
        {
            SetNotPlacable(tryObj);
        }
        else if (state == BuildingPlaceHolder.State.PLACING)
        {
            SetPlacable(tryObj);
        }
    }
Exemple #2
0
    protected void Produce()
    {
        float maxPercentageToAdd = 100f / 10f;
        float percentageToAdd    = maxPercentageToAdd * CitizenFactor();

        productionRound += percentageToAdd;

        if (productionRound < 100f)
        {
            return;
        }
        productionRound = 0f;
        List <ResAmount> actualInputs = new List <ResAmount>();

        foreach (ResAmount input in inputs)
        {
            actualInputs.Add(new ResAmount(input.GetResType(), input.GetAmount()));
        }

        List <ResAmount> actualOutputs = new List <ResAmount>();

        foreach (ResAmount output in outputs)
        {
            actualOutputs.Add(new ResAmount(output.GetResType(), output.GetAmount()));
        }

        if (ResourceHolder.CanAfford(actualInputs))
        {
            ResourceHolder.Consume(actualInputs);
            ResourceHolder.Produce(actualOutputs);
        }
    }