public void SelectMethod(ProduceMethodID id) { applianceContent.gameObject.SetActive(true); selectedProduceMethod = selectedAppliance.methods[id]; for (int i = productPanelContent.childCount - 1; i >= 0; i--) { Destroy(productPanelContent.GetChild(i).gameObject); } UpdateMethodMaterial(); int index = 0; productPanelContent.sizeDelta = new Vector2(220f, selectedProduceMethod.products.Length * 50f); float xoffset = -80f; float yoffset = productPanelContent.rect.height / 2 - blockPrefab.rect.height / 2 - 10f; foreach (object product in selectedProduceMethod.products) { if(product is Item) { Item item = product as Item; RectTransform block = Instantiate(blockPrefab); block.transform.SetParent(productPanelContent); block.localScale = Vector3.one; block.localPosition = new Vector3(xoffset, -index * 50f + yoffset, 0f); block.GetChild(0).GetComponent<Text>().text = item.itemCount.ToString(); block.GetChild(1).GetComponent<Text>().text = item.name.ToString(); index++; } } produceTimeText.text = selectedProduceMethod.processTime.ToString() + "秒"; processButton.enabled = !GameGlobal.Player.IsWorking && selectedProduceMethod.Sufficient(GameGlobal.Inventory); processButton.image.color = (processButton.enabled)?Color.white:Color.grey; }
public void Produce(Appliance appliance, ProduceMethod method) { GameGlobal.Player.IsWorking = true; var parameter = new Dictionary<byte, object> { { (byte)ProduceParameterItem.ApplianceID, appliance.id }, { (byte)ProduceParameterItem.ProduceMethodID, method.id } }; peer.OpCustom((byte)OperationType.Produce, parameter, true, 0, true); }