Exemplo n.º 1
0
 private void Update()
 {
     if (represent == null)
     {
         adjuster.SetActive(false);
     }
     if (adjuster.activeInHierarchy)
     {
         if (represent.GetComponent <Meal>())
         {
             Meal   meal     = represent.GetComponent <Meal>();
             Slider slider   = adjuster.transform.GetChild(4).GetComponent <Slider>();
             Text   textComp = adjuster.transform.GetChild(3).GetChild(0).GetComponent <Text>();
             sendQuantaty  = (int)slider.value * meal.minQuant;
             textComp.text = sendQuantaty.ToString();
         }
         else if (represent.GetComponent <MealMaterial>())
         {
             MealMaterial mealMaterial = represent.GetComponent <MealMaterial>();
             if (mealMaterial.countable)
             {
                 Slider slider   = adjuster.transform.GetChild(4).GetComponent <Slider>();
                 Text   textComp = adjuster.transform.GetChild(3).GetChild(0).GetComponent <Text>();
                 sendQuantaty  = (int)slider.value;
                 textComp.text = sendQuantaty.ToString();
             }
             else if (!mealMaterial.countable)
             {
                 Slider slider   = adjuster.transform.GetChild(4).GetComponent <Slider>();
                 Text   textComp = adjuster.transform.GetChild(3).GetChild(0).GetComponent <Text>();
                 sendQuantaty  = (int)slider.value * mealMaterial.minQuant;
                 textComp.text = sendQuantaty.ToString();
             }
         }
         else if (represent.GetComponent <RawMaterial>())
         {
             RawMaterial raw = represent.GetComponent <RawMaterial>();
             if (raw.countable)
             {
                 Slider slider   = adjuster.transform.GetChild(4).GetComponent <Slider>();
                 Text   textComp = adjuster.transform.GetChild(3).GetChild(0).GetComponent <Text>();
                 sendQuantaty  = (int)slider.value;
                 textComp.text = sendQuantaty.ToString();
             }
             else if (!raw.countable)
             {
                 Slider slider   = adjuster.transform.GetChild(4).GetComponent <Slider>();
                 Text   textComp = adjuster.transform.GetChild(3).GetChild(0).GetComponent <Text>();
                 sendQuantaty  = (int)slider.value * raw.minQuant;
                 textComp.text = sendQuantaty.ToString();
             }
         }
     }
 }
Exemplo n.º 2
0
    public void ProfilePage()
    {
        page7.SetActive(true);

        page7.transform.GetChild(4).GetComponent <Text>().text = mealNameSave;
        page7.transform.GetChild(5).GetComponent <Text>().text = mealDefSave;
        GameObject[] inputs = setInputs().ToArray();
        DefineMeal(inputs);
        float estimatedCost = CostEstimater(inputs);

        producedMeal.GetComponent <Meal>().estimatedCost       = estimatedCost;
        page7.transform.GetChild(8).GetComponent <Text>().text = estimatedCost.ToString(".00") + "$";
        int       counter = 0;
        Transform parent_ = page7.transform.GetChild(9).GetChild(1);

        profileIcon.GetComponent <Image>().sprite = mealImage;
        profileIcon.GetComponent <Image>().color  = Color.white;
        foreach (GameObject item in inputs)
        {
            GameObject slot = parent_.GetChild(counter).gameObject;
            slot.SetActive(true);
            Transform avatar = slot.transform.GetChild(0);
            if (item.GetComponent <MealMaterial>())
            {
                MealMaterial mealMaterial = item.GetComponent <MealMaterial>();
                avatar.GetChild(1).GetComponent <Image>().sprite = mealMaterial.image;
                avatar.GetChild(1).GetComponent <Image>().color  = Color.white;
                avatar.GetChild(2).GetComponent <Text>().text    = producedMeal.GetComponent <Meal>().InputCount[counter].ToString() + " gr";
                avatar.GetChild(3).GetComponent <Text>().text    = mealMaterial.name;
            }
            else if (item.GetComponent <RawMaterial>())
            {
                RawMaterial mealMaterial = item.GetComponent <RawMaterial>();
                avatar.GetChild(1).GetComponent <Image>().sprite = mealMaterial.image;
                avatar.GetChild(1).GetComponent <Image>().color  = Color.white;
                avatar.GetChild(2).GetComponent <Text>().text    = producedMeal.GetComponent <Meal>().InputCount[counter].ToString() + " gr";
                avatar.GetChild(3).GetComponent <Text>().text    = mealMaterial.name;
            }
            counter++;
        }
        for (int i = counter; i < 6; i++)
        {
            GameObject slot = parent_.GetChild(i).gameObject;
            slot.SetActive(false);
        }
        averageTaker();
    }
Exemplo n.º 3
0
    public void OnPointerClick(PointerEventData eventData)
    {
        if (station.inventory[index].typeOfItem != null)
        {
            if (eventData.button == PointerEventData.InputButton.Left)
            {
                represent = station.inventory[index].typeOfItem;
                if (!adjuster.activeInHierarchy)
                {
                    int tkg    = InventoryOfPlayer.tkg;
                    int tkgCur = InventoryOfPlayer.tkgCur;
                    adjuster.SetActive(true);
                    int yyFactor = Mathf.FloorToInt(index / 4);
                    int xxFactor = index % 4;
                    Station.adjusterIndex = index;
                    adjuster.GetComponent <RectTransform>().localPosition = new Vector3(992 + xx * xxFactor, 202 - yy * yyFactor);
                    int Count = station.inventory[index].count;
                    if (represent.GetComponent <Meal>())
                    {
                        Meal   meal     = represent.GetComponent <Meal>();
                        Slider slider   = adjuster.transform.GetChild(4).GetComponent <Slider>();
                        Text   textComp = adjuster.transform.GetChild(3).GetChild(0).GetComponent <Text>();
                        slider.wholeNumbers = true;
                        slider.maxValue     = tkg - tkgCur > Count?Mathf.FloorToInt(Count / meal.minQuant) : (tkg - tkgCur) / meal.minQuant;

                        slider.value  = 1;
                        textComp.text = meal.minQuant.ToString();
                        sendQuantaty  = meal.minQuant;
                    }
                    else if (represent.GetComponent <MealMaterial>())
                    {
                        MealMaterial mealMaterial = represent.GetComponent <MealMaterial>();
                        if (mealMaterial.countable)
                        {
                            Slider slider   = adjuster.transform.GetChild(4).GetComponent <Slider>();
                            Text   textComp = adjuster.transform.GetChild(3).GetChild(0).GetComponent <Text>();
                            slider.wholeNumbers = true;
                            slider.maxValue     = tkg - tkgCur > Count ? Count : tkg - tkgCur;
                            slider.value        = 1;
                            textComp.text       = 1.ToString();
                            sendQuantaty        = 1;
                        }
                        else if (!mealMaterial.countable)
                        {
                            MealMaterial meal     = represent.GetComponent <MealMaterial>();
                            Slider       slider   = adjuster.transform.GetChild(4).GetComponent <Slider>();
                            Text         textComp = adjuster.transform.GetChild(3).GetChild(0).GetComponent <Text>();
                            slider.wholeNumbers = true;
                            slider.maxValue     = tkg - tkgCur > Count?Mathf.FloorToInt(Count / meal.minQuant) : (tkg - tkgCur) / meal.minQuant;

                            slider.value  = 1;
                            textComp.text = meal.minQuant.ToString();
                            sendQuantaty  = meal.minQuant;
                        }
                    }
                    else if (represent.GetComponent <RawMaterial>())
                    {
                        RawMaterial raw = represent.GetComponent <RawMaterial>();
                        if (raw.countable)
                        {
                            Slider slider   = adjuster.transform.GetChild(4).GetComponent <Slider>();
                            Text   textComp = adjuster.transform.GetChild(3).GetChild(0).GetComponent <Text>();
                            slider.wholeNumbers = true;
                            slider.maxValue     = tkg - tkgCur > Count ? Count : tkg - tkgCur;
                            slider.value        = 1;
                            textComp.text       = 1.ToString();
                            sendQuantaty        = 1;
                        }
                        else if (!raw.countable)
                        {
                            RawMaterial meal     = raw;
                            Slider      slider   = adjuster.transform.GetChild(4).GetComponent <Slider>();
                            Text        textComp = adjuster.transform.GetChild(3).GetChild(0).GetComponent <Text>();
                            slider.wholeNumbers = true;
                            slider.maxValue     = tkg - tkgCur > Count?Mathf.FloorToInt(Count / meal.minQuant) : (tkg - tkgCur) / meal.minQuant;

                            slider.value  = 1;
                            textComp.text = meal.minQuant.ToString();
                            sendQuantaty  = meal.minQuant;
                        }
                    }
                    Station.sendQuantaty = sendQuantaty;
                }
                else
                {
                    adjuster.SetActive(false);
                }
            }
            else if (eventData.button == PointerEventData.InputButton.Middle)
            {
            }
            else if (eventData.button == PointerEventData.InputButton.Right)
            {
                ImageCreator.TakeIn(station.inventory[index].typeOfItem, out decrease);
            }
        }
    }
Exemplo n.º 4
0
    void UpdateAdjuster()
    {
        if (index == Station.adjusterIndex)
        {
            if (adjuster.activeInHierarchy)
            {
                int tkg    = InventoryOfPlayer.tkg;
                int tkgCur = InventoryOfPlayer.tkgCur;
                int Count  = station.inventory[index].count;
                if (represent.GetComponent <Meal>())
                {
                    Meal   meal     = represent.GetComponent <Meal>();
                    Slider slider   = adjuster.transform.GetChild(4).GetComponent <Slider>();
                    Text   textComp = adjuster.transform.GetChild(3).GetChild(0).GetComponent <Text>();
                    slider.maxValue = tkg - tkgCur > Count?Mathf.FloorToInt(Count / meal.minQuant) : (tkg - tkgCur) / meal.minQuant;

                    sendQuantaty  = (int)slider.value * meal.minQuant;
                    textComp.text = sendQuantaty.ToString();
                }
                else if (represent.GetComponent <MealMaterial>())
                {
                    MealMaterial mealMaterial = represent.GetComponent <MealMaterial>();
                    if (mealMaterial.countable)
                    {
                        Slider slider   = adjuster.transform.GetChild(4).GetComponent <Slider>();
                        Text   textComp = adjuster.transform.GetChild(3).GetChild(0).GetComponent <Text>();
                        slider.maxValue = tkg - tkgCur > Count ? Count : tkg - tkgCur;
                        sendQuantaty    = (int)slider.value;
                        textComp.text   = sendQuantaty.ToString();
                    }
                    else if (!mealMaterial.countable)
                    {
                        Slider slider   = adjuster.transform.GetChild(4).GetComponent <Slider>();
                        Text   textComp = adjuster.transform.GetChild(3).GetChild(0).GetComponent <Text>();
                        slider.maxValue = tkg - tkgCur > Count?Mathf.FloorToInt(Count / mealMaterial.minQuant) : (tkg - tkgCur) / mealMaterial.minQuant;

                        sendQuantaty  = (int)slider.value * mealMaterial.minQuant;
                        textComp.text = sendQuantaty.ToString();
                    }
                }
                else if (represent.GetComponent <RawMaterial>())
                {
                    RawMaterial raw = represent.GetComponent <RawMaterial>();
                    if (raw.countable)
                    {
                        Slider slider   = adjuster.transform.GetChild(4).GetComponent <Slider>();
                        Text   textComp = adjuster.transform.GetChild(3).GetChild(0).GetComponent <Text>();
                        slider.maxValue = tkg - tkgCur > Count ? Count : tkg - tkgCur;
                        sendQuantaty    = (int)slider.value;
                        textComp.text   = sendQuantaty.ToString();
                    }
                    else if (!raw.countable)
                    {
                        Slider slider   = adjuster.transform.GetChild(4).GetComponent <Slider>();
                        Text   textComp = adjuster.transform.GetChild(3).GetChild(0).GetComponent <Text>();
                        slider.maxValue = tkg - tkgCur > Count?Mathf.FloorToInt(Count / raw.minQuant) : (tkg - tkgCur) / raw.minQuant;

                        sendQuantaty  = (int)slider.value * raw.minQuant;
                        textComp.text = sendQuantaty.ToString();
                    }
                }
                Station.sendQuantaty = sendQuantaty;
            }
        }
    }
Exemplo n.º 5
0
 public void OnPointerClick(PointerEventData eventData)
 {
     if (represent != null && !OrdersMenuController.atOrderStation && !GameObject.FindWithTag("Player").GetComponent <PlayerController>().marketInventoryOpen)
     {
         if (eventData.button == PointerEventData.InputButton.Left && !adjuster.activeInHierarchy)
         {
             adjuster.SetActive(true);
             if (represent.GetComponent <Meal>())
             {
                 Meal   meal     = represent.GetComponent <Meal>();
                 Slider slider   = adjuster.transform.GetChild(4).GetComponent <Slider>();
                 Text   textComp = adjuster.transform.GetChild(3).GetChild(0).GetComponent <Text>();
                 slider.wholeNumbers = true;
                 slider.maxValue     = Mathf.FloorToInt(Count / meal.minQuant);
                 slider.value        = 1;
                 textComp.text       = meal.minQuant.ToString();
                 sendQuantaty        = meal.minQuant;
             }
             else if (represent.GetComponent <MealMaterial>())
             {
                 MealMaterial mealMaterial = represent.GetComponent <MealMaterial>();
                 if (mealMaterial.countable)
                 {
                     Slider slider   = adjuster.transform.GetChild(4).GetComponent <Slider>();
                     Text   textComp = adjuster.transform.GetChild(3).GetChild(0).GetComponent <Text>();
                     slider.wholeNumbers = true;
                     slider.maxValue     = Count;
                     slider.value        = 1;
                     textComp.text       = 1.ToString();
                     sendQuantaty        = 1;
                 }
                 else if (!mealMaterial.countable)
                 {
                     MealMaterial meal     = represent.GetComponent <MealMaterial>();
                     Slider       slider   = adjuster.transform.GetChild(4).GetComponent <Slider>();
                     Text         textComp = adjuster.transform.GetChild(3).GetChild(0).GetComponent <Text>();
                     slider.wholeNumbers = true;
                     slider.maxValue     = Mathf.FloorToInt(Count / meal.minQuant);
                     slider.value        = 1;
                     textComp.text       = meal.minQuant.ToString();
                     sendQuantaty        = meal.minQuant;
                 }
             }
             else if (represent.GetComponent <RawMaterial>())
             {
                 RawMaterial raw = represent.GetComponent <RawMaterial>();
                 if (raw.countable)
                 {
                     Slider slider   = adjuster.transform.GetChild(4).GetComponent <Slider>();
                     Text   textComp = adjuster.transform.GetChild(3).GetChild(0).GetComponent <Text>();
                     slider.wholeNumbers = true;
                     slider.maxValue     = Count;
                     slider.value        = 1;
                     textComp.text       = 1.ToString();
                     sendQuantaty        = 1;
                 }
                 else if (!raw.countable)
                 {
                     RawMaterial meal     = represent.GetComponent <RawMaterial>();
                     Slider      slider   = adjuster.transform.GetChild(4).GetComponent <Slider>();
                     Text        textComp = adjuster.transform.GetChild(3).GetChild(0).GetComponent <Text>();
                     slider.wholeNumbers = true;
                     slider.maxValue     = Mathf.FloorToInt(Count / meal.minQuant);
                     slider.value        = 1;
                     textComp.text       = meal.minQuant.ToString();
                     sendQuantaty        = meal.minQuant;
                 }
             }
             foreach (var item in InventoryOfPlayer.slots)
             {
                 if (item.slotui != gameObject)
                 {
                     item.slotui.GetComponent <PlayerSlot>().adjuster.SetActive(false);
                 }
             }
         }
         else if (eventData.button == PointerEventData.InputButton.Left && adjuster.activeInHierarchy)
         {
             adjuster.SetActive(false);
         }
         else if (eventData.button == PointerEventData.InputButton.Middle)
         {
         }
         else if (eventData.button == PointerEventData.InputButton.Right)
         {
             /* bool decrease = false;
              * ImageCreator.TakeIn(represent, out decrease);
              * if(decrease)
              * InventoryOfPlayer.BackTransaction(represent,1);*/
         }
     }
 }
Exemplo n.º 6
0
    /// <summary>
    /// yemeklerin iceriklerinin neyden ne kadar olacaginin oransal olarak hesaplayip listeler.
    /// </summary>
    /// <param name="inputs"> icerik cesitlerini gameobject olarak tutan liste.</param>
    /// <returns></returns>
    List <float> setInputCount(GameObject[] inputs)
    {
        List <float> returnable = new List <float>();
        float        total      = 0;

        foreach (var item in inputs)
        {
            Debug.Log(item.name);
            if (item.GetComponent <MealMaterial>())
            {
                switch (item.GetComponent <MealMaterial>().reqForPasta)
                {
                case MealMaterial.ReqForPasta.none:
                    break;

                case MealMaterial.ReqForPasta.low:
                    MealMaterial mat            = item.GetComponent <MealMaterial>();
                    float        necessaryQuant = 0.25f * (1f + Mathf.Pow(quality, mat.qualityIndex) / 100f);
                    total += necessaryQuant;
                    returnable.Add(necessaryQuant);
                    break;

                case MealMaterial.ReqForPasta.mid:
                    mat            = item.GetComponent <MealMaterial>();
                    necessaryQuant = 0.75f * (1f + Mathf.Pow(quality, mat.qualityIndex) / 100f);
                    total         += necessaryQuant;
                    returnable.Add(necessaryQuant);
                    break;

                case MealMaterial.ReqForPasta.high:
                    mat            = item.GetComponent <MealMaterial>();
                    necessaryQuant = 1.5f * (1f + Mathf.Pow(quality, mat.qualityIndex) / 100f);
                    total         += necessaryQuant;
                    returnable.Add(necessaryQuant);
                    break;

                case MealMaterial.ReqForPasta.veryHigh:
                    mat            = item.GetComponent <MealMaterial>();
                    necessaryQuant = 3f * (1f + Mathf.Pow(quality, mat.qualityIndex) / 100f);
                    total         += necessaryQuant;
                    returnable.Add(necessaryQuant);
                    break;

                default:
                    break;
                }
            }
            else if (item.GetComponent <RawMaterial>())
            {
                switch (item.GetComponent <RawMaterial>().req)
                {
                case RawMaterial.ReqForPasta.none:

                    break;

                case RawMaterial.ReqForPasta.low:
                    RawMaterial mat            = item.GetComponent <RawMaterial>();
                    float       necessaryQuant = 0.25f * (1f + Mathf.Pow(quality, mat.qualityIndex) / 100f);
                    total += necessaryQuant;
                    returnable.Add(necessaryQuant);
                    break;

                case RawMaterial.ReqForPasta.mid:
                    mat            = item.GetComponent <RawMaterial>();
                    necessaryQuant = 0.75f * (1f + Mathf.Pow(quality, mat.qualityIndex) / 100f);
                    total         += necessaryQuant;
                    returnable.Add(necessaryQuant);
                    break;

                case RawMaterial.ReqForPasta.high:
                    mat            = item.GetComponent <RawMaterial>();
                    necessaryQuant = 1.5f * (1f + Mathf.Pow(quality, mat.qualityIndex) / 100f);
                    total         += necessaryQuant;
                    returnable.Add(necessaryQuant);
                    break;

                case RawMaterial.ReqForPasta.veryHigh:
                    mat            = item.GetComponent <RawMaterial>();
                    necessaryQuant = 3f * (1f + Mathf.Pow(quality, mat.qualityIndex) / 100f);
                    total         += necessaryQuant;
                    returnable.Add(necessaryQuant);
                    break;

                default:
                    break;
                }
            }
        }
        Debug.Log("returnab;le count: " + returnable.Count);
        for (int i = 0; i < returnable.Count; i++)
        {
            returnable[i] /= total;
        }
        return(returnable);
    }