public MapSceneObject(ConfigurationSection sect) { Radius = sect.GetSingle("Radius", 0); IsForest = sect.GetBool("IsForest", false); Amount = sect.GetSingle("Amount", 0); Model = sect.GetString("Model", string.Empty); }
public void Parse(ConfigurationSection sect) { float lng = sect.GetSingle("Longitude"); float lat = sect.GetSingle("Latitude"); lng = MathEx.Degree2Radian(lng); lat = MathEx.Degree2Radian(lat); float alt = TerrainData.Instance.QueryHeight(lng, lat); position = PlanetEarth.GetPosition(lng, lat); radius = sect.GetSingle("Radius"); radius = PlanetEarth.GetTileHeight(MathEx.Degree2Radian(radius)); string sfxName = sect["SFX"]; sound = SoundManager.Instance.MakeSoundObjcet(sfxName, null, radius); sound.Position = position; //probability = sect.GetSingle("Probability", 1); }
private void toolStripButton1_Click(object sender, EventArgs e) { SimulationWorld sim = new SimulationWorld(); if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { string dir = folderBrowserDialog1.SelectedPath; Configuration config = ConfigurationManager.Instance.CreateInstance(new FileLocation(Path.Combine(dir, "cities.xml"))); foreach (KeyValuePair <string, ConfigurationSection> s in config) { ConfigurationSection sect = s.Value; MapCity city = new MapCity(sim, sect); MapObject obj = new MapObject(); obj.Longitude = city.Longitude; obj.Latitude = city.Latitude; obj.Tag = city; obj.Type = ObjectType.City; obj.StringDisplay = city.Name; obj.SectionName = sect.Name; cityTable.Add(sect.Name, city); objectList.Add(obj); } config = ConfigurationManager.Instance.CreateInstance(new FileLocation(Path.Combine(dir, "sceneObjects.xml"))); foreach (KeyValuePair <string, ConfigurationSection> s in config) { ConfigurationSection sect = s.Value; MapSceneObject sceObj = new MapSceneObject(sect); MapObject obj = new MapObject(); obj.Longitude = sect.GetSingle("Longitude"); obj.Latitude = sect.GetSingle("Latitude"); obj.Type = ObjectType.Scene; obj.Tag = sceObj; obj.StringDisplay = sceObj.Model; obj.Radius = sceObj.Radius; obj.SectionName = sect.Name; objectList.Add(obj); } config = ConfigurationManager.Instance.CreateInstance(new FileLocation(Path.Combine(dir, "resources.xml"))); foreach (KeyValuePair <string, ConfigurationSection> s in config) { ConfigurationSection sect = s.Value; MapResource res = new MapResource(sim, sect); MapObject obj = new MapObject(); obj.Longitude = res.Longitude; obj.Latitude = res.Latitude; obj.Tag = res; if (res.Type == NaturalResourceType.Wood) { obj.Type = ObjectType.ResWood; } else if (res.Type == NaturalResourceType.Petro) { obj.Type = ObjectType.ResOil; } obj.StringDisplay = (obj.Type == ObjectType.ResOil ? "O" : "W") + res.Amount.ToString(); obj.Radius = res.Radius; obj.SectionName = sect.Name; objectList.Add(obj); } config = ConfigurationManager.Instance.CreateInstance(new FileLocation(Path.Combine(dir, "soundObjects.xml"))); foreach (KeyValuePair <string, ConfigurationSection> s in config) { ConfigurationSection sect = s.Value; MapSoundObject sndObj = new MapSoundObject(sect); MapObject obj = new MapObject(); obj.Longitude = sect.GetSingle("Longitude"); obj.Latitude = sect.GetSingle("Latitude"); obj.Type = ObjectType.Sound; obj.Tag = sndObj; obj.StringDisplay = sndObj.SFXName; obj.Radius = sndObj.Radius; obj.SectionName = sect.Name; objectList.Add(obj); } config = ConfigurationManager.Instance.CreateInstance(new FileLocation(Path.Combine(dir, "soundEffect.xml"))); foreach (KeyValuePair <string, ConfigurationSection> s in config) { comboBox2.Items.Add(s.Key); } } pictureBox1.Refresh(); }
public MapSoundObject(ConfigurationSection sect) { Radius = sect.GetSingle("Radius", 0); SFXName = sect.GetString("SFX", string.Empty); }
public static void LoadRules() { FileLocation fl = FileSystem.Instance.Locate("rules.xml", GameFileLocs.Config); GameConfiguration con = new GameConfiguration(fl);// Utils.LoadConfig("rules.xml"); ConfigurationSection sect = con["CityCommon"]; CityBallLimit = sect.GetInt("BallLimit"); CityMaxDevelopment = sect.GetSingle("MaxDevelopment", 10000); CityDevHealthRate = sect.GetSingle("DevHealthRate", 0.1f); CityInitialDevelopment = sect.GetSingle("InitialDevelopment", 1000); CityRadius = sect.GetSingle("Radius", 300); CityDevRBallHealthRate = sect.GetSingle("DevRBallHealthRate"); CityArmor = sect.GetSingle("Armor"); sect = con["NRCommon"]; FRecoverBias = sect.GetSingle("ORecoverBias", 1); ORecoverBias = sect.GetSingle("FRecoverBias", 1); FRecoverRate = sect.GetSingle("FRecoverRate", 0.0015f); sect = con["HarvCommon"]; HarvLoadingSpeed = sect.GetSingle("LoadingSpeed", 2.5f); HarvLoadingTime = sect.GetSingle("HarvLoadingTime", 3); #region 各种资源球配置读取 sect = con["OilBall"]; OilBallBaseHealth = sect.GetSingle("BaseHealth"); OilBallCost = sect.GetSingle("Cost"); OilBallContribution = sect.GetSingle("Contribution"); OilBallBaseDamage = sect.GetSingle("BaseDamage"); OilBallBaseHeal = sect.GetSingle("BaseHeal"); sect = con["GreenBall"]; GreenBallBaseHealth = sect.GetSingle("BaseHealth"); GreenBallCost = sect.GetSingle("Cost"); GreenBallContribution = sect.GetSingle("Contribution"); GreenBallBaseDamage = sect.GetSingle("BaseDamage"); GreenBallBaseHeal = sect.GetSingle("BaseHeal"); sect = con["EducationBall"]; EducationBallBaseHealth = sect.GetSingle("BaseHealth"); EducationBallGenInterval = sect.GetSingle("GenInterval"); EducationBallContribution = sect.GetSingle("Contribution"); EducationBallBaseDamage = sect.GetSingle("BaseDamage"); EducationBallBaseHeal = sect.GetSingle("BaseHeal"); sect = con["HealthBall"]; HealthBallBaseHealth = sect.GetSingle("BaseHealth"); HealthBallGenInterval = sect.GetSingle("GenInterval"); HealthBallContribution = sect.GetSingle("Contribution");; HealthBallBaseDamage = sect.GetSingle("BaseDamage"); HealthBallBaseHeal = sect.GetSingle("BaseHeal"); sect = con["DiseaseBall"]; DiseaseBallBaseHealth = sect.GetSingle("BaseHealth"); DiseaseBallGenInterval = sect.GetSingle("GenInterval"); DiseaseBallContribution = sect.GetSingle("Contribution"); DiseaseBallBaseDamage = sect.GetSingle("BaseDamage"); DiseaseBallBaseHeal = sect.GetSingle("BaseHeal"); sect = con["VolienceBall"]; VolienceBallBaseHealth = sect.GetSingle("BaseHealth"); VolienceBallGenInterval = sect.GetSingle("GenInterval"); VolienceBallContribution = sect.GetSingle("Contribution"); VolienceBallBaseDamage = sect.GetSingle("BaseDamage"); VolienceBallBaseHeal = sect.GetSingle("BaseHeal"); #endregion #region 各种城市的配置读取 sect = con["OilCity"]; OilGatherDistance = sect.GetSingle("GatherDistance", 150); OilHarvHP = sect.GetSingle("HarvHealth", 300); OilHarvStorage = sect.GetSingle("HarvStorage", 300); OilHarvSpeed = sect.GetSingle("HarvSpeed", 1); OilDevelopStep = sect.GetSingle("DevelopStep", 10); sect = con["GreenCity"]; GreenGatherDistance = sect.GetSingle("GatherDistance", 150); GreenHarvHP = sect.GetSingle("HarvHealth", 300); GreenHarvStorage = sect.GetSingle("HarvStorage", 300); GreenHarvSpeed = sect.GetSingle("HarvSpeed", 1); GreenDevelopStep = sect.GetSingle("DevelopStep", 10); sect = con["DiseaseCity"]; DiseaseDevelopStep = sect.GetSingle("DevelopStep", 10); sect = con["VolienceCity"]; VolienceDevelopStep = sect.GetSingle("VolienceCity", 10); sect = con["HealthCity"]; HealthDevelopStep = sect.GetSingle("HealthCity", 10); sect = con["EducationCity"]; EducationDevelopStep = sect.GetSingle("EducationCity", 10); #endregion }
public SoundEffectGame(AudioListener listener, SoundManager sm, ConfigurationSection sect) { this.contentManager = sm.Content; this.listener = listener; string[] control = sect.GetStringArray("Control"); for (int i = 0; i < control.Length; i++) { control[i] = control[i].ToLowerInvariant(); switch (control[i]) { case "loop": Control |= SoundControl.Loop; break; case "random": Control |= SoundControl.Random; break; case "ambient": Control |= SoundControl.Ambient; break; } } Probability = sect.GetSingle("Probability", 1); Volume = sect.GetSingle("Volume", 1); Type = (SoundType)Enum.Parse(typeof(SoundType), sect.GetString("Type", SoundType.Normal.ToString()), true); //this.soundEffect = contentManager.Load<SoundEffect>(sect.Name); soundEffects = new SoundEffect[3][]; if ((Control & SoundControl.Loop) == SoundControl.Loop) { string[] fadein = sect.GetStringArray("Fadein"); soundEffects[(int)SoundEffectPart.Fadein] = new SoundEffect[fadein.Length]; for (int index = 0; index < fadein.Length; index++) { soundEffects[(int)SoundEffectPart.Fadein][0] = contentManager.Load <SoundEffect>(fadein[index]); } string[] mediumstring = sect.GetStringArray("Medium"); soundEffects[(int)SoundEffectPart.Medium] = new SoundEffect[mediumstring.Length]; for (int index = 0; index < mediumstring.Length; index++) { soundEffects[(int)SoundEffectPart.Medium][index] = contentManager.Load <SoundEffect>(mediumstring[index]); } string[] fadeout = sect.GetStringArray("Fadeout"); soundEffects[(int)SoundEffectPart.Fadeout] = new SoundEffect[fadeout.Length]; for (int index = 0; index < fadein.Length; index++) { soundEffects[(int)SoundEffectPart.Fadeout][0] = contentManager.Load <SoundEffect>(fadeout[index]); } } else { string[] sounds = sect.GetStringArray("Sounds"); soundEffects[(int)SoundEffectPart.Fadein] = new SoundEffect[sounds.Length]; for (int i = 0; i < sounds.Length; i++) { soundEffects[0][i] = contentManager.Load <SoundEffect>(sounds[i]); } soundEffects[1] = soundEffects[0]; soundEffects[2] = soundEffects[0]; } }
public SoundEffectGame(AudioListener listener, SoundManager sm, ConfigurationSection sect) { this.contentManager = sm.Content; this.listener = listener; string[] control = sect.GetStringArray("Control"); for (int i = 0; i < control.Length; i++) { control[i] = control[i].ToLowerInvariant(); switch (control[i]) { case "loop": Control |= SoundControl.Loop; break; case "random": Control |= SoundControl.Random; break; case "ambient": Control |= SoundControl.Ambient; break; } } Probability = sect.GetSingle("Probability", 1); Volume = sect.GetSingle("Volume", 1); Type = (SoundType)Enum.Parse(typeof(SoundType), sect.GetString("Type", SoundType.Normal.ToString()), true); //this.soundEffect = contentManager.Load<SoundEffect>(sect.Name); soundEffects = new SoundEffect[3][]; if ((Control & SoundControl.Loop) == SoundControl.Loop) { string[] fadein = sect.GetStringArray("Fadein"); soundEffects[(int)SoundEffectPart.Fadein] = new SoundEffect[fadein.Length]; for (int index = 0; index < fadein.Length; index++) { soundEffects[(int)SoundEffectPart.Fadein][0] = contentManager.Load<SoundEffect>(fadein[index]); } string[] mediumstring = sect.GetStringArray("Medium"); soundEffects[(int)SoundEffectPart.Medium] = new SoundEffect[mediumstring.Length]; for (int index = 0; index < mediumstring.Length; index++) { soundEffects[(int)SoundEffectPart.Medium][index] = contentManager.Load<SoundEffect>(mediumstring[index]); } string[] fadeout = sect.GetStringArray("Fadeout"); soundEffects[(int)SoundEffectPart.Fadeout] = new SoundEffect[fadeout.Length]; for (int index = 0; index < fadein.Length; index++) { soundEffects[(int)SoundEffectPart.Fadeout][0] = contentManager.Load<SoundEffect>(fadeout[index]); } } else { string[] sounds = sect.GetStringArray("Sounds"); soundEffects[(int)SoundEffectPart.Fadein] = new SoundEffect[sounds.Length]; for (int i = 0; i < sounds.Length; i++) { soundEffects[0][i] = contentManager.Load<SoundEffect>(sounds[i]); } soundEffects[1] = soundEffects[0]; soundEffects[2] = soundEffects[0]; } }