document.addEventListener('DOMContentLoaded', function() { // Add download functionality const downloadBtn = document.querySelector('.bg-amber-600'); downloadBtn.addEventListener('click', function() { // In a real implementation, this would generate and download the package alert('Character package generated! Check your downloads folder for the .unitypackage file.'); // Simulate download (for demo purposes) const link = document.createElement('a'); link.href = '#'; // Replace with actual package URL link.download = 'unity_boy_character.unitypackage'; link.click(); }); // Character customization logic const hairColors = document.querySelectorAll('.hair-color-option'); hairColors.forEach(color => { color.addEventListener('click', function() { hairColors.forEach(c => c.classList.remove('border-2', 'border-amber-900')); this.classList.add('border-2', 'border-amber-900'); // Update character preview const hairPreview = document.querySelector('.character-hair'); const colorClass = Array.from(this.classList).find(cls => cls.startsWith('bg-')); if (colorClass) { hairPreview.className = `character-hair ${colorClass} w-32 h-40 rounded-t-full mx-auto mb-1`; } }); }); // Clothing style selector const clothingSelect = document.querySelector('select'); clothingSelect.addEventListener('change', function() { const clothingPreview = document.querySelector('.character-body'); const colors = ['bg-blue-500', 'bg-gray-600', 'bg-red-500', 'bg-green-500', 'bg-purple-500']; const randomColor = colors[Math.floor(Math.random() * colors.length)]; clothingPreview.className = `character-body ${randomColor} w-24 h-32 rounded mx-auto`; }); // Accessory buttons const accessoryButtons = document.querySelectorAll('.accessory-option'); accessoryButtons.forEach(button => { button.addEventListener('click', function() { this.classList.toggle('bg-gray-200'); this.classList.toggle('bg-amber-600'); this.classList.toggle('text-white'); }); }); });