private InfInt CalculateWaveHP(int dozen, int one, bool beforeFirstBoss) { _tempBigNumber.Set(1); for (int i = 0; i < dozen; i++) { _tempBigNumber.Multiply(_gameConfig.waveSettings.bossHPMultiplier); } if (beforeFirstBoss) { _tempBigNumber.Multiply(_gameConfig.waveSettings.firstWaveHP); } else { _tempBigNumber.Multiply(_gameConfig.waveSettings.firstBossHP); } _tmpBigNumber.Set(0); if (one > 1) { _tmpBigNumber.Set(_tempBigNumber); _tmpBigNumber.Multiply(one - 1); _tmpBigNumber.MultiplyInPercents(_gameConfig.waveSettings.waveMultiplier); } _tempBigNumber.Add(_tmpBigNumber); return(_tempBigNumber); }
public void ResetOnNight() { Debug.Log("=============== ResetOnNight START ==============="); _zombies.Clear(); _GOfactory.ResetOnNight(); _waveStarted = false; int waveModulo = WaveNumber % 10; // отстаток int waveQuotient = WaveNumber / 10; // целое waveQuotient -= _gameConfig.nightSettings.waveCorrection; if (waveQuotient < 0) { waveQuotient = 0; } WaveNumber = waveQuotient * 10; _currentDecadeStartHP.Set(CalculateWaveHP(WaveNumber)); _currentWaveHP.Set(_currentDecadeStartHP); // считаем количество зомби при откате int zombieCount = CalculateZombieCount(WaveNumber); _zombieCountBeforeBoss = zombieCount; _currentDecadeZombieCount = zombieCount; _currentZombieCount = zombieCount; _lastBossAlive = false; Debug.Log("=============== ResetOnNight END ==============="); if (_tutorialManager.ActiveTutorialStep.Action != TutorialAction.OpenPuzzlesWindow) { StartNewWave(); } SetDirty(); }
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(); }