Beispiel #1
0
        public static SpawnItem Get(Type type)
        {
            SpawnItem si = (SpawnItem)m_Table[type];

            if (si == null)
            {
                si            = new SpawnItem(type);
                m_Table[type] = si;
            }

            return(si);
        }
Beispiel #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);
            }
            }
        }