// Methods public static MovementPath GetClientMovement(List<UInt32> Keys) { MovementPath path = new MovementPath(); PathElement element = null; int num = 0; int num2 = 0; foreach (int num2_loopVariable in Keys) { num2 = num2_loopVariable; MapPoint point = new MapPoint((num2 & 4095)); PathElement item = new PathElement { Cell = point }; if ((num == 0)) { path.CellStart = point; } else { element.Orientation = element.Cell.OrientationTo(item.Cell); } if ((num == (Keys.Count - 1))) { path.CellEnd = point; } path.Cells.Add(item); element = item; num += 1; } return path; }
public bool IsCorrectionRequiredFromA(PathElement pathElement) { Init(); var lastTimeInCurrentDay = TimeUtil.ToInt(LastDeparture.AddMinutes(pathElement.DistanceFromA)); return(lastTimeInCurrentDay < GetFirstDepartureFromZ(pathElement)); }
private void TileClicked(Tile clickedTile) { // If there is no selected tile - select clicked tile. if (selectedTile == null) { SelectTile(clickedTile); return; } // If selected tile was clicked again - deselect it. if (selectedTile == clickedTile) { SelectTile(null); return; } PathElement pathFromDestination = Modules.Pathfinding.GetPathEndAtDestination(selectedTile, clickedTile, tiles); // If selected tile can not be moved to clicked tile - select clicked tile. if (pathFromDestination == null) { SelectTile(clickedTile); return; } // If selected tile is successfully moved to clicked tile - deselect it. clickedTile.SetContent(selectedTile.TileContent, selectedTile.FruitId, true); selectedTile.SetContent(TileContent.None, -1, true); SelectTile(null); TileSuccessfullyMoved?.Invoke(clickedTile); NewPathCreated?.Invoke(pathFromDestination, tiles); }
public override void Execute() { using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(StringTable.UndoUnitReleaseCompoundPath)) { SceneElementSelectionSet elementSelectionSet = this.SceneViewModel.ElementSelectionSet; ICollection <SceneElement> collection = (ICollection <SceneElement>)elementSelectionSet.Selection; elementSelectionSet.Clear(); SceneElementCollection elementCollection = new SceneElementCollection(); foreach (SceneElement sceneElement in (IEnumerable <SceneElement>)collection) { PathElement pathElement1 = sceneElement as PathElement; if (ReleaseCompoundPathCommand.GetFigureCount(pathElement1) > 1) { foreach (PathElement pathElement2 in PathCommandHelper.ReleaseCompoundPaths(pathElement1, editTransaction)) { elementCollection.Add((SceneElement)pathElement2); } } else { elementCollection.Add(sceneElement); } } elementSelectionSet.SetSelection((ICollection <SceneElement>)elementCollection, (SceneElement)null); editTransaction.Commit(); } }
private static int GetFigureCount(PathElement pathElement) { if (pathElement == null || !pathElement.IsViewObjectValid) { return(0); } IPlatformTypes metadata = pathElement.Platform.Metadata; if (!PlatformTypes.IsInstance(pathElement.GetLocalValue(PathElement.DataProperty), PlatformTypes.PathGeometry, metadata.DefaultTypeResolver)) { return(pathElement.PathGeometry.Figures.Count); } object obj = new PropertyReference(new List <ReferenceStep>() { metadata.ResolveProperty(PathElement.DataProperty) as ReferenceStep, metadata.ResolveProperty(PathElement.FiguresProperty) as ReferenceStep, metadata.ResolveProperty(PathElement.PathFigureCollectionCountProperty) as ReferenceStep }).GetValue(pathElement.ViewObject.PlatformSpecificObject); if (obj is int) { return((int)obj); } return(0); }
public ExpressionParameterDTO() { GroupingPathDTO = new PathElement(); ContainerPathDTO = new PathElement(); CompartmentPathDTO = new PathElement(); Parameter = new NullParameterDTO(); }
/// <summary> /// 添加点对象 /// </summary> /// <param name="item"></param> /// <param name="item"></param> /// <param name="type"></param> /// <param name="point"></param> /// <returns></returns> /// <summary> /// 多线段 /// </summary> /// <returns></returns> /// <summary> /// 圆弧 /// </summary> /// <returns></returns> private PathElement LoadArc(RTSafe.DxfCore.Entities.Arc item, int type) { PathElement pathElement = new PathElement(); pathElement.Tag = item.Layer.Name; pathElement.Color = GetBrush(item.Color, item.Layer, type); pathElement.StartAngle = item.StartAngle; pathElement.EndAngle = item.EndAngle; var s = item.StartAngle; if (item.Center.X.Equals(269.001501586602d)) { pathElement.IsLargeArc = true; } //pathElement.StartPoint = new EPoint(Math.Cos(s) * item.Radius + item.Center.X - MinX, MaxY - (Math.Sin(s) * item.Radius + item.Center.Y)); pathElement.StartPoint = new EPoint(item.Center.X - MinX, MaxY - item.Center.Y); var c = item.EndAngle - item.StartAngle; ////若果结束角度小于开始角度,弧长为差值加2*pi if (c < 0) { c += 360; } if (c > 180) { pathElement.IsLargeArc = true; } pathElement.RotationAngle = c; pathElement.Radius = item.Radius; return(pathElement); }
public void DrawPath(PathElement lastElementOfPath, Tile[,] tiles) { if (hidingCoroutine != null) { StopCoroutine(hidingCoroutine); } CreateNewPathElementsIfNecessary(lastElementOfPath); HideAllElements(); PathElement currentPathElement = lastElementOfPath; int highlightedElementIndex = 0; while (currentPathElement != null) { highlightedElements[highlightedElementIndex].enabled = true; highlightedElements[highlightedElementIndex].transform.position = tiles[currentPathElement.Tile.XPosition, currentPathElement.Tile.YPosition].transform.position; highlightedElementIndex++; currentPathElement = currentPathElement.PreviousElement; } hidingCoroutine = StartCoroutine(HideHighlightedElementsAfterDelay()); }
private static void TransferPathFigureAnimations(PathElement oldElement, PathElement newElement, PropertyReference pathProperty, int oldFigureIndex, int newFigureIndex, Transform transform) { PathAnimationMovePackage animationMove = new PathAnimationMovePackage(); PathCommandHelper.TransferPathFigureAnimations(oldElement, newElement, pathProperty, oldFigureIndex, newFigureIndex, transform, animationMove); animationMove.AddAndRemove(); }
public void HighlightProperty(PropertyReference propertyReference) { if (propertyReference.Count < 4 || !propertyReference[1].Equals((object)PathElement.FiguresProperty)) { return; } IndexedClrPropertyReferenceStep propertyReferenceStep1 = propertyReference[2] as IndexedClrPropertyReferenceStep; if (propertyReferenceStep1 == null) { return; } this.HighlightFigureIndex = propertyReferenceStep1.Index; if (propertyReference.Count == 4 && propertyReference[3].Equals((object)PathElement.PathFigureStartPointProperty)) { this.HighlightSegmentPointIndex = 0; this.HighlightSegmentIndex = -1; this.RenderHighlight = true; } else { if (propertyReference.Count != 6 || !propertyReference[3].Equals((object)PathElement.PathFigureSegmentsProperty)) { return; } IndexedClrPropertyReferenceStep propertyReferenceStep2 = propertyReference[4] as IndexedClrPropertyReferenceStep; if (propertyReferenceStep2 == null) { return; } this.HighlightSegmentIndex = propertyReferenceStep2.Index; this.HighlightSegmentPointIndex = PathElement.GetPointIndexFromPointProperty((IPropertyId)propertyReference[5]); this.RenderHighlight = true; } }
public static void AdjustPathForAnimations(PathElement pathElement, SceneEditTransaction editTransaction) { using (pathElement.ViewModel.ForceBaseValue()) { System.Windows.Media.Geometry geometry1 = (System.Windows.Media.Geometry)pathElement.GetLocalOrDefaultValueAsWpf(PathElement.DataProperty); PathGeometry pathGeometry = new PathGeometry(); pathGeometry.AddGeometry(geometry1); Rect bounds = PathCommandHelper.InflateRectByStrokeWidth(pathGeometry.Bounds, pathElement, false); PropertyReference propertyReference = PathCommandHelper.GetPathDataPropertyReference(pathElement.Platform); Rect maxAnimatedExtent = PathCommandHelper.FindMaxAnimatedExtent((SceneElement)pathElement, bounds, propertyReference); double num1 = Math.Min(0.0, maxAnimatedExtent.Left); double num2 = Math.Min(0.0, maxAnimatedExtent.Top); Vector vector = new Vector(-num1, -num2); ILayoutDesigner designerForChild = pathElement.ViewModel.GetLayoutDesignerForChild((SceneElement)pathElement, true); editTransaction.Update(); Rect childRect = designerForChild.GetChildRect((BaseFrameworkElement)pathElement); childRect.X += num1; childRect.Y += num2; childRect.Width = Math.Max(maxAnimatedExtent.Width, childRect.Width); childRect.Height = Math.Max(maxAnimatedExtent.Height, childRect.Height); designerForChild.SetChildRect((BaseFrameworkElement)pathElement, childRect); Transform transform = (Transform) new TranslateTransform(vector.X, vector.Y); PathGeometry geometry2 = PathGeometryUtilities.TransformGeometry((System.Windows.Media.Geometry)pathGeometry, transform); if (!pathElement.DesignerContext.ActiveDocument.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf)) { PathGeometryUtilities.EnsureOnlySingleSegmentsInGeometry(geometry2); } pathElement.PathGeometry = geometry2; PathCommandHelper.TransformPointKeyframes((SceneElement)pathElement, propertyReference, transform); pathElement.SetValueAsWpf(ShapeElement.StretchProperty, (object)(Stretch)(pathElement.HasVertexAnimations ? 0 : 1)); } }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as CodeFilterComponent; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (PathElement != null) { dest.PathElement = (Hl7.Fhir.Model.FhirString)PathElement.DeepCopy(); } if (ValueSet != null) { dest.ValueSet = (Hl7.Fhir.Model.DataType)ValueSet.DeepCopy(); } if (ValueCodeElement != null) { dest.ValueCodeElement = new List <Hl7.Fhir.Model.Code>(ValueCodeElement.DeepCopy()); } if (ValueCoding != null) { dest.ValueCoding = new List <Hl7.Fhir.Model.Coding>(ValueCoding.DeepCopy()); } if (ValueCodeableConcept != null) { dest.ValueCodeableConcept = new List <Hl7.Fhir.Model.CodeableConcept>(ValueCodeableConcept.DeepCopy()); } return(dest); }
private MovementPath method_3(SimpleCellInfo class13_0) { var range = new List <MapPoint>(); var class2 = class13_0; while (class2.v_OriginPoint.CellId != MapPoint_FromCell.CellId) { class2 = class2.class13_0; range.Add(class2.v_OriginPoint); } range.Reverse(); range.Add(class13_0.v_OriginPoint); if (v_MouvementPoints != -1) { range = range.GetRange(0, v_MouvementPoints + 1 > range.Count ? range.Count : v_MouvementPoints + 1); } var path = new MovementPath { CellStart = MapPoint_FromCell, CellEnd = range[range.Count - 1] }; var num = range.Count - 2; var i = 0; while (i <= num) { var item = new PathElement { Cell = range[i], Orientation = range[i].OrientationTo(range[i + 1]) }; path.Cells.Add(item); i += 1; } path.Compress(); return(path); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testParseSubsystemWithJobExecutorXml() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testParseSubsystemWithJobExecutorXml() { string subsystemXml = FileUtils.readFile(SUBSYSTEM_WITH_JOB_EXECUTOR); // System.out.println(normalizeXML(subsystemXml)); IList <ModelNode> operations = parse(subsystemXml); // System.out.println(operations); assertEquals(4, operations.Count); ModelNode jobExecutor = operations[1]; PathAddress pathAddress = PathAddress.pathAddress(jobExecutor.get(ModelDescriptionConstants.OP_ADDR)); assertEquals(2, pathAddress.size()); PathElement element = pathAddress.getElement(0); assertEquals(ModelDescriptionConstants.SUBSYSTEM, element.Key); assertEquals(org.camunda.bpm.container.impl.jboss.extension.ModelConstants_Fields.SUBSYSTEM_NAME, element.Value); element = pathAddress.getElement(1); assertEquals(Element.JOB_EXECUTOR.LocalName, element.Key); assertEquals(Attribute.DEFAULT.LocalName, element.Value); assertEquals("job-executor-tp", jobExecutor.get(Element.THREAD_POOL_NAME.LocalName).asString()); ModelNode jobAcquisition = operations[2]; assertEquals("default", jobAcquisition.get(Attribute.NAME.LocalName).asString()); assertEquals("SEQUENTIAL", jobAcquisition.get(Element.ACQUISITION_STRATEGY.LocalName).asString()); jobAcquisition = operations[3]; assertEquals("anders", jobAcquisition.get(Attribute.NAME.LocalName).asString()); assertEquals("SEQUENTIAL", jobAcquisition.get(Element.ACQUISITION_STRATEGY.LocalName).asString()); }
private void Add(MazeUnit newUnit) { var newElement = new PathElement(newUnit); newElement = PathEditorUtils.GetElementType(newElement); var nr_el = pathToEdit.PathAsLinkedList.Count; // count all elements in the path to get the second last for turning calculation if (nr_el >= 1) { var previousElement = pathToEdit.PathAsLinkedList.Last.Value; if (nr_el >= 2) { var secpreviousElement = pathToEdit.PathAsLinkedList.Last.Previous.Value; newElement = PathEditorUtils.GetTurnType(newElement, previousElement, secpreviousElement); } else { newElement.Turn = TurnType.STRAIGHT; } } pathToEdit.PathAsLinkedList.AddLast(newElement); }
private void BuildPathElementRoot() { Dictionary<string, PathElement> propertyDictionary = new Dictionary<string, PathElement>(); foreach (ShowPlanProperty planProperty in _properties) { string currentPath = null; PathElement property = _root; foreach (string pathPart in planProperty.PathElements) { if (currentPath == null) currentPath = pathPart; else currentPath = currentPath + "." + pathPart; PathElement currentProperty; if (!propertyDictionary.TryGetValue(currentPath, out currentProperty)) { currentProperty = new PathElement(); currentProperty.Name = pathPart; property.Children.Add(currentProperty); propertyDictionary.Add(currentPath, currentProperty); } property = currentProperty; } property.Value = planProperty.Value; } }
public ExpressionContainerDTO() { GroupingPathDTO = new PathElement(); ContainerPathDTO = new PathElement(); RelativeExpressionParameter = new NullParameterDTO(); RelativeExpressionNormParameter = new NullParameterDTO(); }
private static List <PathElement> GetAdjacentTilesOfTile(PathElement tile, IPathTile[,] tiles) { List <PathElement> adjacentTiles = new List <PathElement>(); // Up tile. if (tile.Tile.YPosition < Modules.Balance.BoardYSize - 1) { adjacentTiles.Add(new PathElement(tiles[tile.Tile.XPosition, tile.Tile.YPosition + 1], tile)); } // Right tile. if (tile.Tile.XPosition < Modules.Balance.BoardXSize - 1) { adjacentTiles.Add(new PathElement(tiles[tile.Tile.XPosition + 1, tile.Tile.YPosition], tile)); } // Down tile. if (tile.Tile.YPosition > 0) { adjacentTiles.Add(new PathElement(tiles[tile.Tile.XPosition, tile.Tile.YPosition - 1], tile)); } // Left tile. if (tile.Tile.XPosition > 0) { adjacentTiles.Add(new PathElement(tiles[tile.Tile.XPosition - 1, tile.Tile.YPosition], tile)); } return(adjacentTiles); }
private MovementPath method_3(SimpleCellInfo class13_0) { List <MapPoint> range = new List <MapPoint>(); SimpleCellInfo class2 = class13_0; while (class2.v_OriginPoint.CellId != this.MapPoint_FromCell.CellId) { class2 = class2.class13_0; range.Add(class2.v_OriginPoint); } range.Reverse(); range.Add(class13_0.v_OriginPoint); if (this.v_MouvementPoints != -1) { range = range.GetRange(0, (((this.v_MouvementPoints + 1) > range.Count) ? range.Count : (this.v_MouvementPoints + 1))); } MovementPath path = new MovementPath { CellStart = this.MapPoint_FromCell, CellEnd = range[(range.Count - 1)] }; int num = (range.Count - 2); int i = 0; while (i <= num) { PathElement item = new PathElement { Cell = range[i], Orientation = range[i].OrientationTo(range[(i + 1)]) }; path.Cells.Add(item); i += 1; } path.Compress(); return(path); }
/// <summary> /// Removes one or two last <see cref="PathElement"/> of <see cref="DynamicPath"/>. /// </summary> /// <param name="group">The closed group.</param> /// <param name="conclusions">Texts that conclude the group. Never null but can be empty.</param> protected override void OnGroupClosed(IActivityLogGroup group, IReadOnlyList <ActivityLogGroupConclusion> conclusions) { if (_currentIsGroupClosed) { HandleCurrentGroupIsClosed(); } if (_path.Count > 0) { if (!_currentIsGroup) { _path.RemoveAt(_path.Count - 1); } _currentIsGroupClosed = false; _current = null; if (_path.Count > 0) { _current = _path[_path.Count - 1]; _current.GroupConclusion = conclusions; _currentIsGroup = true; _currentIsGroupClosed = _path.Count > 0; } else { _currentIsGroup = false; } } }
public void PathConstructorUnitTest2() { Assert.Inconclusive("TODO"); PathElement pathElement = null; // TODO: Initialize to an appropriate value var target = new Path(pathElement); }
internal PathElement CreatePathElement() { PathElement pathElement = PathCreateBehavior.CreatePathElement(this.ActiveSceneViewModel, this.ActiveSceneInsertionPoint, this.ToolBehaviorContext); this.EditingElement = (BaseFrameworkElement)pathElement; return(pathElement); }
private void BuildPathElementRoot() { Dictionary <string, PathElement> propertyDictionary = new Dictionary <string, PathElement>(); foreach (ShowPlanProperty planProperty in _properties) { string currentPath = null; PathElement property = _root; foreach (string pathPart in planProperty.PathElements) { if (currentPath == null) { currentPath = pathPart; } else { currentPath = currentPath + "." + pathPart; } PathElement currentProperty; if (!propertyDictionary.TryGetValue(currentPath, out currentProperty)) { currentProperty = new PathElement(); currentProperty.Name = pathPart; property.Children.Add(currentProperty); propertyDictionary.Add(currentPath, currentProperty); } property = currentProperty; } property.Value = planProperty.Value; } }
// Checks for matches on the path element's connections // public bool TaskFromConnections (PathElement elem, out MatchResult result) { public bool TaskFromConnections(PathElement elem, out PathElement destination, out MatchResult result) { destination = null; result = null; // Convert to point // If conversion fails (because elem is a Connect and no points under construction are connected) then skip GridPoint point = ConnectionToPoint(elem); if (point == null) { return(false); } // If the connected point is under construction, move to it if (point.State == DevelopmentState.UnderConstruction) { destination = point; return(true); } // If there's a connection under construction, begin construction Connection connection = point.Connections.Find(x => x.State == DevelopmentState.UnderConstruction); if (connection == null) { return(false); } return(TaskFromPathElement(connection, out result)); }
public void go(PathElement from, PathElement to) { GD.Print(string.Format("train '{0}' should go from '{1}' to '{2}'", color, from, to)); prepareTrainRoute(from, to); move = true; // GlobalTransform = destination; }
public PathElement(int x1, int y1, float so, PathElement p) { x = x1; y = y1; sofar = so; prev = p; }
protected override void Context() { base.Context(); _columnWithCompound = PathElement.Molecule; _parameterDTO1.PathElements[PathElement.TopContainer] = new PathElementDTO { DisplayName = "Organsim" }; _parameterDTO1.PathElements[PathElement.Container] = new PathElementDTO { DisplayName = "Liver" }; _parameterDTO1.PathElements[_columnWithCompound] = new PathElementDTO { DisplayName = "Drug" }; _parameterDTO2.PathElements[PathElement.TopContainer] = new PathElementDTO { DisplayName = "Organsim" }; _parameterDTO2.PathElements[PathElement.Container] = new PathElementDTO { DisplayName = "Liver" }; _parameterDTO2.PathElements[_columnWithCompound] = new PathElementDTO { DisplayName = "Inhibitor" }; _parameters = new List <IParameter> { _parameter1, _parameter2 }; var simulation = A.Fake <Simulation>(); A.CallTo(() => simulation.CompoundNames).Returns(new[] { "Drug", "Inhibitor" }); A.CallTo(_withIdRepository).WithReturnType <Simulation>().Returns(simulation); }
public PathElement(int x1, int y1, PathElement p) { x = x1; y = y1; sofar = 0.0f; prev = p; }
// Methods public static MovementPath GetClientMovement(List <uint> Keys) { var path = new MovementPath(); PathElement element = null; var num = 0; var num2 = 0; foreach (int num2_loopVariable in Keys) { num2 = num2_loopVariable; var point = new MapPoint(num2 & 4095); var item = new PathElement { Cell = point }; if (num == 0) { path.CellStart = point; } else { element.Orientation = element.Cell.OrientationTo(item.Cell); } if (num == Keys.Count - 1) { path.CellEnd = point; } path.Cells.Add(item); element = item; num += 1; } return(path); }
private IEnumerator UpdateConnection(PathElement newElement) { if (!newElement.Connected) { // Get Connected Elements with their direction and select only the ones that are connected to the start element; var connections = GetConnectedElements(newElement) .Where(element => element.bot.Connected) .Select(element => newElement.Connect(element.Bottom)).ToList(); if (connections.Count == 0) { yield break; } while (connections.Any()) { for (var i = connections.Count - 1; i >= 0; i--) { if (!connections[i].MoveNext()) { connections.RemoveAt(i); } } // Wait a frame yield return(null); } } newElement.Connected = true; GetConnectedElements(newElement).Where(e => !e.bot.Connected) .ForEach(e => StartCoroutine(UpdateConnection(e.bot))); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as CodeFilterComponent; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (PathElement != null) { dest.PathElement = (Hl7.Fhir.Model.FhirString)PathElement.DeepCopy(); } if (SearchParamElement != null) { dest.SearchParamElement = (Hl7.Fhir.Model.FhirString)SearchParamElement.DeepCopy(); } if (ValueSetElement != null) { dest.ValueSetElement = (Hl7.Fhir.Model.Canonical)ValueSetElement.DeepCopy(); } if (Code != null) { dest.Code = new List <Hl7.Fhir.Model.Coding>(Code.DeepCopy()); } return(dest); }
// Method to remove extraneous edges that are not part of the shortest paths private static void RemoveEdgesInCloud(Graph <T> graph, List <T> finalized, Dictionary <T, PathElement <T> > costs) { // Create List to store the adjacent edges of the most-recently finalized vertex List <Edge <T> > adjEdges; // Get the path element related to the most-recently finalized vertex PathElement <T> last = costs[finalized.Last()]; // Get all edges that lead to or come from the last vertex adjEdges = graph.GetIncidentEdges(last.currVertex); // For each edge in the neighboring edges of the last vertex foreach (var e in adjEdges) { // If both vertices of the current edge are finalized if (finalized.Contains(e.EndVertices.start.Element) && finalized.Contains(e.EndVertices.end.Element)) { // If the previous edge of the last vertex is equal to the current edge if (last.inEdge == null || !e.Equals(last.inEdge)) { // Remove the current edge from the graph Logger.WriteLine("Removed Edge: " + e.EndVertices.start.Element + " " + e.EndVertices.end.Element + " " + e.Weight); graph.RemoveEdge(e); } } } }
private ulong GetNextCore(ulong root, PathElement element) { if (element == PathElement.Source) return GetSourceCore(root); if (element == PathElement.Target) return GetTargetCore(root); throw new NotSupportedException(); }
public static Vector3[] FindRoute(Vector3 s, Vector3 e) { PriorityQueue q = new PriorityQueue(); Dictionary<Square, bool> dic = new Dictionary<Square, bool>(); PathElement start = new PathElement(PathGrid.FromReal(s.x), PathGrid.FromReal(s.z), null); PathElement end = new PathElement(PathGrid.FromReal(e.x), PathGrid.FromReal(e.z), null); q.Enqueue(new PriorityElement(DistFromEnd(start, end), start)); //Debug.Log("Calculating for " + start.x + ", " + start.y + " :: " + end.x + ", " + end.y); int tick = 0 ; while(!q.IsEmpty() && tick < 100000) { tick ++; PathElement p = (PathElement)q.Dequeue().stuff; float dist = DistFromEnd(p, end); if(dist < 1.0f) { PathElement cur = p; int size = 1; while(cur != start) { //Debug.Log(cur.x + " " + cur.y); cur = cur.prev; size ++; } cur = p; Vector3[] route = new Vector3[size - 1]; while(cur != start) { route[size - 2] = PathGrid.ToReal(cur.x, cur.y); cur = cur.prev; size --; } //SDebug.Log("START"); return route; } else { AddOptions(q, p, end, dic); } } Debug.Log("Cannot find route!"); Vector3[] route2 = new Vector3[1]; route2[0] = Vector3.zero; return route2; }
private static PathElement GeneratePath(int dx, int dy, float dist, PathElement p, Dictionary<Square, bool> dic) { Square s = new Square(dx + p.x, dy + p.y); if(dic.ContainsKey(s)) { return null; } else { dic.Add(s, true); float difficulty = PathGrid.getGrid(p.x + dx, p.y + dy); if(Mathf.Abs(dx) == 1 && Mathf.Abs(dy) == 1) { difficulty = 0.33f * (difficulty + PathGrid.getGrid(p.x + dx, p.y) + PathGrid.getGrid(p.x, p.y + dy)); } return new PathElement(p.x + dx, p.y + dy, p.sofar + dist + difficulty, p); } }
private static void AddOptions(PriorityQueue q, PathElement p, PathElement end, Dictionary<Square, bool> dic) { PathElement[] next = new PathElement[8]; next[0] = GeneratePath(1, 0, 1.0f , p, dic); next[1] = GeneratePath(0, 1, 1.0f, p, dic); next[2] = GeneratePath(-1, 0, 1.0f, p, dic); next[3] = GeneratePath(0, -1, 1.0f, p, dic); next[4] = GeneratePath(1, 1, 1.4f, p, dic); next[5] = GeneratePath(-1, -1, 1.4f, p, dic); next[6] = GeneratePath(-1, 1, 1.4f, p, dic); next[7] = GeneratePath(1, -1, 1.4f, p, dic); for(int loop = 0; loop < 8; loop++) { if(next[loop] != null) q.Enqueue(new PriorityElement(next[loop].sofar + Random.value * 0.5f + DistFromEnd(next[loop], end), next[loop])); } }
/// <summary> /// Appends or updates the last <see cref="PathElement"/> of <see cref="DynamicPath"/> /// and handles errors or warning. /// </summary> /// <param name="data">Log data. Never null.</param> protected override void OnUnfilteredLog( ActivityMonitorLogData data ) { if( data.Text != ActivityMonitor.ParkLevel ) { if( _currentIsGroupClosed ) HandleCurrentGroupIsClosed(); if( _currentIsGroup || _current == null ) { _current = new PathElement(); _path.Add( _current ); _currentIsGroup = false; } _current.Tags = data.Tags; _current.MaskedLevel = data.Level&LogLevel.Mask; _current.Text = data.Text; CheckSnapshot(); } }
/// <summary> /// Removes one or two last <see cref="PathElement"/> of <see cref="DynamicPath"/>. /// </summary> /// <param name="group">The closed group.</param> /// <param name="conclusions">Texts that conclude the group. Never null but can be empty.</param> protected override void OnGroupClosed( IActivityLogGroup group, IReadOnlyList<ActivityLogGroupConclusion> conclusions ) { if( _currentIsGroupClosed ) HandleCurrentGroupIsClosed(); if( _path.Count > 0 ) { if( !_currentIsGroup ) _path.RemoveAt( _path.Count - 1 ); _currentIsGroupClosed = false; _current = null; if( _path.Count > 0 ) { _current = _path[_path.Count - 1]; _current.GroupConclusion = conclusions; _currentIsGroup = true; _currentIsGroupClosed = _path.Count > 0; } else _currentIsGroup = false; } }
private static float DistFromEnd(PathElement p, PathElement end) { return Vector2.Distance(new Vector2(p.x, p.y), new Vector2(end.x, end.y)); }
void HandleCurrentGroupIsClosed() { Debug.Assert( _currentIsGroupClosed && _path.Count > 0 ); _current = null; _path.RemoveAt( _path.Count - 1 ); if( _path.Count > 0 ) _current = _path[_path.Count - 1]; _currentIsGroup = _current != null; _currentIsGroupClosed = false; }
public void MovementPathFromArray(MapPoint[] squares) { PathElement path = null; for (var i = 0; i <= squares.Length - 2; i++) { path = new PathElement(); path.Cell = squares[i]; path.Orientation = squares[i].OrientationTo(squares[i + 1]); this.MovPath.Cells.Add(path); } this.MovPath.Compress(); }
public PriorityElement(float p, PathElement s) { priority = p; stuff = s; }
public PathElementPropertyDescriptor(PathElement pathElement) : base(pathElement.Name, new Attribute[0]) { _pathElement = pathElement; }
/// <summary> /// Appends or updates the last <see cref="PathElement"/> of <see cref="DynamicPath"/> /// and handles errors or warning. /// </summary> /// <param name="group">The newly opened <see cref="IActivityLogGroup"/>.</param> protected override void OnOpenGroup( IActivityLogGroup group ) { if( _currentIsGroupClosed ) HandleCurrentGroupIsClosed(); if( _currentIsGroup || _current == null ) { _current = new PathElement(); _path.Add( _current ); } _currentIsGroup = true; _current.Tags = group.GroupTags; _current.MaskedLevel = group.MaskedGroupLevel; _current.Text = group.GroupText; CheckSnapshot(); }
private MovementPath method_3(SimpleCellInfo class13_0) { List<MapPoint> range = new List<MapPoint>(); SimpleCellInfo class2 = class13_0; while (class2.v_OriginPoint.CellId != this.MapPoint_FromCell.CellId) { class2 = class2.class13_0; range.Add(class2.v_OriginPoint); } range.Reverse(); range.Add(class13_0.v_OriginPoint); if (this.v_MouvementPoints != -1) { range = range.GetRange(0, (((this.v_MouvementPoints + 1) > range.Count) ? range.Count : (this.v_MouvementPoints + 1))); } MovementPath path = new MovementPath { CellStart = this.MapPoint_FromCell, CellEnd = range[(range.Count - 1)] }; int num = (range.Count - 2); int i = 0; while (i <= num) { PathElement item = new PathElement { Cell = range[i], Orientation = range[i].OrientationTo(range[(i + 1)]) }; path.Cells.Add(item); i += 1; } path.Compress(); return path; }
/// <summary> /// Appends or updates the last <see cref="PathElement"/> of <see cref="DynamicPath"/> /// and handles errors or warning. /// </summary> /// <param name="level">Log level.</param> /// <param name="text">Text (not null).</param> protected override void OnUnfilteredLog( LogLevel level, string text ) { if( text != ActivityLogger.ParkLevel ) { if( _currentIsGroupClosed ) HandleCurrentGroupIsClosed(); if( _currentIsGroup || _current == null ) { _current = new PathElement(); _path.Add( _current ); _currentIsGroup = false; } _current.Level = level; _current.Text = text; CheckSnapshot(); } }