private void OnInventoryButtonPressed(object source, ItemEventArgs args) { ItemObjectUiElement newItemUi = ItemDataManager.CreateItemObjectUiElement(transform, args.ItemToPass.itemId); newItemUi.transform.SetAsFirstSibling(); this.PlaceObjects(newItemUi); }
private void SetFromItem(ItemObjectUiElement itemObj, Item item) { itemObj.SetItemFromId(item.itemId); Sprite itemSprite = ItemDataManager.GetDisplaySprite(item.itemName); itemObj.SetItemObjectSprite(itemSprite); int focusAreas = item.FocusAreaCount; Transform transform = itemObj.transform; if (focusAreas > 0) { for (int i = 0; i < focusAreas; i++) { FocusAreaUI uiElement = Object.Instantiate(focusAreaPrefab).GetOrAddComponent <FocusAreaUI>(); uiElement.transform.SetParent(transform); FocusAreaUiDetails details = item.GetFocusAreaUiDetailsAtIndex(i); uiElement.SetDetails(details); } } itemObj.RegisterFocusHandlerAreas(); }
void Update() { if (parent == null) { try { parent = GetComponentInParent <ItemObjectUiElement>(); } catch (NullReferenceException) { } } }
private void PlaceObjects(ItemObjectUiElement element) { bool placedSuccessfully = craftingUiMenu.occupiablePositionContainer.TryPlaceObjectInOccupiablePosition(element); element.OccupierTransform.ToUnitScaleLocal(); if (!placedSuccessfully) { element.SetPositionAndUnitScale(Vector3.zero); } }
public ItemObjectUiElement CreateItemObjectUiElement(Transform parent, Item item) { ItemObjectUiElement element = Object.Instantiate(uiElementPrefab).GetOrAddComponent <ItemObjectUiElement>(); element.name = $"{item.DisplayName}: Obj #{spawnCount}"; spawnCount++; SetFromItem(element, item); return(element); }
private void OnRecipeCompleted(Recipe recipe) { ItemObjectUiElement completed = ItemDataManager.CreateItemObjectUiElement(transform, recipe.outputId); this.PlaceObjects(completed); float outroDelay = 1f; craftingConversationBehavior.InvokeOutroDialogue(outroDelay * 0.75f); craftingUiMenu.occupiablePositionContainer.ReleaseAll(this, outroDelay); }