Ejemplo n.º 1
0
        public static void ApplyConfig(Track track, TrackConfig cfg)
        {
            track.Gravity       = cfg.Gravity;
            track.AirResistance = cfg.AirResistance;

            var regions = track.Regions;

            for (int i = 0; i < Math.Min(regions.Length, cfg.Regions.Count); ++i)
            {
                var r = regions[i];
                TrackRegionConfig rc = cfg.Regions[i];
                r.IsObstacle         = rc.IsObstacle;
                r.TerraSlideFriction = rc.TerraSlideFriction;
                r.TerraRollFriction  = rc.TerraRollFriction;
                r.TerraGrip          = rc.TerraGrip;
                r.EnvResistance      = rc.EnvResistance;
            }
        }
Ejemplo n.º 2
0
        private void readAIAndPhysicsConfig(string cfgAsset)
        {
            // TODO: switch between config types
            TrackConfig tcfg = TrackConfigurator.LoadConfig(_track, _roomAssetFolder + cfgAsset);

            if (tcfg != null)
            {
                TrackConfigurator.ApplyConfig(_track, tcfg);
            }

            VehicleConfig vcfg = VehicleConfigurator.LoadConfig(_track, _roomAssetFolder + cfgAsset);

            if (vcfg != null)
            {
                foreach (var car in _race.Cars)
                {
                    VehicleConfigurator.ApplyConfig(car.Veh, vcfg);
                }
            }
        }
Ejemplo n.º 3
0
        public static TrackConfig LoadConfig(Track track, string iniFilePath)
        {
            FileIniDataParser file = new FileIniDataParser();

            file.Parser.Configuration.CommentString = "//";
            IniData inidata = file.ReadFile(iniFilePath);

            if (inidata == null)
            {
                return(null);
            }

            IniGetter   ini = new IniGetter(inidata);
            TrackConfig cfg = new TrackConfig();

            cfg.Gravity       = ini.GetFloat("track", "gravity");
            cfg.AirResistance = ini.GetFloat("track", "air_resistance");
            int regions = ini.GetInt("track", "regions");

            cfg.Regions = new List <TrackRegionConfig>();
            for (int i = 0; i < regions; ++i)
            {
                string secname = String.Format("area{0}", i);
                if (!inidata.Sections.ContainsSection(secname))
                {
                    continue;
                }
                TrackRegionConfig r = new TrackRegionConfig();
                r.IsObstacle         = ini.GetBool(secname, "is_obstacle");
                r.TerraSlideFriction = ini.GetFloat(secname, "slide_friction");
                r.TerraRollFriction  = ini.GetFloat(secname, "roll_friction");
                r.TerraGrip          = ini.GetFloat(secname, "grip");
                r.EnvResistance      = ini.GetFloat(secname, "env_resistance");
                cfg.Regions.Add(r);
            }
            return(cfg);
        }