public void SetHoldingPattern(Vector3 location) { _flightpath = null; _currentWaypoint = null; _navState = NavigationState.holdingPattern; _holdingPatternLocation = transform.position; }
/// <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); }
public void AssignPath(Flightpath flightpath, bool startFollowing) { _flightpath = flightpath; if (startFollowing) { _navState = NavigationState.followingFlightPath; _currentWaypoint = _flightpath.GetFirstWaypoint(); } }
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(); }
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); } }
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); }
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); }
public void SetPath(Flightpath landingPath) { _landingPath = landingPath; }
public void StartPath(Vector3 position) { _flightpath = new Flightpath(position); _navState = NavigationState.followingFlightPath; _currentWaypoint = _flightpath.GetFirstWaypoint(); }