public void AddLowestFloor(Game Game) { if (Game.CanBuild(Data.StairsAddFloorCost, Left, Width, Floor - 1.0f, 1.0f) == true) { Floor -= 1.0; Height += 1.0; Game.UpdateBuilding(Data.StairsAddFloorCost, this); var NewNode = new Node(Left + Width / 2.0, Floor.GetNearestInt32()); Node LowestFloorNode = null; foreach (var Node in _TransportationNodes) { if ((LowestFloorNode == null) || (Node.Floor < LowestFloorNode.Floor)) { LowestFloorNode = Node; } } Debug.Assert(LowestFloorNode != null); Edge.AddEdge(LowestFloorNode, NewNode, Data.StairsWeightDownwards, _CreateUseStairsGoal, _CreateTravelActionUseStairs); Edge.AddEdge(NewNode, LowestFloorNode, Data.StairsWeightUpwards, _CreateUseStairsGoal, _CreateTravelActionUseStairs); _TransportationNodes.Add(NewNode); Game.Transportation.AddNode(NewNode); } }
public void SelectAllInBaseEdge() { TurnOffSelectedItemsUpdate = true; IVertex selectedEdges = Vertex.Get("SelectedEdges:"); if (selectedEdges is VertexBase) { ((VertexBase)selectedEdges).CanFireChangeEvent = false; } foreach (IEdge ee in Vertex.Get(@"BaseEdge:\To:")) { Edge.AddEdge(selectedEdges, ee); } if (selectedEdges is VertexBase) { ((VertexBase)selectedEdges).CanFireChangeEvent = true; } TurnOffSelectedItemsUpdate = false; foreach (TreeViewItem i in Items) { if (i is TreeVisualiserViewItem) { TreeVisualiserViewItem ii = (TreeVisualiserViewItem)i; ii.IsSelected = true; } } }
public void UpdateTransportation(Game Game) { Node LowerNode = null; for (var FloorCurrent = Floor.GetNearestInt32(); FloorCurrent < (Floor + Height).GetNearestInt32(); ++FloorCurrent) { var NewNode = new Node(Left + Width / 2.0, FloorCurrent); if (LowerNode != null) { Edge.AddEdge(LowerNode, NewNode, Data.StairsWeightUpwards, _CreateUseStairsGoal, _CreateTravelActionUseStairs); Edge.AddEdge(NewNode, LowerNode, Data.StairsWeightDownwards, _CreateUseStairsGoal, _CreateTravelActionUseStairs); } _TransportationNodes.Add(NewNode); Game.Transportation.AddNode(NewNode); LowerNode = NewNode; } }
public void UpdateSelectedVertexes(bool IsCtrl, TreeVisualiserViewItem item) { if (TurnOffSelectedVertexesUpdate) { return; } TurnOffSelectedItemsUpdate = true; IVertex sv = Vertex.Get("SelectedEdges:"); IEdge e = (IEdge)item.Tag; if (!IsCtrl) { GraphUtil.RemoveAllEdges(sv); } if (item.IsSelected) { Edge.AddEdge(sv, e); } else { Edge.DeleteVertexByEdgeOnlyToVertex(sv, e); } // LEGACY // // currently there is no support for same vertex in two places in tree begin selected / unselected // this is due to performance // /*IVertex sv = Vertex.Get("SelectedVertexes:"); * * GraphUtil.RemoveAllEdges(sv); * * foreach (TreeViewItem i in Items) * UpdateSelectedVertexes_Reccurent(i, sv); */ TurnOffSelectedItemsUpdate = false; }
protected void _OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if (!TurnOffSelectedVertexesUpdate) { TurnOffSelectedItemsUpdate = true; IVertex sv = Vertex.Get("SelectedEdges:"); UnselectAllSelectedEdges(); IVertex baseVertex = Vertex.Get(@"BaseEdge:\To:"); foreach (IEdge ee in ThisDataGrid.SelectedItems) { Edge.AddEdge(sv, baseVertex, ee.Meta, ee.To); // becouse of possible FilterQuery } // Edge.AddEdge(sv, ee); TurnOffSelectedItemsUpdate = false; } }
public void BuildEdge(int v1, int v2) { Vertex n1 = null, n2 = null; Vertex temp = Vfirst; while (temp != null) { int i = Decimal.Compare(v1, temp.Name); if (i == 0) { //found 1st node.. n1 = temp; break; } else { temp = temp.Next; } } //check if edge already exists for (int i = 0; i < n1.Num_Edges; i++) { int j = Decimal.Compare(v2, n1.Adjacent[i].Name); if (j == 0) { return; } } temp = Vfirst; while (temp != null) { int i = Decimal.Compare(v2, temp.Name); if (i == 0) { //found 2nd node.. n2 = temp; break; } else { temp = temp.Next; } } n1.Adjacent[n1.Num_Edges++] = n2; Edge temp2; try { temp2 = new Edge(n1, n2); }catch (Exception e) { Console.WriteLine("Caught: {0}", e); return; } if (Efirst == null) { Efirst = temp2; Elast = temp2; } else { temp2.AddEdge(Elast, temp2); Elast = temp2; } }
public void AddToSelectedEdges() { Edge.AddEdge(Diagram.Vertex.Get("SelectedEdges:"), Vertex.Get("BaseEdge:")); }
public void BuildEdge(int v1,int v2) { Vertex n1 = null,n2 = null; Vertex temp = Vfirst; while(temp != null) { int i = Decimal.Compare(v1,temp.Name); if(i==0) { //found 1st node.. n1 = temp; break; } else temp = temp.Next; } //check if edge already exists for(int i=0;i<n1.Num_Edges;i++) { int j = Decimal.Compare(v2,n1.Adjacent[i].Name); if(j==0) return; } temp = Vfirst; while(temp != null) { int i = Decimal.Compare(v2,temp.Name); if(i==0) { //found 2nd node.. n2 = temp; break; } else temp = temp.Next; } n1.Adjacent[n1.Num_Edges++]=n2; Edge temp2; try { temp2 = new Edge(n1,n2); }catch(Exception e) { Console.WriteLine("Caught: {0}",e); return; } if(Efirst==null) { Efirst = temp2; Elast = temp2; } else { temp2.AddEdge(Elast,temp2); Elast = temp2; } }