コード例 #1
0
        /// <summary>
        /// Stop listen to location update / gatherer device location.
        /// </summary>
        private void StopLocationUpdate(GeolocationStatus status)
        {
            if (LocationRetrieveTimer != null)
            {
                // Destroy the timer
                LocationRetrieveTimer.Dispose();
                LocationRetrieveTimer = null;
            }

            if (LocationManager != null)
            {
                // Stop listen to location changes
                LocationManager.StopUpdatingLocation();
                LocationManager.LocationsUpdated -= LocationManager_LocationsUpdated;

                // Remove the reference
                LocationManager = null;
            }

            // Make sure we only update the result if it is not completed yet
            if (LocationTaskCompletionSource != null &&
                !LocationTaskCompletionSource.Task.IsCompleted)
            {
                // Craft the location with all information we have whatever the location is acceptable or not
                var location = IsLastKnownLocationFresh() ?
                               LastKnownLocation.ToNewGeolocation(status) :
                               new Geolocation(status);

                // return the location
                LocationTaskCompletionSource.SetResult(location);
            }
        }
コード例 #2
0
 private void Start()
 {
     _playerGO          = GameObject.FindGameObjectWithTag("Player");
     _playerController  = _playerGO.GetComponent <PlayerController>();
     _charLocomotion    = _playerGO.GetComponent <CharacterLocomotion>();
     _aiHealth          = GetComponent <Health>();
     _lastKnownLocation = FindObjectOfType <LastKnownLocation>();
 }
コード例 #3
0
 public void Initialize(AIAgent agent)
 {
     _aiWeapon          = agent.GetComponent <AIWeapons>();
     _navAgent          = agent.GetComponent <NavMeshAgent>();
     _aiHealth          = agent.GetComponent <AIHealth>();
     _fov               = agent.GetComponent <FieldOfView>();
     _lastKnownLocation = GameObject.FindObjectOfType <LastKnownLocation>();
     _agent             = agent;
 }
コード例 #4
0
        public override VoyageState DepartFrom(ILocation location)
        {
            if (LastKnownLocation.Equals(location.UnLocode))
            {
                return(new MovingVoyage(Number, Schedule, _movementIndex));
            }
            string message = string.Format("The voyage stopped over at {0}.", LastKnownLocation);

            throw new ArgumentException(message, "location");
        }
コード例 #5
0
        public override VoyageState StopOverAt(ILocation location)
        {
            if (LastKnownLocation.Equals(location.UnLocode))
            {
                return(this);
            }
            string message = string.Format("The voyage stopped over at {0}.", LastKnownLocation);

            throw new ArgumentException(message, "location");
        }
コード例 #6
0
        public override VoyageState DepartFrom(ILocation location)
        {
            if (LastKnownLocation.Equals(location.UnLocode))
            {
                return(this);
            }
            string message = string.Format("The voyage departed from {0}.", LastKnownLocation);

            throw new ArgumentException(message, "location");
        }
コード例 #7
0
    public AISearchForPlayerState(AIAgent agent)
    {
        _agent = agent;
        _playersKnownLocation = GameObject.FindObjectOfType <LastKnownLocation>();

        if (_playersKnownLocation == null)
        {
            Debug.LogError("Last Player Location prefab not placed in scene.");
        }

        _navAgent = agent.GetComponent <NavMeshAgent>();

        _fov = agent.GetComponent <FieldOfView>();
    }
コード例 #8
0
    public void Enter()
    {
        _arrivedAtPoint = false;

        if (_lastKnownLocation == null)
        {
            _lastKnownLocation = GameObject.FindObjectOfType <LastKnownLocation>();

            if (_lastKnownLocation == null)
            {
                Debug.LogError("Last Player Location prefab not placed in scene.");
            }
        }

        //Generates a point near the last known location of the player for the AI to stand
        _navAgent.SetDestination(_lastKnownLocation.GeneratePointInRange(7.5f));
    }
コード例 #9
0
        /// <summary>
        /// Stop listen to location update / gatherer device location.
        /// </summary>
        private void StopLocationUpdate(GeolocationStatus status)
        {
            if (LocationRetrieveTimer != null)
            {
                // Destroy the timer
                LocationRetrieveTimer.Dispose();
                LocationRetrieveTimer = null;
            }

            if (FusedLocationClient != null)
            {
                // Stop listen to location changes
                if (FusedLocationCallback != null)
                {
                    FusedLocationCallback.LocationResult -= FusedLocationCallback_LocationResult;
                    FusedLocationClient.RemoveLocationUpdates(FusedLocationCallback);
                    FusedLocationCallback = null;
                }
                FusedLocationClient.Dispose();
                FusedLocationClient = null;
            }

            if (LocationManager != null)
            {
                // Stop listen to location changes
                LocationManager.RemoveUpdates(this);
                LocationManager.Dispose();
                LocationManager = null;
            }

            // Make sure we only update the result if it is not completed yet
            if (LocationTaskCompletionSource != null &&
                !LocationTaskCompletionSource.Task.IsCompleted)
            {
                // Craft the location with all information we have whatever the location is acceptable or not
                var location = IsLastKnownLocationFresh() ?
                               LastKnownLocation.ToNewGeolocation(status) :
                               new Geolocation(status);

                // return the location
                LocationTaskCompletionSource.SetResult(location);
            }
        }
コード例 #10
0
        /// <summary>
        /// Stop listen to location update / gatherer device location.
        /// </summary>
        private void StopLocationUpdate(GeolocationStatus status)
        {
            if (WindowsGeolocator != null)
            {
                WindowsGeolocator.PositionChanged -= WindowsGeolocator_PositionChanged;
                WindowsGeolocator = null;
            }

            // Make sure we only update the result if it is not completed yet
            if (LocationTaskCompletionSource != null &&
                !LocationTaskCompletionSource.Task.IsCompleted)
            {
                // Craft the location with all information we have whatever the location is acceptable or not
                var location = IsLastKnownLocationFresh() ?
                               LastKnownLocation.ToNewGeolocation(status) :
                               new Geolocation(status);

                // return the location
                LocationTaskCompletionSource.SetResult(location);
            }
        }
コード例 #11
0
 public bool Equals(IDelivery other)
 {
     if (null == other)
     {
         return(false);
     }
     if (object.ReferenceEquals(this, other))
     {
         return(true);
     }
     if (null != CurrentVoyage && !CurrentVoyage.Equals(other.CurrentVoyage))
     {
         return(false);
     }
     if (null == CurrentVoyage && null != other.CurrentVoyage)
     {
         return(false);
     }
     if (null != LastKnownLocation && !LastKnownLocation.Equals(other.LastKnownLocation))
     {
         return(false);
     }
     if (null == LastKnownLocation && null != other.LastKnownLocation)
     {
         return(false);
     }
     if (TransportStatus != other.TransportStatus)
     {
         return(false);
     }
     if (_routingStatus != other.RoutingStatus)
     {
         return(false);
     }
     if (IsUnloadedAtDestination != other.IsUnloadedAtDestination)
     {
         return(false);
     }
     return(true);
 }
コード例 #12
0
    private void Awake()
    {
        _aiHealth          = GetComponent <Health>();
        _audioSource       = GetComponent <AudioSource>();
        _owningZone        = GetComponentInParent <CombatZone>();
        _defaultMoveSpeed  = GetComponent <NavMeshAgent>().speed;
        _lastKnownLocation = FindObjectOfType <LastKnownLocation>();

        //Error Logging
        if (!_aiHealth)
        {
            Debug.LogError(gameObject.name + " has no derivative of Health Component attached to it");
        }
        if (!_audioSource)
        {
            Debug.LogError(gameObject.name + " has no AudioSource component attached to it");
        }
        if (!_owningZone)
        {
            Debug.LogError(gameObject.name + " has no CombatZone component in parent GameObject");
        }
    }
コード例 #13
0
ファイル: VoyageState.cs プロジェクト: dmitribodiu/Epic.NET
 public sealed override int GetHashCode()
 {
     return(this.GetType().GetHashCode() ^ LastKnownLocation.GetHashCode());
 }
コード例 #14
0
 /// <summary>
 /// Check if the retrieve last known location is still consider fresh and but ignore the accurate.
 /// </summary>
 private bool IsLastKnownLocationFresh()
 {
     return(LastKnownLocation != null &&
            LastKnownLocation.IsFresh(TargetFreshness));
 }
コード例 #15
0
 /// <summary>
 /// Check if the retrieve last known location is still consider fresh and accurate.
 /// </summary>
 private bool IsLastKnownLocationFreshAndAccurate()
 {
     return(LastKnownLocation != null &&
            LastKnownLocation.IsFresh(TargetFreshness) &&
            LastKnownLocation.IsAccurate(TargetAccuracy));
 }