Esempio n. 1
0
            private void ImportMegaSpawner(XmlNode node, string fileName)
            {
                int errors = 0;

                amountOfSpawners++;

                Map     map      = null;
                Point3D location = new Point3D();

                MegaSpawner megaSpawner = new MegaSpawner();

                megaSpawner.Imported      = MC.CropDirectory(fileName.ToLower());
                megaSpawner.ImportVersion = version;
                megaSpawner.Editor        = null;
                megaSpawner.Workspace     = false;

                double ver;

                try{ ver = Convert.ToDouble(version); }
                catch { ver = 0.0; }

                try{ megaSpawner.Name = GetInnerText(node["Name"]); }
                catch { errors++; totalErrors++; }

                try{ megaSpawner.Active = bool.Parse(GetInnerText(node["Active"])); }
                catch { errors++; totalErrors++; }

                try{ map = Map.Parse(GetInnerText(node["Map"])); }
                catch { errors++; totalErrors++; }

                try{ location = Point3D.Parse(GetInnerText(node["Location"])); }
                catch { errors++; totalErrors++; }

                XmlElement entryLists = null;

                try{ entryLists = node["EntryLists"]; }
                catch { errors++; totalErrors++; }

                if (entryLists != null)
                {
                    int cnt = 0;

                    try
                    {
                        foreach (XmlElement entry in entryLists.GetElementsByTagName("EntryList"))
                        {
                            string entryCompare = null;

                            try{ entryCompare = GetInnerText(entry["EntryType"]); }
                            catch { errors++; totalErrors++; }

                            int entryCount = 0;

                            for (int i = 0; i < megaSpawner.EntryList.Count; i++)
                            {
                                string entryType = (string)megaSpawner.EntryList[i];

                                if (entryType.ToLower() == entryCompare.ToLower())
                                {
                                    entryCount++;
                                }
                            }

                            if (entryCount == 0)
                            {
                                megaSpawner.EntryList.Add(entryCompare);
                            }

                            try{ megaSpawner.SpawnRangeList.Add(int.Parse(GetInnerText(entry["SpawnRange"]))); }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.WalkRangeList.Add(int.Parse(GetInnerText(entry["WalkRange"]))); }
                            catch { errors++; totalErrors++; }

                            try
                            {
                                int amount = int.Parse(GetInnerText(entry["Amount"]));

                                if (amount == 0)
                                {
                                    amount = 1;
                                }

                                megaSpawner.AmountList.Add(amount);
                            }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.MinDelayList.Add(int.Parse(GetInnerText(entry["MinDelay"]))); }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.MaxDelayList.Add(int.Parse(GetInnerText(entry["MaxDelay"]))); }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.SpawnTypeList.Add(int.Parse(GetInnerText(entry["SpawnType"]))); }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.ActivatedList.Add(bool.Parse(GetInnerText(entry["Activated"]))); }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.EventRangeList.Add(int.Parse(GetInnerText(entry["EventRange"]))); }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.EventKeywordList.Add(GetInnerText(entry["EventKeyword"])); }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.KeywordCaseSensitiveList.Add(bool.Parse(GetInnerText(entry["KeywordCaseSensitive"]))); }
                            catch { megaSpawner.KeywordCaseSensitiveList.Add((bool)false); exceptions++; }

                            megaSpawner.TriggerEventNowList.Add((bool)true);

                            try{ megaSpawner.EventAmbushList.Add(bool.Parse(GetInnerText(entry["EventAmbush"]))); }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.BeginTimeBasedList.Add(int.Parse(GetInnerText(entry["BeginTimeBased"]))); }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.EndTimeBasedList.Add(int.Parse(GetInnerText(entry["EndTimeBased"]))); }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.GroupSpawnList.Add(bool.Parse(GetInnerText(entry["GroupSpawn"]))); }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.MinStackAmountList.Add(int.Parse(GetInnerText(entry["MinStackAmount"]))); }
                            catch { megaSpawner.MinStackAmountList.Add(1); exceptions++; }

                            try{ megaSpawner.MaxStackAmountList.Add(int.Parse(GetInnerText(entry["MaxStackAmount"]))); }
                            catch { megaSpawner.MaxStackAmountList.Add(1); exceptions++; }

                            if (ver < 3.2)
                            {
                                try{ megaSpawner.MovableList.Add(bool.Parse(GetInnerText(entry["ItemMovable"]))); }
                                catch { megaSpawner.MovableList.Add((bool)true); exceptions++; }
                            }
                            else
                            {
                                try{ megaSpawner.MovableList.Add(bool.Parse(GetInnerText(entry["Movable"]))); }
                                catch { megaSpawner.MovableList.Add((bool)true); exceptions++; }
                            }

                            if (ver >= 3.5)
                            {
                                try{ megaSpawner.MinDespawnList.Add(int.Parse(GetInnerText(entry["MinDespawn"]))); }
                                catch { errors++; totalErrors++; }

                                try{ megaSpawner.MaxDespawnList.Add(int.Parse(GetInnerText(entry["MaxDespawn"]))); }
                                catch { errors++; totalErrors++; }

                                try{ megaSpawner.DespawnList.Add(bool.Parse(GetInnerText(entry["Despawn"]))); }
                                catch { errors++; totalErrors++; }

                                try{ megaSpawner.DespawnGroupList.Add(bool.Parse(GetInnerText(entry["DespawnGroup"]))); }
                                catch { errors++; totalErrors++; }

                                try{ megaSpawner.DespawnTimeExpireList.Add(bool.Parse(GetInnerText(entry["DespawnTimeExpire"]))); }
                                catch { errors++; totalErrors++; }
                            }
                            else
                            {
                                megaSpawner.MinDespawnList.Add(1800);
                                megaSpawner.MaxDespawnList.Add(3600);
                                megaSpawner.DespawnList.Add((bool)false);
                                megaSpawner.DespawnGroupList.Add((bool)false);
                                megaSpawner.DespawnTimeExpireList.Add((bool)true);
                            }

                            cnt++;
                        }
                    }
                    catch { errors++; totalErrors++; }
                }

                XmlElement settingsList = null;

                try{ settingsList = node["SettingsList"]; }
                catch { errors++; totalErrors++; }

                if (settingsList != null)
                {
                    if (ver >= 3.6)
                    {
                        try
                        {
                            foreach (XmlElement setting in settingsList.GetElementsByTagName("OverrideIndividualEntries"))
                            {
                                int err = errors;

                                ArrayList List = new ArrayList();

                                List.Add(Setting.OverrideIndividualEntries);

                                try{ List.Add(int.Parse(GetInnerText(setting["SpawnRange"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["WalkRange"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["Amount"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["MinDelay"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["MaxDelay"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(bool.Parse(GetInnerText(setting["GroupSpawn"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(bool.Parse(GetInnerText(setting["EventAmbush"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add((SpawnType)int.Parse(GetInnerText(setting["SpawnType"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(GetInnerText(setting["EventKeyword"])); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(bool.Parse(GetInnerText(setting["CaseSensitive"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["EventRange"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["BeginTimeBasedHour"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["BeginTimeBasedMinute"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["EndTimeBasedHour"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["EndTimeBasedMinute"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["MinDespawn"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["MaxDespawn"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(bool.Parse(GetInnerText(setting["Despawn"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(bool.Parse(GetInnerText(setting["DespawnGroup"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(bool.Parse(GetInnerText(setting["DespawnTimeExpire"]))); }
                                catch { errors++; totalErrors++; }

                                if (err == errors)
                                {
                                    megaSpawner.SettingsList.Add(List);
                                }
                            }
                        }
                        catch {}

                        try
                        {
                            foreach (XmlElement setting in settingsList.GetElementsByTagName("AddItemSetting"))
                            {
                                int err = errors;

                                ArrayList List = new ArrayList();

                                List.Add(Setting.AddItem);

                                try{ List.Add(GetInnerText(setting["EntryName"])); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["EntryIndex"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(GetInnerText(setting["AddItem"])); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["MinStackAmount"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["MaxStackAmount"]))); }
                                catch { errors++; totalErrors++; }

                                if (err == errors)
                                {
                                    megaSpawner.SettingsList.Add(List);
                                }
                            }
                        }
                        catch {}

                        try
                        {
                            foreach (XmlElement setting in settingsList.GetElementsByTagName("AddContainerSetting"))
                            {
                                int err = errors;

                                ArrayList List = new ArrayList();

                                List.Add(Setting.AddContainer);

                                try{ List.Add(GetInnerText(setting["EntryName"])); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["EntryIndex"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(GetInnerText(setting["AddItem"])); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["MinStackAmount"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["MaxStackAmount"]))); }
                                catch { errors++; totalErrors++; }

                                XmlElement contList = null;

                                try{ contList = setting["ContainerItems"]; }
                                catch { errors++; totalErrors++; }

                                try
                                {
                                    foreach (XmlElement contItem in contList.GetElementsByTagName("ContainerItem"))
                                    {
                                        ArrayList ItemsList = new ArrayList();

                                        try{ ItemsList.Add(GetInnerText(contItem["AddItem"])); }
                                        catch { errors++; totalErrors++; }

                                        try{ ItemsList.Add(int.Parse(GetInnerText(contItem["MinStackAmount"]))); }
                                        catch { errors++; totalErrors++; }

                                        try{ ItemsList.Add(int.Parse(GetInnerText(contItem["MaxStackAmount"]))); }
                                        catch { errors++; totalErrors++; }

                                        List.Add(ItemsList);
                                    }
                                }
                                catch {}

                                if (err == errors)
                                {
                                    megaSpawner.SettingsList.Add(List);
                                }
                            }
                        }
                        catch {}
                    }
                    else
                    {
                        foreach (XmlElement setting in settingsList.GetElementsByTagName("Setting"))
                        {
                            try{ megaSpawner.SettingsList.Add(setting.InnerText); }
                            catch { errors++; totalErrors++; }
                        }

                        megaSpawner.ConvertOldSettings();
                    }
                }

                if (errors > 0)
                {
                    megaSpawner.Delete();

                    amountOfSpawners--;
                }
                else
                {
                    megaSpawner.MoveToWorld(location, map);

                    if (location.Z == -999)
                    {
                        megaSpawner.Location = GetLocation(megaSpawner, location);
                    }

                    if (megaSpawner.Location.Z == -999)
                    {
                        megaSpawner.Delete();

                        amountOfSpawners--;
                        autoFailures++;

                        return;
                    }

                    megaSpawner.CheckDupedSettings();
                    megaSpawner.CompileSettings();

                    megaSpawner.SettingsList.Sort(new MC.SettingsSorter());

                    if (megaSpawner.OverrideIndividualEntries)
                    {
                        for (int i = 0; i < megaSpawner.OverrideAmount; i++)
                        {
                            megaSpawner.OverrideRespawnEntryList.Add("");
                            megaSpawner.OverrideRespawnTimeList.Add(0);
                            megaSpawner.OverrideSpawnCounterList.Add(DateTime.Now);
                            megaSpawner.OverrideSpawnTimeList.Add(0);
                            megaSpawner.OverrideDespawnTimeList.Add(0);
                        }
                    }
                    else
                    {
                        for (int i = 0; i < megaSpawner.EntryList.Count; i++)
                        {
                            ArrayList respawnEntryList  = new ArrayList();
                            ArrayList respawnTimeList   = new ArrayList();
                            ArrayList spawnCounterList  = new ArrayList();
                            ArrayList spawnTimeList     = new ArrayList();
                            ArrayList respawnOnSaveList = new ArrayList();
                            ArrayList despawnTimeList   = new ArrayList();

                            for (int j = 0; j < (int)megaSpawner.AmountList[i]; j++)
                            {
                                respawnEntryList.Add((string)megaSpawner.EntryList[i]);
                                respawnTimeList.Add(0);
                                spawnCounterList.Add(DateTime.Now);
                                spawnTimeList.Add(0);
                                respawnOnSaveList.Add((bool)false);
                                despawnTimeList.Add(0);
                            }

                            megaSpawner.RespawnEntryList.Add(respawnEntryList);
                            megaSpawner.RespawnTimeList.Add(respawnTimeList);
                            megaSpawner.SpawnCounterList.Add(spawnCounterList);
                            megaSpawner.SpawnTimeList.Add(spawnTimeList);
                            megaSpawner.RespawnOnSaveList.Add(respawnOnSaveList);
                            megaSpawner.DespawnTimeList.Add(despawnTimeList);
                            megaSpawner.SpawnedEntries.Add(new ArrayList());
                            megaSpawner.LastMovedList.Add(new ArrayList());
                        }
                    }

                    SpawnerList.Add(megaSpawner);

                    if (megaSpawner.Active)
                    {
                        megaSpawner.Respawn();
                    }

                    HideSpawnerList.Add((bool)false);
                    MSGCheckBoxesList.Add((bool)false);

                    MC.FileImportAdd(megaSpawner.Imported, megaSpawner.ImportVersion);
                }
            }