Beispiel #1
0
    // 해당 아이템을 조합하기 위한 재료를 List에 추가
    public void AddMaterial(csItem item, int count)
    {
        csItems items = new csItems(item, count);

        if (materialList == null)
        {
            materialList = new List <csItems> ();
        }
        materialList.Add(items);
    }
Beispiel #2
0
    // 조합 가능한 아이템을 List에 추가
    public void AddCombination(csItem item, int count)
    {
        csItems items = new csItems(item, count);

        if (combList == null)
        {
            combList = new List <csItems> ();
        }
        combList.Add(items);
    }
Beispiel #3
0
    // 조합아이템 및 재료가 표시될 Panel Update
    private void UpdateCombPanel(Transform panel, csItem combItem)
    {
        // 조합 재료를 출력하기 위한 StringBuilder
        StringBuilder sb         = new StringBuilder();
        short         checkCount = 0;
//		bool checkPossibility = false;
        List <csItems> materials = combItem.MaterialList;

        // 조합에 필요한 재료들을 StringBuilder에 Append한다.
        for (int i = 0; i < materials.Count; i++)
        {
            csItems needItem  = materials [i];
            int     needCount = needItem.count;
            csItem  item      = csItemList.Instance.GetItem((int)needItem.id);
            int     count     = csInventory.Instance.CountToInventory(item);

            // 현재 가지고 있는 아이템의 개수가 조합에 필요한 개수보다 많다면 카운트한다.
            if (count >= needCount)
            {
                checkCount++;
            }
//			if (count > 0)
//				checkPossibility = true;

            sb.Append(item.Name + " : " + count + "/" + needCount + "\n");
        }

        // 조합창에 출력될 Panel의 조합아이템 이미지와 조합재료 문자열을 설정한다.
        csWorktablePanel workPanel = panel.GetComponent <csWorktablePanel> ();

        panel.GetChild(0).GetComponent <Image> ().sprite = combItem.Picture;
        panel.GetChild(1).GetComponent <Text> ().text    = sb.ToString();

        // 현재 Update될 Panel에 조합아이템과 개수와 해당 클래스의 객체를 인자로 보낸다.
        workPanel.SetWorkPanel(combItem, 1, this);

        // 카운트된 개수가 조합에 필요한 아이템의 종류 수와 같다면 workPanel 객체의 HasItems를 true로 바꾼다.
        // 이 HasItems은 해당 Panel에서 조합 가능한 유무를 판단한다.
        if (checkCount == materials.Count)
        {
            workPanel.HasItems = true;
        }
        else
        {
            workPanel.HasItems = false;
        }

        // 조합 재료가 하나도 없을 때 false를 반환한다.
//		if (checkPossibility) {
//			return true;
//		} else {
//			return false;
//		}
    }