public IEnumerator Start() { var spawnManager = ManagerLocator.TryGet <SpawnManager>(); while (spawnManager == null) { yield return(null); spawnManager = ManagerLocator.TryGet <SpawnManager>(); } while (true) { Debug.Log("Starting to spawn with seed " + (++seed)); Random.InitState(seed); spawnManager.StartSpawning(); var totalElapsed = 0f; while (totalElapsed < testUnitDuration) { totalElapsed += Time.deltaTime; yield return(null); } spawnManager.StopSpawning(); spawnManager.RemoveSpawnedEnemies(); spawnManager.Reset(); yield return(null); } }
private void Start() { _hitManager = ManagerLocator.TryGet <HitManager>(); _pool = ManagerLocator.TryGet <PoolManager>(); ManagerLocator.TryGet <GameController>().OnGameOver += HandleGameOver; ManagerLocator.TryGet <GameController>().OnGameStart += HandleGameStart; }
private void OnDisable() { if (_isDirty) { ManagerLocator.TryGet <SettingsManager>().SetSettings(invertMouseToggle.isOn, sensitivitySlider.value); _isDirty = false; } }
private void Start() { _player = ManagerLocator.TryGet <PlayerController>(); ManagerLocator.TryGet <GameController>().OnGameOver += HandleGameOver; ManagerLocator.TryGet <GameController>().OnGameStart += HandleGameStart; Setup(); }
private void OnDestroy() { var hitManager = ManagerLocator.TryGet <HitManager>(); if (hitManager != null) { hitManager.Unregister(gameObject); } }
private void OnDestroy() { var sm = ManagerLocator.TryGet <SettingsManager>(); if (sm != null) { sm.OnSettingsChanged -= HandleSettingsChanged; } }
private void Start() { var gc = ManagerLocator.TryGet <GameController>(); if (gc != null) { gc.OnGameOver += HandleGameOver; } }
private void TryFindPlayerHP() { var player = ManagerLocator.TryGet <PlayerController>(); if (player != null) { hpToObserve = player.HP; } }
private void Start() { _isMouseInverted = SettingsManager.IsMouseInverted(); _mouseSensitivity = SettingsManager.MouseSensitivity(); camManagerClient.CanShake = _currentViewPos == ViewPosition.FirstPerson; ManagerLocator.TryGet <SettingsManager>().OnSettingsChanged += HandleSettingsChanged; }
private void OnDestroy() { var gc = ManagerLocator.TryGet <GameController>(); if (gc != null) { gc.OnGameOver -= HandleGameOver; } }
private void Start() { Camera = GetComponent <Camera>(); if (Camera != null) { ManagerLocator.TryGet <CameraManager>().Register((int)camType, this); } CanShake = true; }
private void OnDestroy() { var gc = ManagerLocator.TryGet <GameController>(); if (gc != null) { gc.OnLiveEnemyCountChanged -= HandleLiveEnemyCountChanged; gc.OnDeadEnemyCountChanged -= HandleDeadEnemyCountChanged; gc.OnBulletsFiredCountChanged -= HandleBulletsFiredCountChanged; } }
private void Update() { if (Input.GetKey(KeyCode.Escape)) { var gc = ManagerLocator.TryGet <GameController>(); if (gc != null && gc.IsPlaying) { StartCoroutine(PauseGameRoutine(gc)); } } }
private void ProcessCamPerspectiveSwitchInput() { if (Input.GetKeyDown(KeyCode.C)) { camRotator.TogglePerspective(); } if (Input.GetKeyDown(KeyCode.R)) { var hud = ManagerLocator.TryGet <HUD>(); hud?.ToggleRearViewMirrorCamera(); } }
private void Start() { var hitManager = ManagerLocator.TryGet <HitManager>(); if (hitManager != null) { hitManager.Register(gameObject, this); if (log) { Debug.Log("Registering: " + gameObject.name); } } }
private void Start() { var gc = ManagerLocator.TryGet <GameController>(); gc.OnLiveEnemyCountChanged += HandleLiveEnemyCountChanged; gc.OnDeadEnemyCountChanged += HandleDeadEnemyCountChanged; gc.OnBulletsFiredCountChanged += HandleBulletsFiredCountChanged; gc.OnBulletsHitCountChanged += HandleBulletsHitCountChanged; HandleLiveEnemyCountChanged(0); HandleDeadEnemyCountChanged(0); HandleBulletsFiredCountChanged(0); HandleBulletsHitCountChanged(0); }
private void OnDestroy() { if (_player != null) { _player.weaponController.OnWeaponChanged -= HandleWeaponChanged; _player.weaponController.OnDispersionChanged -= HandleDispersionChanged; } var gc = ManagerLocator.TryGet <GameController>(); if (gc != null) { gc.OnGameOver -= HandleGameOver; } }
private IEnumerator QuitConfirmationFlowRoutine(ConfirmationContext doesUserWantToQuit) { var menuManager = ManagerLocator.TryGet <MenuUIManager>(); var quitConfirm = new ConfirmationContext(); menuManager.ShowConfirmPopup("Back to main menu?", quitConfirm); while (!quitConfirm.IsFinished) { yield return(null); } if (quitConfirm.IsConfirmed) { gameObject.SetActive(false); doesUserWantToQuit.Confirm(); } }
private IEnumerator Start() { var camManager = ManagerLocator.TryGet <CameraManager>(); while (rearViewCamera == null || topDownViewCamera == null) { rearViewCamera = camManager.TryGetCamera((int)CamType.Rear); topDownViewCamera = camManager.TryGetCamera((int)CamType.TopDown); yield return(null); } var pixelRect = GetPixelRectForCamera(); rearViewCamera.pixelRect = pixelRect; topDownViewCamera.pixelRect = pixelRect; Setup(); }
private void OnTriggerEnter(Collider other) { if (_hasDealtDamage) { return; } var collisionManager = ManagerLocator.TryGet <HitManager>(); collisionManager?.ReportHit(other.gameObject, transform.position, damage); _hasDealtDamage = true; OnImpact?.Invoke(); if (destroySelfOnImpact) { Destroy(gameObject); } }
private IEnumerator GameOverRoutine(GameController.GameResult playerHasWon) { var gc = ManagerLocator.TryGet <GameController>(); gc.PauseGame(true); if (playerHasWon != GameController.GameResult.PlayerQuit) { var playerWon = playerHasWon == GameController.GameResult.PlayerWon; var context = new ConfirmationContext(); gameOverPopup.Show(playerWon, context); while (!context.IsFinished) { yield return(null); } } gc.AbortGameServices(); ShowMainMenu(); }
private void MakePlayerDie() { ManagerLocator.TryGet <PlayerController>().HP.Hit(Vector3.zero, 200); }
private void CacheDependencies() { _spawner = ManagerLocator.TryGet <SpawnManager>(); _player = ManagerLocator.TryGet <PlayerController>(); _hud = ManagerLocator.TryGet <HUD>(); }
private void Start() { _poolManager = ManagerLocator.TryGet <PoolManager>(); }
private void Start() { ManagerLocator.TryGet <GameController>().OnGameOver += HandleGameOver; }
public void OnNewGameButtonClicked() { HideAllMenuItems(); ManagerLocator.TryGet <GameController>().StartNewGame(); }