Irgendjemand musste es ja machen...
This commit is contained in:
@ -13,11 +13,34 @@ public class VendingMachine : MonoBehaviour
|
||||
|
||||
[SerializeField]
|
||||
private float _shootForce;
|
||||
|
||||
[SerializeField]
|
||||
private bool _isReady;
|
||||
|
||||
[SerializeField] private AudioSource _audioSource;
|
||||
|
||||
[SerializeField] private AudioClip _vendingMachineSound;
|
||||
[SerializeField] private AudioClip _errorSound;
|
||||
|
||||
public void DropPiza()
|
||||
{
|
||||
PickupInteractible pizza = Instantiate(_pizzaPrefab, _pizzaChute.position, _pizzaChute.rotation);
|
||||
if (_isReady)
|
||||
StartCoroutine(DropPizzaRoutine());
|
||||
else
|
||||
_audioSource.PlayOneShot(_errorSound);
|
||||
}
|
||||
|
||||
private IEnumerator DropPizzaRoutine()
|
||||
{
|
||||
_isReady = false;
|
||||
|
||||
_audioSource.PlayOneShot(_vendingMachineSound);
|
||||
|
||||
yield return new WaitForSeconds(2.7f);
|
||||
|
||||
PickupInteractible pizza = Instantiate(_pizzaPrefab, _pizzaChute.position, _pizzaChute.rotation);
|
||||
pizza.GetComponent<Rigidbody>().AddForce(new Vector3(0, 0, _shootForce), ForceMode.Impulse);
|
||||
|
||||
_isReady = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user