Esempio n. 1
0
    //Get appropriate value for current resource and its highest unlocked upgrade modifier
    //sourceType determines which modifier to return
    public float getModifier(rescType type, sourceType source)
    {
        //set tempUpgrade to the default for modifiers. Is always set default so that modifiers from other selections do not carry over
        tempUpgrade = upgradeLibrary[upgradeName.defMods];

        switch (type)
        {
        case rescType.Food:
            //Check for highest available upgrade
            if (Check(upgradeName.HarvestingI) == true)
            {
                tempUpgrade = upgradeLibrary[upgradeName.HarvestingI];
            }
            else if (Check(upgradeName.HarvestingII) == true)
            {
                tempUpgrade = upgradeLibrary[upgradeName.HarvestingII];
            }

            //check to use button or peon modifier and return
            if (source == sourceType.Button)
            {
                return(tempUpgrade.buttonModifier);
            }
            else
            {
                return(tempUpgrade.peonModifier);
            }
        }
        Debug.LogError("No rescType of type " + type.ToString() + " returning def button modifier");
        return(tempUpgrade.buttonModifier);
    }
Esempio n. 2
0
    //Public method to increase resources, based on resource type
    public void updateCount(rescType type, sourceType source)
    {
        if (type == rescType.Food)
        {
            oldCount[0] = foodCount;

            foodCount = incCount(rescType.Food, foodCount, source);
        }
    }
Esempio n. 3
0
    //Private method for resourceManager to increase resource
    private float incCount(rescType Type, float Count, sourceType source, float multiplier = 1)
    {
        float newCount = 0, modifier;

        //Apply appropriate modifier
        modifier = upgradeMan.getModifier(Type, source);

        //Apply increase
        newCount = (modifier * multiplier) + Count;

        return(newCount);
    }