Town System Quick Setup Guide
What Has Been Created
Core Scripts
✅ TownManager.cs - Main town controller
✅ TownShopManager.cs - UI interaction handler
✅ TownBuilding.cs - Base building class
✅ TownShop.cs - Shop logic and inventory
✅ TownShopUI.cs - Complete shop interface
UI Assets
✅ TownUI.uxml - Main town visual layout
✅ TownUI.uss - Town styling
Helper Scripts
✅ TownSetupHelper.cs - Auto-configuration tool
✅ ItemCreatorHelper.cs - Sample item creation
Quick Setup Steps
1. Create Sample Items (Editor Only)
- In Unity Editor, go to RPG Tools > Create Sample Items
- This creates weapons, armor, potions, and tools in Resources/Items/
2. Setup Town Scene
- Open the existing
TownScene.unity
- Create empty GameObject "TownManager"
- Add
TownManager component
- Create UI Document GameObject
- Assign
TownUI.uxml to UI Document
- Link UI Document to TownManager's
townUI field
3. Auto-Configure Shops
- Add
TownSetupHelper component to TownManager
- In Inspector, click Setup Sample Town
- Click Setup Shop Manager
- This creates all shop GameObjects with proper configuration
4. Test the System
- Play the scene
- Click on colored building squares to open shops
- Buy/sell items with different characters
- Money and inventory persist between shop visits
Visual Layout
The town uses a grid layout with:
- Red squares = Weapon Shop
- Blue squares = Armor Shop
- Green squares = Potion Shop
- Orange squares = General Store
- Purple squares = Adventurer's Guild (coming soon)
- Light blue squares = Harbor (coming soon)
- Tan squares = Inn (coming soon)
- Brown strips = Roads
Shop Features
Weapon Shop - "The Forge"
- Sells swords, axes, bows, daggers
- 30% markup on base prices
- Accepts weapon trade-ins at 60% value
Armor Shop - "Ironclad Armory"
- Sells helmets, chest armor, accessories
- 25% markup on base prices
- Accepts armor trade-ins at 60% value
Potion Shop - "The Bubbling Cauldron"
- Sells health/mana potions, antidotes
- 40% markup (specialized goods)
- Accepts consumable trade-ins at 50% value
General Store - "Pete's General Goods"
- Sells basic weapons, armor, tools, misc items
- 20% markup (competitive prices)
- Accepts most items at 65% value
Currency System
- 1 Gold = 10 Silver = 100 Copper
- Characters start with varied amounts of money
- Automatic currency conversion when buying/selling
- Money displays update in real-time
Next Steps
Immediate Improvements
- Add More Items: Create specialized weapons and armor
- Polish UI: Improve shop interface styling
- Add Tooltips: Show item stats on hover
- Sound Effects: Add audio feedback for transactions
Future Features
- Adventurer's Guild: Quest system and job board
- Harbor System: Travel to other towns/locations
- Inn Functionality: Rest, heal, save progress
- NPC Dialogue: Conversations with shopkeepers
- Dynamic Events: Special sales, traveling merchants
Troubleshooting
Common Issues
- Shops don't open: Ensure TownShopManager has shop references
- No items in shops: Run "Setup Sample Town" again
- UI not responsive: Check that UXML/USS files are properly linked
- Money not saving: Verify GameStateManager integration
Debug Tools
- Use TownSetupHelper context menu options
- Check console for setup completion messages
- Verify item loading in Resources/Items/ folders
Integration Notes
This town system integrates seamlessly with your existing:
- TeamCharacter system: Uses gold/silver/copper fields
- Save system: Works with GameStateManager
- Scene management: Proper transitions to/from map
- Item system: Compatible with WeaponItem, ArmorItem, etc.
The system is designed to be:
- Modular: Easy to add new building types
- Extensible: Simple to add new shop features
- Maintainable: Clear separation of concerns
- User-friendly: Intuitive click-to-interact interface
Success Indicators
You'll know the system is working when:
✅ Town scene loads with colored building grid
✅ Clicking buildings opens appropriate shop interfaces
✅ Shop inventories populate with items automatically
✅ Buy/sell transactions update money and inventory
✅ Money changes persist when switching between shops
✅ System integrates smoothly with existing save/load
The town system provides a solid foundation that can grow with your game's needs!