Exemple #1
0
    /// <summary>
    /// Static method to calculate the cost of upgrading a building
    /// Allows checks for whether the player can upgrade a building and display UI information on upgrade cost
    /// </summary>
    /// <param name="penumBuildingType"></param>
    /// <param name="pintUpgradeLevel"></param>
    /// <returns></returns>
    public static int CalculateBuildingUpgradeCost(Building.BUILDING_TYPE penumBuildingType, int pintUpgradeLevel = 1)
    {
        // Cost calculation is exponential to scale with extra area player is given on tier unlock
        // Upgrading will be required to save space, so will cost more
        int intBuildingCost = int.MaxValue;

        switch (penumBuildingType)
        {
        case (Building.BUILDING_TYPE.ALTAR):     // 10,100,1000
            intBuildingCost = mcintAltarCost * Convert.ToInt32(Mathf.Pow(10, pintUpgradeLevel) * BuildingCostModifier);
            break;

        case (Building.BUILDING_TYPE.MATERIAL):     // 100, 1000, 10000
            intBuildingCost = mcintMaterialCost * Convert.ToInt32(Mathf.Pow(10, pintUpgradeLevel) * BuildingCostModifier);
            break;

        case (Building.BUILDING_TYPE.HOUSING):     // 100, 1000, 10000
            intBuildingCost = mcintHousingCost * Convert.ToInt32(Mathf.Pow(10, pintUpgradeLevel) * BuildingCostModifier);
            break;

        case (Building.BUILDING_TYPE.VILLAGE):     // Upgrade done by tier unlock
            intBuildingCost = 0;
            break;

        case (BUILDING_TYPE.UPGRADE):     // 1000, 10000, 100000
            intBuildingCost = mcintUpgradeCost * Convert.ToInt32(Mathf.Pow(10, pintUpgradeLevel) * BuildingCostModifier);
            break;
        }
        return(intBuildingCost);
    }
Exemple #2
0
    /// <summary>
    /// Static method to calculate the cost of a building based on the type of building.
    /// Allows UI feedback and information before a building has been created.
    /// </summary>
    /// <param name="penumBuildingType"></param>
    /// <returns></returns>
    public static int CalculateBuildingCost(Building.BUILDING_TYPE penumBuildingType)
    {
        // Set to max value in case cost calc fails, players don't get free building
        int intBuildingCost = int.MaxValue;

        switch (penumBuildingType)
        {
        case (Building.BUILDING_TYPE.ALTAR):
            intBuildingCost = Convert.ToInt32(mcintAltarCost * BuildingCostModifier);
            break;

        case (Building.BUILDING_TYPE.MATERIAL):
            intBuildingCost = Convert.ToInt32(mcintMaterialCost * BuildingCostModifier);
            break;

        case (Building.BUILDING_TYPE.HOUSING):
            intBuildingCost = Convert.ToInt32(mcintHousingCost * BuildingCostModifier);
            break;

        case (Building.BUILDING_TYPE.VILLAGE):
            intBuildingCost = Convert.ToInt32(mcintVillageCost * BuildingCostModifier);
            break;

        case (Building.BUILDING_TYPE.UPGRADE):
            intBuildingCost = Convert.ToInt32(mcintUpgradeCost * BuildingCostModifier);
            break;
        }
        return(intBuildingCost);
    }