void Update() { if (Input.GetKeyDown(KeyCode.E)) { if (_useableObject != null && Time.time >= _lastUseTime + _useWaitTime) { _lastUseTime = Time.time; if (_useableObject.CanBeUsed(this)) { _useableObject.OnUse(this); _externalUseEnd = _useableObject.HasExternalUseEnd(); _using = true; if (_cameraMover != null) { _playerScript.enabled = false; _cameraMover.ZoomCameraIn(_useableGameObject.transform); _interactionCanvasInstance.SetActive(false); Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } } else if (_using && !_externalUseEnd) { _useableObject.OnEndUse(this); EndUse(); } } } }
public override void Use() { if (_interactionLogic != null) { IUseable useableObject = _interactionLogic.UseableObject; if (useableObject != null && useableObject.CanBeUsed(gameObject) && (Time.time >= _lastUseTime + _useWaitTime)) { _lastUseTime = Time.time; useableObject.OnUse(gameObject); } } }
void OnTriggerEnter(Collider other) { IUseable tempUseable = (IUseable)other.gameObject.GetComponentInChildren(typeof(IUseable)); if (tempUseable != null && _oldUseableObject != tempUseable && tempUseable.CanBeUsed(this)) { _oldUseableObject = tempUseable; _useableObject = (IUseable)other.gameObject.GetComponentInChildren(typeof(IUseable)); _useableGameObject = other.gameObject; if (_interactionCanvas != null) { _interactionCanvasInstance.SetActive(true); } } }
void OnTriggerEnter(Collider other) { IUseable tempUseable = GetUseableObject(other.gameObject); if (tempUseable != null && _oldUseableObject != tempUseable && tempUseable.CanBeUsed(_player.gameObject)) { _oldUseableObject = tempUseable; UseableObject = tempUseable; if (_canvasInstance) { _canvasInstance.transform.SetParent(other.transform); _canvasInstance.transform.position = other.transform.position; if (_canvasGroup) { _canvasGroup.alpha = 1; } } } }