private void OnInventoryItemSuccessfullyUsed(EInventoryItemId id) { if (_itemsData[id].IsDisposable) { _itemsData[id].IsInStock = false; } }
public void ActivateInventoryMode(Texture2D backgroundTexture) { if (CanActivateInventoryMode) { IsInventoryModeOn = true; _backgroundTexture = backgroundTexture; _backgroundImageComponent.sprite = Sprite.Create(backgroundTexture, new Rect(0, 0, Screen.width, Screen.height), new Vector2(0, 0)); _inventoryCamera.IsInventoryModeOn = true; _inventoryCamera.DrawInventory = DrawInventory; HideAllInstances(); CurrentItemId = ArrayOfAvailableItemsIds.First(); ShowInstance(CurrentItemId); StartInstanceAnimation(CurrentItemId); _inventoryCamera.gameObject.SetActive(true); _inventoryCameraAudioListener.enabled = true; } else { throw new Exception("cannot activate inventory mode: there is no items in inventory"); } }
private void SwitchCurrentItemIdToNext() { var arrayOfAvailableItemsIdsCopy = ArrayOfAvailableItemsIds; int indexOfCurrentItemId = Array.IndexOf(arrayOfAvailableItemsIdsCopy, CurrentItemId); CurrentItemId = arrayOfAvailableItemsIdsCopy[(indexOfCurrentItemId + 1) % arrayOfAvailableItemsIdsCopy.Length]; }
private void OnInventoryObjectWasClicked(EInventoryItemId id) { if (IsInventoryModeOn) { return; } _itemsData[id].IsInStock = true; Messenger.Broadcast(Events.InventoryWasUpdated); }
public static T GetAsChild <T>(GameObject parent, EInventoryItemId id) where T : InventoryObject { return((T)GetAsChild(parent, id)); }
public static InventoryObject GetAsChild(GameObject parent, EInventoryItemId id) { return(parent.transform.Find(GetName(id)).GetComponent <InventoryObject>()); }
public static string GetName(EInventoryItemId id) { return(GameUtils.GetNameByPath(GameConstants.inventoryObjectPaths[id])); }
public static string GetPath(EInventoryItemId id) { return(GameConstants.inventoryObjectPaths[id]); }
public void ShowInventoryObject(EInventoryItemId id) { SetActivityOfInventoryObject(id, true); }
public void HideInventoryObject(EInventoryItemId id) { SetActivityOfInventoryObject(id, false); }
private void SetActivityOfInventoryObject(EInventoryItemId id, bool active) { _inventoryObjects[id].gameObject.SetActive(active); }
public bool Contains(EInventoryItemId id) { return(_itemsData[id].IsInStock); }
private void StartInstanceAnimation(EInventoryItemId id) { _itemsData[id].AnimatorComponent.speed = 1f; }
private void StopInstanceAnimation(EInventoryItemId id) { _itemsData[id].AnimatorComponent.Play(ItemRotationStateNameHash, -1, 0f); _itemsData[id].AnimatorComponent.speed = 0f; }
private void HideInstance(EInventoryItemId id) { StopInstanceAnimation(id); _itemsData[id].Content.SetActive(false); }
private void ShowInstance(EInventoryItemId id) { _itemsData[id].Content.SetActive(true); }