コード例 #1
0
        private static SpawnPoint GetSpawn(string location)
        {
            if (Xml.Root.XPathSelectElement(Root + location + "x").Value == "null")
            {
                return(SpawnPoint.Zero);
            }

            var sp = new SpawnPoint
            {
                Position =
                    new Vector3(
                        float.Parse(Xml.Root.XPathSelectElement(Root + location + "x").Value, NumberStyles.Float, CultureInfo.InvariantCulture),
                        float.Parse(Xml.Root.XPathSelectElement(Root + location + "y").Value, NumberStyles.Float, CultureInfo.InvariantCulture),
                        float.Parse(Xml.Root.XPathSelectElement(Root + location + "z").Value, NumberStyles.Float, CultureInfo.InvariantCulture))
            };

            try
            {
                sp.Heading = float.Parse(Xml.Root.XPathSelectElement(Root + location + "h").Value, NumberStyles.Float, CultureInfo.InvariantCulture);
            }
            catch
            {
                sp.Heading = 0;
            }
            return(sp);
        }
コード例 #2
0
        private static void LoadXml()
        {
            try
            {
                "Retreiving XML Data".AddLog();
                Xml = XDocument.Load(Xmlpath);
                ("XML Loaded from " + Xmlpath).AddLog();

                var count = XDocument.Load(Xmlpath).XPathSelectElements("CSI/Location").Count();
                ("Number of Locations: " + count.ToString()).AddLog();

                var l = Rand.RandomNumber(6);
                switch (l)
                {
                case 0:
                    Root = "CSI/Location/Storage";
                    break;

                case 1:
                    Root = "CSI/Location/Alta";
                    break;

                case 2:
                    Root = "CSI/Location/Greenwich";
                    break;

                case 3:
                    Root = "CSI/Location/Grove";
                    break;

                case 4:
                    Root = "CSI/Location/LaborPl";
                    break;

                case 5:
                    Root = "CSI/Location/NorthRockfordDr";
                    break;
                }
                $"Scene: {Root}".AddLog(true);
                var sp = GetSpawn("/Victim/");
                Victim = new DeadBody("Vic", "Victim", sp, Vmodel[Rand.RandomNumber(Vmodel.Length)]);
                "Victim created".AddLog();

                OfficerNum = Rand.RandomNumber(1, 5);
                VehicleNum = Rand.RandomNumber(0, 4);
                FbiNum     = Rand.RandomNumber(0, 3);
                PedNum     = Rand.RandomNumber(0, 6);

                ("Victim Model: " + Victim.Ped.Model.Name).AddLog();

                if (Xml.Root.XPathSelectElement(Root + "/Officers/FirstOfficer/x").Value != "null")
                {
                    var spawn = GetSpawn("/Officers/FirstOfficer/");

                    FirstOfficer = new StageObject("s_m_y_cop_01", spawn.Position, spawn.Heading);

                    FirstOfficer.Ped.MakeMissionPed();
                    Functions.SetCopAsBusy(FirstOfficer.Ped, true);

                    FirstOfficer.Exists = true;

                    ObjectList.Add(FirstOfficer);
                }
                ("FirstOfficer.Exists = " + FirstOfficer.Exists).AddLog();

                CreateStage_Object(Officer1, "/Officers/Officer1/", ObjectType.Cop);

                CreateStage_Object(Officer2, "/Officers/Officer2/", ObjectType.Cop);

                CreateStage_Object(Officer3, "/Officers/Officer3/", ObjectType.Cop);

                CreateStage_Object(Officer4, "/Officers/Officer4/", ObjectType.Cop);

                _W1SpawnPoint = new SpawnPoint(GetSpawn("/Witnesses/Witness1/").Heading,
                                               GetSpawn("/Witnesses/Witness1/").Position);

                _W2SpawnPoint = new SpawnPoint(GetSpawn("/Witnesses/Witness2/").Heading,
                                               GetSpawn("/Witnesses/Witness2/").Position);

                CreateStage_Object(PoliceCar1, "/Vehicles/Vehicle1/", ObjectType.Vehicle);

                CreateStage_Object(PoliceCar2, "/Vehicles/Vehicle2/", ObjectType.Vehicle);

                CreateStage_Object(PoliceCar3, "/Vehicles/Vehicle3/", ObjectType.Vehicle);

                CreateStage_Object(Fbi1, "/Ambient/FBI1/", ObjectType.Cop);

                CreateStage_Object(Fbi2, "/Ambient/FBI2/", ObjectType.Cop);

                CreateStage_Object(Ped1, "/Ambient/Ped1/", ObjectType.Ped);

                CreateStage_Object(Ped2, "/Ambient/Ped2/", ObjectType.Ped);

                CreateStage_Object(Ped3, "/Ambient/Ped3/", ObjectType.Ped);

                CreateStage_Object(Ped4, "/Ambient/Ped4/", ObjectType.Ped);

                CreateStage_Object(Ped5, "/Ambient/Ped5/", ObjectType.Ped);

                EmsQueue = new Queue <SpawnPoint>();
                EmsQueue.Enqueue(GetSpawn("/EMS/Queue/"));

                EmsLast = GetSpawn("/EMS/FinalPos/");

                SecCamSpawnPoint = GetSpawn("/Camera/");
                SusSpawnPoint    = GetSpawn("/SusSpawn/");
                SusTargetPoint   = GetSpawn("/SusTarget/");

                $" ***SPAWNPOINTS*** {SecCamSpawnPoint.Position.X} {SusSpawnPoint.Position.X} {SusTargetPoint.Position.X} ".AddLog(true);

                loadCreated = true;
            }
            catch (Exception e)
            {
                e.ToString().AddLog(true);
            }
        }