public void AssignItemToEntity(Database.db_item item) { if (attachedItemList.ContainsKey(item.id)) { Debug.LogError("There is already attached itemId " + item.id + " !"); return; } Transform tempModel = Game.InstantiateResource(item.path); if (item.boneNameAttach != "" && mainModelBoneList.ContainsKey(item.boneNameAttach)) { tempModel.SetParent(mainModelBoneList[item.boneNameAttach]); } else { Transform modelHolder = baseEntity.transform.Find("_model"); if (item.boneNameAttach != "") { Debug.LogError("cannot find bone '" + item.boneNameAttach + "' requested by model '" + item.id + "' in body '" + modelHolder.GetChild(0).name + "'"); } tempModel.SetParent(modelHolder); } tempModel.localPosition = Vector3.zero; tempModel.localEulerAngles = Vector3.zero; attachedItemList.Add(item.id, tempModel); }
private void ReconstructionItemPanel(Database.db_item.Type type) { itemPanelHolder.GetComponentInChildren <ScrollRect>().verticalNormalizedPosition = 0; if (!itemPanelHolder.gameObject.activeSelf) { itemPanelHolder.gameObject.SetActive(true); } for (int i = 0; i < itemPanelButtonList.Count; i++) { DestroyImmediate(itemPanelButtonList[i].gameObject); } itemPanelButtonList.Clear(); for (int i = 0; i < itemsToShow.Count; i++) { if (itemsToShow[i].type != type) { continue; } int index = itemPanelButtonList.Count; Database.db_item tempItem = itemsToShow[i]; Transform tempButton = Instantiate(buttonPrefab); tempButton.SetParent(itemPanel); tempButton.GetComponent <Button>().onClick.AddListener(() => ItemClickButton(tempItem, index)); tempButton.GetComponentInChildren <Text>().text = itemsToShow[i].name; tempButton.gameObject.SetActive(true); itemPanelButtonList.Add(tempButton); } }
private void ReconstructionItemInfo(Database.db_item item) { if (modelToShow != null) { DestroyImmediate(modelToShow.gameObject); } modelToShow = Game.InstantiateResource(item.path); modelToShow.position = new Vector3(0, item.yPosInInventory, 0); modelToShow.eulerAngles = item.inventoryRotation; modelToShow.localScale = new Vector3(item.sizeInInventory, item.sizeInInventory, item.sizeInInventory); ChangeLayer(modelToShow, 31); itemTextInfoPanel.Find("Name").GetComponent <Text>().text = item.name; itemTextInfoPanel.Find("Info").GetComponent <Text>().text = item.description; itemTextInfoPanel.Find("Count").GetComponent <Text>().text = "Count: " + Game.GetPlayer().GetItems().Find(x => x.id == item.id).count; if (!itemTextInfoPanel.gameObject.activeSelf) { itemTextInfoPanel.gameObject.SetActive(true); } }
public void ItemClickButton(Database.db_item item, int index) { itemPanelHolder.GetComponentInChildren <ScrollRect>().verticalNormalizedPosition = 1f - (index / ((float)itemPanelButtonList.Count - 1)); ReconstructionItemInfo(item); }