コード例 #1
0
ファイル: StationSlot.cs プロジェクト: LogXose/MealOrder
    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);
            }
        }
    }