コード例 #1
0
 public void SetHoldingPattern(Vector3 location)
 {
     _flightpath             = null;
     _currentWaypoint        = null;
     _navState               = NavigationState.holdingPattern;
     _holdingPatternLocation = transform.position;
 }
コード例 #2
0
    /// <summary>
    /// Invoked whenever we have had a plan exit it's path
    /// </summary>
    private void OnExitedPath(Flightpath flightPath, IDirectable iDirectable)
    {
        flightPath.drawPath = flightPath.occupancy > 0;

        Rigidbody dRigidBody = iDirectable.GetComponent <Rigidbody>();

        dRigidBody.constraints = RigidbodyConstraints.FreezeAll;
        Destroy((Object)iDirectable);
    }
コード例 #3
0
 public void AssignPath(Flightpath flightpath, bool startFollowing)
 {
     _flightpath = flightpath;
     if (startFollowing)
     {
         _navState        = NavigationState.followingFlightPath;
         _currentWaypoint = _flightpath.GetFirstWaypoint();
     }
 }
コード例 #4
0
 private void Awake()
 {
     _landingPath = new Flightpath(transform.position);
     _landingPath.lookAheadDistance = 8f;
     for (int i = 0; i < _pathSegements.Length; i++)
     {
         _landingPath.AddPosition(_pathSegements[i] + transform.position);
     }
     _landingPath.drawPath          = true;
     _landingPath.disposeOnComplete = false;
     _landingPath.onPathExited     += OnExitedPath;
     _landingPath.Finialized();
 }
コード例 #5
0
        public void GenerateScenario()
        {
            Flightpaths = new List <Flightpath>();

            foreach (var flightpathSettings in ScenarioSettings.FlightpathSettings)
            {
                var flightpath = new Flightpath(ScenarioSettings.LLAOrigin, flightpathSettings);

                flightpath.GenerateFlightpath(0, 100.0);

                Flightpaths.Add(flightpath);
            }
        }
コード例 #6
0
    private void Update()
    {
        if (_flightController == null)
        {
            return;
        }

        Flightpath flightPath = _flightController.flightpath;
        LinkedListNode <Flightpath.Waypoint> currentWaypoint = _flightController.currentWaypoint;

        if (flightPath == null || currentWaypoint == null || !flightPath.drawPath)
        {
            _flightpathLineRenderer.positionCount           = 0;
            _flightpathConnectionLineRenderer.positionCount = 0;
            return;
        }

        // Draw connecting line from plane to path
        _flightpathConnectionLineRenderer.positionCount = 2;
        _flightpathConnectionLineRenderer.SetPosition(0, currentWaypoint.Value.Position);
        _flightpathConnectionLineRenderer.SetPosition(1, _flightController.transform.position);

        // Draw flight path line
        List <Vector3> points = new List <Vector3>(flightPath.waypointCount);

        for (LinkedListNode <Flightpath.Waypoint> wp = currentWaypoint; wp != null; wp = wp.Next)
        {
            points.Add(wp.Value.Position);
        }

        // Feed it the points backwards because the tiling UVs look nicer.
        Vector3[] pointsBackwards = new Vector3[points.Count];
        for (int i = 0; i < points.Count; i++)
        {
            pointsBackwards[(points.Count - 1) - i] = points[i];
        }
        _flightpathLineRenderer.positionCount = points.Count;
        _flightpathLineRenderer.SetPositions(pointsBackwards);
    }
コード例 #7
0
    private void Spawn()
    {
        float angle = ((Mathf.PI * 2) * Random.value);
        float sin   = Mathf.Sin(angle);
        float cos   = Mathf.Cos(angle);

        // Pick a spawn position
        Vector3 spawnPosition = _root.position;

        spawnPosition.x += _radius * sin;
        spawnPosition.z += _radius * cos;
        GameObject go = _factory.CreateRandomPlane(spawnPosition, Quaternion.identity);

        go.transform.SetParent(_root);

        // Grab our directable component
        IDirectable iDirectable = go.GetComponent <IDirectable>();
        // Set our primary travel position
        Vector3 primaryTravelPosition = _root.position;

        primaryTravelPosition.x += (_radius - _primaryTargetRadiusOffset) * sin;
        primaryTravelPosition.z += (_radius - _primaryTargetRadiusOffset) * cos;
        primaryTravelPosition.y += _primaryTargetHeightOffset;

        // Secondary Point
        angle = ((Mathf.PI * 2) * Random.value);
        Vector3 holdingPosition = _playerTransform.position;
        float   hpRadius        = Random.value * _holdingPositionRadius * _playerTransform.scale;

        holdingPosition.x += sin * hpRadius;
        holdingPosition.z += cos * hpRadius;

        Flightpath flightPath = new Flightpath(primaryTravelPosition);

        flightPath.drawPath = false;
        flightPath.AddPosition(holdingPosition);
        flightPath.Finialized();
        iDirectable.AssignPath(flightPath, true);
    }
コード例 #8
0
 public void SetPath(Flightpath landingPath)
 {
     _landingPath = landingPath;
 }
コード例 #9
0
 public void StartPath(Vector3 position)
 {
     _flightpath      = new Flightpath(position);
     _navState        = NavigationState.followingFlightPath;
     _currentWaypoint = _flightpath.GetFirstWaypoint();
 }