예제 #1
0
        public void UpdateProjectedCost(double cost, string resourceType)
        {
            double surplus      = cost - Resource;
            double resourceCost = 0.0;

            for (int i = 0; i < Variables.GetNumberVariables(); ++i)
            {
                // optimizable with reflexion to call the switch just once and fix the resource we are interested by?
                switch (resourceType)
                {
                case "mineral":
                    resourceCost = Variables.GetValue(i) * Data.Dataset[Variables.Name(i)].CostMineral;
                    break;

                case "gas":
                    resourceCost = Variables.GetValue(i) * Data.Dataset[Variables.Name(i)].CostGas;
                    break;

                case "supply":
                    resourceCost = Variables.GetValue(i) * Data.Dataset[Variables.Name(i)].CostSupply;
                    break;
                }
                if (resourceCost >= surplus)
                {
                    Variables.AddProjectedCost(i, resourceCost);
                }
            }
        }