public void loadInventory(BackpackInventory inventory) { if (inventory == null) { this.inventory = null; noBackpackText.color = new Color(noBackpackText.color.r, noBackpackText.color.g, noBackpackText.color.b, 1); destroySlots(); return; } destroySlots(); this.inventory = inventory; buildSlots(); updateUI(); noBackpackText.color = new Color(noBackpackText.color.r, noBackpackText.color.g, noBackpackText.color.b, 0); }
public static bool validateRequest(InventoryOperationRequest request, PlayerInfo info) { BackpackInventory backpack = null; if (info.backpack != null) { backpack = info.backpack.inventory; } BeltInventory belt = info.belt; ItemInventorySlot cursor = info.cursorSlot; ItemInventorySlot swapSlot = null; EquipmentItem swapEquipItem = null; bool drop = false; switch (request.swapInv) { case InventoryType.Ground: drop = true; break; case InventoryType.Backpack: swapSlot = assertSlotExists(backpack.getSlots(), request.swapInvSlot); if (swapSlot == null) { Debug.Log("InventoryOperation validation error: trying to swap to bad backpack slot"); return(false); } break; case InventoryType.Belt: swapSlot = assertSlotExists(belt.getSlots(), request.swapInvSlot); if (swapSlot == null) { Debug.Log("InventoryOperation validation error: trying to swap to bad belt slot"); return(false); } break; case InventoryType.Equip: swapEquipItem = getEquipItem(info, request.swapInvSlot); break; default: Debug.Log("InventoryOperation validation error: unsupported inventory detected"); return(false); } switch (request.op) { case Operation.ToCursor: return(validateToCursorOperation(swapSlot, swapEquipItem, request.quantity, info)); case Operation.FromCursor: return(validateFromCursorOperation(swapSlot, swapEquipItem, request.swapInvSlot, drop, request.quantity, info)); default: Debug.Log("InventoryOperation validation error: unsupported operation detected"); return(false); } }
public override void Deserialize(NetworkReader reader) { base.Deserialize(reader); inventory = new BackpackInventory(0); inventory.Deserialize(reader); }
public BackpackItem() { this.inventory = new BackpackInventory(numSlots); }
private void Start() { inventory = GameObject.Find("Player").GetComponent <Inventory>(); backInventory = GameObject.Find("Player").GetComponent <BackpackInventory>(); player = GameObject.Find("Player"); }
void Start() { inventory = GameObject.FindGameObjectWithTag("Player").GetComponent <BackpackInventory>(); dropText = inventory.dropText; dropInspectText = inventory.dropInspectText; }