private void Consume() { _currentAmount -= _consumingTimeStep * Time.deltaTime; if (GameEventsManager.OnFuelAmountChanged != null) { GameEventsManager.OnFuelAmountChanged(_currentAmount / _maxAmount); } if (_currentAmount <= 0) { if (GameEventsManager.OnFuelEmpty != null) { GameEventsManager.OnFuelEmpty(); } } }
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); }
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; }