protected override void ExecuteInteraction() { if (Input.GetMouseButtonUp(0) && CurrentInteractable) { CurrentInteractable.Interact(); CurrentInteractable.DisableHighlight(); } }
private IEnumerator Interact() { crosshair.ActivateCrosshair(); yield return(new WaitForSeconds(interactionTime)); CurrentInteractable.Interact(); crosshair.DeactivateCrosshair(); CurrentInteractable.DisableHighlight(); }
private void Update() { if (!Freeze) { if (Input.GetKeyDown(KeyCode.E)) { if (CurrentInteractable != null) { CurrentInteractable.Interact(this); } } } }
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(); } }
protected override void CancelCurrentInteraction() { if (!CurrentInteractable) { return; } CurrentInteractable.DisableHighlight(); CurrentInteractable = null; if (interactionCoroutine == null) { return; } crosshair.DeactivateCrosshair(); StopCoroutine(interactionCoroutine); interactionCoroutine = null; }
/// <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; } } }
// 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(); }
public void ResetInteractable() { CurrentInteractable.GetComponent <InteractableManager>().Release(this); CurrentInteractable = null; }
private void InteractWithNPC() { CurrentInteractable.Interact(); OnInteracted(CurrentInteractable); }