public void setMake( ItemType makeType, int resId ) { DataCenter dataCenter = MainData.dataCenter; usePlan = MainData.dataCenter.makePlans.getMakePlan(makeType, resId); List<MakeElement> makeElement = usePlan.getMakeElement(); clearMake(); // 設定材料視窗的大小 setSize(makeElement.Count); // 設定材料視窗顯示的資料 for(int i=0; i<makeElement.Count && i<rawElement.Length ; i++ ){ int itemId = makeElement[i].itemId; ItemType itemType = makeElement[i].type; ItemData itemData = dataCenter.get_item_by_id(itemType, itemId); rawElement[i].text = itemData.itemName; rawNum[i].text = itemData.itemNum+"/"+makeElement[i].itemNum; rawNum[i].color = (itemData.itemNum < makeElement[i].itemNum )? Color.red : Color.black; } resName.text = dataCenter.get_name_by_itemid(makeType, resId, 1); usePlan = MainData.dataCenter.makePlans.getMakePlan(makeType, resId); }
// 更新製作中的道具數量 public bool updateMakeNum(MakePlan makePlan) { var getItem = makePlan.resItem; ItemData makeItem = dataCenter.get_item_by_id(getItem.itemType, getItem.id); makeItemName.text = makeItem.itemName + "("+makeItem.itemNum+")"; List<MakeElement> makeElement = makePlan.getMakeElement(); elementPanel.sizeDelta = new Vector2(ori_width, ori_height + makeElement.Count*add_height); bool checkFlag = true; foreach(Text element in elements ){ element.color = Color.clear; } for(int i=0; i< makeElement.Count ; i++){ var eItem = makeElement[i]; ItemData info = dataCenter.get_item_by_id(eItem.type, eItem.itemId); elements[i].text = info.itemName + " ("+info.itemNum+"/"+eItem.itemNum+")"; elements[i].color = Color.black; if( info.itemNum < eItem.itemNum ) checkFlag = false; } return checkFlag; }