Exemplo n.º 1
0
        private void Start()
        {
            _currentLives             = _startLives;
            _canExecuteHealingAbility = true;

            // Start losing lives when the game starts
            _loseLivesTask = STasks.DoUntil(LoseOneLife, () => _currentLives == 0, 1.0f).OnComplete(OnGameOver);
        }
Exemplo n.º 2
0
        private void RandomizeCameraColorThreeTimes()
        {
            // Randomizes the color of the camera three times, with a 1.5 seconds wait between changes.
            _startColor = _camera.backgroundColor;
            int timesRandomized = 0;

            // If we already have a task doing this, kill it
            _randomizeCameraColorTask?.Kill();
            _randomizeCameraColorTask = STasks.DoUntil(
                action: () =>
            {
                timesRandomized++;
                _camera.backgroundColor = new Color(Random.value, Random.value, Random.value);
            },
                condition: () => timesRandomized > 3,
                every: 1.5f);

            // Reset the color on complete
            _randomizeCameraColorTask.OnComplete(() => _camera.backgroundColor = _startColor);
        }