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,
|
||||||
"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 Vector3 FinishedDishPosition;
|
||||||
|
public GameObject AllIngredients;
|
||||||
|
|
||||||
public void CreateDish() {
|
public void CreateDish() {
|
||||||
List <GameObject> Ingredients = GetIngredients();
|
List <GameObject> Ingredients = GetIngredients();
|
||||||
@@ -29,8 +30,6 @@ public class Cooking : MonoBehaviour
|
|||||||
|
|
||||||
foreach (GameObject Ingredient in Ingredients) {
|
foreach (GameObject Ingredient in Ingredients) {
|
||||||
|
|
||||||
Debug.Log(Ingredient.name);
|
|
||||||
|
|
||||||
List <GameObject> Dishes = Ingredient.GetComponent<Ingredient>().IngredientIn;
|
List <GameObject> Dishes = Ingredient.GetComponent<Ingredient>().IngredientIn;
|
||||||
|
|
||||||
foreach (GameObject Dish in Dishes) {
|
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) {
|
foreach (GameObject Ingredient in UsedIngredients) {
|
||||||
Transform transform = Ingredient.GetComponent<Ingredient>().transform;
|
Transform transform = Ingredient.GetComponent<Ingredient>().transform;
|
||||||
transform.position = Vector3.up * 50;
|
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 class Dish : MonoBehaviour
|
||||||
{
|
{
|
||||||
public List <GameObject> RequiredIngredients;
|
public List <GameObject> RequiredIngredients;
|
||||||
public int NutritionalValue;
|
public int NutritionalValue = 0;
|
||||||
|
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
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()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,10 @@ public class Ingredient : MonoBehaviour
|
|||||||
public int NutritionalValue;
|
public int NutritionalValue;
|
||||||
bool isMoving = false;
|
bool isMoving = false;
|
||||||
//public GameObject table;
|
//public GameObject table;
|
||||||
|
private Transform DefaultTransform;
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
DefaultTransform = transform; //TODO pointer error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
@@ -24,9 +25,10 @@ public class Ingredient : MonoBehaviour
|
|||||||
{
|
{
|
||||||
Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||||
transform.position = new Vector3 (mousePosition.x, mousePosition.y, transform.position.z);
|
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
|
else
|
||||||
isMoving = true;
|
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