private GraphicInstance CreateGraphicVisualizedInstance(Type type, LogicalInstance logicalInstance, DragEventArgs args) { Point position = args.GetPosition(this); double width = (double)type.GetProperty("Width").GetValue(Activator.CreateInstance(type), null); double height = (double)type.GetProperty("Height").GetValue(Activator.CreateInstance(type), null); GraphicInstance graphicInstance = null; if (type.IsSubclassOf(typeof(NodeType))) { ParentableInstance parent = (this.Content as CanvasItemsControl).FindParent(position, graphicInstance); graphicInstance = new NodeInstance { X = position.X, Y = position.Y, Width = (width != 0 && !double.IsNaN(width)) ? width : 200, Height = (height != 0 && !double.IsNaN(height)) ? height : 200, LogicalInstance = logicalInstance, Parent = parent }; } else { graphicInstance = new EdgeInstance { X = position.X, Y = position.Y, Width = (width != 0 && !double.IsNaN(width)) ? width : 200, Height = (height != 0 && !double.IsNaN(height)) ? height : 200, LogicalInstance = logicalInstance, Parent = InstancesManager.Instance.CanvasRootElement }; } return(graphicInstance); }
public void LoadLevel() { stageList = new List <StageInstance> (); edgeList = new List <EdgeInstance> (); levelManager.Init(); //levelManager.CreateLevel(); levelManager.CreateLevel2(); Vector3 startpos = new Vector3(0, 0, 0); List <LevelNode> nodes = levelManager.LevelNodes; List <LevelEdge> edges = levelManager.LevelEdges; for (int i = 0; i < nodes.Count; i++) { StageInstance stage = new StageInstance(); startpos = stage.Load(nodes[i], 1, i, startpos); stageList.Add(stage); if (i != nodes.Count - 1) { EdgeInstance edge = new EdgeInstance(); startpos = edge.Load(edges[i], 1, startpos); edgeList.Add(edge); } } /*List<LevelEdge> edges=levelManager.LevelEdges; * for (int i = 0; i < edges.Count; i++) { * EdgeInstance edge=new EdgeInstance (); * startpos=edge.Load (edges[i],1,startpos); * edgeList.Add (edge); * }*/ EnterState(0); }
void OnTriggerExit(Collider other) { if (powerSwitches.Remove(other.gameObject)) { EdgeInstance.DisableShader(other.gameObject); EdgeInstance.DestroyShader(other.gameObject); } }
private void Update() { foreach (GameObject ps in powerSwitches) { if (ps != null) { if (IsBlocked(ps)) { EdgeInstance.DisableShader(ps); } else { EdgeInstance.TurnOnShader(ps); } } } }
public void addChildEdge(EdgeInstance edgeInstance) { m_childEdges.Add(edgeInstance); }
public void addParentEdge(EdgeInstance edgeInstance) { m_parentEdges.Add(edgeInstance); }
private void CanvasDDTargetMouseMove(object sender, MouseEventArgs e) { double rightBound = 0; double leftBound = double.PositiveInfinity; double bottomBound = 0; double topBound = double.PositiveInfinity; foreach (var item in (this.Content as CanvasItemsControl).Items) { if (item is NodeInstance) { NodeInstance nodeInstance = item as NodeInstance; rightBound = Math.Max(rightBound, nodeInstance.X + nodeInstance.Width + 10); leftBound = Math.Min(leftBound, nodeInstance.X - 10); topBound = Math.Min(topBound, nodeInstance.Y - 10); bottomBound = Math.Max(bottomBound, nodeInstance.Y + nodeInstance.Height + 10); } else if (item is EdgeInstance) { EdgeInstance edgeInstance = item as EdgeInstance; rightBound = Math.Max(rightBound, edgeInstance.X + edgeInstance.Width + 10); leftBound = Math.Min(leftBound, edgeInstance.X - 10); topBound = Math.Min(topBound, edgeInstance.Y - 10); bottomBound = Math.Max(bottomBound, edgeInstance.Y + edgeInstance.Height + 10); } } if (rightBound > this.Width) { this.Width = rightBound; } if (bottomBound > this.Height) { this.Height = bottomBound; } if (leftBound < 0) { foreach (var item in (this.Content as CanvasItemsControl).Items) { if (item is NodeInstance) { (item as NodeInstance).X -= leftBound; } else if (item is EdgeInstance) { (item as EdgeInstance).X -= leftBound; } } } if (topBound < 0) { foreach (var item in (this.Content as CanvasItemsControl).Items) { if (item is NodeInstance) { (item as NodeInstance).Y -= topBound; } else if (item is EdgeInstance) { (item as EdgeInstance).Y -= topBound; } } } }