示例#1
0
    private void Interact(Interactible interactible)
    {
        if (interactible.consumesRequirements)
        {
            for (int i = 0; i < interactible.inventoryRequirements.Length; ++i)
            {
                RemoveFromInventory(interactible.inventoryRequirements[i]);
            }

            if (_currentInteractible.State == 1)
            {
                heart.gameObject.SetActive(true);
                heart.isInteractive = false;
                AddToInventory(jewel);
            }
            else if (_currentInteractible.isPuzzle2)
            {
                jewel.gameObject.SetActive(true);
            }
        }

        interactible.Interact();
        if (_currentInteractible.tag == "Teacher")
        {
            Mark.SetActive(false);
        }
    }
示例#2
0
    private void Update()
    {
        RaycastHit hit;

        if (Physics.Raycast(cam.transform.position, cam.transform.forward, out hit, 3))
        {
            reticle.localPosition = new Vector3(0, 0, hit.distance - 0.01f);
            Interactible focus = hit.transform.GetComponent <Interactible>();
            if (focus != null)
            {
                if (Controls.Interact)
                {
                    focus.Interact();
                }
                mat.SetColor("_Color", Color.green);
            }
            else
            {
                mat.SetColor("_Color", neutral);
            }
        }
        else
        {
            reticle.localPosition = new Vector3(0, 0, 3);
            mat.SetColor("_Color", neutral);
        }
    }
 public void Interact()
 {
     if (interaction != null)
     {
         interaction.Interact();
     }
 }
示例#4
0
 private void Update()
 {
     if (_focus != null)
     {
         _focus.Interact();
     }
 }
示例#5
0
    public void Interact()
    {
        if (curInteractible == null)
        {
            return;
        }

        curInteractible.Interact();
    }
示例#6
0
    private void Update()
    {
        // Handle rotation

        eulerLookRotation = eulerLookRotation + new Vector3(-Input.GetAxis("Mouse Y"), Input.GetAxis("Mouse X"), 0) * lookSpeed;
        eulerLookRotation = new Vector3(Mathf.Clamp(eulerLookRotation.x, -hLimit, hLimit), eulerLookRotation.y, eulerLookRotation.z);

        head.rotation = Quaternion.Euler(eulerLookRotation);

        if (Input.GetMouseButtonDown(0))
        {
            Cursor.lockState = CursorLockMode.Locked;
        }

        // jumping
        if (Input.GetButtonDown("Jump"))
        {
            jumpTrigger = true;
        }

        // shooty
        if (Input.GetButtonDown("Fire1"))
        {
            ObjectPool pool = bulletPrefabOrPool.GetComponent <ObjectPool>();
            GameObject obj;
            if (pool == null)
            {
                obj = Instantiate(bulletPrefabOrPool);
            }
            else
            {
                obj = pool.GetObject();
            }
            obj.transform.position = head.position;
            obj.transform.rotation = head.rotation;
            obj.GetComponent <Rigidbody>().AddForce(head.forward * bulletSpeed, ForceMode.VelocityChange);
        }

        // interacty
        RaycastHit hit;

        if (Physics.Raycast(head.position, head.forward, out hit, interactionDistance, LayerMask.GetMask("Default")))
        {
            Interactible interactible = hit.collider.gameObject.GetComponentInParent <Interactible>();
            if (interactible != null)
            {
                interactible.showText = true;
                if (Input.GetButtonDown("Fire2"))
                {
                    interactible.Interact();
                }
            }
        }
    }
 private void CheckForInteract()
 {
     if (m_interactible && m_inputController.InteractButtonDown)
     {
         if (m_interactible.Type() == Interactible.InteractibleType.NPCTalk)
         {
             m_talkingNPC.CurrentTalkingNPC = m_interactible.gameObject.GetComponent(typeof(NPCTalk)) as NPCTalk;
             m_stateMachine.SetState(m_talkingState);
         }
         m_interactible.Interact();
     }
 }
示例#8
0
 //Interact with current interactible
 private void Interact(Interactible interactible)
 {
     //If the current interactible has requirements
     if (interactible.consumesRequirements)
     {
         //go though interactible requirements array and remove the pickable
         //objects from the inventory
         for (int i = 0; i < interactible.inventoryRequirements.Length; ++i)
         {
             RemoveFromInventory(interactible.inventoryRequirements[i]);
         }
     }
     //Do this until there are no more requirements in inventory
     interactible.Interact();
 }
示例#9
0
    void Update()
    {
        float time = Time.time - engineStartTime;

        audio.volume = Mathf.Pow(Mathf.Clamp01(time / engineSoundFadeInTime) * engineSoundVolume, .8f);

        if (Input.GetButtonDown("Fire1"))
        {
            hornAudio.Play();
            if (currentInteractible != null)
            {
                currentInteractible.Interact();
                UpdateHelpText();
            }
        }
    }
示例#10
0
    public void Update()
    {
        if (isKeyboardEnabled)
        {
            MoveHands();
        }

        if (Input.GetMouseButton(mouseButton))
        {
            animator.SetBool("gripPressed", true);

            if (!isGrabbing)
            {
                //Grab();
                AdvancedGrab();
            }
        }

        if (Input.GetMouseButtonUp(mouseButton))
        {
            animator.SetBool("gripPressed", false);
            //Release();
            AdvanceRelease();
        }

        float gripValue = Input.GetAxis(gripButtonName);

        //animator.SetBool("gripPressed", true);

        previousPosition = transform.position;
        previousRotation = transform.rotation.eulerAngles;



        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (isGrabbing)
            {
                Interactible interactible = touchedObject.GetComponent <Interactible>();
                interactible.Interact();
            }
        }
    }
示例#11
0
 private void CheckForInteractionClick()
 {
     if (Input.GetKeyDown(KeyCode.F) && _currentInteractible != null)
     {
         if (_currentInteractible.isPickable)
         {
             _currentInteractible.Interact();
             AddToInventory(_currentInteractible);
         }
         else if (HasRequirements(_currentInteractible))
         {
             Interact(_currentInteractible);
         }
     }
     if (Input.GetKey(KeyCode.P))
     {
         for (int i = 0; i < OpenDoorsCheat.Length; ++i)
         {
             OpenDoorsCheat[i].Interact();
         }
     }
 }