예제 #1
0
        private static void LoadItems()
        {
            const string query = "SELECT snoId, itemname, itemdescription from items";
            var cmd = new SQLiteCommand(query, GameDataDBManager.Connection);
            var reader = cmd.ExecuteReader();

            if (!reader.HasRows) return;

            while (reader.Read())
            {
                var itemDefinition = new ItemDefinition(reader.GetInt32(0), reader.GetString(1),reader.IsDBNull(2) ? string.Empty : reader.GetString(2));
                ItemDefinitions.Add(itemDefinition.Type, itemDefinition);
            }            
        }
예제 #2
0
        // Creates an item based on supplied definition.
        public static Item CreateItem(Player player, ItemDefinition definition)
        {
            Logger.Trace("Creating item: {0} [type: {1}, mode: {2}, sno:{3}, gbid {4}]", definition.Name,
                         definition.Type, definition.DifficultyMode, definition.SNOId, definition.GBId);

            var item = new Item(player.World, definition.SNOId, definition.GBId, definition.Type);
            player.GroundItems[item.DynamicID] = item;

            var attributeCreators = new AttributeCreatorFactory().Create(definition.Type);
            foreach (IItemAttributeCreator creator in attributeCreators)
            {
                creator.CreateAttributes(item);
            }

            return item;
        }