Exemple #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="position"></param>
        /// <param name="size"></param>
        public Water(Vector3 position, float size)
        {
            waterPosition = position;
            waterSize     = size;
            waterDetail   = Convert.ToInt32(Bonsai.Utils.Settings.GetValue("WaterDetail", "2"));
            switch (waterDetail)
            {
            case 2:
                qualityLevel = Bonsai.Objects.Terrain.Water.QualityLevelEnum.Medium;
                break;

            case 3:
                qualityLevel = Bonsai.Objects.Terrain.Water.QualityLevelEnum.High;
                break;

            default:
                qualityLevel = Bonsai.Objects.Terrain.Water.QualityLevelEnum.Low;
                break;
            }
            water = new Bonsai.Objects.Terrain.Water(position, size, qualityLevel);
            if (water != null)
            {
                water.WindDirection = (float)Program.Instance.Weather.Wind.Direction;
                water.WindSpeed     = (float)Program.Instance.Weather.Wind.ConstantWindSpeed;
            }
            Bonsai.Utils.Settings.SettingsChanged += new Bonsai.Utils.Settings.SettingsEventHandler(Settings_SettingsChanged);
        }
Exemple #2
0
        /// <summary>
        /// Handles the SettingsChanged event for Bonsai settings.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Settings_SettingsChanged(object sender, Bonsai.Utils.Settings.SettingsEventArgs e)
        {
            int newWaterDetail = Convert.ToInt32(Bonsai.Utils.Settings.GetValue("WaterDetail", "2"));

            if (newWaterDetail != waterDetail)
            {
                waterDetail = newWaterDetail;
                switch (waterDetail)
                {
                case 2:
                    qualityLevel = Bonsai.Objects.Terrain.Water.QualityLevelEnum.Medium;
                    break;

                case 3:
                    qualityLevel = Bonsai.Objects.Terrain.Water.QualityLevelEnum.High;
                    break;

                default:
                    qualityLevel = Bonsai.Objects.Terrain.Water.QualityLevelEnum.Low;
                    break;
                }
                if (water != null)
                {
                    water.Dispose();
                    water = null;
                }
                water                     = new Bonsai.Objects.Terrain.Water(waterPosition, waterSize, qualityLevel);
                water.SunPosition         = sunPosition;
                water.OnFrameRenderMethod = waterCallback;
            }

            if (water != null)
            {
                water.WindDirection = (float)Program.Instance.Weather.Wind.Direction;
                water.WindSpeed     = (float)Program.Instance.Weather.Wind.ConstantWindSpeed;
            }
        }