food position fix
This commit is contained in:
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -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
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
NutritionalValue = 0;
|
||||
|
||||
foreach (GameObject Ingredient in RequiredIngredients) {
|
||||
|
||||
int IngredientValue = Ingredient.GetComponent<Ingredient>().NutritionalValue;
|
||||
|
||||
NutritionalValue += IngredientValue;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user