コード例 #1
0
        public SpawnEntry(int id, BaseRegion region, Point3D home, int range, Direction direction, SpawnDefinition definition, int max, TimeSpan minSpawnTime, TimeSpan maxSpawnTime)
        {
            m_ID             = id;
            m_Region         = region;
            m_Home           = home;
            m_Range          = range;
            m_Direction      = direction;
            m_Definition     = definition;
            m_SpawnedObjects = new List <ISpawnable>();
            m_Max            = max;
            m_MinSpawnTime   = minSpawnTime;
            m_MaxSpawnTime   = maxSpawnTime;
            m_Running        = false;

            if (m_Table.Contains(id))
            {
                Console.WriteLine("Warning: double SpawnEntry ID '{0}'", id);
            }
            else
            {
                m_Table[id] = this;
            }
        }
コード例 #2
0
        public static SpawnDefinition GetSpawnDefinition(XmlElement xml)
        {
            switch (xml.Name)
            {
            case "object":
            {
                Type type = null;
                if (!Region.ReadType(xml, "type", ref type))
                {
                    return(null);
                }

                if (typeof(Mobile).IsAssignableFrom(type))
                {
                    return(SpawnMobile.Get(type));
                }
                else if (typeof(Item).IsAssignableFrom(type))
                {
                    return(SpawnItem.Get(type));
                }
                else
                {
                    Console.WriteLine("Invalid type '{0}' in a SpawnDefinition", type.FullName);
                    return(null);
                }
            }

            case "group":
            {
                string group = null;
                if (!Region.ReadString(xml, "name", ref group))
                {
                    return(null);
                }

                SpawnDefinition def = (SpawnDefinition)SpawnGroup.Table[group];

                if (def == null)
                {
                    Console.WriteLine("Could not find group '{0}' in a SpawnDefinition", group);
                    return(null);
                }
                else
                {
                    return(def);
                }
            }

            case "treasureChest":
            {
                int itemID = 0xE43;
                Region.ReadInt32(xml, "itemID", ref itemID, false);

                BaseTreasureChest.TreasureLevel level = BaseTreasureChest.TreasureLevel.Level2;

                Region.ReadEnum(xml, "level", ref level, false);

                return(new SpawnTreasureChest(itemID, level));
            }

            default:
            {
                return(null);
            }
            }
        }
コード例 #3
0
 public SpawnGroupElement(SpawnDefinition spawnDefinition, int weight)
 {
     m_SpawnDefinition = spawnDefinition;
     m_Weight          = weight;
 }
コード例 #4
0
        public BaseRegion(XmlElement xml, Map map, Region parent) : base(xml, map, parent)
        {
            ReadString(xml["rune"], "name", ref m_RuneName, false);

            bool logoutDelayActive = true;

            ReadBoolean(xml["logoutDelay"], "active", ref logoutDelayActive, false);
            m_NoLogoutDelay = !logoutDelayActive;


            XmlElement spawning = xml["spawning"];

            if (spawning != null)
            {
                ReadBoolean(spawning, "excludeFromParent", ref m_ExcludeFromParentSpawns, false);

                SpawnZLevel zLevel = SpawnZLevel.Lowest;
                ReadEnum(spawning, "zLevel", ref zLevel, false);
                m_SpawnZLevel = zLevel;


                List <SpawnEntry> list = new List <SpawnEntry>();

                foreach (XmlNode node in spawning.ChildNodes)
                {
                    XmlElement el = node as XmlElement;

                    if (el != null)
                    {
                        SpawnDefinition def = SpawnDefinition.GetSpawnDefinition(el);
                        if (def == null)
                        {
                            continue;
                        }

                        int id = 0;
                        if (!ReadInt32(el, "id", ref id, true))
                        {
                            continue;
                        }

                        int amount = 0;
                        if (!ReadInt32(el, "amount", ref amount, true))
                        {
                            continue;
                        }

                        TimeSpan minSpawnTime = SpawnEntry.DefaultMinSpawnTime;
                        ReadTimeSpan(el, "minSpawnTime", ref minSpawnTime, false);

                        TimeSpan maxSpawnTime = SpawnEntry.DefaultMaxSpawnTime;
                        ReadTimeSpan(el, "maxSpawnTime", ref maxSpawnTime, false);

                        Point3D home  = Point3D.Zero;
                        int     range = 0;

                        XmlElement homeEl = el["home"];
                        if (ReadPoint3D(homeEl, map, ref home, false))
                        {
                            ReadInt32(homeEl, "range", ref range, false);
                        }

                        Direction dir = SpawnEntry.InvalidDirection;
                        ReadEnum(el["direction"], "value", ref dir, false);

                        SpawnEntry entry = new SpawnEntry(id, this, home, range, dir, def, amount, minSpawnTime, maxSpawnTime);
                        list.Add(entry);
                    }
                }

                if (list.Count > 0)
                {
                    m_Spawns = list.ToArray();
                }
            }
        }