コード例 #1
0
    private void Update()
    {
        if (!_playerCharging)
        {
            return;
        }

        if (_currentCharge <= 0)
        {
            return;
        }

        if (_fuelComponent == null)
        {
            return;
        }

        float amount = _chargingTimeStep * Time.deltaTime;

        _currentCharge -= amount;

        bool canContinueCharging = _fuelComponent.Charge(amount);

        // If fuel is full then stop charging
        if (!canContinueCharging)
        {
            _playerCharging = false;

            if (GameEventsManager.OnFuelStopCharging != null)
            {
                GameEventsManager.OnFuelStopCharging();
            }
        }

        // Checks if charge station has charge
        if (_currentCharge <= 0)
        {
            Empty();
        }
    }