コード例 #1
0
    private void Consume()
    {
        _currentAmount -= _consumingTimeStep * Time.deltaTime;

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

        if (_currentAmount <= 0)
        {
            if (GameEventsManager.OnFuelEmpty != null)
            {
                GameEventsManager.OnFuelEmpty();
            }
        }
    }
コード例 #2
0
    public bool Charge(float amount)
    {
        if (_currentAmount >= _maxAmount)
        {
            return(false);
        }

        //_currentAmount = Mathf.Clamp(_currentAmount + _chargingTimeStep * Time.deltaTime, 0, _maxAmount);
        _currentAmount = Mathf.Clamp(_currentAmount + amount, 0, _maxAmount);

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

        return(_currentAmount < _maxAmount);
    }
コード例 #3
0
    private void Setup(float consumingStep, float maxAmount)
    {
        _consumingTimeStep = consumingStep;
        _maxAmount         = maxAmount;

        _currentAmount = _maxAmount;

        _isConsuming = false;

        _isCharging = false;

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

        _enabled = true;
    }