Пример #1
0
    public IngredientObject Remove()
    {
        IngredientObject toRemove = ingredients[ingredients.Count - 1];

        ingredients.RemoveAt(ingredients.Count - 1);
        return(toRemove);
    }
Пример #2
0
    public void Init()
    {
        IngredientObject.Init_Ob(prefab);

        TestFoodMaker.Instance.onFeverStart += new OnFeverStart(FeverStart);
        TestFoodMaker.Instance.onFeverEnd   += new OnFeverEnd(FeverEnd);
    }
Пример #3
0
 void OnTriggerStay2D(Collider2D collider)
 {
     Debug.Log("Encountered collider");
     if (collider.tag == "ingredient" && currentItem == null)
     {
         currentItem = collider.gameObject;
         collider.transform.parent        = transform;
         collider.transform.localPosition = new Vector2(0, 7f);
         collider.GetComponent <BoxCollider2D>().enabled = false;
         Debug.Log("changed parent:");
         Debug.Log(collider.transform.parent);
     }
     if (collider.tag == "pot" && currentItem == null && collider.GetComponent <CookingPot>().ingredient != null)
     {
         Debug.Log("removing item from log");
         IngredientObject ingredient = collider.GetComponent <CookingPot>().ingredient;
         collider.GetComponent <CookingPot>().ingredient = null;
         ingredient.gameObject.SetActive(true);
         ingredient.transform.parent        = transform;
         ingredient.transform.localPosition = new Vector2(0, 7f);
         currentItem = ingredient.gameObject;
     }
     if (collider.tag == "plate" && currentItem == null)
     {
         Debug.Log("removing item from plate");
         IngredientObject ingredient = collider.GetComponent <MealObject>().Remove();
         ingredient.gameObject.SetActive(true);
         ingredient.transform.parent        = transform;
         ingredient.transform.localPosition = new Vector2(0, 7f);
         currentItem = ingredient.gameObject;
     }
 }
Пример #4
0
 public void StartGame()
 {
     Time.timeScale = 1f;
     Score          = 0;
     spawner.StartSpawn();
     foodMaker.ResetValue();
     satisfy.ResetValues();
     IngredientObject.ResetObject();
     overUI.SetActive(false);
 }
Пример #5
0
    public void Add(IngredientObject ingredient)
    {
        ingredients.Add(ingredient);
        List <Ingredient> ingredientList = new List <Ingredient>();

        foreach (IngredientObject obj in ingredients)
        {
            ingredientList.Add(obj.ingredient);
        }
        Debug.Log(ingredientList);
        lvlManager.CheckComplete(ingredientList);
    }
Пример #6
0
    public static void Init_Ob(IngredientObject _prefab)
    {
        prefab        = _prefab;
        activatedOb   = new List <IngredientObject>();
        deactivatedOb = new Queue <IngredientObject>();

        for (int i = 0; i < max_Ob; i++)
        {
            IngredientObject temp = Instantiate(prefab);
            deactivatedOb.Enqueue(temp);
            temp.gameObject.SetActive(false);
        }
    }
Пример #7
0
 void Update()
 {
     if (boiling && ingredient != null)
     {
         if (!boilingSound.isPlaying)
         {
             if (cookingTime == 0)
             {
                 Debug.Log("Play Sound");
                 boilingSound.Stop();
                 boilingSound.Play();
             }
             else
             {
                 Debug.Log("Unpause sound");
                 boilingSound.UnPause();
             }
         }
     }
     else
     {
         boilingSound.Pause();
     }
     animator.SetBool("boiling", boiling && ingredient != null);
     if (ingredient != null && boiling)
     {
         // TODO: change to do burning and stuff + check cookable
         cookingTime += Time.deltaTime;
         IngredientData data = levelManager.GetIngredientData(ingredient.ingredient.id);
         if (data.id == ingredient.ingredient.id && cookingTime > data.burnTime)
         {
             burnedSound.Play();
             levelManager.HandleBurned(ingredient.ingredient.id);
             GameObject.Destroy(ingredient.gameObject);
             ingredient = null;
             Debug.Log("Ingredient Burned! Destroying...");
         }
         if (ingredient && data.id == ingredient.ingredient.id && cookingTime > data.cookTime)
         {
             if (!ingredient.ingredient.cooked)
             {
                 cookedSound.Play();
             }
             ingredient.ingredient.cooked = true;
             ingredient.GetComponent <SpriteRenderer>().sprite = data.cookedSprite;
         }
     }
 }
Пример #8
0
    IEnumerator SpawningTrash()
    {
        int randTime = 0;

        while (true)
        {
            FoodIngredient next_trash = ingDB.GetRandomTrash();

            randTime = Random.Range(5, 16);
            yield return(new WaitForSeconds(randTime));

            var ing_Object = IngredientObject.Pull_Ob();

            Vector3 x_offset = new Vector3(Random.Range(-0.1f, 0.1f), 0f, 0f);

            ing_Object.transform.position = transform.position + x_offset;
            ing_Object.Init(next_trash);
        }
    }
Пример #9
0
    IEnumerator SpawnIngRoutine()
    {
        while (true)
        {
            next_ing             = ingDB.GetRandomIngredient();
            nextIng_Image.sprite = next_ing.sprite;

            yield return(new WaitForSeconds(spawnCoolTime));

            FoodIngredient ing = next_ing;

            var ing_Object = IngredientObject.Pull_Ob();

            Vector3 x_offset = new Vector3(Random.Range(-0.1f, 0.1f), 0f, 0f);

            ing_Object.transform.position = transform.position + x_offset;
            ing_Object.Init(ing);
        }
    }
Пример #10
0
 void OnCollisionStay2D(Collision2D collider)
 {
     Debug.Log("Pot collision activated.");
     if (collider.gameObject.tag == "ingredient" && collider.transform.parent == null)
     {
         Ingredient     thatIngredient = collider.gameObject.GetComponent <IngredientObject>().ingredient;
         IngredientData data           = levelManager.GetIngredientData(thatIngredient.id);
         if (this.ingredient == null && (!data.preperable || thatIngredient.prepared))
         {
             Debug.Log("entering pot");
             Debug.Log(collider.transform.parent);
             this.ingredient = collider.gameObject.GetComponent <IngredientObject>();
             collider.gameObject.GetComponent <BoxCollider2D>().enabled = false;
             collider.gameObject.SetActive(false);
             cookingTime = 0;
         }
         else
         {
             // Todo: reject more intelligently
             Debug.Log("rejecting from pot");
             collider.transform.position = (Vector2)this.transform.position + kickOutVector;
         }
     }
 }
Пример #11
0
 public void Input(IngredientObject objectItem)
 {
     ingredient = objectItem;
     procesTime = objectItem.procesTime;
     Proces();
 }