-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCookingBehaviour.cs
More file actions
39 lines (33 loc) · 1.16 KB
/
CookingBehaviour.cs
File metadata and controls
39 lines (33 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System.Collections.Generic;
using System.Linq;
using Cooking.Dishes;
using Cooking.Ingredients;
using UnityEngine;
namespace Cooking
{
public class CookingBehaviour : MonoBehaviour
{
[SerializeField] private Dish currentDish;
private List<Ingredient> _collectedIngredients = new List<Ingredient>();
private PointSystem PointSystem => GameObject.Find("PointSystem").GetComponent<PointSystem>();
public void CollectIngredient(Ingredient ingredient)
{
_collectedIngredients.Add(ingredient);
CheckIngredients();
}
private void CheckIngredients()
{
if (currentDish.ingredients.Count != _collectedIngredients.Count) return;
List<bool> check = new List<bool>();
for (int i = 0; i < _collectedIngredients.Count; i++)
{
check.Add(currentDish.ingredients[i] == _collectedIngredients[i].type);
}
if (!check.All(i => i)) return;
foreach (var ingredient in _collectedIngredients)
{
PointSystem.AddPoint(ingredient.points);
}
}
}
}