コード例 #1
0
    void CreateItemInVIewprot(GameObject ParentGO, ProductionObjInfo info)
    {
        var item = Instantiate(itemPrefabs);

        item.transform.SetParent(ParentGO.transform);
        item.GetComponent <WorkstationItem>().Initialization(info);
        item.GetComponent <WorkstationItem>().ClickItem += OnClickItem;
    }
コード例 #2
0
    public void Initialization(ProductionObjInfo item)
    {
        this.item = new ProductionObjInfo(item);

        text  = GetComponentInChildren <Text>();
        image = GetComponentInChildren <Image>();
        btn   = GetComponentInChildren <Button>();

        btn.onClick.AddListener(OnClickItem);
        SetItem();
    }
コード例 #3
0
    public List <ProductionObjInfo> GetProductionObjInfo(string sortName)
    {
        TextAsset   textAsset = (TextAsset)Resources.Load("XML/" + productionObjXmlFileName);
        XmlDocument xmlDoc    = new XmlDocument();

        Debug.Log(textAsset.text);
        xmlDoc.LoadXml(textAsset.text);
        productionAllnodes = xmlDoc.SelectNodes("CRAFTLIST/text");

        List <ProductionObjInfo> productionObjs = new List <ProductionObjInfo>();

        foreach (XmlNode node in productionAllnodes)
        {
            if (sortName == "물약")
            {
                if (node.SelectSingleNode("SORT").InnerText == "물약")
                {
                    ProductionObjInfo item = new ProductionObjInfo(
                        int.Parse(node.SelectSingleNode("ID").InnerText),
                        node.SelectSingleNode("SORT").InnerText,
                        node.SelectSingleNode("NAME").InnerText,
                        node.SelectSingleNode("ICON").InnerText,
                        node.SelectSingleNode("DESCRIPTION").InnerText,
                        node.SelectSingleNode("needMaterial").InnerText
                        );

                    productionObjs.Add(item);
                }
            }
            else
            {
                ProductionObjInfo item = new ProductionObjInfo(
                    int.Parse(node.SelectSingleNode("ID").InnerText),
                    node.SelectSingleNode("SORT").InnerText,
                    node.SelectSingleNode("NAME").InnerText,
                    node.SelectSingleNode("ICON").InnerText,
                    node.SelectSingleNode("DESCRIPTION").InnerText,
                    node.SelectSingleNode("needMaterial").InnerText
                    );

                productionObjs.Add(item);
            }
        }


        return(productionObjs);
    }
コード例 #4
0
    public ProductionObjInfo(ProductionObjInfo info)
    {
        this.id          = info.ID;
        this.sort        = info.SORT;
        this.name        = info.NAME;
        this.icon_index  = info.ICON_INDEX;
        this.description = info.DESCRIPTION;

        combinationList = new List <string>();
        foreach (var item in info.COMBINATIONLIST)
        {
            combinationList.Add(item);
        }
        amountNumber = info.AMOUNTNUMBER;

        ItemInfo = new ItemInfo(id, sort, name, icon_index, 0, 0, description);
        ItemInfo.AMOUNTNUMBER = info.AMOUNTNUMBER;
    }
コード例 #5
0
    void OnClickItem(ProductionObjInfo item)
    {
        setActiveUI(true);
        SoundManager.instance.PlayEff(EffSound.SFX_UI_button);
        selectItem            = item;
        itemImage.sprite      = Resources.Load <Sprite>("ICON/" + item.ICON_INDEX);
        itemNameText.text     = item.NAME;
        itemDescriptText.text = item.DESCRIPTION;

        var    needMaterialList = item.COMBINATIONLIST;
        string materialId       = needMaterialList[0];
        string materialName     = "test";
        int    materialCounter  = 0;
        int    materialIndex    = 0;
        int    curMaterialCount = 0;
        int    k = 0;

        for (k = 0; k < needMaterialList.Count; k++)
        {
            if (materialId == needMaterialList[k])
            {
                materialCounter++;
            }
            else
            {
                materialImage[materialIndex].sprite = Resources.Load <Sprite>("ICON/" + materialId);

                foreach (var materialItem in materialItems)
                {
                    //Debug.Log("materialId : " + materialId);
                    //Debug.Log("materialItem.ID : " + materialItem.ID);
                    if (materialId == materialItem.ID.ToString())
                    {
                        materialName = materialItem.NAME;
                        //Debug.Log("Name : " + materialItem.NAME);
                        break;
                    }
                }

                foreach (var curMaterialItem in data.CURMATERIALITELIST)
                {
                    curMaterialCount = 0;
                    if (materialId == curMaterialItem.ITEMINFO.ID.ToString())
                    {
                        curMaterialCount = curMaterialItem.ITEMINFO.AMOUNTNUMBER;
                        break;
                    }
                }

                materialText[materialIndex].text = materialName + " " +
                                                   (materialCounter * int.Parse(createCountNumbeText.text)) + "/" + curMaterialCount;
                materialImage[materialIndex].gameObject.SetActive(true);
                materialText[materialIndex].gameObject.SetActive(true);
                Debug.Log("Name : " + materialName);
                //SetMaterialNameAndCount(materialId, materialCounter, materialIndex);
                materialIndex++;
                materialCounter = 1;
                Debug.Log("k : " + k + "count : " + needMaterialList.Count);
                materialId = needMaterialList[k];
                Debug.Log(materialId);
            }

            if (k == needMaterialList.Count - 1)
            {
                materialImage[materialIndex].sprite = Resources.Load <Sprite>("ICON/" + materialId);

                foreach (var materialItem in materialItems)
                {
                    if (materialId == materialItem.ID.ToString())
                    {
                        materialName = materialItem.NAME;
                        break;
                    }
                }

                foreach (var curMaterialItem in data.CURMATERIALITELIST)
                {
                    curMaterialCount = 0;
                    if (materialId == curMaterialItem.ITEMINFO.ID.ToString())
                    {
                        curMaterialCount = curMaterialItem.ITEMINFO.AMOUNTNUMBER;
                        break;
                    }
                }

                materialText[materialIndex].text = materialName + " " +
                                                   (materialCounter * int.Parse(createCountNumbeText.text)) + "/" + curMaterialCount;

                Debug.Log("Name : " + materialName);
                materialImage[materialIndex].gameObject.SetActive(true);
                materialText[materialIndex].gameObject.SetActive(true);
                //SetMaterialNameAndCount(materialId, materialCounter, materialIndex);
                materialIndex++;
                materialCounter = 1;
                Debug.Log("i : " + k + "count : " + needMaterialList.Count);
                materialId = needMaterialList[k];
            }
        }


        for (int i = materialIndex; i < materialImage.Length; i++)
        {
            materialImage[i].gameObject.SetActive(false);
            materialText[i].gameObject.SetActive(false);
        }
    }
コード例 #6
0
    public void OnClickCreateProduction()
    {
        if (selectObj.Count == 0)
        {
            return;
        }

        ProductionObjInfo production = null;

        List <string> tempIdList = new List <string>();
        List <string> tempCombiation;

        foreach (var item in selectObj)
        {
            tempIdList.Add(item.ID.ToString());
        }

        foreach (var item in productionList)
        {
            tempCombiation = new List <string>(item.COMBINATIONLIST);
            int conter          = 0;
            int combiationCount = tempCombiation.Count;

            if (tempCombiation.Count != tempIdList.Count)
            {
                continue;
            }

            if (tempCombiation.Contains(tempIdList[0]))
            {
                for (int i = 0; i < combiationCount; i++)
                {
                    if (tempCombiation.Contains(tempIdList[i]))
                    {
                        conter += 1;
                        tempCombiation.Remove(tempIdList[i]);
                    }

                    if (combiationCount == conter)
                    {
                        production = new ProductionObjInfo(item);
                        Debug.Log(production.AMOUNTNUMBER + " 이름 " + production.NAME);
                    }
                }
            }
        }
        if (production != null)
        {
            bool isHave = false;
            foreach (var item in haveProductionList)
            {
                if (production.ITEMINFO.ID == item.ITEMINFO.ID)
                {
                    isHave = true;
                }
            }
            if (!isHave)
            {
                haveProductionList.Add(production);
            }
        }

        if (production != null)
        {
            //GamasotInIcon.sprite = Resources.Load<Sprite>("ICON/" + production.ICON_INDEX);
            GamasotInIconOnItem.sprite = Resources.Load <Sprite>("ICON/" + production.ICON_INDEX);
        }
        else
        {
            GamasotInIconOnItem.sprite = Resources.Load <Sprite>("ICON/" + "998"); // 쓰레기 이미지 출력
        }

        GamasotInIcon.color       = new Color(GamasotInIcon.color.r, GamasotInIcon.color.g, GamasotInIcon.color.b, 0);
        GamasotInIconOnItem.color = new Color(GamasotInIcon.color.r, GamasotInIcon.color.g, GamasotInIcon.color.b, 1);
        CreateProduction?.Invoke(selectObj, production);
        selectObj.Clear();
        for (int i = 0; i < slot.Length; i++)
        {
            slot[i].sprite = Resources.Load <Sprite>("ICON/" + "9998");
        }
        curSelectIndex = 0;

        recipeMenuManager.GetHaveProductionList(haveProductionList);
    }
コード例 #7
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);
    }
コード例 #8
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);
    }