Beyond_Beyaan.TechnologyManager.GetFieldInvestmentAmount C# (CSharp) Метод

GetFieldInvestmentAmount() приватный Метод

private GetFieldInvestmentAmount ( TechField whichField, float researchPoints ) : float
whichField TechField
researchPoints float
Результат float
        private float GetFieldInvestmentAmount(TechField whichField, float researchPoints)
        {
            switch (whichField)
            {
                case TechField.COMPUTER:
                {
                    if (ComputerPercentage == 0)
                    {
                        if (ComputerResearchAmount > 0)
                        {
                            //Lose 10% of total research invested if no research is being invested
                            return (ComputerResearchAmount * 0.9f) - ComputerResearchAmount;
                        }
                        return 0;
                    }
                    float interest = ComputerResearchAmount * 0.15f;
                    float newPoints = (researchPoints * (ComputerPercentage * 0.01f));
                    if ((newPoints * 2) < interest)
                    {
                        //up to 15% interest, but if we contribute less than half the interest, then cap the interest to double the current investment
                        interest = newPoints * 2;
                    }
                    return (newPoints + interest);
                }
                case TechField.CONSTRUCTION:
                {
                    if (ConstructionPercentage == 0)
                    {
                        if (ConstructionResearchAmount > 0)
                        {
                            //Lose 10% of total research invested if no research is being invested
                            return (ConstructionResearchAmount * 0.9f) - ConstructionResearchAmount;
                        }
                        return 0;
                    }
                    float interest = ConstructionResearchAmount * 0.15f;
                    float newPoints = (researchPoints * (ConstructionPercentage * 0.01f));
                    if ((newPoints * 2) < interest)
                    {
                        //up to 15% interest, but if we contribute less than half the interest, then cap the interest to double the current investment
                        interest = newPoints * 2;
                    }
                    return (newPoints + interest);
                }
                case TechField.FORCE_FIELD:
                {
                    if (ForceFieldPercentage == 0)
                    {
                        if (ForceFieldResearchAmount > 0)
                        {
                            //Lose 10% of total research invested if no research is being invested
                            return (ForceFieldResearchAmount * 0.9f) - ForceFieldResearchAmount;
                        }
                        return 0;
                    }
                    float interest = ForceFieldResearchAmount * 0.15f;
                    float newPoints = (researchPoints * (ForceFieldPercentage * 0.01f));
                    if ((newPoints * 2) < interest)
                    {
                        //up to 15% interest, but if we contribute less than half the interest, then cap the interest to double the current investment
                        interest = newPoints * 2;
                    }
                    return (newPoints + interest);
                }
                case TechField.PLANETOLOGY:
                {
                    if (PlanetologyPercentage == 0)
                    {
                        if (PlanetologyResearchAmount > 0)
                        {
                            //Lose 10% of total research invested if no research is being invested
                            return (PlanetologyResearchAmount * 0.9f) - PlanetologyResearchAmount;
                        }
                        return 0;
                    }
                    float interest = PlanetologyResearchAmount * 0.15f;
                    float newPoints = (researchPoints * (PlanetologyPercentage * 0.01f));
                    if ((newPoints * 2) < interest)
                    {
                        //up to 15% interest, but if we contribute less than half the interest, then cap the interest to double the current investment
                        interest = newPoints * 2;
                    }
                    return (newPoints + interest);
                }
                case TechField.PROPULSION:
                {
                    if (PropulsionPercentage == 0)
                    {
                        if (PropulsionResearchAmount > 0)
                        {
                            //Lose 10% of total research invested if no research is being invested
                            return (PropulsionResearchAmount * 0.9f) - PropulsionResearchAmount;
                        }
                        return 0;
                    }
                    float interest = PropulsionResearchAmount * 0.15f;
                    float newPoints = (researchPoints * (PropulsionPercentage * 0.01f));
                    if ((newPoints * 2) < interest)
                    {
                        //up to 15% interest, but if we contribute less than half the interest, then cap the interest to double the current investment
                        interest = newPoints * 2;
                    }
                    return (newPoints + interest);
                }
                case TechField.WEAPON:
                {
                    if (WeaponPercentage == 0)
                    {
                        if (WeaponResearchAmount > 0)
                        {
                            //Lose 10% of total research invested if no research is being invested
                            return (WeaponResearchAmount * 0.9f) - WeaponResearchAmount;
                        }
                        return 0;
                    }
                    float interest = WeaponResearchAmount * 0.15f;
                    float newPoints = (researchPoints * (WeaponPercentage * 0.01f));
                    if ((newPoints * 2) < interest)
                    {
                        //up to 15% interest, but if we contribute less than half the interest, then cap the interest to double the current investment
                        interest = newPoints * 2;
                    }
                    return (newPoints + interest);
                }
                default: return 0;
            }
        }