示例#1
0
 protected override void ExecuteInteraction()
 {
     if (Input.GetMouseButtonUp(0) && CurrentInteractable)
     {
         CurrentInteractable.Interact();
         CurrentInteractable.DisableHighlight();
     }
 }
示例#2
0
        private IEnumerator Interact()
        {
            crosshair.ActivateCrosshair();
            yield return(new WaitForSeconds(interactionTime));

            CurrentInteractable.Interact();
            crosshair.DeactivateCrosshair();
            CurrentInteractable.DisableHighlight();
        }
示例#3
0
 private void Update()
 {
     if (!Freeze)
     {
         if (Input.GetKeyDown(KeyCode.E))
         {
             if (CurrentInteractable != null)
             {
                 CurrentInteractable.Interact(this);
             }
         }
     }
 }
示例#4
0
    private void Interact()
    {
        if (CurrentInteractable is InventoryItem)
        {
            InventoryItems.AddToInventory(CurrentInteractable as InventoryItem);
        }

        //Remove item from inventory
        if (InventoryItems.HasRequirements(CurrentInteractable))
        {
            // Interact with current detected interactable
            CurrentInteractable.Interact();
            OnInteracted(CurrentInteractable);
            RemoveItemFromInventory();
        }
    }
示例#5
0
        protected override void CancelCurrentInteraction()
        {
            if (!CurrentInteractable)
            {
                return;
            }

            CurrentInteractable.DisableHighlight();
            CurrentInteractable = null;
            if (interactionCoroutine == null)
            {
                return;
            }
            crosshair.DeactivateCrosshair();
            StopCoroutine(interactionCoroutine);
            interactionCoroutine = null;
        }
示例#6
0
        /// <summary>
        /// Called each frame
        /// </summary>
        private void Update()
        {
            if (active)
            {
                // If the player presses "Interact" and is standing in front of something to interact with that is interactable

                if (Input.GetButtonDown("Interact") && CurrentInteractable != null && CurrentInteractable.Interactable)
                {
                    // Interact with it

                    CurrentInteractable.Interact();
                }

                // If the player pressed the reload button, his light is not burning and he has matches

                if (Input.GetButtonDown("Reload") && MatchCount > 0)
                {
                    MovementController.Locked = true;
                    minigameManager.StartMinigame();
                }

                // Update InLight property

                InLight = RoomManager.Instance.PlayerInLight(transform.position);

                switch (CurrentLightState)
                {
                case LightState.InLight:
                    Sanity += sanityHealSpeed * Time.deltaTime;
                    break;

                case LightState.InOwnLight:
                    Sanity -= sanityDamageSpeed / 2 * Time.deltaTime;
                    break;

                case LightState.InShadow:
                    Sanity -= sanityDamageSpeed * Time.deltaTime;
                    break;
                }
            }
        }
示例#7
0
    // Update is called once per frame
    void Update()
    {
        if (!isAlive)
        {
            return;
        }

        if (this.health <= 0.0f && isAlive)
        {
            isAlive = false;
            StartCoroutine(Die());
            return;
        }

        anim.SetBool("Damaged", isInvulnerable);
        if (isInvulnerable)
        {
            invulnerableTimer -= Time.deltaTime;
            if (invulnerableTimer <= 0.0f)
            {
                isInvulnerable = false;
            }
        }

        if (canRecoverStamina && this.stamina < this.maxStamina)
        {
            this.stamina += STAMINA_RECOVERY_PER_SECOND * Time.deltaTime;
            this.stamina  = Mathf.Clamp(this.stamina, 0.0f, this.maxStamina);
        }

        if (this.canInteract && this.IsTouchingInteractable && Controls.interactInputDown())
        {
            CurrentInteractable.OnInteract(this);
        }

        //Controller support works sort of yaaaaay
        //Debug.Log(GamepadInput.GamePad.GetAxis(GamepadInput.GamePad.Axis.LeftStick, GamepadInput.GamePad.Index.One).x);
        this.ActionFsm.Execute();
    }
示例#8
0
 public void ResetInteractable()
 {
     CurrentInteractable.GetComponent <InteractableManager>().Release(this);
     CurrentInteractable = null;
 }
示例#9
0
 private void InteractWithNPC()
 {
     CurrentInteractable.Interact();
     OnInteracted(CurrentInteractable);
 }