IEnumerator Start() { if (instance == null) { inventory = FindObjectOfType <vInventory>(); instance = this; if (!inventory && inventoryPrefab) { inventory = Instantiate(inventoryPrefab); } if (!inventory) { Debug.LogError("No vInventory assigned!"); } if (inventory) { inventory.GetItemsHandler = GetItems; inventory.onEquipItem.AddListener(EquipItem); inventory.onUnequipItem.AddListener(UnequipItem); inventory.onDropItem.AddListener(DropItem); inventory.onLeaveItem.AddListener(LeaveItem); inventory.onUseItem.AddListener(UseItem); inventory.onOpenCloseInventory.AddListener(OnOpenCloseInventory); } animator = GetComponent <Animator>(); if (dropItemsWhenDead) { var character = GetComponent <vCharacter>(); if (character) { character.onDead.AddListener(DropAllItens); } } var genericAction = GetComponent <vGenericAction>(); if (genericAction != null) { genericAction.OnDoAction.AddListener(CollectItem); } yield return(new WaitForEndOfFrame()); items = new List <vItem>(); if (itemListData) { for (int i = 0; i < startItems.Count; i++) { AddItem(startItems[i], true); } } } }
public void OnEnable() { if (inventory == null) { inventory = GetComponentInParent <vInventory>(); } if (inventory && itemWindow) { itemWindow.CreateEquipmentWindow(inventory.items, OnSubmit, OnSelectSlot); } }
void Start() { equipAreas = GetComponentsInChildren <vEquipArea>().vToList(); foreach (vEquipArea area in equipAreas) { area.onPickUpItemCallBack = OnPickUpItemCallBack; } vInventory inventory = GetComponentInParent <vInventory>(); if (inventory) { inventory.onOpenCloseInventory.AddListener(OnOpen); } }
void Start() { inventory = GetComponentInParent <vInventory>(); if (equipSlots.Count == 0) { var equipSlotsArray = GetComponentsInChildren <vEquipSlot>(true); equipSlots = equipSlotsArray.vToList(); } rootWindow = GetComponentInParent <vInventoryWindow>(); foreach (vEquipSlot slot in equipSlots) { slot.onSubmitSlotCallBack = OnSubmitSlot; slot.onSelectSlotCallBack = OnSelectSlot; slot.onDeselectSlotCallBack = OnDeselect; slot.amountText.text = ""; } }
void OnEnable() { try { pop_ups = new List <vWindowPop_up>(); if (inventory == null) { inventory = GetComponentInParent <vInventory>(); } if (lastSelected) { StartCoroutine(SetSelectableHandle(lastSelected)); } inventory.SetCurrentWindow(this); isOpen = true; } catch { } }
void Start() { inventory = GetComponentInParent <vInventory>(); }