Cooking function can find the best dish possible
This commit is contained in:
@@ -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