public bool StickSticker( Script_Sticker sticker, Script_Equipment equipment, Script_Inventory inventory, int itemSlot, bool isBackground = false ) { /// Try to equip, checking if we can equip it & if equipment is full int equipmentSlotId; if (equipment.HasSpace() && equipment.AddSticker(sticker, out equipmentSlotId)) { /// On successful equip, remove sticker from Inventory /// and also update Sticker Holster (done in Equipment) inventory.RemoveItemInSlot(itemSlot); if (!isBackground) { StickerOnSFX(); } return(true); } else { Debug.Log("Failed to equip sticker"); GetComponent <Script_InventoryManager>().ErrorDullSFX(); return(false); } }
public bool HotKeyStickUnstick( Script_Equipment equipment, Script_Inventory inventory, int inventorySlot, int equipmentSlot, bool isBackground = false ) { try { // Cache and remove the sticker if it is not Active Sticker Script_Sticker equipmentSticker = equipment.GetStickerInSlot(equipmentSlot); var activeSticker = Script_ActiveStickerManager.Control.ActiveSticker; // If there is an Active Sticker, warn Player if it's the equipment sticker trying // to be switched out. if (activeSticker != null && activeSticker == equipmentSticker) { return(OnIsActiveEquippedError()); } equipment.RemoveStickerInSlot(equipmentSlot); // Cache and remove the sticker in specified inventory slot. Script_Sticker inventorySticker = inventory.GetItemInSlot(inventorySlot) as Script_Sticker; inventory.RemoveItemInSlot(inventorySlot); if (inventorySticker != null) { equipment.AddStickerInSlot(inventorySticker, equipmentSlot); } if (equipmentSticker != null) { inventory.AddItemInSlot(equipmentSticker, inventorySlot); } // Error SFX if trying to hotkey switch when both designated slots are empty. if (inventorySticker == null && equipmentSticker == null) { return(OnError()); } if (!isBackground) { // If we only removed from equipment and added to inventory, // it's an unequip event. if (inventorySticker == null && equipmentSticker != null) { StickerOffSFX(); } else { StickerOnSFX(); } } return(true); } catch (System.Exception e) { Debug.LogError($"Failed HotKeyStickUnstick with Error:\n{e}"); return(OnError()); } bool OnIsActiveEquippedError() { GetComponent <Script_InventoryManager>().ErrorUnableSFX(); return(false); } bool OnError() { GetComponent <Script_InventoryManager>().ErrorDullSFX(); return(false); } }