コード例 #1
0
 public override void SetEnergy(float i_CurrentEnergyAmount)
 {
     EnergySource.MaxEnergy        = (float)Fuel.eFuelTankCapacity.Truck;
     ((Fuel)EnergySource).FuelType = Fuel.eFuelType.Soler;
     EnergySource.FillEnergy(i_CurrentEnergyAmount);
     CalculateEnergyPercent();
 }
コード例 #2
0
        public override void SetEnergy(float i_CurrentEnergyAmount)
        {
            if (EnergySource is Fuel)
            {
                EnergySource.MaxEnergy        = (float)Fuel.eFuelTankCapacity.Car;
                ((Fuel)EnergySource).FuelType = Fuel.eFuelType.Octan96;
                EnergySource.FillEnergy(i_CurrentEnergyAmount);
            }
            else
            {
                EnergySource.MaxEnergy = k_MaxBatteryCapacity;
                EnergySource.FillEnergy(i_CurrentEnergyAmount / 60);
            }

            CalculateEnergyPercent();
        }
コード例 #3
0
ファイル: Vehicle.cs プロジェクト: Ziv3r/Garage-
 public void FillEnergy(string i_Amount, string i_FuelType = "None")
 {
     try
     {
         string        formatedFuelType = char.ToUpper(i_FuelType[0]) + i_FuelType.Substring(1);
         float         amount           = float.Parse(i_Amount);
         Gas.eFuelType type             = (Gas.eFuelType)Enum.Parse(typeof(Gas.eFuelType), formatedFuelType);
         amount = type == Gas.eFuelType.None ? amount / 60 : amount; // user provide amount in minutes. amount saved in hours
         m_EnergySource.FillEnergy(amount, type);
     }
     catch (FormatException ex)
     {
         throw new ArgumentException(
                   string.Format(
                       "Error: \"{0}\" is not a valid type of feul, " +
                       "or \"{1}\" is not a valid amount",
                       i_FuelType),
                   ex);
     }
 }