1 using System.Collections;
2 using System.Collections.Generic;
4 using UnityEngine.Events;
15 [Header(
"Fuel Properties")]
16 [Tooltip(
"The total number of gallons in the fuel tank.")]
17 public float fuelCapacity = 26f;
18 [Tooltip(
"The average fuel burn per hour")]
19 public float fuelBurnRate = 6.1f;
22 public UnityEvent onFuelFull =
new UnityEvent();
27 private float currentFuel;
28 public float CurrentFuel
30 get{
return currentFuel;}
33 private float normalizeFuel;
34 public float NormalizedFuel
36 get{
return normalizeFuel;}
41 #region Custom Methods
47 currentFuel = fuelCapacity;
55 currentFuel += aFuelAmount;
56 currentFuel = Mathf.Clamp(currentFuel, 0f, fuelCapacity);
58 if(currentFuel >= fuelCapacity)
60 if(onFuelFull !=
null)
71 currentFuel = fuelCapacity;
79 float currentBurn = ((fuelBurnRate * aPrecentage) / 3600f) * Time.deltaTime;
80 currentFuel -= currentBurn;
81 currentFuel = Mathf.Clamp(currentFuel, 0f, fuelCapacity);
84 normalizeFuel = currentFuel / fuelCapacity;