Example #1
0
    public void OnAddShoppingBaskeBtn(int number)
    {
        if (curShoppingBaskeList != null)
        {
            foreach (var item in curShoppingBaskeList)
            {
                if (item.NAME == selectMaterialItem.NAME)
                {
                    isAlreadyAdded = true;
                    item.setShoppingBaske(number);
                }
            }
        }

        if (!isAlreadyAdded)
        {
            var instance             = Instantiate(itemprefabs);
            MaterialItemManager temp = instance.GetComponent <MaterialItemManager>();
            instance.GetComponent <MaterialItemManager>().InitializationShoppingBaske(selectMaterialItem, number);
            instance.transform.SetParent(shoppingBaskeContentTr);
            curShoppingBaskeList.Add(temp);
            temp.ClickMaterialInShoppingBaske += OnDestroyMaterial;
        }

        isAlreadyAdded = false;
    }
Example #2
0
    public void Initialization(MaterialItemManager materialItemManager, bool isOrderMenu)
    {
        this.itemInfo    = new ItemInfo(materialItemManager.itemInfo);
        this.isOrderMenu = isOrderMenu;

        setContent();
        m_bt = GetComponent <Button>();
        m_bt.onClick.AddListener(onClickMaterial);
    }
Example #3
0
 private void OnDestroyMaterial(MaterialItemManager item)
 {
     item.ClickMaterialInShoppingBaske -= this.OnDestroyMaterial;
     curShoppingBaskeList.Remove(item);
 }
Example #4
0
    public void OnCreateInWorkStation(List <ItemInfo> materials, int id, int amo)
    {
        foreach (var material in materials)
        {
            MaterialItemManager finditem = null;
            bool isZreo = false;
            foreach (var dataItem in data.CURMATERIALITELIST)
            {
                if (material.ID == dataItem.ITEMINFO.ID)
                {
                    dataItem.ITEMINFO.AMOUNTNUMBER -= material.AMOUNTNUMBER;
                    data.BAGSPACE -= material.AMOUNTNUMBER;
                    if (dataItem.ITEMINFO.AMOUNTNUMBER <= 0)
                    {
                        finditem = dataItem;
                        isZreo   = true;
                    }
                }
            }
            if (isZreo)
            {
                data.CURMATERIALITELIST.Remove(finditem);
            }
        }

        foreach (var workstationItem in workStationItemList)
        {
            bool isHave = false;
            if (workstationItem.ID == id)
            {
                if (workstationItem.SORT != "가구" && workstationItem.SORT != "재료")
                {
                    foreach (var item in data.CURPRODUCTIONITEMLIST)
                    {
                        if (item.ID == workstationItem.ID)
                        {
                            isHave = true;
                            item.ITEMINFO.AMOUNTNUMBER += amo;
                        }
                    }
                    if (!isHave)
                    {
                        Debug.Log("제작물");

                        var temp = new ProductionObjInfo(workstationItem);
                        if (amo >= 2)
                        {
                            temp.ITEMINFO.AMOUNTNUMBER = amo;
                        }
                        data.CURPRODUCTIONITEMLIST.Add(temp);
                    }
                }
                else if (workstationItem.SORT == "가구")
                {
                    foreach (var item in data.CURFURNITUREITEMLIST)
                    {
                        if (item.ITEMINFO.ID == workstationItem.ID)
                        {
                            isHave = true;
                            item.ITEMINFO.AMOUNTNUMBER += amo;
                        }
                    }
                    if (!isHave)
                    {
                        Debug.Log("가구");
                        var temp = new FurnitureItem();
                        temp.Initialization(workstationItem.ITEMINFO);
                        if (amo >= 2)
                        {
                            temp.ITEMINFO.AMOUNTNUMBER = amo;
                        }
                        data.CURFURNITUREITEMLIST.Add(temp);
                    }
                }
                else if (workstationItem.SORT == "재료")
                {
                    foreach (var item in data.CURMATERIALITELIST)
                    {
                        if (item.ITEMINFO.ID == workstationItem.ID)
                        {
                            isHave = transform;
                            item.ITEMINFO.AMOUNTNUMBER += amo;
                        }
                    }
                    if (!isHave)
                    {
                        var temp = new MaterialItemManager();
                        Debug.Log(workstationItem.ITEMINFO.ICON_INDEX);
                        temp.Initialization(workstationItem.ITEMINFO);
                        if (amo >= 2)
                        {
                            temp.ITEMINFO.AMOUNTNUMBER = amo;
                        }
                        data.CURMATERIALITELIST.Add(temp);
                    }
                }
            }
        }
        data.BAGSPACE += amo;
        changeData?.Invoke(data);
    }
Example #5
0
    public void OnCreateProduction(List <ItemInfo> materials, ProductionObjInfo production)
    {
        bool isHave  = false;
        bool isWaste = false;

        // null이라면 아무것도 조합되지 않았다는 뜻이므로 쓰레기를 던져야함.
        if (production == null)
        {
            production = new ProductionObjInfo(999, "테스트", "쓰레기", "998", "실패한 연금술", "NONE");
            data.CURWASTEITEMLIST.Add(production);
            isWaste = true;
        }

        foreach (var curItem in data.CURPRODUCTIONITEMLIST)
        {
            if (production.NAME == curItem.NAME)
            {
                Debug.Log(production.NAME);
                curItem.ITEMINFO.AMOUNTNUMBER += production.ITEMINFO.AMOUNTNUMBER;
                isHave = true;
            }
        }

        if (!isHave && !isWaste)
        {
            data.CURPRODUCTIONITEMLIST.Add(production);
            Debug.Log("isHaved" + production.AMOUNTNUMBER);
        }

        MaterialItemManager tempItem = null;

        foreach (var item in materials)     // 소지 재료 감소
        {
            foreach (var dataItem in data.CURMATERIALITELIST)
            {
                if (item.NAME == dataItem.NAME)
                {
                    //Debug.Log(item.AMOUNTNUMBER + " 갯수");
                    dataItem.ITEMINFO.AMOUNTNUMBER -= 1;
                    data.BAGSPACE -= 1;
                    if (dataItem.ITEMINFO.AMOUNTNUMBER <= 0)
                    {
                        //         tempItem = dataItem;
                        data.CURMATERIALITELIST.Remove(dataItem);
                        //Debug.Log(dataItem.NAME +"이게 왜 NULL?");
                        break;
                    }
                }
            }
            //if (tempItem.NAME != null)
            //{
            //    data.CURMATERIALITELIST.Remove(tempItem);
            //    Debug.Log("진입");
            //}
        }

        if (!isWaste)
        {
            data.BAGSPACE += 1;  //1인 이유는 현재 아이템이 하나씩 추가되서
        }
        Debug.Log("가방 수량 : " + data.BAGSPACE + data.CURPRODUCTIONITEMLIST.Count);
        changeData?.Invoke(data);
    }