示例#1
0
            public Int32 CompareTo(Object obj)
            {
                SpawnerMatch tmpObj = (SpawnerMatch)obj;

                return(-this.Distance.CompareTo(tmpObj.Distance));
            }
示例#2
0
        // Searches for spawners and returns struct list containing
        // relevant detail

        public static ArrayList FindMobSpawners(string searchtext, int x, int y, int tilerange)
        {
            ArrayList SpawnerList   = new ArrayList();
            Regex     SearchPattern = new Regex(searchtext.ToLower());

            // Loop through mobiles and check for Spawners

            foreach (Item item in World.Items.Values)
            {
                if (item is Server.Mobiles.Spawner)
                {
                    Spawner sp = (Spawner)item;

                    // Now check range / ignore range accordingly

                    int spX = sp.Location.X - x;
                    int spY = sp.Location.Y - y;

                    if ((tilerange == 0) || (
                            (sqr(sp.Location.X - x) <= sqr(tilerange) &&
                             sqr(sp.Location.Y - y) <= sqr(tilerange))
                            ))
                    {
                        // Loop through spawners' creature list and match
                        // against search text

                        foreach (string CreatureName in sp.CreaturesName)
                        {
                            if (SearchPattern.IsMatch(CreatureName.ToLower()))
                            {
                                SpawnerMatch ms = new SpawnerMatch();

                                ms.Item = false;
                                ms.Sp   = sp;

                                // Check if item type

                                Type   TestType = SpawnerType.GetType(CreatureName);
                                string strTest  = TestType.ToString();

                                Regex InvalidPatt = new Regex("^Server.Item");

                                if (InvalidPatt.IsMatch(strTest))
                                {
                                    ms.Item = true;
                                }
                                // We have a match! Create new match struct
                                // and add to return reference list

                                if (sp.Running == true)
                                {
                                    ms.Status = "on";
                                }
                                else
                                {
                                    ms.Status = "off";
                                }

                                ms.Matched  = CreatureName;
                                ms.Distance = (int)Math.Sqrt(sqr(spX) + sqr(spY));

                                SpawnerList.Add(ms);
                            }
                        }
                    }
                }

                if (item is Server.Items.ChestItemSpawner)
                {
                    ChestItemSpawner sp = (ChestItemSpawner)item;

                    // Now check range / ignore range accordingly

                    int spX = sp.Location.X - x;
                    int spY = sp.Location.Y - y;

                    if ((tilerange == 0) || (
                            (sqr(sp.Location.X - x) <= sqr(tilerange) &&
                             sqr(sp.Location.Y - y) <= sqr(tilerange))
                            ))
                    {
                        // Loop through spawners' creature list and match
                        // against search text

                        foreach (string ItemName in sp.ItemsName)
                        {
                            if (SearchPattern.IsMatch(ItemName.ToLower()))
                            {
                                SpawnerMatch ms = new SpawnerMatch();

                                ms.Item = false;
                                ms.Sp   = sp;

                                // Check if item type

                                Type   TestType = SpawnerType.GetType(ItemName);
                                string strTest  = TestType.ToString();

                                Regex InvalidPatt = new Regex("^Server.Item");

                                if (InvalidPatt.IsMatch(strTest))
                                {
                                    ms.Item = true;
                                }
                                // We have a match! Create new match struct
                                // and add to return reference list

                                if (sp.Running == true)
                                {
                                    ms.Status = "on";
                                }
                                else
                                {
                                    ms.Status = "off";
                                }

                                ms.Matched  = ItemName;
                                ms.Distance = (int)Math.Sqrt(sqr(spX) + sqr(spY));

                                SpawnerList.Add(ms);
                            }
                        }
                    }
                }
            }

            return(SpawnerList);
        }