File size: 2,294 Bytes
9b9ed61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

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');
        });
    });
});