/** * ZOMBIE SCOUT LEVELING SYSTEM (1-20) * XP progression, stat increases, level-up rewards * Integrates with ZombieScout companion */ export class ZombieScoutLevelingSystem { constructor(scene) { this.scene = scene; // Current stats this.currentLevel = 1; this.currentXP = 0; this.skillPoints = 0; // Stats per level this.baseStats = { health: 50, attack: 5, digSpeed: 1.0, moveSpeed: 100, defense: 0 }; this.currentStats = { ...this.baseStats }; // XP curve this.xpRequirements = this.generateXPCurve(); // Level rewards this.levelRewards = new Map(); this.init(); } init() { this.initializeLevelRewards(); } /** * Generate XP requirements for each level (exponential curve) */ generateXPCurve() { const curve = [0]; // Level 1 = 0 XP for (let level = 2; level <= 20; level++) { // Formula: baseXP * (level ^ 1.5) const baseXP = 100; const requiredXP = Math.floor(baseXP * Math.pow(level, 1.5)); curve.push(requiredXP); } return curve; } /** * Initialize rewards for each level */ initializeLevelRewards() { // Skill points every level for (let level = 2; level <= 20; level++) { this.levelRewards.set(level, { skillPoints: 1, statBonus: this.getStatBonusForLevel(level), specialUnlock: this.getSpecialUnlockForLevel(level) }); } } /** * Get stat bonus for specific level */ getStatBonusForLevel(level) { const bonuses = { health: 10, // +10 HP per level attack: 1, // +1 attack per level digSpeed: 0.05, // +5% dig speed per level defense: 0.5 // +0.5 defense per level }; // Every 5 levels: bonus move speed if (level % 5 === 0) { bonuses.moveSpeed = 10; // +10 speed at levels 5, 10, 15, 20 } return bonuses; } /** * Get special unlock for milestone levels */ getSpecialUnlockForLevel(level) { const unlocks = { 5: { type: 'skill', name: 'Basic Attack', description: 'Zombie can attack enemies' }, 10: { type: 'skill', name: 'Speed Dig', description: 'Dig 50% faster for 10 seconds' }, 15: { type: 'skill', name: 'Treasure Sense', description: 'Reveal nearby buried items' }, 20: { type: 'evolution', name: 'Scout Commander', description: 'Zombie becomes elite unit' } }; return unlocks[level] || null; } /** * Award XP to Zombie Scout */ awardXP(amount, source = 'general') { this.currentXP += amount; // Visual feedback this.showXPGain(amount, source); // Check for level up this.checkLevelUp(); console.log(`+${amount} XP from ${source} (${this.currentXP}/${this.getRequiredXP()})`); } /** * Check if Zombie Scout should level up */ checkLevelUp() { if (this.currentLevel >= 20) return; // Max level cap const requiredXP = this.getRequiredXP(); if (this.currentXP >= requiredXP) { this.levelUp(); } } /** * Level up Zombie Scout */ levelUp() { this.currentLevel++; this.currentXP -= this.getRequiredXP(this.currentLevel - 1); // Carry over excess XP // Apply stat bonuses const rewards = this.levelRewards.get(this.currentLevel); if (rewards) { // Apply stat increases for (const [stat, bonus] of Object.entries(rewards.statBonus)) { this.currentStats[stat] += bonus; } // Award skill points this.skillPoints += rewards.skillPoints; // Special unlock if (rewards.specialUnlock) { this.unlockSpecial(rewards.specialUnlock); } } // Visual effects this.playLevelUpEffects(); // Notification this.scene.uiSystem?.showNotification( `Zombie Scout reached Level ${this.currentLevel}!`, 'level_up', { skillPoints: this.skillPoints } ); // Update Zombie Scout sprite if evolution if (this.currentLevel === 20) { this.evolveScout(); } console.log(`🎉 LEVEL UP! Zombie Scout is now Level ${this.currentLevel}`); console.log(`Stats:`, this.currentStats); console.log(`Skill Points: ${this.skillPoints}`); // Quest check this.scene.questSystem?.checkScoutLevel(this.currentLevel); } /** * Unlock special ability or feature */ unlockSpecial(unlock) { console.log(`✨ Special Unlock: ${unlock.name} - ${unlock.description}`); if (unlock.type === 'skill') { this.scene.zombieScoutSkills?.unlockSkill(unlock.name); } else if (unlock.type === 'evolution') { // Mark for visual evolution this.isEvolved = true; } this.scene.uiSystem?.showNotification( `Unlocked: ${unlock.name}!`, 'unlock', { description: unlock.description } ); } /** * Visual evolution at level 20 */ evolveScout() { // Update sprite to "Commander" version const scout = this.scene.zombieScout; if (scout) { scout.setTexture('zombie_scout_commander'); scout.setScale(scout.scale * 1.2); // Slightly larger // VFX: Evolution animation this.scene.vfxSystem?.playEffect('evolution', scout.x, scout.y); } } /** * Award XP for different actions */ onCombatKill(enemyType) { const xpValues = { 'zombie': 10, 'raider': 25, 'mutant': 50, 'boss': 200 }; this.awardXP(xpValues[enemyType] || 10, 'combat'); } onDigComplete(itemRarity) { const xpValues = { 'common': 5, 'uncommon': 15, 'rare': 30, 'legendary': 100 }; this.awardXP(xpValues[itemRarity] || 5, 'digging'); } onExplorationProgress() { // Award XP for exploring new areas this.awardXP(20, 'exploration'); } onQuestComplete(questDifficulty) { const xpValues = { 'easy': 50, 'medium': 100, 'hard': 200, 'story': 300 }; this.awardXP(xpValues[questDifficulty] || 50, 'quest'); } /** * Get required XP for current or specific level */ getRequiredXP(level = this.currentLevel) { return this.xpRequirements[level] || 0; } /** * Get XP progress percentage */ getXPProgress() { if (this.currentLevel >= 20) return 100; const required = this.getRequiredXP(); return Math.min(100, Math.floor((this.currentXP / required) * 100)); } /** * Visual effects */ showXPGain(amount, source) { // Floating text above Zombie Scout const scout = this.scene.zombieScout; if (scout) { this.scene.vfxSystem?.floatingText(`+${amount} XP`, scout.x, scout.y - 30, '#FFD700'); } } playLevelUpEffects() { const scout = this.scene.zombieScout; if (!scout) return; // VFX: Level up particles this.scene.vfxSystem?.playEffect('level_up', scout.x, scout.y); // SFX: Level up sound this.scene.soundSystem?.play('level_up'); // Camera shake this.scene.cameras.main.shake(200, 0.005); // Flash this.scene.cameras.main.flash(300, 255, 215, 0); // Gold flash } /** * Get current level data */ getLevelData() { return { level: this.currentLevel, xp: this.currentXP, requiredXP: this.getRequiredXP(), progress: this.getXPProgress(), stats: { ...this.currentStats }, skillPoints: this.skillPoints, isMaxLevel: this.currentLevel >= 20, nextUnlock: this.levelRewards.get(this.currentLevel + 1)?.specialUnlock || null }; } /** * Save/Load support */ getSaveData() { return { currentLevel: this.currentLevel, currentXP: this.currentXP, skillPoints: this.skillPoints, currentStats: this.currentStats, isEvolved: this.isEvolved || false }; } loadSaveData(data) { this.currentLevel = data.currentLevel || 1; this.currentXP = data.currentXP || 0; this.skillPoints = data.skillPoints || 0; this.currentStats = data.currentStats || { ...this.baseStats }; this.isEvolved = data.isEvolved || false; // Apply visual evolution if loaded at level 20 if (this.isEvolved) { this.evolveScout(); } } }