food position fix

This commit is contained in:
2024-04-03 09:45:30 +02:00
parent 5646ed6504
commit 7c026e34ff
5 changed files with 308 additions and 297 deletions

View File

@@ -56,5 +56,5 @@
"temp/": true,
"Temp/": true
},
"dotnet.defaultSolution": "Let-Him-Cook.sln"
"dotnet.defaultSolution": "Let Him Cook.sln"
}

File diff suppressed because it is too large Load Diff

View File

@@ -15,6 +15,7 @@ public class Cooking : MonoBehaviour
// }
public Vector3 FinishedDishPosition;
public GameObject AllIngredients;
public void CreateDish() {
List <GameObject> Ingredients = GetIngredients();
@@ -29,8 +30,6 @@ public class Cooking : MonoBehaviour
foreach (GameObject Ingredient in Ingredients) {
Debug.Log(Ingredient.name);
List <GameObject> Dishes = Ingredient.GetComponent<Ingredient>().IngredientIn;
foreach (GameObject Dish in Dishes) {
@@ -97,14 +96,27 @@ public class Cooking : MonoBehaviour
}
}
// Remove ingredients and add the dish
// // Remove ingredients and add the dish
// foreach (GameObject Ingredient in UsedIngredients) {
// Transform transform = Ingredient.GetComponent<Ingredient>().transform;
// transform.position = Vector3.up * 50;
// }
BestDish.transform.position = FinishedDishPosition;
foreach (GameObject Ingredient in UsedIngredients) {
Transform transform = Ingredient.GetComponent<Ingredient>().transform;
transform.position = Vector3.up * 50;
}
BestDish.transform.position = FinishedDishPosition;
// Return ingredients to table
for (int i = 0; i < AllIngredients.transform.childCount; i++)
{
GameObject ingredient = AllIngredients.transform.GetChild(i).gameObject;
ingredient.GetComponent<Ingredient>().ResetPosition();
}
}

View File

@@ -5,18 +5,26 @@ using UnityEngine;
public class Dish : MonoBehaviour
{
public List <GameObject> RequiredIngredients;
public int NutritionalValue;
public int NutritionalValue = 0;
// Start is called before the first frame update
void Start()
{
if (NutritionalValue > 0) {
return;
}
NutritionalValue = 0;
foreach (GameObject Ingredient in RequiredIngredients) {
int IngredientValue = Ingredient.GetComponent<Ingredient>().NutritionalValue;
NutritionalValue += IngredientValue;
}
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -12,9 +12,10 @@ public class Ingredient : MonoBehaviour
public int NutritionalValue;
bool isMoving = false;
//public GameObject table;
private Transform DefaultTransform;
void Start()
{
DefaultTransform = transform; //TODO pointer error
}
// Update is called once per frame
@@ -24,9 +25,10 @@ public class Ingredient : MonoBehaviour
{
Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
transform.position = new Vector3 (mousePosition.x, mousePosition.y, transform.position.z);
//Debug.Log(table.Bounds.Contains(mousePosition));
}
ResetPosition();
}
@@ -37,4 +39,12 @@ public class Ingredient : MonoBehaviour
else
isMoving = true;
}
public void ResetPosition()
{
transform.position = DefaultTransform.position;
Debug.Log(gameObject.name);
Debug.Log(transform.position);
Debug.Log(DefaultTransform.position);
}
}