Exemplo n.º 1
0
 public void AddIngredients(ManaController.ManaIngredients ingredientType, int count)
 {
     for (int i = 0; i < count; i++)
     {
         CreateSingleIngredient(ingredientType, GetObjectByType(ingredientType));
     }
 }
Exemplo n.º 2
0
    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));
    }
Exemplo n.º 3
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);
    }
Exemplo n.º 4
0
    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);
    }
Exemplo n.º 5
0
 public void RemoveSingleIngredient(ManaController.ManaIngredients ingredientType, GameObject gameObject)
 {
     Destroy(gameObject);
     m_ingredientCount[ingredientType]--;
 }