Example #1
0
        public bool FillFuelToMax(Vehicle i_VehicleToActOn, eEngineType i_EngineTypeBasedOnMethodUse, eFuelType i_TypeOfFuelToAdd, float i_AmountOfFuel)
        {
            bool resultOfFuel = false;

            switch (i_EngineTypeBasedOnMethodUse)
            {
            case eEngineType.Fuel:
                FuelEngine currentFuelEngine = m_VehicleInGarage.VehicleEngine as FuelEngine;
                resultOfFuel = currentFuelEngine.ChargeEnergyIfPossible(i_AmountOfFuel, i_TypeOfFuelToAdd);
                break;

            case eEngineType.Electric:
                ElectricEngine currentElectricEngine = m_VehicleInGarage.VehicleEngine as ElectricEngine;
                resultOfFuel = currentElectricEngine.ChargeEnergyIfPossible(i_AmountOfFuel);
                break;
            }

            if (resultOfFuel)
            {
                i_VehicleToActOn.PercentOfEnergyLeft = 100;
                i_VehicleToActOn.VehicleEngine.CurrentAmountOfEnergy = i_VehicleToActOn.VehicleEngine.MaxAmountOfEnergy;
            }

            return(resultOfFuel);
        }