// Use this for initialization void Awake() { myTransform = transform; //assign the reference of Transform if (wayPoints.Length > 0) { currentWayPoint = wayPoints[0];//set initial waypoint currentWayPointIndex = 0; } else { Debug.LogError("No waypoint assigned"); } }
public void AddWaypoint(WaypointInfo waypointInfo) { Waypoint wp = new Waypoint(waypointInfo); foreach (var order in waypointInfo.UnitOrders) { BaseOrder baseOrder = GameManager.Instance.Game.GetBaseOrderFromUnitOrder(order); if (baseOrder != null) { wp.Orders.Add(baseOrder); } } AddWaypoint(wp); }
IEnumerator MoveToWaypoint(WaypointInfo waypoint) { float t = Time.fixedDeltaTime; float startTime = Time.time - t; Vector3 startPos = transform.position; Vector3 targetPos = waypoint.Waypoint.GetPosition(); while (t < 1) { t = (Time.time - startTime) / waypoint.TimeToWaypoint; transform.position = Vector3.Lerp(startPos, targetPos, waypoint.MovementCurve.Evaluate(t)); yield return(new WaitForFixedUpdate()); } }
public WaypointInfo GetWaypointInfo() { WaypointInfo info = new WaypointInfo(); info.Position = GetPositionInfo(); if (TargetDetectedUnit != null) { info.TargetDetectedUnitId = TargetDetectedUnit.Id; } if (TargetBaseUnit != null) { info.ReturningToUnitId = TargetBaseUnit.Id; } return(info); }
private void OnGUI() { if (_drawDebugInfo) { string DebugText = ""; DebugText += "Angular veocity Y: " + _rb.angularVelocity.y + "\n"; if (_currentWaypoint != null) { WaypointInfo info = ComputeWaypointInfo(_currentWaypoint.Value); DebugText += "Direction X: " + info.localDirection.x + "\n"; } DebugText += "debugFloat1: " + debugFloat1 + "\n"; GUILayout.Label(DebugText, GUI.skin.box); } }
private void Update() { if (_drawDebugInfo) { DrawDebugInfo(); } if (_navState == NavigationState.holdingPattern) { AdjustForHoldingPattern(); } else if (_navState == NavigationState.landing) { throw new System.NotImplementedException(); } else { WaypointInfo info = ComputeWaypointInfo(_currentWaypoint.Value); while (ShouldAdvanceWaypoint(info)) { LinkedListNode <Flightpath.Waypoint> nextWaypoint = _currentWaypoint.Next; if (nextWaypoint == null) { if (_flightpath.isFinalized) { flightpath.OnPathExited(this); SetHoldingPattern(transform.position); } return; } _currentWaypoint = nextWaypoint; info = ComputeWaypointInfo(_currentWaypoint.Value); } AdjustForWaypoint(info); } }
private void addWaypointsToMap(List<Framework.Data.Waypoint> wpList) { List<WaypointInfo> wpInfoList = new List<WaypointInfo>(); if (wpList != null) { foreach (Framework.Data.Waypoint wp in wpList) { if (wp.Lat != null && wp.Lon != null) { StringBuilder bln = new StringBuilder(); bln.AppendFormat("{0}<br />", Utils.Conversion.GetCoordinatesPresentation((double)wp.Lat, (double)wp.Lon)); bln.AppendFormat("{0}<br />", wp.Code); bln.AppendFormat("{0}<br />", HttpUtility.HtmlEncode(Utils.LanguageSupport.Instance.GetTranslation(wp.WPType.Name))); bln.AppendFormat("{0}<br />", HttpUtility.HtmlEncode(wp.Description)).Replace("\r\n", "<br />").Replace("\n", ""); bln.AppendFormat("{0}", HttpUtility.HtmlEncode(wp.Comment).Replace("\r\n", "<br />").Replace("\n", "")); WaypointInfo wpi = new WaypointInfo(); wpi.a = wp.Code; wpi.b = (double)wp.Lat; wpi.c = (double)wp.Lon; wpi.d = string.Format("wpt{0}Icon", wp.WPType.ID.ToString().Replace("-", "_")); wpi.e = bln.ToString(); wpInfoList.Add(wpi); } } } var jsonSerialiser = new JavaScriptSerializer(); var json = jsonSerialiser.Serialize(wpInfoList); executeScript(string.Format("updateWaypoints({0})", json)); }
public void Parse(GameBitBuffer buffer) { serQuests = new SerializeData(); serQuests.Parse(buffer); Field1 = new DT_VARIABLEARRAY(); Field1.Parse(buffer); Field2 = new WaypointInfo[25]; for(int i = 0;i < _Field2.Length;i++) { _Field2[i] = new WaypointInfo(); _Field2[i].Parse(buffer); } Field3 = new ResolvedPortalDestination(); Field3.Parse(buffer); Field4 = new ActStartLocOverride[6]; for(int i = 0;i < _Field4.Length;i++) { _Field4[i] = new ActStartLocOverride(); _Field4[i].Parse(buffer); } }
protected bool IsWaypointInfront(WaypointInfo info) { return(Vector3.Dot(info.worldDirection, transform.forward) > -0.2); }
protected void AdjustForWaypoint(WaypointInfo info) { _plane.targetFacing = info.worldDirection; _plane.targetUp = GetBankedUpVector(_plane.targetFacing, 5.0f, 0.5f); _plane.throttle = 1.0f; }
protected bool ShouldAdvanceWaypoint(WaypointInfo info) { return(IsWaypointInfront(info) && (info.distance < _flightpath.lookAheadDistance)); }