コード例 #1
0
        private void ImportMegaSpawner(XmlElement node)
        {
            string text1 = ImportMSF.GetText(node["Name"], "MegaSpawner");

            bool.Parse(ImportMSF.GetText(node["Active"], "True"));
            MapLocation mapLocation = MapLocation.Parse(ImportMSF.GetText(node["Location"], "Error"));
            WorldMap    Map         = (WorldMap)Enum.Parse(typeof(WorldMap), ImportMSF.GetText(node["Map"], "Error"));
            string      path        = Path.Combine(this._Editor.StartingDirectory, "import.log");
            bool        flag1       = false;
            int         num1        = 0;
            int         num2        = 4;
            int         num3        = 4;
            TimeSpan    timeSpan1   = TimeSpan.FromMinutes(10.0);
            TimeSpan    timeSpan2   = TimeSpan.FromMinutes(5.0);
            XmlElement  xmlElement1 = node["EntryLists"];
            int         length      = 0;

            SpawnObject[] spawnObjectArray = (SpawnObject[])null;
            if (xmlElement1 != null)
            {
                if (xmlElement1.HasAttributes)
                {
                    length = int.Parse(xmlElement1.Attributes.GetNamedItem("count").Value);
                }
                if (length > 0)
                {
                    spawnObjectArray = new SpawnObject[length];
                    int  index = 0;
                    bool flag2 = false;
                    foreach (XmlElement xmlElement2 in xmlElement1.GetElementsByTagName("EntryList"))
                    {
                        if (xmlElement2 != null)
                        {
                            if (index == 0)
                            {
                                flag1     = bool.Parse(ImportMSF.GetText(xmlElement2["GroupSpawn"], "False"));
                                timeSpan1 = TimeSpan.FromSeconds((double)int.Parse(ImportMSF.GetText(xmlElement2["MaxDelay"], "10:00")));
                                timeSpan2 = TimeSpan.FromSeconds((double)int.Parse(ImportMSF.GetText(xmlElement2["MinDelay"], "05:00")));
                                num2      = int.Parse(ImportMSF.GetText(xmlElement2["WalkRange"], "10"));
                                num3      = int.Parse(ImportMSF.GetText(xmlElement2["SpawnRange"], "4"));
                            }
                            else
                            {
                                if (flag1 != bool.Parse(ImportMSF.GetText(xmlElement2["GroupSpawn"], "False")))
                                {
                                    flag2 = true;
                                    try
                                    {
                                        using (StreamWriter streamWriter = new StreamWriter(path, true))
                                            streamWriter.WriteLine("MSFimport : individual group entry difference: {0} vs {1}", (object)ImportMSF.GetText(xmlElement2["GroupSpawn"], "False"), (object)(flag1 ? 1 : 0));
                                    }
                                    catch
                                    {
                                    }
                                }
                                if (timeSpan2 != TimeSpan.FromSeconds((double)int.Parse(ImportMSF.GetText(xmlElement2["MinDelay"], "05:00"))))
                                {
                                    flag2 = true;
                                    try
                                    {
                                        using (StreamWriter streamWriter = new StreamWriter(path, true))
                                            streamWriter.WriteLine("MSFimport : individual mindelay entry difference: {0} vs {1}", (object)ImportMSF.GetText(xmlElement2["MinDelay"], "05:00"), (object)timeSpan2);
                                    }
                                    catch
                                    {
                                    }
                                }
                                if (timeSpan1 != TimeSpan.FromSeconds((double)int.Parse(ImportMSF.GetText(xmlElement2["MaxDelay"], "10:00"))))
                                {
                                    flag2 = true;
                                    try
                                    {
                                        using (StreamWriter streamWriter = new StreamWriter(path, true))
                                            streamWriter.WriteLine("MSFimport : individual maxdelay entry difference: {0} vs {1}", (object)ImportMSF.GetText(xmlElement2["MaxDelay"], "10:00"), (object)timeSpan1);
                                    }
                                    catch
                                    {
                                    }
                                }
                                if (num2 != int.Parse(ImportMSF.GetText(xmlElement2["WalkRange"], "10")))
                                {
                                    flag2 = true;
                                    try
                                    {
                                        using (StreamWriter streamWriter = new StreamWriter(path, true))
                                            streamWriter.WriteLine("MSFimport : individual homerange entry difference: {0} vs {1}", (object)ImportMSF.GetText(xmlElement2["WalkRange"], "10"), (object)num2);
                                    }
                                    catch
                                    {
                                    }
                                }
                                if (num3 != int.Parse(ImportMSF.GetText(xmlElement2["SpawnRange"], "4")))
                                {
                                    flag2 = true;
                                    try
                                    {
                                        using (StreamWriter streamWriter = new StreamWriter(path, true))
                                            streamWriter.WriteLine("MSFimport : individual spawnrange entry difference: {0} vs {1}", (object)ImportMSF.GetText(xmlElement2["SpawnRange"], "4"), (object)num3);
                                    }
                                    catch
                                    {
                                    }
                                }
                            }
                            int    maxamount = int.Parse(ImportMSF.GetText(xmlElement2["Amount"], "1"));
                            string text2     = ImportMSF.GetText(xmlElement2["EntryType"], "");
                            num1 += maxamount;
                            spawnObjectArray[index] = new SpawnObject(text2, maxamount);
                            ++index;
                            if (index > length)
                            {
                                try
                                {
                                    using (StreamWriter streamWriter = new StreamWriter(path, true))
                                    {
                                        streamWriter.WriteLine("{0} MSFImport Error; inconsistent entry count {1} {2}", (object)DateTime.Now, (object)mapLocation, (object)Map);
                                        streamWriter.WriteLine();
                                        break;
                                    }
                                }
                                catch
                                {
                                    break;
                                }
                            }
                        }
                    }
                    if (flag2)
                    {
                        try
                        {
                            using (StreamWriter streamWriter = new StreamWriter(path, true))
                            {
                                streamWriter.WriteLine("{0} MSFImport: Individual entry setting differences listed above from spawner at {1} {2}", (object)DateTime.Now, (object)mapLocation, (object)Map);
                                streamWriter.WriteLine();
                            }
                        }
                        catch
                        {
                        }
                    }
                }
            }
            if (mapLocation.Z == -999)
            {
                mapLocation.Z = (int)short.MinValue;
            }
            SpawnPoint Spawn = new SpawnPoint(Guid.NewGuid(), Map, (short)mapLocation.X, (short)mapLocation.Y, (short)(num3 * 2), (short)(num3 * 2));

            Spawn.SpawnName      = text1;
            Spawn.SpawnHomeRange = num2;
            Spawn.CentreZ        = (short)mapLocation.Z;
            Spawn.SpawnMinDelay  = timeSpan2.TotalMinutes;
            Spawn.SpawnMaxDelay  = timeSpan1.TotalMinutes;
            Spawn.SpawnMaxCount  = num1;
            Spawn.SpawnIsGroup   = flag1;
            Spawn.IsSelected     = false;
            for (int index = 0; index < spawnObjectArray.Length; ++index)
            {
                Spawn.SpawnObjects.Add((object)spawnObjectArray[index]);
            }
            this._Editor.tvwSpawnPoints.Nodes.Add((TreeNode) new SpawnPointNode(Spawn));
        }