Example #1
0
        internal override void Refuel(Enums.eFuelTypes i_FuelType, float i_FuelAmount)
        {
            if (i_FuelType != m_FuelType)
            {
                throw new ArgumentException("Unable to fuel car with not matching fuel type");
            }
            if (m_CurrentEnergy + i_FuelAmount > m_MaxEnergy)
            {
                throw new ValueOutOfRangeException(0, m_MaxEnergy);
            }

            m_CurrentEnergy += i_FuelAmount;
        }
Example #2
0
        public object CreateGarageObject(object[] i_Parameters, Type i_Type, Type i_VehicleType)
        {
            object obj;

            Enums.eVehicleType vehicleType = (Enums.eVehicleType)Enum.Parse(typeof(Enums.eVehicleType), i_VehicleType.Name);

            if (i_Type == typeof(Wheel))
            {
                float           maxEnergy = (float)VehiclesDefualtConfigurations.sr_DefaultDictionary[vehicleType]["Maximum Air Pressure"];
                ConstructorInfo ci        = i_Type.GetConstructors()[0];
                i_Parameters[i_Parameters.Length - 1] = maxEnergy;
                obj = new Wheel((string)i_Parameters[0], (float)i_Parameters[1], (float)i_Parameters[2]);
            }
            if (i_Type == typeof(ElectricEngine))
            {
                float           maxEnergy = (float)VehiclesDefualtConfigurations.sr_DefaultDictionary[vehicleType]["Maximum Energy"];
                ConstructorInfo ci        = i_Type.GetConstructors()[0];
                i_Parameters[i_Parameters.Length - 1] = maxEnergy;
                obj = new ElectricEngine((float)i_Parameters[0], (float)i_Parameters[1]);
            }
            else if (i_Type == typeof(FuelEngine))
            {
                Enums.eFuelTypes fuelType  = (Enums.eFuelTypes)VehiclesDefualtConfigurations.sr_DefaultDictionary[vehicleType]["Fuel Type"];
                float            maxEnergy = (float)VehiclesDefualtConfigurations.sr_DefaultDictionary[vehicleType]["Maximum Energy"];
                ConstructorInfo  ci        = i_Type.GetConstructors()[0];
                i_Parameters[i_Parameters.Length - 2] = maxEnergy;
                i_Parameters[i_Parameters.Length - 1] = fuelType;
                obj = new FuelEngine((float)i_Parameters[0], (float)i_Parameters[1], (Enums.eFuelTypes)i_Parameters[2]);
            }
            else
            {
                ConstructorInfo ci = i_Type.GetConstructors()[0];
                obj = ci.Invoke(i_Parameters);
            }

            return(obj);
        }
Example #3
0
 internal abstract void Refuel(Enums.eFuelTypes i_FuelType, float i_FuelAmount);
Example #4
0
 internal override void Refuel(Enums.eFuelTypes i_FuelType, float i_FuelAmount)
 {
     throw new ArgumentException("Electric car can't fuel.");
 }
Example #5
0
 public FuelEngine(float i_CurrentEnergy, float i_MaxEnergy = float.MaxValue, Enums.eFuelTypes i_FuelType = Enums.eFuelTypes.None) :
     base(i_CurrentEnergy, i_MaxEnergy)
 {
     m_FuelType = i_FuelType;
 }