Example #1
0
        /// <summary>
        /// (Tiffanie) Create a new Environment with the given values unique to a chosen type of Environment
        /// </summary>
        /// <param name="defaultFood"> The default amount of food in this type of environment </param>
        /// <param name="defaultWater"> The default amount of water in this type of environment </param>
        /// <param name="oxygenLevel"> The percentage of the atmosphere that is oxygen </param>
        /// <param name="carbonDioxideLevel"> The percentage of the atmosphere that is carbon dioxide </param>
        /// <param name="temperature"> The temperature of this environment </param>
        /// <param name="probOfRain"> The probability of rain in this environment </param>
        /// <param name="envImage"> The background image for this environment </param>
        /// <param name="eventPic"> The image for the unique event of this environment </param>
        /// <param name="envType"> The subclass representing the class or type of the environment </param>
        public Environment(double defaultFood, int defaultWater,
                           int oxygenLevel, int carbonDioxideLevel,
                           int temperature, int probOfRain,
                           Image envImage, Image eventPic,
                           Enums.EnvironmentType envType)
        {
            // **** INITIALIZE ENVIRONMENT PARAMETERS BASED ON TYPE OF ENVIRONMENT ****
            // Save the type of environment
            environmentType = envType;
            // Save the default amount of food and water in this biome
            DefaultFood  = defaultFood;
            DefaultWater = defaultWater;
            // Initialize the amount of food and water available in the environment to be the default values
            // These values can be modified by the user in the StartForm
            foodAvailability  = DefaultFood;
            waterAvailability = DefaultWater;
            // Save the atmospheric composition
            CarbonDioxideLevel = carbonDioxideLevel;
            OxygenLevel        = oxygenLevel;
            // Save the environment's temperature
            Temperature = temperature;
            // Save probability of rain as a percent
            probabilityOfRain = probOfRain;

            // IMAGES
            // Save the background of the environment
            EnvironmentImage = envImage;
            // Save image for the unique environmental event
            EventImage = eventPic;
            // Save image for rain event
            RainImage = Properties.Resources.Rain;
        }
Example #2
0
 /// <summary>
 /// Creates and sets the environment of the current state
 /// </summary>
 /// <param name="envType">The type of the environment</param>
 public void CreateEnvironment(Enums.EnvironmentType envType)
 {
     //check if a state exists
     if (currentState != null)
     {
         //create a new environment using environment factory and assign it to the current states environment
         currentState.GameEnvironment = EnvironmentFactory.CreateEnvironment(envType);
     }
 }
        /// <summary>
        /// Creates a new object that is of the given environment type
        /// </summary>
        /// <param name="environmentType">The type of environment to create</param>
        /// <returns>An environment object of the given type</returns>
        public static Environment CreateEnvironment(Enums.EnvironmentType environmentType)
        {
            //check which environment type is given and create the corresponding type of object
            switch (environmentType)
            {
            case Enums.EnvironmentType.Rainforest:
                return(new Rainforest());

            case Enums.EnvironmentType.Greenhouse:
                return(new Greenhouse());

            case Enums.EnvironmentType.Tundra:
                return(new Tundra());

            case Enums.EnvironmentType.Desert:
                return(new Desert());

            default:
                return(null);
            }
        }