Files
let-him-cook/Assets/Scripts/Cooking.cs
2024-03-12 13:50:20 +01:00

41 lines
884 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Cooking : MonoBehaviour
{
void CheckDishes()
{
foreach (GameObject ingredient in currentCollisions) {
Debug.Log(ingredient.name);
Debug.Log(ingredient.GetComponent<Ingredient>().NutritionalValue);
}
}
// Keep track of ingredients going on and off the cooker.
List <GameObject> currentCollisions = new List <GameObject> ();
private void OnTriggerEnter2D(Collider2D other) {
currentCollisions.Add (other.gameObject);
CheckDishes();
}
private void OnTriggerExit2D(Collider2D other) {
currentCollisions.Remove (other.gameObject);
}
void Update()
{
GetIngredients();
}
List <GameObject> GetIngredients()
{
return currentCollisions;
}
}