protected override void InitializeSettings(ParticleSettings settings)
        {
            PixFile pix = new PixFile(_pixFileName);

            settings.Texture = pix.PixMaps[0].Texture;

            settings.MaxParticles = 200;

            settings.Duration = TimeSpan.FromSeconds(1f);

            settings.MinHorizontalVelocity = 1f;
            settings.MaxHorizontalVelocity = 2f;

            settings.MinVerticalVelocity = 2.5f;
            settings.MaxVerticalVelocity = 4.5f;
            settings.DurationRandomness = 0.3f;
            settings.EmitterVelocitySensitivity = 0.7f;

            settings.Gravity = new Vector3(0, -3.5f, 0);

            settings.EndVelocity = 1f;

            settings.MinStartSize = 0.25f * _sizeMultiplier;
            settings.MaxStartSize = 0.65f * _sizeMultiplier;

            settings.MinEndSize = 0.25f * _sizeMultiplier;
            settings.MaxEndSize = 1.15f * _sizeMultiplier;

            settings.MinRotateSpeed = 0f;
            settings.MaxRotateSpeed = 6f;
        }
Exemple #2
0
        public PixMapFont(string name, FontDescriptionFile description)
        {
            string path = FindDataFile(name + ".pix");

            PixFile pix = new PixFile(path);
            if (!pix.Exists)
            {
                Exists = false;
                return;
            }

            _texture = pix.PixMaps[0].Texture;

            if (description == null)
            {
                path = path.Replace(".pix", ".txt");
                _description = new FontDescriptionFile(path);
            }
            else
            {
                _description = description;
                _description.CharWidths = new int[100];
                for (int i = 0; i < 100; i++) _description.CharWidths[i] = _texture.Width;
            }
            if (path.Contains("32X20")) _description.Scale = 2;
        }
Exemple #3
0
        public void ResolveTexture(List<PixMap> pixmaps)
        {
            if (Texture != null) return;  //weve already resolved this material

            if (!String.IsNullOrEmpty(PixName))
            {
                PixMap pixmap = null;
                if (pixmaps != null)
                    pixmap = pixmaps.Find(p => p.Name.Equals(PixName, StringComparison.InvariantCultureIgnoreCase));
                else
                {
                    PixFile pixfile = new PixFile(PixName);
                    if (pixfile.Exists)
                        pixmap = pixfile.PixMaps[0];
                }
                if (pixmap != null)
                    Texture = pixmap.Texture;
            }

            if (Texture == null)
            {
                //simp mat
                if (SimpMatGradientCount > 1)
                    GenerateSimpMatGradient();
                else
                    Texture = TextureGenerator.Generate(GameVars.Palette.GetRGBColorForPixel(SimpMatPixelIndex));
            }
        }
Exemple #4
0
        public PixmapBillboard(Vector2 scale, string filename)
        {
            _scale = new Vector3(scale, 1);
            CreateGeometry();
            _vertexDeclaration = new VertexDeclaration(Engine.Device, VertexPositionTexture.VertexElements);

            PixFile pix = new PixFile(filename);
            _pixmaps = pix.PixMaps;
        }
Exemple #5
0
        public RaceMap(Race race)
        {
            _race = race;
            PixFile pix = new PixFile(race.ConfigFile.MapTexture);
            if (pix.Exists)
                _mapTexture = pix.PixMaps[0].Texture;
            _player = Engine.ContentManager.Load<Texture2D>("content/map-icon-player");
            _opponent = Engine.ContentManager.Load<Texture2D>("content/map-icon-opponent");
            _deadOpponent = Engine.ContentManager.Load<Texture2D>("content/map-icon-opponent-dead");

            _mapRect = new Rectangle(0, 60, Engine.Window.Width, Engine.Window.Height - 90);
        }
Exemple #6
0
        private Texture2D GetTextureFromPixFile(string curFolder, string filename)
        {
            if (filename == "none")
            {
                return(null);
            }
            PixFile pixFile = new PixFile(filename);

            if (pixFile.PixMaps.Count > 0)
            {
                return(pixFile.PixMaps[0].Texture);
            }
            return(null);
        }
Exemple #7
0
        public static List<Texture2D> LoadAnimation(string filename)
        {
            FliFile fli = new FliFile(filename);
            if (fli.Exists)
                return fli.Frames;
            filename = filename.Substring(0, filename.Length - 3) + "png";
            if (File.Exists(GameVars.BasePath + "anim\\" + filename))
            {
                return new List<Texture2D> { (Texture2D)Texture.FromFile(Engine.Device, GameVars.BasePath + "anim\\" + filename) };
            }

            filename = filename.Substring(0, filename.Length - 3) + "pix";
            PixFile pix = new PixFile(filename);
            if (pix.Exists)
                return new List<Texture2D> { pix.PixMaps[0].Texture };

            return null;
        }
Exemple #8
0
        public RevCounter(VehicleChassis vehicle)
        {
            _chassis = vehicle;

            x = 0.01f;
            y = 0.8f;
            if (GameVars.Emulation == EmulationMode.Demo)
            {
                PixFile pix = new PixFile("tacho.pix");
                _speedoTexture = pix.PixMaps[0].Texture;
            }
            else
            {
                PixFile pix = new PixFile("hirestch.pix");
                _speedoTexture = pix.PixMaps[0].Texture;
            }
            _speedoLineTexture = TextureGenerator.Generate(new Color(255, 0, 0));
        }
Exemple #9
0
        public void PostMainMessage(string pixname, float displayTime, float y, float scale, float animationSpeed)
        {
            if (!_textures.ContainsKey(pixname))
            {
                PixFile pix = new PixFile(pixname);
                if (pix.Exists) _textures.Add(pixname, pix.PixMaps[0].Texture);
            }

            if (!_textures.ContainsKey(pixname))
                return;

            _hasPaused = false;
            _pauseTime = 0;
            _messageTexture = _textures[pixname];
            _scale = scale;
            _y = y;
            _messageTtl = displayTime;
            _animationSpeed = animationSpeed;
            _progress = 0;
            _messageRect = CenterRectX(_y, _messageTexture.Width * _scale, _messageTexture.Height * _scale);
            _centerX = _messageRect.X;
            _messageX = _screenWidth;
        }
Exemple #10
0
        public VehicleModel(VehicleFile file, bool forDisplayOnly)
        {
            Config = file;

            if (file.DrivenWheelRefs.Count == 0 || file.NonDrivenWheelRefs.Count == 0)
                throw new Exception("No wheel refs specified");

            foreach (string pixFileName in file.PixFiles)
            {
                PixFile pixFile = new PixFile(pixFileName);
                ResourceCache.Add(pixFile);
            }

            foreach (string matFileName in file.MaterialFiles)
            {
                MatFile matFile = new MatFile(matFileName);
                ResourceCache.Add(matFile);
            }

            foreach (string matFileName in file.CrashMaterialFiles)
            {
                MatFile matFile = new MatFile(matFileName);
                ResourceCache.Add(matFile);
            }

            ResourceCache.ResolveMaterials();

            _grooves = new List<BaseGroove>();
            foreach (BaseGroove g in file.Grooves)
                if (!g.IsWheelActor) _grooves.Add(g);

            ActFile actFile = new ActFile(file.ActorFile);
            _actors = actFile.Hierarchy;
            DatFile modelFile = new DatFile(_actors.Root.ModelName, !forDisplayOnly);
            ModelName = _actors.Root.ModelName;

            _actors.AttachModels(modelFile.Models);
            _actors.ResolveTransforms(!forDisplayOnly, _grooves);

            foreach (BaseGroove g in _grooves)
                g.SetActor(_actors.GetByName(g.ActorName));

            // link the funks and materials
            foreach (BaseFunk f in file.Funks)
                f.Resolve();

            Vector3 tireWidth = new Vector3(0.034f, 0, 0) * GameVars.Scale;

            foreach (int id in file.DrivenWheelRefs)
            {
                BaseGroove g = file.Grooves.Find(a => a.Id == id);
                if (g == null) continue;
                CActor actor = _actors.GetByName(g.ActorName);
                CWheelActor ca = new CWheelActor(actor, true, false);
                ca.Position = actor.Matrix.Translation + (ca.IsLeft ? -1 * tireWidth : tireWidth);
                file.WheelActors.Add(ca);
            }
            foreach (int id in file.NonDrivenWheelRefs)
            {
                BaseGroove g = file.Grooves.Find(a => a.Id == id);
                CActor actor = _actors.GetByName(g.ActorName);
                if (actor == null) continue;  //BUSTER.TXT does some weird shit for cockpit view of the front wheels
                CWheelActor ca = new CWheelActor(actor, false, true);
                ca.Position = actor.Matrix.Translation + (ca.IsLeft ? -1 * tireWidth : tireWidth);
                file.WheelActors.Add(ca);
            }

            if (forDisplayOnly) _actors.RenderWheelsSeparately = false;
        }
        private void Initialize()
        {
            _behaviours = new PedestriansFile()._pedestrians;

            List<string> loadedFiles = new List<string>();
            foreach (PedestrianBehaviour behaviour in _behaviours)
            {
                if (!loadedFiles.Contains(behaviour.PixFile))
                {
                    PixFile pixFile = new PixFile(behaviour.PixFile);
                    _pixMaps.AddRange(pixFile.PixMaps);
                    loadedFiles.Add(behaviour.PixFile);
                }
            }

            foreach (PedestrianBehaviour behaviour in _behaviours)
            {
                foreach (PedestrianSequence seq in behaviour.Sequences)
                {
                    var allFrames = new List<PedestrianFrame>();
                    allFrames.AddRange(seq.InitialFrames);
                    allFrames.AddRange(seq.LoopingFrames);

                    foreach (PedestrianFrame frame in allFrames)
                    {
                        PixMap pix = _pixMaps.Find(a => a.Name.Equals(frame.PixName, StringComparison.InvariantCultureIgnoreCase));
                        if (pix == null)
                        {
                            PixFile pixFile = new PixFile(frame.PixName);
                            _pixMaps.AddRange(pixFile.PixMaps);
                            pix = pixFile.PixMaps.Find(a => a.Name.Equals(frame.PixName, StringComparison.InvariantCultureIgnoreCase));
                        }
                        if (pix != null)
                            frame.Texture = pix.Texture;
                    }
                }
            }

            CreateGeometry();
        }
Exemple #12
0
 private Texture2D GetTextureFromPixFile(string curFolder, string filename)
 {
     if (filename == "none") return null;
     PixFile pixFile = new PixFile(filename);
     if (pixFile.PixMaps.Count > 0)
         return pixFile.PixMaps[0].Texture;
     return null;
 }
Exemple #13
0
        public Race(string filename, string playerVehicleFile)
        {
            Race.Current = this;

            Logger.Log("Starting race " + Path.GetFileName(filename));

            ConfigFile = new RaceFile(filename);

            foreach (string matFileName in ConfigFile.MaterialFiles)
            {
                MatFile matFile = new MatFile(matFileName);
                ResourceCache.Add(matFile);
            }

            foreach (string pixFileName in ConfigFile.PixFiles)
            {
                PixFile pixFile = new PixFile(pixFileName);
                ResourceCache.Add(pixFile);
            }

            if (GameVars.Emulation == EmulationMode.Demo)
                ResourceCache.Add(new CMaterial("drkcurb.mat", 226)); //demo doesn't have this file, I guess the color is hard-coded
            else
                ResourceCache.Add(new MatFile("drkcurb.mat"));

            ResourceCache.ResolveMaterials();

            if (filename.Contains("TESTMAP")) //nasty hack...
                GameVars.Scale.Y *= 0.5f;

            DatFile modelFile = new DatFile(ConfigFile.ModelFile);

            ActFile actFile = new ActFile(ConfigFile.ActorFile);
            _actors = actFile.Hierarchy;
            _actors.AttachModels(modelFile.Models);
            _actors.ResolveTransforms(false, ConfigFile.Grooves);

            if (filename.Contains("TESTMAP")) //nasty hack...
                GameVars.Scale.Y *= 2f;

            // link the actors and grooves
            foreach (BaseGroove g in ConfigFile.Grooves)
                g.SetActor(_actors.GetByName(g.ActorName));

            // link the funks and materials
            foreach (BaseFunk f in ConfigFile.Funks)
            {
                f.Resolve();
            }

            if (ConfigFile.SkyboxTexture != "none")
            {
                PixFile horizonPix = new PixFile(ConfigFile.SkyboxTexture);
                _skybox = SkyboxGenerator.Generate(horizonPix.PixMaps[0].Texture, ConfigFile.SkyboxRepetitionsX - 3f, ConfigFile.DepthCueMode);
                _skybox.HeightOffset = -220 + ConfigFile.SkyboxPositionY * 1.5f;
            }

            Physics.TrackProcessor.GenerateTrackActor(ConfigFile, _actors, out _nonCars);

            Logger.Log("NonCars: " + _nonCars.Count);

            GridPlacer.Reset();

            List<int> opponentIds = new List<int>();
            List<int> pickedNbrs = new List<int>();
            for (int i = 0; i < 5; i++)
            {
                int index = 0;
                while (true)
                {
                    index = Engine.Random.Next(1, OpponentsFile.Instance.Opponents.Count);
                    if (!pickedNbrs.Contains(index))
                    {
                        pickedNbrs.Add(index);
                        break;
                    }
                }
                try
                {
                    Opponents.Add(new Opponent(OpponentsFile.Instance.Opponents[index].FileName, ConfigFile.GridPosition, ConfigFile.GridDirection));
                    NbrOpponents++;
                }
                catch(Exception ex)
                {
                    Logger.Log("Error while loading opponent " + OpponentsFile.Instance.Opponents[index].FileName + ", " + ex.Message);
                }
            }

            foreach (CopStartPoint point in ConfigFile.CopStartPoints)
            {
                Opponents.Add(new Opponent(point.IsSpecialForces ? "bigapc.txt" : "apc.txt", point.Position, 0, new CopDriver()));
            }

            foreach (Opponent o in Opponents) Drivers.Add(o.Driver);

            OpponentController.Nodes = ConfigFile.OpponentPathNodes;

            PlayerVehicle = new Vehicle(GameVars.BasePath + @"cars\" + playerVehicleFile, new PlayerDriver());
            PlayerVehicle.PlaceOnGrid(ConfigFile.GridPosition, ConfigFile.GridDirection);
            Drivers.Add(PlayerVehicle.Driver);

            Peds = new PedestrianController(ConfigFile.Peds);
            _map = new RaceMap(this);

            RaceTime = new RaceTimeController();

            PhysX.Instance.Scene.SetActorGroupPairFlags(PhysXConsts.TrackId, PhysXConsts.VehicleId, ContactPairFlag.Forces | ContactPairFlag.OnStartTouch | ContactPairFlag.OnTouch);
            PhysX.Instance.Scene.SetActorGroupPairFlags(PhysXConsts.VehicleId, PhysXConsts.NonCarId, ContactPairFlag.Forces | ContactPairFlag.OnStartTouch | ContactPairFlag.OnTouch);
            PhysX.Instance.Scene.SetActorGroupPairFlags(PhysXConsts.TrackId, PhysXConsts.NonCarId, ContactPairFlag.OnTouch);
            PhysX.Instance.Scene.SetActorGroupPairFlags(PhysXConsts.VehicleId, PhysXConsts.VehicleId, ContactPairFlag.Forces | ContactPairFlag.OnTouch | ContactPairFlag.OnStartTouch | ContactPairFlag.OnEndTouch);
        }