/// <summary> /// Construct a new Plant unit /// </summary> /// <param name="row"> The row of the Plant within the grid. </param> /// <param name="col"> The column of the Plant within the grid. </param> public Plant(int row = -1, int col = -1) : base(Enums.UnitType.Plant, senescence: 50, foodRequirement: 5, waterRequirement: 25, gasRequirement: 4, inputGas: Enums.GasType.CarbonDioxide, outputGas: Enums.GasType.Oxygen, idealTemperature: 35, infectionResistance: 7, decompositionValue: 10, row: row, col: col) { // Generate a unique toxicity factor for this plant -- used to calculate its toxicity ToxicityFactor = ProbabilityHelper.RandomInteger(TOXICITY_FACTOR_LOWER_BOUND, TOXICITY_FACTOR_UPPER_BOUND); // Store the minimum water requirement for a plant BaselineWaterRequirement = WaterRequirement; }
/// <summary> /// Performs photosynthesis, consuming a random amount of the carbon dioxide and water to return food to the environment /// </summary> /// <remarks> Tiffanie Truong </remarks> /// <param name="gameEnv"> The Environment of the simulation that the plants reside in </param> protected void Photosynthesize(Environment gameEnv) { // Generate how many carbon dioxide and water units are consumed to turn into food int resourceUsage = ProbabilityHelper.RandomInteger(PHOTOSYNTHESIS_RESOURCE_LOWER_BOUND, PHOTOSYNTHESIS_RESOURCE_UPPER_BOUND); // Check if there is enough carbon dioxide and water in the environment to create this given amount of food if (resourceUsage <= gameEnv.CarbonDioxideLevel && resourceUsage <= gameEnv.WaterAvailability) { // Perform photosynthesis and create more food gameEnv.IncreaseFood(resourceUsage); // Consume water and carbon dioxide in the environment gameEnv.DecreaseFood(resourceUsage); gameEnv.DecreaseWater(resourceUsage); } }