Beispiel #1
0
    public void GetInformed(GameObject toInspectLocation)
    {
        _overrideTarget = toInspectLocation;
        _state          = GuardModes.Searching;

        ToggleSearching();
    }
Beispiel #2
0
    public override void Load(Dictionary <string, object> saveState)
    {
        base.Load(saveState);
        gameObject.transform.position = (Vector3)saveState["position"];
        _target = (Vector3?)saveState["target"];
        _state  = (GuardModes)saveState["state"];

        ToggleSearching();
    }
Beispiel #3
0
    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;
            }
        }
    }