private void CalculateWaveHP(WaveType waveType) { if (_tutorialManager.ActiveTutorialStep.Action == TutorialAction.FirstWave || _tutorialManager.ActiveTutorialStep.Action == TutorialAction.SecondWave) { TutorialWaveSettings waveSettings = _tutorialManager.GetWave(); _currentWaveHP.Set(waveSettings.waveHP); _currentZombieCount = waveSettings.zombieCount; _currentDecadeZombieCount = _gameConfig.waveSettings.startZombieCount; _currentDecadeStartHP.Set(_gameConfig.waveSettings.firstWaveHP); return; } if (_tutorialManager.ActiveTutorialStep.Action == TutorialAction.ThirdWave || (WaveNumber == 1 && !_tutorialManager.IsTutorialEnabled)) { _currentZombieCount = _gameConfig.waveSettings.startZombieCount; _currentDecadeZombieCount = _gameConfig.waveSettings.startZombieCount; _currentWaveHP.Set(_gameConfig.waveSettings.firstWaveHP); _currentDecadeStartHP.Set(_gameConfig.waveSettings.firstWaveHP); return; } int firstBossWaveNumber = _gameConfig.waveSettings.firstBossWaveNumber; switch (waveType) { case WaveType.Boss: // босс волна _zombieCountBeforeBoss = _currentZombieCount; _currentZombieCount = 1; // босс всегда приходит один if (WaveNumber == firstBossWaveNumber) { _currentWaveHP.Set(_gameConfig.waveSettings.firstBossHP); } else { _currentWaveHP.Set(_currentDecadeStartHP); _currentWaveHP.Multiply(_gameConfig.waveSettings.bossHPMultiplier); } Debug.Log("BOSS wave = " + WaveNumber.ToString() + "; wave HP = " + _currentWaveHP.ToFullString() + "; zombie count = " + _currentZombieCount.ToString()); break; case WaveType.AfterBoss: _currentZombieCount = _zombieCountBeforeBoss; _currentDecadeZombieCount = _currentZombieCount; _currentDecadeStartHP.Set(_currentWaveHP); Debug.Log("AFTER BOSS wave = " + WaveNumber.ToString() + "; wave HP = " + _currentWaveHP.ToFullString() + "; zombie count = " + _currentZombieCount.ToString()); break; case WaveType.Test: _currentWaveHP.Set(_gameConfig.waveSettings.firstWaveHP); _currentDecadeStartHP.Set(_gameConfig.waveSettings.firstWaveHP); _zombieCountBeforeBoss = _gameConfig.waveSettings.startZombieCount; _currentZombieCount = _zombieCountBeforeBoss; _currentDecadeZombieCount = _gameConfig.waveSettings.startZombieCount; WaveNumber = _gameConfig.waveSettings.startWave; Debug.Log("TEST WAVE!"); break; case WaveType.TestBoss: _currentWaveHP.Set(_gameConfig.waveSettings.firstWaveHP); _currentDecadeStartHP.Set(_gameConfig.waveSettings.firstWaveHP); _zombieCountBeforeBoss = _gameConfig.waveSettings.startZombieCount; _currentZombieCount = 1; _currentDecadeZombieCount = _gameConfig.waveSettings.startZombieCount; WaveNumber = _gameConfig.waveSettings.startWave; Debug.Log("TEST BOSS WAVE!"); break; default: Debug.Log("prev wave hp = " + _currentWaveHP.ToString()); _tempBigNumber.Set(_currentDecadeStartHP); _tempBigNumber.MultiplyInPercents(_gameConfig.waveSettings.waveMultiplier); Debug.Log("temp big number = " + _tempBigNumber.ToString()); _currentWaveHP.Add(_tempBigNumber); Debug.Log("simple wave = " + WaveNumber.ToString() + "; wave HP = " + _currentWaveHP.ToFullString() + "; zombie count = " + _currentZombieCount.ToString()); break; } }
private void StartNewWave(WaveType testWaveType = WaveType.Default) { if (_timeTravelStartLock) { Debug.Log("START NEW WAVE LOCKED BY TIME TRAVEL"); return; } _waveStarted = true; Debug.Log("==================== StartNewWave START ===================="); if (_zombies.Count > 0 && !_autoStartNewWave) { _autoStartNewWave = true; _GOfactory.StartNewWave(_zombies); _onUpdateZombiesCountSignal.Fire(_zombies.Count); _onWaveStartedSignal.Fire(WaveNumber, _currentWaveHP, _zombies[0].Type); Debug.Log("decade hp start = " + _currentDecadeStartHP.ToString()); Debug.Log("SAVED WAVE wave = " + WaveNumber.ToString() + "; wave HP = " + _currentWaveHP.ToFullString() + "; zombie count = " + _currentZombieCount.ToString()); Debug.Log("HP Per Zombie = " + _hpPerZombie.ToFullString()); Debug.Log("==================== StartNewWave END ===================="); return; } if (!_autoStartNewWave) { _autoStartNewWave = true; } WaveType waveType = WaveType.Default; int firstBossWaveNumber = _gameConfig.waveSettings.firstBossWaveNumber; WaveNumber++; CustomWaveSettings customSettings = null; if (_zombieConfig.IsCustomWave(WaveNumber)) { customSettings = _zombieConfig.GetCustomWaveSettings(WaveNumber); } int zombiesBeforeMax = _gameConfig.waveSettings.maxZombieCount - _currentZombieCount; if (_currentZombieCount < _gameConfig.waveSettings.maxZombieCount) { _currentZombieCount += zombiesBeforeMax > _gameConfig.waveSettings.zombieCountStep ? _gameConfig.waveSettings.zombieCountStep : zombiesBeforeMax; } int modulo = WaveNumber % _gameConfig.waveSettings.bossPeriod; switch (modulo) { case 0: // босс волна if (WaveNumber >= firstBossWaveNumber) { waveType = WaveType.Boss; _lastBossAlive = true; } else { waveType = WaveType.Default; } break; case 1: if (WaveNumber > firstBossWaveNumber) { waveType = WaveType.AfterBoss; } else { waveType = WaveType.Default; } break; default: waveType = WaveType.Default; break; } if (testWaveType != WaveType.Default) { waveType = testWaveType; } CalculateWaveHP(waveType); Debug.Log("decade hp start = " + _currentDecadeStartHP.ToString()); int mainZombieCount = 0; int extraZombieCount = 0; if (waveType == WaveType.Boss) { mainZombieCount = _currentZombieCount; } else { if (customSettings != null) { if (customSettings.waveEvent == ZombieWaveEvent.UnlockAddZombieType) { _otherAddTypes.Add(customSettings.zombieType); SetDirty(); } } if (_otherAddTypes.Count > 0) { extraZombieCount = Mathf.CeilToInt(_currentZombieCount * _gameConfig.waveSettings.extraZombiePercent); mainZombieCount = _currentZombieCount - extraZombieCount; } else { mainZombieCount = _currentZombieCount; } } Debug.Log("Main Zombie Count = " + mainZombieCount.ToString()); Debug.Log("Extra Zombie Count = " + extraZombieCount.ToString()); _hpPerZombie.Set(_currentWaveHP); _tempBigNumber.Set(_currentZombieCount); _hpPerZombie.Divide(_tempBigNumber); _tempBigNumber.Set(_hpPerZombie); _tempBigNumber.Multiply(_currentZombieCount); Debug.Log("HP Per Zombie = " + _hpPerZombie.ToFullString()); Debug.Log("HP of ALL Zombies = " + _tempBigNumber.ToFullString()); List <Zombie> newZombies = FillZombieList(waveType, mainZombieCount, extraZombieCount, customSettings); _zombies.AddRange(newZombies); _GOfactory.StartNewWave(newZombies); _onUpdateZombiesCountSignal.Fire(_zombies.Count); _onWaveStartedSignal.Fire(WaveNumber, _currentWaveHP, newZombies[0].Type); _analyticsManager.SendWaveStarted(WaveNumber); Debug.Log("==================== StartNewWave END ===================="); SetDirty(); }