Exemplo n.º 1
0
    void HandleInteraction(Interactable interactable)
    {
        Interactable.InteractionType interactionType = interactable.GetInteractionType();

        switch (interactionType)
        {
        case Interactable.InteractionType.Click:
            gameUI.ShowClickButton("E");

            if (Input.GetButtonDown("Interact"))
            {
                interactable.Interact(this.gameObject);
            }
            break;

        case Interactable.InteractionType.Hold:
            gameUI.ShowHoldingButton("E");

            if (Input.GetButton("Interact"))
            {
                interactable.IncreaseCurrentHoldTime();
                if (interactable.GetCurrentHoldTime() > interactable.GetHoldTime())
                {
                    interactable.ResetCurrentHoldTime();
                    interactable.Interact(this.gameObject);
                }
            }
            else
            {
                interactable.ResetCurrentHoldTime();
            }

            gameUI.UpdateHoldingButton(interactable.GetCurrentHoldTime() / interactable.GetHoldTime());
            break;

        default:
            throw new System.Exception("Unsupported type of interactable.");
        }
    }
Exemplo n.º 2
0
        private void HandleInteraction(Interactable interactable)
        {
            Interactable.InteractionType interactionType = interactable.InteractType;
            switch (interactionType)
            {
            case Interactable.InteractionType.Press:
                if (Input.GetKeyDown(KeyCode.E))
                {
                    interactable.Interact();
                }
                break;

            case Interactable.InteractionType.Hold:
                if (Input.GetKey(KeyCode.T))
                {
                    interactable.Interact();
                }
                break;
                ;

            default: throw new Exception("Not such Interaction Type as mentiond");
            }
        }