// Update is called once per frame private void Update() { // Check if the camera is not in the provided range of an object. if (_introMove && _movementHelper.IsNotInRange(ParentObject.gameObject.transform.position, 1f)) { // If not, move the camera to that object. _movementHelper.Move(_rigidbody, ParentObject.gameObject.transform.position, 10f); return; } if (_introMove) { // The camera is close enough and the intro should end. FinishIntro(); } // Player object no longer exists, maybe it got killed. // Just return instead. if (ParentObject == null) { return; } // Set the camera position to be above the parent's position. transform.position = new Vector3(ParentObject.transform.position.x, transform.localPosition.y, ParentObject.transform.position.z); }
private void ChaseTarget() { // If there is no override target, there is no chase going on. // Execute the basic movement and stop the execution of this method. if (_overrideTarget == null) { return; } // If we aren't next to the target. if (_movementHelper.IsNotInRange(_overrideTarget.transform.position, 5f)) { // If it is not within the max distance of the guards "vision" if (_movementHelper.IsNotInRange(_overrideTarget.transform.position, 25f)) { // Stop chasing the target and go back to the normal route. _lastSpotted = _overrideTarget.transform.position; GenerateNewPattern(); _overrideTarget = null; _state = GuardModes.Route; ChangeState(GuardVariables.MaximumAlert / 2f); ToggleSearching(); return; } _navMeshAgent.destination = _overrideTarget.transform.position; } else { // Inspect the target and decrease or increase the alert. if (_currentWaiting >= _waitingTime) { HandleSuspiciousTarget(); _currentWaiting = 0f; } else { _currentWaiting += Time.deltaTime; } } }
private void Update() { if (Game.IsPaused || _isTaken) { return; } // Check if the player is in range of the object. // Make sure that the player was not in the range already to not // keep setting the material. if (!_movementHelper.IsNotInRange(Game.PlayerObject.transform.position, 2.5f) && !_isInRange) { _renderer.material = HighlightMaterial; _isInRange = true; Game.UI.SetBottomText("Press E to steal"); } // Only perform this if the first check fails and the player is in range else if (_movementHelper.IsNotInRange(Game.PlayerObject.transform.position, 2.5f) && _isInRange) { _renderer.material = _initialMaterial; _isInRange = false; Game.UI.HideBottom(); } }