Esempio n. 1
0
File: Node.cs Progetto: dzamkov/DUIP
 public _NodeInputContext(Node Node, Context Parent)
 {
     this._Node = Node;
     this._Parent = Parent;
 }
Esempio n. 2
0
File: Node.cs Progetto: dzamkov/DUIP
 public _NodeProbe(Node Node, Probe Source)
     : base(Source)
 {
     this._Node = Node;
 }
Esempio n. 3
0
File: Node.cs Progetto: dzamkov/DUIP
        /// <summary>
        /// Performs a collision response for two nodes.
        /// </summary>
        public static void CollisionResponse(Node A, Node B)
        {
            const double res = 0.9;
            const double fri = 0.1;
            const double pus = 0.4;
            Point asize = A.Size;
            Point bsize = B.Size;
            Point tsize = asize + bsize;

            Point acenter = A._Position + asize * 0.5;
            Point bcenter = B._Position + bsize * 0.5;

            Point diff = bcenter - acenter;
            Point pen = tsize * 0.5 - new Point(Math.Abs(diff.X), Math.Abs(diff.Y));
            Point vdiff = B._Velocity - A._Velocity;

            if (pen.X > 0.0 && pen.Y > 0.0)
            {
                if (pen.X < pen.Y)
                {
                    if (diff.X > 0.0)
                    {
                        A._Position -= new Point(pen.X * 0.5, 0.0);
                        B._Position += new Point(pen.X * 0.5, 0.0);
                    }
                    else
                    {
                        A._Position += new Point(pen.X * 0.5, 0.0);
                        B._Position -= new Point(pen.X * 0.5, 0.0);
                    }
                    A._Velocity += new Point(vdiff.X * res, vdiff.Y * fri - diff.Y * Math.Abs(vdiff.X) * pus);
                    B._Velocity -= new Point(vdiff.X * res, vdiff.Y * fri - diff.Y * Math.Abs(vdiff.X) * pus);
                }
                else
                {
                    if (diff.Y > 0.0)
                    {
                        A._Position -= new Point(0.0, pen.Y * 0.5);
                        B._Position += new Point(0.0, pen.Y * 0.5);
                    }
                    else
                    {
                        A._Position += new Point(0.0, pen.Y * 0.5);
                        B._Position -= new Point(0.0, pen.Y * 0.5);
                    }
                    A._Velocity += new Point(vdiff.X * fri - diff.X * Math.Abs(vdiff.Y) * pus, vdiff.Y * res);
                    B._Velocity -= new Point(vdiff.X * fri - diff.X * Math.Abs(vdiff.Y) * pus, vdiff.Y * res);
                }
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Places the given node into the world, displacing other nodes as needed.
 /// </summary>
 public void Spawn(Node Node)
 {
     this._Nodes.Add(Node);
 }
Esempio n. 5
0
 /// <summary>
 /// Spawns a node for the given content near or at the given location.
 /// </summary>
 public Node Spawn(Disposable<Content> Content, Point Location)
 {
     Point size;
     Block block = Content.Object.CreateBlock(this._Theme);
     Layout layout = block.CreateLayout(null, Node.SizeRange, out size);
     Node node = new Node(this._InputContext, Content, block, layout, size, Location - size * 0.5, Point.Zero);
     this.Spawn(node);
     return node;
 }
Esempio n. 6
0
 /// <summary>
 /// Despawns a node, removing it from the world.
 /// </summary>
 public void Despawn(Node Node)
 {
     this._Nodes.Remove(Node);
 }
Esempio n. 7
0
File: Arc.cs Progetto: dzamkov/DUIP
 public EndPoint(Node Node, Direction Edge, double Offset)
 {
     this.Node = Node;
     this.Edge = Edge;
     this.Offset = Offset;
 }