public void RefreshDisplay() { items = inventory.GetItems(); Logger.log("Items in inventory: " + items.Length); items = SortInventory(items); for (int i = 0; i < items.Length; i++) { GameObject instance = Instantiate(slotPrefab, slotParent); int ii = i; //instance.GetComponent<Button>().onClick.AddListener(() => displayDetails(ii)); ButtonClick click = instance.GetComponent <ButtonClick>(); click.leftClick.AddListener(() => DisplayDetails(ii)); click.rightClick.AddListener(() => DisplayContext(ii)); instance.GetComponent <InventorySlot>().Display(items[i]); Logger.log("Added listener with ID: " + i); } slotText.text = "Items: " + inventory.GetSlotsUsed() + "/" + playerProperties.slotCapacity; weightText.text = "Capacity: " + playerProperties.weight.Value + "/" + playerProperties.maxWeight.Value; float gradientTime = playerProperties.weight.Value / playerProperties.maxWeight.Value; //Logger.log("Time: " + gradientTime); weightText.color = weightTextGradient.Evaluate(gradientTime); slotText.gameObject.SetActive(playerProperties.GetSlotCapacityEnabled()); weightText.gameObject.SetActive(playerProperties.GetWeightCapacityEnabled()); //Only show texts if type capacity is enabled }
public bool CanPickup(float itemWeight) { //TODO: This is ugly... but it should work float weight = playerProperties.weight.Value; return((!playerProperties.GetWeightCapacityEnabled() || weight + itemWeight <= playerProperties.maxWeight.Value) && (!playerProperties.GetSlotCapacityEnabled() || slotsFilled <= playerProperties.slotCapacity)); }