Initial commit
This commit is contained in:
21
Assets/Scripts/FuelTank.cs
Normal file
21
Assets/Scripts/FuelTank.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class FuelTank : MonoBehaviour
|
||||
{
|
||||
public float fuelAmount = 1000f; // kg of fuel available in the tank
|
||||
public bool isEmpty => fuelAmount <= 0f;
|
||||
public float RequestFuel(float amount)
|
||||
{
|
||||
float fuelGiven = Mathf.Min(amount, fuelAmount);
|
||||
fuelAmount -= fuelGiven;
|
||||
return fuelGiven;
|
||||
}
|
||||
public float GetFuelAmount() => fuelAmount;
|
||||
void Update()
|
||||
{
|
||||
if (fuelAmount <= 0f)
|
||||
{
|
||||
fuelAmount = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user