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); } } }
private void UseableInput() { if (Input.GetKeyDown(KeyCode.E)) { if (m_currentObj == null) { return; } IUseable useable = m_currentObj.GetComponent <IUseable>(); useable.OnUse(); } }