2024-04-07 15:46:17 +02:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using Interaction;
|
|
|
|
using Microsoft.VisualStudio.RpcContracts.Logging;
|
|
|
|
using UnityEngine;
|
|
|
|
using Utility;
|
|
|
|
|
|
|
|
public class CoffeeMachine : MonoBehaviour
|
|
|
|
{
|
2024-04-07 17:30:22 +02:00
|
|
|
[SerializeField]
|
|
|
|
private AudioClip _buttonClick;
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private AudioSource _audioSource;
|
|
|
|
|
2024-04-07 15:46:17 +02:00
|
|
|
[SerializeField]
|
|
|
|
private List<CoffeePlace> _coffeePlaces = new();
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private bool _isCooking = false;
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private List<PickupInteractible> _coffeItemPrefabs = new();
|
|
|
|
|
|
|
|
public void CookCoffee()
|
|
|
|
{
|
2024-04-07 17:30:22 +02:00
|
|
|
_audioSource.PlayOneShot(_buttonClick);
|
2024-04-07 15:46:17 +02:00
|
|
|
|
|
|
|
if (_isCooking)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_isCooking = true;
|
|
|
|
|
|
|
|
StartCoroutine(CookCoffeeRoutine());
|
|
|
|
}
|
|
|
|
|
|
|
|
private IEnumerator CookCoffeeRoutine()
|
|
|
|
{
|
|
|
|
// TODO: Start blinking
|
|
|
|
|
|
|
|
Debug.Log("Blinky");
|
|
|
|
|
|
|
|
yield return new WaitForSeconds(2);
|
|
|
|
|
|
|
|
// SPiele kaffeemaschinen sound
|
|
|
|
Debug.Log("Brrrrr");
|
|
|
|
|
|
|
|
yield return new WaitForSeconds(5);
|
|
|
|
|
|
|
|
CoffeePlace coffeePlace = _coffeePlaces.Where(c => c.IsFree()).ToList().GetRandomElement();
|
|
|
|
|
|
|
|
if (coffeePlace == null)
|
|
|
|
{
|
|
|
|
// TODO: Spill coffee
|
|
|
|
Debug.Log("misty kaki");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Instantiate(_coffeItemPrefabs.GetRandomElement(), coffeePlace.transform.position, Quaternion.Euler(0, Random.Range(0.0f, 360.0f), 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
yield return new WaitForSeconds(1);
|
|
|
|
|
|
|
|
// todo: Play pling sound
|
|
|
|
|
|
|
|
_isCooking = false;
|
|
|
|
}
|
|
|
|
}
|