Пример #1
0
        //Debug.Log((transform.position - hit.point).sqrMagnitude + "<" + (interactionDistance * interactionDistance));
        //if((transform.position - hit.point).sqrMagnitude < (interactionDistance * interactionDistance)) {
        //	canUse.Value = true;
        //}

        public void TriggerInteraction()
        {
            if (canUse.Value)
            {
                currentInteractible.Interact();
            }
        }
Пример #2
0
 private void OtherInput()
 {
     if (Input.GetKeyDown(KeyCode.E))
     {
         invPanel.SetActive(!invPanel.activeSelf);
     }
     if (Input.GetKeyDown(KeyCode.R))
     {
         body.velocity = new Vector2(0, body.velocity.y);
         canMove       = false;
         anim.SetTrigger("Attack");
     }
     if (Input.GetKeyDown(KeyCode.F))
     {
         Collider2D[] col = Physics2D.OverlapBoxAll(transform.position, Vector2.one, 0);
         foreach (var item in col)
         {
             IInteractible interactible = item.gameObject.GetComponent <IInteractible>();
             if (interactible != null)
             {
                 interactible.Interact(character);
             }
         }
     }
 }
Пример #3
0
            private void Update()
            {
                IInteractible interactible = inputManager.CheckForInteractibleObject(Input.mousePosition);

                if (Input.GetMouseButtonDown(0) && gravityHandler.CheckForOnGround(transform.position, gravityCheckersPositions) && currentDashCooldown == 0)
                {
                    if (interactible == null)
                    {
                        Debug.Log("may be dash");
                        if (currentPriestDashDuration == 0 && inputManager.GetMouseDirection(Input.mousePosition, transform.position) != PlayerDirection.None)
                        {
                            StartDash();
                        }
                    }
                    else
                    {
                        interactible.Interact();
                    }
                }

                if (currentDashCooldown > 0)
                {
                    currentDashCooldown -= Time.deltaTime;
                }
                else if (currentDashCooldown < 0)
                {
                    currentDashCooldown = 0;
                }

                if (dashing)
                {
                    priestRenderer.material.color = Color.cyan;
                }
                else if (currentDashCooldown > 0)
                {
                    priestRenderer.material.color = Color.red;
                }
                else
                {
                    priestRenderer.material.color = Color.green;
                }
            }
Пример #4
0
    void Interact()
    {
        Ray        ray = Camera.main.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2));
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, maxReach))
        {
            //Debug.DrawLine(ray.origin, hit.point, Color.red, 10);

            IInteractible interactible = hit.transform.gameObject.GetComponent <IInteractible>();
            IPickUp       iPickUp      = hit.transform.gameObject.GetComponent <IPickUp>();

            if (interactible != null)
            {
                interactible.Interact();
            }
            else if (iPickUp != null)
            {
                iPickUp.Interact(this);
            }
        }
    }
Пример #5
0
    private void Awake()
    {
        LockCursor();
        xAxisClamp = 0.0f;

        layerMask = LayerMask.NameToLayer("Interact");

        InputActionAsset actions = InputHandler.Inputs.actions;

        m_Interact = actions["inputs.interact"];
        m_Look     = actions["inputs.look"];

        m_Interact.performed += (context) =>
        {
            if (m_CurrentSelection && !UISystem.MenuPresence)
            {
                m_CurrentSelection.Interact();
            }
        };

        m_PlayerPrefs  = Core.instance.PlayerPrefs;
        m_PlayerCenter = playerBody.GetComponent <PlayerControl>().Center;
    }
Пример #6
0
    private void Update()
    {
        // Resetting the outline
        if (_interactingObject != null)
        {
            //Debug.Log("Resetting");
            _interactingObject.GetComponentInChildren <Outline>().enabled = false;
            _interactingObject = null;
        }
        RaycastHit hit;
        Outline    targetOutline = null;

        // Chehcking raycast
        if (Physics.Raycast(transform.position, transform.forward, out hit, interactDistance, interactLayer))
        {
            //Debug.Log("hit");
            Transform interactingObject = hit.transform;
            if (!targetOutline)
            {
                targetOutline = interactingObject.GetComponentInChildren <Outline>();
            }
            // enable the outline
            targetOutline.enabled = true;
            // wait for interaction input
            if (Input.GetButtonDown("Interact"))
            {
                IInteractible interactible = hit.collider.GetComponent <IInteractible>();
                if (interactible != null)
                {
                    SoundyManager.Play("General", "Grab");
                    interactible.Interact();
                }
            }
            _interactingObject = interactingObject;
        }
    }
 void InteractWithoutItem(IInteractible interactible)
 {
     interactible.Interact(this);
 }