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()); }
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); }
private void OnDestroy() { // Kill the Lose Lives task when the player is destroyed _loseLivesTask?.Kill(); _healingAbilityCooldownTask?.Kill(); }