示例#1
0
    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);
        }
    }
示例#2
0
    private void Start()
    {
        _hitManager = ManagerLocator.TryGet <HitManager>();
        _pool       = ManagerLocator.TryGet <PoolManager>();

        ManagerLocator.TryGet <GameController>().OnGameOver  += HandleGameOver;
        ManagerLocator.TryGet <GameController>().OnGameStart += HandleGameStart;
    }
示例#3
0
 private void OnDisable()
 {
     if (_isDirty)
     {
         ManagerLocator.TryGet <SettingsManager>().SetSettings(invertMouseToggle.isOn, sensitivitySlider.value);
         _isDirty = false;
     }
 }
示例#4
0
    private void Start()
    {
        _player = ManagerLocator.TryGet <PlayerController>();
        ManagerLocator.TryGet <GameController>().OnGameOver  += HandleGameOver;
        ManagerLocator.TryGet <GameController>().OnGameStart += HandleGameStart;

        Setup();
    }
示例#5
0
    private void OnDestroy()
    {
        var hitManager = ManagerLocator.TryGet <HitManager>();

        if (hitManager != null)
        {
            hitManager.Unregister(gameObject);
        }
    }
示例#6
0
    private void OnDestroy()
    {
        var sm = ManagerLocator.TryGet <SettingsManager>();

        if (sm != null)
        {
            sm.OnSettingsChanged -= HandleSettingsChanged;
        }
    }
示例#7
0
    private void Start()
    {
        var gc = ManagerLocator.TryGet <GameController>();

        if (gc != null)
        {
            gc.OnGameOver += HandleGameOver;
        }
    }
示例#8
0
    private void TryFindPlayerHP()
    {
        var player = ManagerLocator.TryGet <PlayerController>();

        if (player != null)
        {
            hpToObserve = player.HP;
        }
    }
示例#9
0
    private void Start()
    {
        _isMouseInverted  = SettingsManager.IsMouseInverted();
        _mouseSensitivity = SettingsManager.MouseSensitivity();

        camManagerClient.CanShake = _currentViewPos == ViewPosition.FirstPerson;

        ManagerLocator.TryGet <SettingsManager>().OnSettingsChanged += HandleSettingsChanged;
    }
示例#10
0
    private void OnDestroy()
    {
        var gc = ManagerLocator.TryGet <GameController>();

        if (gc != null)
        {
            gc.OnGameOver -= HandleGameOver;
        }
    }
示例#11
0
    private void Start()
    {
        Camera = GetComponent <Camera>();
        if (Camera != null)
        {
            ManagerLocator.TryGet <CameraManager>().Register((int)camType, this);
        }

        CanShake = true;
    }
示例#12
0
    private void OnDestroy()
    {
        var gc = ManagerLocator.TryGet <GameController>();

        if (gc != null)
        {
            gc.OnLiveEnemyCountChanged    -= HandleLiveEnemyCountChanged;
            gc.OnDeadEnemyCountChanged    -= HandleDeadEnemyCountChanged;
            gc.OnBulletsFiredCountChanged -= HandleBulletsFiredCountChanged;
        }
    }
示例#13
0
 private void Update()
 {
     if (Input.GetKey(KeyCode.Escape))
     {
         var gc = ManagerLocator.TryGet <GameController>();
         if (gc != null && gc.IsPlaying)
         {
             StartCoroutine(PauseGameRoutine(gc));
         }
     }
 }
示例#14
0
    private void ProcessCamPerspectiveSwitchInput()
    {
        if (Input.GetKeyDown(KeyCode.C))
        {
            camRotator.TogglePerspective();
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            var hud = ManagerLocator.TryGet <HUD>();
            hud?.ToggleRearViewMirrorCamera();
        }
    }
示例#15
0
    private void Start()
    {
        var hitManager = ManagerLocator.TryGet <HitManager>();

        if (hitManager != null)
        {
            hitManager.Register(gameObject, this);
            if (log)
            {
                Debug.Log("Registering: " + gameObject.name);
            }
        }
    }
示例#16
0
    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);
    }
示例#17
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;
        }
    }
示例#18
0
    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();
        }
    }
示例#19
0
    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();
    }
示例#20
0
    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);
        }
    }
示例#21
0
    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();
    }
示例#22
0
 private void MakePlayerDie()
 {
     ManagerLocator.TryGet <PlayerController>().HP.Hit(Vector3.zero, 200);
 }
示例#23
0
 private void CacheDependencies()
 {
     _spawner = ManagerLocator.TryGet <SpawnManager>();
     _player  = ManagerLocator.TryGet <PlayerController>();
     _hud     = ManagerLocator.TryGet <HUD>();
 }
示例#24
0
 private void Start()
 {
     _poolManager = ManagerLocator.TryGet <PoolManager>();
 }
示例#25
0
 private void Start()
 {
     ManagerLocator.TryGet <GameController>().OnGameOver += HandleGameOver;
 }
示例#26
0
 public void OnNewGameButtonClicked()
 {
     HideAllMenuItems();
     ManagerLocator.TryGet <GameController>().StartNewGame();
 }