Esempio n. 1
0
    private void Consume()
    {
        _currentAmount -= _consumingTimeStep * Time.deltaTime;

        if (_currentAmount <= 0)
        {
            _currentAmount = 0;

            // Deactivates automatically until full reloading
            _isActive = false;

            // Starts full reloading
            _fullReloading = true;

            // Informs that boost speed was deactivated
            if (GameEventsManager.OnBoostActivated != null)
            {
                GameEventsManager.OnBoostActivated(false);
            }
        }

        if (GameEventsManager.OnBoostAmountChanged != null)
        {
            GameEventsManager.OnBoostAmountChanged(_currentAmount / _maxAmount);
        }
    }
Esempio n. 2
0
    private void Reload()
    {
        if (_currentAmount >= _maxAmount)
        {
            return;
        }

        _currentAmount += _consumingTimeStep * Time.deltaTime;

        if (_currentAmount >= _maxAmount)
        {
            _currentAmount = _maxAmount;
            _fullReloading = false;
        }

        if (GameEventsManager.OnBoostAmountChanged != null)
        {
            GameEventsManager.OnBoostAmountChanged(_currentAmount / _maxAmount);
        }
    }
Esempio n. 3
0
    private void Setup(float reloadingStep, float consumingStep, float maxAmount)
    {
        _fullReloading = true;

        _reloadingTimeStep = reloadingStep;
        _consumingTimeStep = consumingStep;
        _maxAmount         = maxAmount;

        _currentAmount = 0;

        _isActive = false;

        if (GameEventsManager.OnBoostAmountChanged != null)
        {
            GameEventsManager.OnBoostAmountChanged(_currentAmount / _maxAmount);
        }

        if (GameEventsManager.OnBoostActivated != null)
        {
            GameEventsManager.OnBoostActivated(false);
        }

        _enabled = true;
    }