Example #1
0
 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);
 }
Example #2
0
        public void Parse(ConfigurationSection sect)
        {
            string dayTexFile = sect.GetString("DayTexture", null);

            if (dayTexFile != null)
            {
                FileLocation fl = FileSystem.Instance.Locate(dayTexFile, FileLocateRules.Default);

                dayTex = CubeTexture.FromStream(device, fl.GetStream, Usage.None, Pool.Managed);
            }

            string nightTexFile = sect.GetString("NightTexture", null);

            if (nightTexFile != null)
            {
                FileLocation fl = FileSystem.Instance.Locate(nightTexFile, FileLocateRules.Default);

                nightTex = CubeTexture.FromStream(device, fl.GetStream, Usage.None, Pool.Managed);
            }
        }
Example #3
0
        public override void Update(ConfigurationSection rootNode, API api)
        {
            ConfigurationSection weekendInfo    = rootNode.GetConfigurationSection("WeekendInfo");
            ConfigurationSection weekendOptions = weekendInfo.GetConfigurationSection("WeekendOptions");

            Track.Name = weekendInfo.GetString("TrackName");
            Track.Id   = int.Parse(weekendInfo.GetString("TrackID"));
            string length = weekendInfo.GetString("TrackLength");

            Track.Length           = float.Parse(length.Substring(0, length.Length - 3).Replace('.', ',')) * 1000;
            Track.DisplayName      = weekendInfo.GetString("TrackDisplayName");
            Track.DisplayShortName = weekendInfo.GetString("TrackDisplayShortName");
            Track.City             = weekendInfo.GetString("TrackCity");
            Track.Country          = weekendInfo.GetString("TrackCountry");
            string alt = weekendInfo.GetString("TrackAltitude");

            Track.Altitude = float.Parse(alt.Substring(0, alt.Length - 2).Replace('.', ','));
            string lat = weekendInfo.GetString("TrackLatitude");

            Track.Latitude = float.Parse(lat.Substring(0, lat.Length - 2).Replace('.', ','));
            string lon = weekendInfo.GetString("TrackLongitude");

            Track.Longitude     = float.Parse(lon.Substring(0, lon.Length - 2).Replace('.', ','));
            Track.NumberOfTurns = int.Parse(weekendInfo.GetString("TrackNumTurns"));
            string pl = weekendInfo.GetString("TrackPitSpeedLimit");

            Track.PitSpeedLimit = float.Parse(pl.Substring(0, pl.Length - 4).Replace('.', ','));
            string trackType = weekendInfo.GetString("TrackType");

            if (trackType.StartsWith("road"))
            {
                Track.TrackType = TrackType.Road;
            }
            else if (trackType.StartsWith("oval"))
            {
                Track.TrackType = TrackType.Oval;
            }
            else
            {
                Track.TrackType = TrackType.None;
            }

            Weather.Skies = (Skies)Enum.Parse(typeof(Skies), weekendInfo.GetString("TrackSkies").Replace(" ", ""));
            string airTemp = weekendInfo.GetString("TrackAirTemp");

            Weather.AirTemp = float.Parse(airTemp.Substring(0, airTemp.Length - 2).Replace('.', ','));
            string trackTemp = weekendInfo.GetString("TrackSurfaceTemp");

            Weather.TrackTemp = float.Parse(trackTemp.Substring(0, trackTemp.Length - 2).Replace('.', ','));
            string windSpeed = weekendInfo.GetString("TrackWindVel");

            Weather.WindSpeed = float.Parse(windSpeed.Substring(0, windSpeed.Length - 4).Replace('.', ','));
            string humidity = weekendOptions.GetString("RelativeHumidity");

            Weather.Humidity = int.Parse(humidity.Substring(0, humidity.Length - 2));

            Track.Sectors.Clear();
            ConfigurationSection splitTime = rootNode.GetConfigurationSection("SplitTimeInfo");

            foreach (Dictionary <string, object> dict in splitTime.GetMapList("Sectors"))
            {
                Track.Sectors.Add(float.Parse(dict.GetDictValue("SectorStartPct").Replace('.', ',')));
            }
        }
Example #4
0
 public MapSoundObject(ConfigurationSection sect)
 {
     Radius  = sect.GetSingle("Radius", 0);
     SFXName = sect.GetString("SFX", string.Empty);
 }
Example #5
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];
            }
        }
Example #6
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];
            }
        }
Example #7
0
 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);
 }
Example #8
0
 public MapSoundObject(ConfigurationSection sect)
 {
     Radius = sect.GetSingle("Radius", 0);
     SFXName = sect.GetString("SFX", string.Empty);
 }
Example #9
0
        private unsafe TreeModelLibrary(RenderSystem rs)
        {
            renderSys = rs;

            FileLocation  fl   = FileSystem.Instance.Locate("trees.xml", GameFileLocs.Config);
            Configuration conf = ConfigurationManager.Instance.CreateInstance(fl);

            foreach (KeyValuePair <string, ConfigurationSection> s in conf)
            {
                ConfigurationSection sect = s.Value;
                TreeModelData        mdl;

                int          type     = sect.GetInt("Type", 0);
                string       fileName = sect.GetString("Level0", string.Empty);
                FileLocation fl2      = FileSystem.Instance.Locate(fileName, GameFileLocs.Model);

                ModelMemoryData mdlData = new ModelMemoryData(rs, fl2);

                loadedModels.Add(mdlData);

                MeshData[] dataArr = mdlData.Entities;

                if (dataArr.Length == 1)
                {
                    MeshData data = dataArr[0];

                    Material[][] mtrls = data.Materials;

                    int partCount            = mtrls.Length;
                    FastList <int>[] indices = new FastList <int> [partCount];
                    for (int i = 0; i < partCount; i++)
                    {
                        indices[i] = new FastList <int>();
                    }

                    mdl.Materials    = new Material[partCount];
                    mdl.Indices      = new int[partCount][];
                    mdl.PartVtxCount = new int[partCount];

                    MeshFace[] faces = data.Faces;

                    for (int i = 0; i < faces.Length; i++)
                    {
                        int matId = faces[i].MaterialIndex;
                        indices[matId].Add(faces[i].IndexA);
                        indices[matId].Add(faces[i].IndexB);
                        indices[matId].Add(faces[i].IndexC);
                    }


                    for (int i = 0; i < partCount; i++)
                    {
                        Material mtrl = mtrls[i][0];
                        mdl.Materials[i] = mtrl;

                        indices[i].Trim();
                        mdl.Indices[i] = indices[i].Elements;

                        int partVtxCount = 0;

                        bool[] passed = new bool[data.VertexCount];

                        for (int j = 0; j < mdl.Indices[i].Length; j++)
                        {
                            passed[indices[i][j]] = true;
                        }

                        for (int j = 0; j < data.VertexCount; j++)
                        {
                            if (passed[j])
                            {
                                partVtxCount++;
                            }
                        }

                        mdl.PartVtxCount[i] = partVtxCount;
                    }

                    mdl.VertexCount = data.VertexCount;
                    mdl.VertexData  = new byte[data.VertexCount * data.VertexSize];
                    fixed(byte *dst = &mdl.VertexData[0])
                    {
                        Memory.Copy(data.Data.ToPointer(), dst, mdl.VertexData.Length);
                    }

                    if (typedList[type] == null)
                    {
                        typedList[type] = new FastList <TreeModelData>();
                    }

                    typedList[type].Add(mdl);
                }
                BuildTrunk(rs);
            }



            for (int i = 0; i < typedList.Length; i++)
            {
                typedList[i].Trim();
            }
        }