Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo n.º 3
0
        private void GainOneLife()
        {
            _canExecuteHealingAbility = false;
            _currentLives++;
            _livesUI.SetLives(_currentLives);

            // Show the cooldown UI
            _cooldownUI.Show();

            _healingAbilityCooldownTask?.Kill();

            // Reenable the healing ability after the cooldown
            _healingAbilityCooldownTask = STasks.Do(() => _canExecuteHealingAbility = true, _healingCooldown);

            // Update the cooldown UI every frame
            _healingAbilityCooldownTask.OnUpdate(() => _cooldownUI.SetProgress(_healingAbilityCooldownTask.Progress));

            // Hide the cooldown UI when the task is complete
            _healingAbilityCooldownTask.OnComplete(() => _cooldownUI.Hide());
        }
Ejemplo n.º 4
0
 private void PrintHelloWorldAfterThreeSeconds()
 {
     // Print "hello world" after three seconds
     STasks.Do(() => Debug.Log("Hello world!"), after: 3.0f);
 }