void UpdateSlot(bool animateItem)
    {
        // Check if an item is held
        smokeParticles.Stop();
        fontColor.a = 1;
        if (heldItem != null)
        {
            // Update the state of the item
            heldItem.CurrentState = ItemPickup.State.Animating;

            // Snap the item to this slot's transform
            if (animateItem == true)
            {
                heldItem.AnimatePositioningItem(transform, UpdateItem, ItemPickup.AudioType.Place);
            }
            else
            {
                heldItem.SnapItemToTransform(transform, UpdateItem);
            }
            fontColor.a = 0;
        }

        // Check if the renderer should be turned off
        if ((heldItem != null) && (animateItem == false))
        {
            // Turn off the mesh renderer
            GetComponent <Renderer>().enabled = false;
            timeFadeOutStarted = -1;
        }
        else
        {
            // Turn on the text mesh renderer
            GetComponent <Renderer>().enabled = true;
            timeFadeOutStarted = Time.time;
            if ((heldItem == null) && (animateItem == false))
            {
                timeFadeOutStarted = -1;
            }
        }

        if (optionalDoor != null)
        {
            optionalDoor.OnItemSlotChanged(this);
        }

        // Update the font color
        slotLabel.color = fontColor;
    }
Beispiel #2
0
    void UpdateItemPickup()
    {
        if ((currentSlot != null) && (currentSlot.IsInteractable == true) && (CrossPlatformInput.GetButtonDown("Pickup") == true))
        {
            if ((currentSlot.HeldItem != null) && (carriedItem == null))
            {
                // Move the slot item to the player
                carriedItem          = currentSlot.HeldItem;
                currentSlot.HeldItem = null;

                // Animate carrying items
                carriedItem.AnimatePositioningItem(carryPosition, null, ItemPickup.AudioType.PickUp);
            }
            else if ((currentSlot.HeldItem == null) && (carriedItem != null))
            {
                // Moved the carried item to the slot
                currentSlot.HeldItem = carriedItem;
                carriedItem          = null;
            }
        }
    }