Cooking function can find the best dish possible
This commit is contained in:
@@ -641,7 +641,7 @@ Transform:
|
||||
m_GameObject: {fileID: 537514707}
|
||||
serializedVersion: 2
|
||||
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_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
@@ -1031,7 +1031,7 @@ Transform:
|
||||
m_GameObject: {fileID: 885031692}
|
||||
serializedVersion: 2
|
||||
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_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
|
||||
@@ -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
|
||||
|
||||
foreach (GameObject Dish in AllDishes) {
|
||||
@@ -51,11 +52,29 @@ public class Cooking : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
foreach (GameObject Dish in PossibleDishes) {
|
||||
Debug.Log(Dish);
|
||||
// No dishes possible
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user