/** * ZombieCommunicationSystem.js * ============================= * KRVAVA Ε½ETEV - Zombie Communication System (Hybrid Skill) * * Features: * - Level-based zombie understanding * - Level 1: Groaning only ("Hnggg...") * - Level 5: Keywords in subtitles * - Level 10: Full sentences (warnings, memories) * - Subtitle UI * - Translation system * * @author NovaFarma Team * @date 2025-12-23 */ export default class ZombieCommunicationSystem { constructor(scene) { this.scene = scene; // Player's communication level this.communicationLevel = 0; this.maxLevel = 10; // Subtitle UI this.subtitleText = null; this.subtitleContainer = null; this.currentSubtitle = null; // Zombie speech library this.zombiePhrases = new Map(); console.log('🧠 ZombieCommunicationSystem initialized'); // Create subtitle UI this.createSubtitleUI(); // Load zombie phrases this.loadZombiePhrases(); } /** * Create subtitle UI */ createSubtitleUI() { const width = this.scene.cameras.main.width; const height = this.scene.cameras.main.height; // Container at bottom of screen this.subtitleContainer = this.scene.add.container(width / 2, height - 100); this.subtitleContainer.setScrollFactor(0); this.subtitleContainer.setDepth(10000); this.subtitleContainer.setAlpha(0); // Background const bg = this.scene.add.rectangle(0, 0, 800, 100, 0x000000, 0.8); this.subtitleContainer.add(bg); // Subtitle text this.subtitleText = this.scene.add.text(0, 0, '', { fontSize: '24px', fontFamily: 'Arial', color: '#00FF00', // Green zombie text align: 'center', wordWrap: { width: 750 } }); this.subtitleText.setOrigin(0.5); this.subtitleContainer.add(this.subtitleText); console.log('βœ… Subtitle UI created'); } /** * Load zombie phrase library */ loadZombiePhrases() { // Level 1: Pure groaning const level1Phrases = [ { zombie: 'Hnggg...', translation: null }, { zombie: 'Grrraaa...', translation: null }, { zombie: 'Uuuhhh...', translation: null }, { zombie: 'Aaarrgh...', translation: null } ]; // Level 5: Keywords visible const level5Phrases = [ { zombie: 'Hnggg... HUNGER... grrr...', translation: 'I am hungry...' }, { zombie: 'Grrr... DANGER... hnggg...', translation: 'Danger nearby!' }, { zombie: 'Uhhh... MASTER... grrr...', translation: 'Looking for master...' }, { zombie: 'Aaah... PAIN... hnggg...', translation: 'I am in pain...' }, { zombie: 'Grrr... HELP... uhhh...', translation: 'Help me...' }, { zombie: 'Hnggg... FRIEND... grrr...', translation: 'You are my friend...' } ]; // Level 10: Full sentences const level10Phrases = [ { zombie: 'I remember... my family...', translation: 'I remember my family before I turned...' }, { zombie: 'The darkness... it hurts...', translation: 'The curse is painful...' }, { zombie: 'Thank you... for saving me...', translation: 'Thank you for taming me instead of killing me.' }, { zombie: 'Enemies... coming from east...', translation: 'I sense enemies approaching from the east!' }, { zombie: 'My name was... John...', translation: 'I remember my name was John...' }, { zombie: 'Ana... she calls us...', translation: 'Ana\'s Twin Bond resonates with us zombies...' }, { zombie: 'The Black Serpent... did this...', translation: 'The Black Serpent Initiative caused this outbreak.' }, { zombie: 'I was a farmer... before...', translation: 'I was a farmer before the infection...' }, { zombie: 'Danger! Big zombie nearby!', translation: 'WARNING: Boss zombie detected!' }, { zombie: 'I protect you... master...', translation: 'I will protect you with my unlife, master.' } ]; // Special contextual phrases const contextualPhrases = [ { context: 'low_health', zombie: 'Hnggg... weak... dying...', translation: 'I am badly hurt!' }, { context: 'enemy_near', zombie: 'Grrr! Intruders!', translation: 'Enemies detected!' }, { context: 'happy', zombie: 'Grraaa... good... happy...', translation: 'I am happy serving you!' }, { context: 'task_complete', zombie: 'Uhhh... done... master...', translation: 'Task completed, master!' }, { context: 'hungry', zombie: 'Need... food... hnggg...', translation: 'I need to eat soon...' }, { context: 'scared', zombie: 'Aaaah! Fear! Run!', translation: 'Something terrifying is here!' } ]; this.zombiePhrases.set('level1', level1Phrases); this.zombiePhrases.set('level5', level5Phrases); this.zombiePhrases.set('level10', level10Phrases); this.zombiePhrases.set('contextual', contextualPhrases); console.log(`βœ… Loaded ${level1Phrases.length + level5Phrases.length + level10Phrases.length + contextualPhrases.length} zombie phrases`); } /** * Set communication level */ setCommunicationLevel(level) { this.communicationLevel = Math.min(this.maxLevel, Math.max(0, level)); console.log(`🧠 Communication level: ${this.communicationLevel}/10`); this.showNotification({ title: 'Zombie Understanding Improved!', text: `🧠 Level ${this.communicationLevel}: ${this.getLevelDescription()}`, icon: '🧟' }); } /** * Get level description */ getLevelDescription() { if (this.communicationLevel >= 10) { return 'Full sentences! You understand zombies completely!'; } else if (this.communicationLevel >= 5) { return 'Keywords visible! You understand basic meanings!'; } else { return 'Only groaning... You need more practice!'; } } /** * Zombie speaks */ zombieSpeak(zombieId, context = null) { let phrase; // Get appropriate phrase based on level if (context) { phrase = this.getContextualPhrase(context); } else if (this.communicationLevel >= 10) { phrase = this.getRandomPhrase('level10'); } else if (this.communicationLevel >= 5) { phrase = this.getRandomPhrase('level5'); } else { phrase = this.getRandomPhrase('level1'); } if (!phrase) return; // Show subtitle this.showSubtitle(phrase, zombieId); } /** * Get random phrase from level */ getRandomPhrase(level) { const phrases = this.zombiePhrases.get(level); if (!phrases || phrases.length === 0) return null; return Phaser.Utils.Array.GetRandom(phrases); } /** * Get contextual phrase */ getContextualPhrase(context) { const phrases = this.zombiePhrases.get('contextual'); const found = phrases.filter(p => p.context === context); if (found.length === 0) return this.getRandomPhrase('level1'); return Phaser.Utils.Array.GetRandom(found); } /** * Show subtitle */ showSubtitle(phrase, zombieId = 'Zombie') { let displayText = phrase.zombie; // Add translation if level is high enough if (this.communicationLevel >= 5 && phrase.translation) { displayText += `\n[${phrase.translation}]`; } // Show speaker name displayText = `${zombieId}: ${displayText}`; this.subtitleText.setText(displayText); // Fade in this.scene.tweens.add({ targets: this.subtitleContainer, alpha: 1, duration: 300 }); // Auto-hide after 3 seconds if (this.currentSubtitle) { clearTimeout(this.currentSubtitle); } this.currentSubtitle = setTimeout(() => { this.hideSubtitle(); }, 3000); console.log(`πŸ’¬ ${displayText}`); } /** * Hide subtitle */ hideSubtitle() { this.scene.tweens.add({ targets: this.subtitleContainer, alpha: 0, duration: 300 }); this.currentSubtitle = null; } /** * Zombie conversation (interactive) */ startConversation(zombieId) { if (this.communicationLevel < 5) { this.showSubtitle({ zombie: 'Hnggg... grrr...', translation: null }, zombieId); this.showNotification({ title: 'Cannot Understand', text: 'Your zombie communication skill is too low!', icon: '🧠' }); return false; } console.log(`πŸ’¬ Conversation with ${zombieId}`); // Show conversation phrases const phrases = [ 'What is your name?', 'What do you remember?', 'Are you loyal?', 'Do you feel pain?', 'Goodbye' ]; // TODO: Create actual dialogue UI with choices console.log('Conversation options:', phrases); return true; } /** * Zombie warning (important messages) */ zombieWarning(message, urgency = 'normal') { const urgencyIcons = { low: 'ℹ️', normal: '⚠️', high: '🚨', critical: 'πŸ’€' }; this.showSubtitle({ zombie: message, translation: message }, `${urgencyIcons[urgency]} ZOMBIE ALERT`); // Play alert sound for high/critical if (urgency === 'high' || urgency === 'critical') { // TODO: Play alert sound this.scene.cameras.main.shake(200, 0.005); } } /** * Level up communication skill */ levelUpCommunication() { if (this.communicationLevel >= this.maxLevel) { console.log('🧠 Already at max level!'); return false; } this.setCommunicationLevel(this.communicationLevel + 1); // Show what's unlocked if (this.communicationLevel === 5) { this.showNotification({ title: 'Keywords Unlocked!', text: '🧠 You can now see KEYWORDS in zombie speech!', icon: '✨' }); } else if (this.communicationLevel === 10) { this.showNotification({ title: 'Full Understanding!', text: '🧠 You can now understand COMPLETE zombie sentences!', icon: 'πŸ‘‘' }); } return true; } /** * Get communication level */ getCommunicationLevel() { return this.communicationLevel; } /** * Can understand zombie */ canUnderstandZombie(requiredLevel = 1) { return this.communicationLevel >= requiredLevel; } /** * Helper: Show notification */ showNotification(notification) { console.log(`πŸ“’ ${notification.icon} ${notification.title}: ${notification.text}`); const ui = this.scene.scene.get('UIScene'); if (ui && ui.showNotification) { ui.showNotification(notification); } } }