Cooking function can find the best dish possible

This commit is contained in:
2024-03-12 14:57:25 +01:00
parent 9636ce41d3
commit 35211790a4
2 changed files with 25 additions and 6 deletions

View File

@@ -641,7 +641,7 @@ Transform:
m_GameObject: {fileID: 537514707} m_GameObject: {fileID: 537514707}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 2.04, y: -2.51, z: 0} m_LocalPosition: {x: 0.19, y: -0.12, z: 0}
m_LocalScale: {x: 2, y: 2, z: 2} m_LocalScale: {x: 2, y: 2, z: 2}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
@@ -1031,7 +1031,7 @@ Transform:
m_GameObject: {fileID: 885031692} m_GameObject: {fileID: 885031692}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 3.06, y: -2.09, z: 0} m_LocalPosition: {x: 2.08, y: -0.27, z: 0}
m_LocalScale: {x: 2, y: 2, z: 2} m_LocalScale: {x: 2, y: 2, z: 2}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []

View File

@@ -29,8 +29,9 @@ public class Cooking : MonoBehaviour
} }
} }
List <GameObject> PossibleDishes = new List <GameObject>();
List <GameObject> PossibleDishes = new List <GameObject>();
// Find the dishes, where all ingredients exist // Find the dishes, where all ingredients exist
foreach (GameObject Dish in AllDishes) { foreach (GameObject Dish in AllDishes) {
@@ -51,11 +52,29 @@ public class Cooking : MonoBehaviour
} }
} }
foreach (GameObject Dish in PossibleDishes) { // No dishes possible
Debug.Log(Dish);
if (PossibleDishes.Count < 1) {
return;
} }
GameObject BestDish = null;
foreach (GameObject Dish in PossibleDishes) {
if (BestDish == null) {
BestDish = Dish;
continue;
}
int CurrentNutritionalValue = Dish.GetComponent<Dish>().NutritionalValue;
int BestNutrionnalValue = BestDish.GetComponent<Dish>().NutritionalValue;
if (CurrentNutritionalValue > BestNutrionnalValue) {
BestDish = Dish;
}
}
Debug.Log(BestDish.name);
} }