Exemple #1
0
    /// <summary> 생산품 리스트 초기화 </summary>
    void InitProductionList(string type = "food")
    {
        for (int i = 0; i < productSlotList.Count; i++)
        {
            productSlotList[i].gameObject.SetActive(false);
        }

        int slotCount = 0;

        if (type == "food")
        {
            foodList.Sort((Item a, Item b) => {
                int indexA = a.index;
                int indexB = b.index;
                return(indexA.CompareTo(indexB));
            });
            for (int i = 0; i < foodList.Count; i++)
            {
                if (foodList[i].isProduction && foodList[i].id != productID)
                {
                    continue;
                }
                slotCount++;
                UIProductSlot slot = CreateSlot();
                slot.InitSlot(foodList[i]);
                slot.gameObject.SetActive(true);
            }
        }
        else
        {
            etcList.Sort((Item a, Item b) => {
                int indexA = a.index;
                int indexB = b.index;
                return(indexA.CompareTo(indexB));
            });
            for (int i = 0; i < etcList.Count; i++)
            {
                if (etcList[i].isProduction && etcList[i].id != productID)
                {
                    continue;
                }
                slotCount++;
                UIProductSlot slot = CreateSlot();
                slot.InitSlot(etcList[i]);
                slot.gameObject.SetActive(true);
            }
        }

        SizeControl(slotCount);
    }
Exemple #2
0
    UIProductSlot CreateSlot()
    {
        UIProductSlot slot = null;

        for (int i = 0; i < productSlotList.Count; i++)
        {
            if (!productSlotList[i].gameObject.activeSelf)
            {
                slot = productSlotList[i];
                break;
            }
        }

        if (slot == null)
        {
            GameObject go = Instantiate(territoryProductSlotPrefab);
            go.transform.SetParent(rectProductSlotParent, false);
            slot          = go.GetComponent <UIProductSlot>();
            slot.onApply += OnApply;
            productSlotList.Add(slot);
        }

        return(slot);
    }