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 { [SerializeField] private AudioClip _buttonClick; [SerializeField] private AudioClip _deny; [SerializeField] private AudioClip _coffeeMachine; [SerializeField] private AudioSource _audioSource; [SerializeField] private List _coffeePlaces = new(); [SerializeField] private bool _isCooking = false; [SerializeField] private List _coffeItemPrefabs = new(); public void CookCoffee() { _audioSource.PlayOneShot(_buttonClick); if (_isCooking) return; _isCooking = true; StartCoroutine(CookCoffeeRoutine()); } private IEnumerator CookCoffeeRoutine() { yield return new WaitForSeconds(0.5f); _audioSource.PlayOneShot(_coffeeMachine); yield return new WaitForSeconds(7); for (int i = 0; i < 2; i++) { 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)); } } _isCooking = false; } }