Shop/Inventory System Documentation
Overview
This system provides a comprehensive shop and inventory management solution for your RPG game. It includes:
- Filterable and searchable shop interface
- Currency system (Gold, Silver, Copper)
- Inventory management for weapons, armor, and miscellaneous items
- Integration with the existing team character creation system
Components Created
Core Item System
- Item.cs: Base class for all items with cost, search functionality
- WeaponItem.cs: ScriptableObject for weapon data
- ArmorItem.cs: ScriptableObject for armor data
- MiscellaneousItem.cs: ScriptableObject for consumables and misc items
Shop System
- Shop.cs: ScriptableObject shop configuration
- ShopUI.cs: Advanced shop UI controller (full featured)
- SimpleShopManager.cs: Basic shop implementation that works with existing system
Inventory System
- Inventory.cs: Character inventory management
- Bank.cs: Enhanced currency system
Integration
- MainTeamSelectScript.cs: Updated to include shop/inventory functionality
- SimpleSword.cs & SimpleBow.cs: Updated to work with item system
UI Files
- ShopUI.uxml: Shop interface layout
- ShopUI.uss: Shop styling
- InventorySheet.uxml: Already existed, now fully functional
Quick Setup Guide
1. Basic Setup
- Create a GameObject in your scene called "ShopManager"
- Attach the
SimpleShopManager script to it
- Add a
UIDocument component to the same GameObject
- Assign
ShopUI.uxml as the Visual Tree Asset in the UIDocument
2. Alternative: Use Setup Script
- Add the
ShopSystemSetup script to any GameObject
- Check "Create Shop GameObject" in the inspector
- The shop system will be automatically set up
3. Test the System
- Open the Team Select scene
- Create a character
- Click "Add Weapon", "Add Armor", or "Add Misc" buttons
- The shop will open with filterable/searchable items
Features
Shop Features
- Search: Type to find items by name, description, or tags
- Filtering: Filter by category (All, Weapons, Armor, Miscellaneous)
- Affordability: Items you can't afford are grayed out
- Dynamic Pricing: Gold/Silver/Copper conversion system
Inventory Features
- Currency Management: Gold, Silver, Copper with automatic conversion
- Item Lists: Separate lists for weapons, armor, and misc items
- Add/Remove: Easy item management through UI buttons
- Persistence: Items are saved with character data
Sample Items Included
The system comes with sample items:
Weapons:
- Simple Sword (10g)
- Simple Bow (15g)
- Iron Sword (25g)
- Composite Bow (35g)
Armor:
- Leather Helmet (5g)
- Leather Vest (12g)
- Iron Chainmail (30g)
Miscellaneous:
- Health Potion (3g)
- Hemp Rope (8s)
- Torch (2s)
Currency System
- 1 Gold = 10 Silver = 100 Copper
- Characters start with 50 gold
- Automatic conversion when making purchases
- Bank fields in inventory are editable for testing
Extending the System
Adding New Items
- Create ScriptableObject assets using the "RPG/Items/" menu
- Configure item properties (name, description, cost, stats)
- Add search tags for better discoverability
- Add to shop's available items list
Adding New Weapon Types
- Create a new weapon script inheriting from
Weapon
- Add an
InitializeFromItem(WeaponItem) method
- Update
WeaponItem.CreateWeaponInstance() to handle the new type
Customizing Shop
- Modify
SimpleShopManager.InitializeDefaultItems() for different starting inventory
- Create multiple shop GameObjects with different item sets
- Customize shop appearance by editing
ShopUI.uss styles
Integration with Existing Weapon System
The new system is backward compatible with your existing weapon system:
SimpleSword and SimpleBow classes updated to work with WeaponItem data
- Characters can still use weapons without the shop system
- Weapon creation can use either old direct instantiation or new item-based creation
Troubleshooting
Shop Not Opening
- Check that
SimpleShopManager exists in scene
- Verify
UIDocument has ShopUI.uxml assigned
- Look for error messages in console
Items Not Showing
- Check
InitializeDefaultItems() method is populating lists
- Verify filter/search settings aren't hiding items
- Check item costs aren't higher than character's money
Inventory Not Updating
- Ensure
UpdateInventoryUI() is called after character changes
- Check that character has the new currency fields initialized
- Verify UI elements are properly connected in
GetUIElementReferences()
Performance Notes
- Items are created dynamically in UI for better performance
- Character data uses simple string lists for basic compatibility
- Full ScriptableObject system available for more complex item management
Future Enhancements
This system provides a solid foundation that can be extended with:
- Item tooltips with detailed stats
- Equipment slots and stat bonuses
- Item rarity and visual effects
- Shop keeper NPCs and dialogue
- Item crafting and upgrades
- Save/load integration