Ejemplo n.º 1
0
 public override void StartCooking()
 {
     StartCoroutine("WaitAFrame");
     friedEgg.SetParent(null);
     canvas.transform.SetParent(friedEgg);
     fEgg.SetMarker(GetMarker());
 }
    public IEnumerator RestockFood(GameObject foodType, float time)
    {
        List <PlaceMarker> markers = GetComponentsInChildren <PlaceMarker>().ToList();

        for (int i = 0; i < markers.Count; i++)
        {
            if (markers[i].transform.parent.CompareTag("Food"))
            {
                continue;
            }

            if (!markers[i].GetOccupation())
            {
                GameObject food = Instantiate(foodType, markers[i].transform.position, markers[i].transform.rotation);
                Food_O     f    = food.GetComponent <Food_O>();
                f.SetMarker(markers[i]);
                f.EnablePhysics(transform);
                f.ChangeDrag(f.defaultDrag);
                f.SetOnSurface(true);
                f.SetFreshness(true);
                markers[i].SetOccupation(true);
                ListOfFood().Add(f);
                MarkerList().Remove(markers[i]);
                yield return(new WaitForSeconds(time));
            }
        }
    }
    bool CheckForChildren(Food_O bottom) //checking if the food has children and configuring accordingly
    {
        Food_O[] food = bottom.GetComponentsInChildren <Food_O>();
        Move_S   m    = bottom.GetComponentInParent <Move_S>(); //if the foo is stacked, bottom is the food at the bottom of the stack

        if (bottom.GetFreshness())                              //untouched food
        {
            if (manager != null)                                //cheap way to configure, checking scene basically
            {
                if (manager.GetItemPrice(bottom.GetName()))     //if can afford
                {
                    bottom.SetFreshness(false);
                }
                else
                {
                    return(false);
                }
            }
        }
        i.OnPickUp(bottom.transform);
        if (m != null) //checking if on board/ plate / tray
        {
            for (int i = 0; i < food.Length; i++)
            {
                food[i].SetOnSurface(false);
                m.ListOfFood().Remove(food[i]);         //removing the food from the script list
            }
            if (firstOnStack != null || stack == 1)     //if theres a stack or singular food
            {
                m.MarkerList().Add(bottom.GetMarker()); //readding the marker to the board/plate/tray for future
                bottom.SetMarker(null);
            }
            if (m.startedWithFood) //checking if the surface needs replenishing
            {
                if (m.ListOfFood().Count == 0)
                {
                    StartCoroutine(m.RestockFood(m.foodType, .2f));
                }
            }
        }
        for (int i = 0; i < food.Length; i++) //for all food, be it one or more
        {
            food[i].stack = i + 1;            //changing the food variables
            food[i].ChangeDrag(3);
            if (CheckObjectCount.objects.Contains(food[i].gameObject))
            {
                CheckObjectCount.objects.Remove(food[i].gameObject);
            }
            if (food[i] != bottom)
            {
                food[i].DisablePhysics(food[i - 1].transform);
            }
            food[i].inStack = false;
        }
        return(true);
    }