private void OnMouseDown() { // Get the player Player player = FindObjectOfType <Player>(); // Does the player have a matching fuel type? FuelTank emptiest = player.GetEmptiestNonEmptyFuelTankOfType(type); // If so, get the emptiest tank with that type and put it in the torch if (emptiest != null) { float leftover = addFuel(emptiest.quantity, emptiest.type); emptiest.SetFuel(leftover, emptiest.type); } }
private void AttemptLightTorch() { Torch nearest = GameManager.instance.GetNearestTorch(this.gameObject.transform.position, lightTorchRange); if (nearest == null) { // TODO: Other stuff here, like start a shrug animation? return; } // Does the player have a matching fuel type? FuelTank emptiest = GetEmptiestNonEmptyFuelTankOfType(nearest.type); // If so, get the emptiest tank with that type and put it in the torch if (emptiest != null) { float leftover = nearest.addFuel(emptiest.quantity, emptiest.type); emptiest.SetFuel(leftover, emptiest.type); } }