Esempio n. 1
0
        /**
         * This function distributes items randomly amongst the dungeon
         * @param numberOfItems the number of items to scatter
         */
        public void AddItems(int numberOfItems)
        {
            sqliteCommand command;
            Random        r = new Random();

            //populate item table with items
            for (int i = 0; i < numberOfItems; i++)
            {
                String room = "room";
                room += r.Next(0, DungeonSize);
                Item item = gameObjectList.GetRandomItem();

                command = new sqliteCommand("INSERT INTO " + itemTableName +
                                            "  (name, itemID, uniqueID, owner) " +
                                            "VALUES (?,?,?,?) ", Database);
                command.Parameters.Add("@name", DbType.String).Value     = item.itemName.ToLower();
                command.Parameters.Add("@itemID", DbType.String).Value   = item.ID;
                command.Parameters.Add("@uniqueID", DbType.String).Value = Guid.NewGuid().ToString();
                command.Parameters.Add("@owner", DbType.String).Value    = room;
                command.ExecuteNonQuery();
            }
        }