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

GetFieldProgressString() публичный Метод

public GetFieldProgressString ( TechField whichField, float researchPoints ) : string
whichField TechField
researchPoints float
Результат string
        public string GetFieldProgressString(TechField whichField, float researchPoints)
        {
            string progressString = string.Empty;
            int chance = 0;
            float amount = 0;
            float researchedAmount = 0;
            int researchCost = 0;
            switch (whichField)
            {
                case TechField.COMPUTER:
                    {
                        if (WhichComputerBeingResearched == null)
                        {
                            return "N/A";
                        }
                        amount = GetFieldInvestmentAmount(whichField, researchPoints);
                        //Temporarily update the research amount to get accurate chance of discovery
                        float oldAmount = ComputerResearchAmount;
                        ComputerResearchAmount += amount;
                        chance = GetChanceForDiscovery(whichField);
                        ComputerResearchAmount = oldAmount;
                        researchedAmount = ComputerResearchAmount;
                        researchCost = (int)(WhichComputerBeingResearched.ResearchPoints * COST_MODIFIER * RaceModifiers[TechField.COMPUTER]);
                    } break;
                case TechField.CONSTRUCTION:
                    {
                        if (WhichConstructionBeingResearched == null)
                        {
                            return "N/A";
                        }
                        amount = GetFieldInvestmentAmount(whichField, researchPoints);
                        //Temporarily update the research amount to get accurate chance of discovery
                        float oldAmount = ConstructionResearchAmount;
                        ConstructionResearchAmount += amount;
                        chance = GetChanceForDiscovery(whichField);
                        ConstructionResearchAmount = oldAmount;
                        researchedAmount = ConstructionResearchAmount;
                        researchCost = (int)(WhichConstructionBeingResearched.ResearchPoints * COST_MODIFIER * RaceModifiers[TechField.CONSTRUCTION]);
                    } break;
                case TechField.FORCE_FIELD:
                    {
                        if (WhichForceFieldBeingResearched == null)
                        {
                            return "N/A";
                        }
                        amount = GetFieldInvestmentAmount(whichField, researchPoints);
                        //Temporarily update the research amount to get accurate chance of discovery
                        float oldAmount = ForceFieldResearchAmount;
                        ForceFieldResearchAmount += amount;
                        chance = GetChanceForDiscovery(whichField);
                        ForceFieldResearchAmount = oldAmount;
                        researchedAmount = ForceFieldResearchAmount;
                        researchCost = (int)(WhichForceFieldBeingResearched.ResearchPoints * COST_MODIFIER * RaceModifiers[TechField.FORCE_FIELD]);
                    } break;
                case TechField.PLANETOLOGY:
                    {
                        if (WhichPlanetologyBeingResearched == null)
                        {
                            return "N/A";
                        }
                        amount = GetFieldInvestmentAmount(whichField, researchPoints);
                        //Temporarily update the research amount to get accurate chance of discovery
                        float oldAmount = PlanetologyResearchAmount;
                        PlanetologyResearchAmount += amount;
                        chance = GetChanceForDiscovery(whichField);
                        PlanetologyResearchAmount = oldAmount;
                        researchedAmount = PlanetologyResearchAmount;
                        researchCost = (int)(WhichPlanetologyBeingResearched.ResearchPoints * COST_MODIFIER * RaceModifiers[TechField.PLANETOLOGY]);
                    } break;
                case TechField.PROPULSION:
                    {
                        if (WhichPropulsionBeingResearched == null)
                        {
                            return "N/A";
                        }
                        amount = GetFieldInvestmentAmount(whichField, researchPoints);
                        //Temporarily update the research amount to get accurate chance of discovery
                        float oldAmount = PropulsionResearchAmount;
                        PropulsionResearchAmount += amount;
                        chance = GetChanceForDiscovery(whichField);
                        PropulsionResearchAmount = oldAmount;
                        researchedAmount = PropulsionResearchAmount;
                        researchCost = (int)(WhichPropulsionBeingResearched.ResearchPoints * COST_MODIFIER * RaceModifiers[TechField.PROPULSION]);
                    } break;
                case TechField.WEAPON:
                    {
                        if (WhichWeaponBeingResearched == null)
                        {
                            return "N/A";
                        }
                        amount = GetFieldInvestmentAmount(whichField, researchPoints);
                        //Temporarily update the research amount to get accurate chance of discovery
                        float oldAmount = WeaponResearchAmount;
                        WeaponResearchAmount += amount;
                        chance = GetChanceForDiscovery(whichField);
                        WeaponResearchAmount = oldAmount;
                        researchedAmount = WeaponResearchAmount;
                        researchCost = (int)(WhichWeaponBeingResearched.ResearchPoints * COST_MODIFIER * RaceModifiers[TechField.WEAPON]);
                    } break;
            }
            progressString = string.Format("{0:0.0} / {1:0.0}", researchedAmount, researchCost);
            progressString += " (" + (amount >= 0 ? " +" : "") + string.Format("{0:0.0}", amount) + ")";
            if (chance > 0)
            {
                progressString += " " + chance + "%";
            }

            return progressString;
        }