public static void Equip(Script_Sticker sticker)
 {
     if (OnEquip != null)
     {
         OnEquip(sticker);
     }
 }
    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 UnstickSticker(
        Script_Sticker sticker,
        Script_Equipment equipment,
        Script_Inventory inventory,
        int stickerSlotId,
        bool isBackground = false
        )
    {
        // try to unequip, checking if inventory is full
        if (equipment.RemoveStickerInSlot(stickerSlotId))
        {
            /// On successful unequip, remove sticker from Equipment
            /// and also update Sticker Holster (done in Equipment)
            inventory.AddItem(sticker);

            if (!isBackground)
            {
                StickerOffSFX();
            }

            return(true);
        }
        else
        {
            Debug.LogWarning("Failed to unstick sticker; no space in inventory or not found");
            // TODO: show messaging or SFX
            GetComponent <Script_InventoryManager>().ErrorDullSFX();

            return(false);
        }
    }
Ejemplo n.º 4
0
    private void HandleForceSyncAnimator(Script_Sticker sticker)
    {
        if (syncSticker.id == sticker.id)
        {
            AnimatorStateInfo animatorStateInfo = animator.GetCurrentAnimatorStateInfo(Script_PlayerMovement.Layer);

            game.GetPlayer().SyncAnimatorState(animatorStateInfo);
        }
    }
Ejemplo n.º 5
0
 bool UnstickSticker(
     Script_Sticker sticker,
     Script_Equipment equipment,
     Script_Inventory inventory,
     int stickerSlotId,
     bool isBackground = false
     )
 {
     return(stickersHandler.UnstickSticker(sticker, equipment, inventory, stickerSlotId, isBackground));
 }
Ejemplo n.º 6
0
    public bool SearchForSticker(Script_Sticker stickerToFind)
    {
        for (int i = 0; i < stickers.Length; i++)
        {
            if (stickers[i] == stickerToFind)
            {
                return(true);
            }
        }

        return(false);
    }
Ejemplo n.º 7
0
    public bool AddStickerInSlot(Script_Sticker stickerToAdd, int i)
    {
        if (stickers[i] != null)
        {
            Debug.LogWarning($"You are about to overwrite sticker in slot {i}. Be careful this isn't a bug.");
        }

        stickers[i]              = stickerToAdd;
        stickerImages[i].sprite  = stickerToAdd.sprite;
        stickerImages[i].enabled = true;

        HandleStickerHolsterAdd(stickerToAdd, i);

        return(true);
    }
Ejemplo n.º 8
0
    private void MatchPlayerAnimator(Script_Sticker sticker)
    {
        int Layer = Script_PlayerMovement.Layer;

        RuntimeAnimatorController playerAnimatorController = game?.GetPlayer()?.MyAnimator.runtimeAnimatorController;

        if (playerAnimatorController == null)
        {
            return;
        }

        animator.runtimeAnimatorController = playerAnimatorController;

        AnimatorStateInfo animatorStateInfo = game.GetPlayer().MyAnimator
                                              .GetCurrentAnimatorStateInfo(Layer);

        animator.Play(animatorStateInfo.fullPathHash, Layer, animatorStateInfo.normalizedTime);
    }
Ejemplo n.º 9
0
    private bool StickSticker(
        Script_Sticker sticker,
        Script_Equipment equipment,
        Script_Inventory inventory,
        int itemSlotId
        )
    {
        if (stickersHandler.StickSticker(sticker, equipment, inventory, itemSlotId))
        {
            /// Hide ItemChoices must come before hydrating slots;
            /// otherwise, will trigger a deselect and select on the slot
            /// due to exiting its EventSystem causing a flicker
            HideItemChoices();
            EnterInventory();
            return(true);
        }

        return(false);
    }
Ejemplo n.º 10
0
    /// <returns>false, if stickers are full</returns>
    public bool AddSticker(Script_Sticker stickerToAdd, out int stickerSlotId)
    {
        for (int i = 0; i < stickers.Length; i++)
        {
            if (stickers[i] == null)
            {
                stickers[i]              = stickerToAdd;
                stickerImages[i].sprite  = stickerToAdd.sprite;
                stickerImages[i].enabled = true;
                stickerSlotId            = i;

                HandleStickerHolsterAdd(stickerToAdd, i);

                return(true);
            }
        }

        stickerSlotId = -1;
        return(false);
    }
Ejemplo n.º 11
0
 public bool CheckStickerEquipped(Script_Sticker item)
 {
     return(equipment.SearchForSticker(item));
 }
Ejemplo n.º 12
0
 void HandleStickerHolsterAdd(Script_Sticker stickerToAdd, int i)
 {
     Script_StickerHolsterManager.Control.AddSticker(stickerToAdd, i);
 }
    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);
        }
    }