public void AddIngredients(ManaController.ManaIngredients ingredientType, int count) { for (int i = 0; i < count; i++) { CreateSingleIngredient(ingredientType, GetObjectByType(ingredientType)); } }
private void CreateSingleIngredient(ManaController.ManaIngredients ingredient, GameObject objectToInstantiate) { if (m_ingredientCount[ingredient] >= m_maxIngredientCount) { return; } GameObject instansiated; Vector3 pos = GetRandomPositionInRange(ingredient); instansiated = Instantiate(objectToInstantiate, pos, new Quaternion(0, 0, 0, 0), m_parent); m_ingredientCount[ingredient]++; instansiated.transform.localPosition = pos; instansiated.transform.Rotate(new Vector3(-90, 0, 0)); }
private GameObject GetObjectByType(ManaController.ManaIngredients ingredientType) { switch (ingredientType) { case ManaController.ManaIngredients.Hummus: return(HummusObject); case ManaController.ManaIngredients.Fries: return(FriesObject); case ManaController.ManaIngredients.Salad: return(SaladObject); case ManaController.ManaIngredients.Falafel: return(FalafelObject); } return(null); }
private Vector3 GetRandomPositionInRange(ManaController.ManaIngredients ingredient) { Vector3 res = new Vector3(); switch (ingredient) { case ManaController.ManaIngredients.Hummus: { res.x = UnityEngine.Random.Range(HummusMinX, HummusMaxX); res.y = HummusY; res.z = UnityEngine.Random.Range(HummusMinZ, HummusMaxZ); break; } case ManaController.ManaIngredients.Fries: { res.x = UnityEngine.Random.Range(friesMinX, friesMaxX); res.y = friesY; res.z = UnityEngine.Random.Range(friesMinZ, friesMaxZ); break; } case ManaController.ManaIngredients.Salad: { res.x = UnityEngine.Random.Range(saladMinX, saladMaxX); res.y = saladY; res.z = UnityEngine.Random.Range(saladMinZ, saladMaxZ); break; } case ManaController.ManaIngredients.Falafel: { res.x = UnityEngine.Random.Range(falafelMinX, falafelMaxX); res.y = falafelY; res.z = UnityEngine.Random.Range(falafelMinZ, falafelMaxZ); break; } } return(res); }
public void RemoveSingleIngredient(ManaController.ManaIngredients ingredientType, GameObject gameObject) { Destroy(gameObject); m_ingredientCount[ingredientType]--; }