コード例 #1
0
        private static Vehicle newVehicle(Garage i_Garage)
        {
            Vehicle       newVehicle  = null;
            eVehicleTypes vehicleType = ChooseVehicle();
            string        userInput;
            bool          checkInput = true;
            Dictionary <string, string> properites = VehicleSetup.BuiltPropertiesList(vehicleType);

            Printer.PrintSystemFormat("\n{0} Details:\n", vehicleType);
            foreach (KeyValuePair <string, string> str in properites)
            {
                while (checkInput)
                {
                    Printer.PrintMessage(str.Key + ": ");
                    userInput = Console.ReadLine();
                    try
                    {
                        if (VehicleSetup.CheckProperty(i_Garage, userInput, str.Key, str.Value))
                        {
                            m_SetProperites.Add(str.Key, userInput);
                            checkInput = false;
                        }
                    }

                    catch (FormatException fx)
                    {
                        Printer.PrintError(fx.Message + "\n");
                    }
                    catch (ArgumentException ae)
                    {
                        Printer.PrintError(ae.Message + "\n");
                    }
                }

                checkInput = true;
            }

            newVehicle = VehicleSetup.CreateNewVehicle(i_Garage, vehicleType, m_SetProperites);

            return(newVehicle);
        }
コード例 #2
0
        public static void OpenVehicle(string path)
        {
            SceneManager.Current.SetCoordinateSystem(CoordinateSystem.LeftHanded);

            SceneManager.Current.Reset();

            string assetFolder = Path.GetDirectoryName(path);

            Model vehicle = (Model)SceneManager.Current.Add(SceneManager.Current.Content.Load <Model, CNTImporter>(Path.GetFileName(path), assetFolder));

            // Load supporting documents
            if (File.Exists(Path.Combine(assetFolder, "setup.lol")))
            {
                vehicle.SupportingDocuments["Setup"] = Setup.Load(Path.Combine(assetFolder, "setup.lol"));
            }
            if (File.Exists(Path.Combine(assetFolder, "Structure.xml")))
            {
                List <string> findMaterials(StructurePart part)
                {
                    List <string> materials = new List <string>();

                    materials.AddRange(part.DamageSettings.Methods.Where(m => m.Name == "CrushDamageMaterial" && m.HasBeenSet).Select(m => m.Parameters[2].Value.ToString()));

                    foreach (StructurePart child in part.Parts)
                    {
                        materials.AddRange(findMaterials(child));
                    }

                    return(materials);
                }

                Structure structure = Structure.Load(Path.Combine(assetFolder, "Structure.xml"));

                foreach (string material in findMaterials(structure.Root))
                {
                    SceneManager.Current.Content.Load <Material, MT2Importer>(material, assetFolder, true);
                }

                vehicle.SupportingDocuments["Structure"] = structure;
            }

            if (File.Exists(Path.Combine(assetFolder, "SystemsDamage.xml")))
            {
                vehicle.SupportingDocuments["SystemsDamage"] = SystemsDamage.Load(Path.Combine(assetFolder, "SystemsDamage.xml"));
            }

            if (File.Exists(Path.Combine(assetFolder, "vehicle_setup.cfg")))
            {
                vehicle.SupportingDocuments["VehicleSetupConfig"] = VehicleSetupConfig.Load(Path.Combine(assetFolder, "vehicle_setup.cfg"));

                foreach (VehicleMaterialMap materialMap in vehicle.GetSupportingDocument <VehicleSetupConfig>("VehicleSetupConfig").MaterialMaps)
                {
                    foreach (KeyValuePair <string, string> kvp in materialMap.Substitutions)
                    {
                        SceneManager.Current.Content.Load <Material, MT2Importer>(kvp.Value, assetFolder, true);
                    }
                }
            }

            if (File.Exists(Path.Combine(assetFolder, "vehicle_setup.lol")))
            {
                vehicle.SupportingDocuments["VehicleSetup"] = VehicleSetup.Load(Path.Combine(assetFolder, "vehicle_setup.lol"));
            }
            if (File.Exists(Path.Combine(assetFolder, "vfx_anchors.lol")))
            {
                vehicle.SupportingDocuments["VFXAnchors"] = VFXAnchors.Load(Path.Combine(assetFolder, "vfx_anchors.lol"));
            }

            if (File.Exists(Path.Combine(assetFolder, "collision.cnt")))
            {
                vehicle.SupportingDocuments["Collision"] = SceneManager.Current.Content.Load <Model, CNTImporter>("collision.cnt", assetFolder);
            }
            if (File.Exists(Path.Combine(assetFolder, "opponent_collision.cnt")))
            {
                vehicle.SupportingDocuments["OpponentCollision"] = SceneManager.Current.Content.Load <Model, CNTImporter>("opponent_collision.cnt", assetFolder);
            }

            //if (File.Exists(assetFolder + "CrashSoundsConfig_Car.xml")) { vehicle.SupportingDocuments["SystemsDamage"] = SystemsDamage.Load(assetFolder + "SystemsDamage.xml"); }

            foreach (ModelBone bone in vehicle.Bones)
            {
                string boneName = bone.Name.ToLower();

                // Name = bone.Name

                if (boneName.StartsWith("wheel_"))
                {
                    Core.Entities.Wheel wheel = new Core.Entities.Wheel();
                    wheel.LinkWith(bone);
                    SceneManager.Current.Entities.Add(wheel);
                }
                else if (boneName.StartsWith("vfx_"))
                {
                    VFX vfx = new VFX();
                    vfx.LinkWith(bone);
                    SceneManager.Current.Entities.Add(vfx);
                }
                else if (boneName.StartsWith("driver"))
                {
                    Driver driver = new Driver();
                    driver.LinkWith(bone);
                    SceneManager.Current.Entities.Add(driver);
                }
            }

            SceneManager.Current.SetContext("Carmageddon Max Damage", ContextMode.Car);
        }