Пример #1
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.E))
     {
         currentTarget?.Interact(this);
     }
 }
Пример #2
0
        /// <summary>
        /// Handles interacting with various level objects such as respawn points.
        /// </summary>
        /// <returns>Is the interaction successful</returns>
        public bool HandleInteractionInput()
        {
            bool input = Input.GetInteractInput();

            if (input && InteractionTarget != null)
            {
                // TODO: No more energy charges.

                // Checks whether the energy cost is not too high
                if (World.Instance.CurrentEnergyCharges >=
                    InteractionTarget.EnergyCost)
                {
                    if (InteractionTarget.Interact())
                    {
                        //if (InteractionTarget.EnergyCost != 0)
                        //{
                        //    // Removes the energy cost from the players
                        //    EnergyCollector.ChangeCharges(-1 * InteractionTarget.EnergyCost);
                        //}

                        // Makes the interaction target forget the player
                        InteractionTarget.TryRemoveInteractorAfterInteraction();

                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #3
0
    void Update()
    {
        horizontal += Input.GetAxis("Mouse X") * mouseSensitivity;
        vertical   -= Input.GetAxis("Mouse Y") * mouseSensitivity;
        vertical    = Mathf.Clamp(vertical, -80, 80);
        transform.localRotation      = Quaternion.Euler(0, horizontal, 0);
        cam.transform.localRotation  = Quaternion.Euler(vertical, 0, 0);
        arms.transform.localRotation = Quaternion.Euler(vertical, 0, 0);
        forward = Input.GetAxis("Horizontal");
        left    = Input.GetAxis("Vertical");
        float currentSpeedReduction = speedReduction;

        if (Input.GetKey(KeyCode.LeftShift))
        {
            currentSpeedReduction = currentSpeedReduction / 2; isSprinting = true;
        }
        else
        {
            isSprinting = false;
        }
        transform.Translate(new Vector3(forward / currentSpeedReduction, 0, left / currentSpeedReduction));
        if (forward == 0 && left == 0)
        {
            isMoving = false;
        }
        else
        {
            isMoving = true;
        }
        if (Input.GetKey(KeyCode.E) && interact_target != null)
        {
            interact_target.Interact();
        }
    }
Пример #4
0
    public override void OnTargetReached(Transform target)
    {
        base.OnTargetReached(target);

        if (InteractionTarget != null)
        {
            InteractionTarget.Interact();
        }
    }
 public YieldResult Interact(Interaction interaction)
 {
     if (InteractionTarget.Interact(interaction, human, InteractionInfo.issuedByAI))
     {
         return(YieldResult.Continue);
     }
     else
     {
         return(YieldResult.Failed);
     }
 }