private void Interact()
    {
        if (DetectPlayer())
        {
            Debug.Log("Player Detected");

            if (playerInteract.Interact())
            {
                if (playerInteract.InteractedUpon().name == transform.GetChild(1).name)
                {
                    if (isGrounded == true)
                    {
                        if (playerGrabTransform.childCount == 0)
                        {
                            GrabBlock();
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
    void Actions()
    {
        if (Input.GetKey(KeyMap.fire))
        {
            weapon.Shoot();
        }

        aim.Aim(Input.GetKey(KeyMap.aim));


        if (Input.GetKey(KeyMap.light))
        {
            light.Toggle();
        }
        if (Input.GetKeyDown(KeyMap.interact))
        {
            /* Note : here we use GetKeyDown instead of GetKey */
            interact.Interact();
        }
        if (Input.GetKey(KeyMap.buffLife))
        {
        }
        if (Input.GetKey(KeyMap.buffSpeed))
        {
        }
        if (Input.GetKey(KeyMap.buffStrenght))
        {
        }
        if (Input.GetKey(KeyMap.ability1))
        {
        }
        if (Input.GetKey(KeyMap.ability2))
        {
        }

        if (Input.GetKeyDown(KeyMap.grenade))
        {
            grenade.ThrowGrenade();
        }

        if (Input.GetKey(KeyCode.I))
        {
            walkSpeed = 20;
            runSpeed  = 200;
            jumpForce = 40;
        }
        if (Input.GetKey(KeyCode.K))
        {
            walkSpeed = 8;
            runSpeed  = 20;
            jumpForce = 12;
        }
    }
 private void OnTriggerStay(Collider other)
 {
     if (other.CompareTag("Player"))
     {
         if (playerInteract.Interact())
         {
             if (playerInteract.InteractedUpon().name == gameObject.name)
             {
                 if (isGrounded == true)
                 {
                     if (playerGrabTransform.childCount == 0)
                     {
                         if (interacted == false)
                         {
                             GrabBlock();
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
    private void OpenDoor()
    {
        if (playerInteract.Interact())
        {
            interacted = true;

            if (doorSwitch.isLocked() == false)
            {
                if (doorSwitch.isClosed())
                {
                    doorSwitch.Open();
                }
                else if (doorSwitch.isOpen())
                {
                    doorSwitch.Close();
                }
            }
        }
    }
Exemplo n.º 5
0
    /// <summary>
    /// Reset the stopping distance and starts the interaction once the
    /// player reach the destination(That's what both if's check).
    /// </summary>
    /// <returns></returns>
    private IEnumerator CheckDistanceToInteractable()
    {
        while (objInteractable != null)
        {
            bool distance = (agent.destination - agent.transform.position).sqrMagnitude <=
                            agent.stoppingDistance * agent.stoppingDistance;
            if (distance)
            {
                if (!agent.hasPath || agent.velocity.sqrMagnitude == 0f)
                {
                    playerInteract.Interact(objInteractable);
                    agent.path             = new NavMeshPath();
                    agent.stoppingDistance = 0f;
                    yield break;
                }
            }

            Move(objInteractable.InteractionTransform.position);

            yield return(null);
        }

        agent.stoppingDistance = 0f;
    }