Beispiel #1
0
        private VehiclesSettings ReadVehiclesSettingsFromIniFile(string fileName)
        {
            VehiclesSettings v = new VehiclesSettings();

            v.ReadLegacy(fileName);
            return(v);
        }
Beispiel #2
0
        private void CreateDefaultVehiclesSettingsXMLFile(string fileName)
        {
            VehiclesSettings v = new VehiclesSettings
            {
                Data = new Dictionary <string, VehicleData>
                {
                    { "POLICE", new VehicleData(new XYZ(-0.8f, 1.17f, 0.45f)) },
                    { "POLICE2", new VehicleData(new XYZ(-0.84f, 0.85f, 0.43f)) },
                    { "POLICE3", new VehicleData(new XYZ(-0.84f, 0.78f, 0.5f)) },
                    { "POLICE4", new VehicleData(new XYZ(-0.8f, 1.17f, 0.45f)) },
                    { "POLICET", new VehicleData(new XYZ(-1.1f, 1.37f, 0.94f)) },
                    { "RIOT", new VehicleData(new XYZ(-1.18f, 1.65f, 1.55f)) },
                    { "FBI", new VehicleData(new XYZ(-0.84f, 0.71f, 0.44f)) },
                    { "FBI2", new VehicleData(new XYZ(-1.01f, 1.04f, 0.81f)) },
                    { "POLICEOLD1", new VehicleData(new XYZ(-0.95f, 0.71f, 0.75f)) },
                    { "POLICEOLD2", new VehicleData(new XYZ(-0.88f, 0.805f, 0.49f)) },
                    { "SHERIFF", new VehicleData(new XYZ(-0.8f, 1.17f, 0.45f)) },
                    { "SHERIFF2", new VehicleData(new XYZ(-0.92f, 1.16f, 0.925f)) },
                    { "PRANGER", new VehicleData(new XYZ(-0.92f, 1.16f, 0.925f)) },
                    { "LGUARD", new VehicleData(new XYZ(-1.01f, 1.04f, 0.81f)) },
                    { "POLMAV", new VehicleData(new XYZ(0.0f, 0.0f, 0.0f)) },
                    { "BUZZARD", new VehicleData(new XYZ(0.0f, 2.34f, -0.36f)) },
                    { "BUZZARD2", new VehicleData(new XYZ(0.0f, 2.34f, -0.36f)) },
                    { "PREDATOR", new VehicleData(new XYZ(0.0f, -0.43f, 1.77f)) },
                }
            };

            XmlSerializer ser = new XmlSerializer(typeof(VehiclesSettings));

            using (StreamWriter writer = new StreamWriter(fileName, false))
            {
                ser.Serialize(writer, v);
            }
        }
Beispiel #3
0
        private void CreateDefaultVehiclesSettingsFile(string fileName, bool legacy)
        {
            VehiclesSettings v = new VehiclesSettings
            {
                Data = new Dictionary <string, VehicleData>
                {
                    { "POLICE", new VehicleData(new XYZ(-0.8f, 1.17f, 0.45f)) },
                    { "POLICE2", new VehicleData(new XYZ(-0.84f, 0.85f, 0.43f)) },
                    { "POLICE3", new VehicleData(new XYZ(-0.84f, 0.78f, 0.5f), VehicleData.DefaultDisableTurret, 1) },
                    { "POLICE4", new VehicleData(new XYZ(-0.8f, 1.17f, 0.45f)) },
                    { "POLICET", new VehicleData(new XYZ(-1.1f, 1.37f, 0.94f)) },
                    { "RIOT", new VehicleData(new XYZ(-1.18f, 1.65f, 1.55f)) },
                    { "FBI", new VehicleData(new XYZ(-0.84f, 0.71f, 0.44f)) },
                    { "FBI2", new VehicleData(new XYZ(-1.01f, 1.04f, 0.81f)) },
                    { "POLICEOLD1", new VehicleData(new XYZ(-0.95f, 0.71f, 0.75f)) },
                    { "POLICEOLD2", new VehicleData(new XYZ(-0.88f, 0.805f, 0.49f)) },
                    { "SHERIFF", new VehicleData(new XYZ(-0.8f, 1.17f, 0.45f)) },
                    { "SHERIFF2", new VehicleData(new XYZ(-0.92f, 1.16f, 0.925f)) },
                    { "PRANGER", new VehicleData(new XYZ(-0.92f, 1.16f, 0.925f)) },
                    { "LGUARD", new VehicleData(new XYZ(-1.01f, 1.04f, 0.81f)) },
                    { "POLMAV", new VehicleData(new XYZ(0.0f, 0.0f, 0.0f)) },
                    { "BUZZARD", new VehicleData(new XYZ(0.0f, 0.0f, 0.0f)) },
                    { "BUZZARD2", new VehicleData(new XYZ(0.0f, 2.34f, -0.36f)) },
                    { "PREDATOR", new VehicleData(new XYZ(0.0f, -0.43f, 1.77f)) },
                }
            };

            if (legacy)
            {
                File.WriteAllLines(fileName, new[]
                {
                    // TODO: explain requirements for turret movement and DisableTurret option
                    "",
                });
                v.WriteLegacy(fileName);
            }
            else
            {
                XmlSerializer ser = new XmlSerializer(typeof(VehiclesSettings));
                using (StreamWriter writer = new StreamWriter(fileName, false))
                {
                    ser.Serialize(writer, v);
                }
            }
        }