Exemplo n.º 1
0
        protected override void Run(string[] args)
        {
            var c     = new Conduit();
            var clay1 = new RClay();
            var clay2 = new RClay();
            var clay3 = new RClay();

            c.Link(new LinkDef[] {
                new LinkDef(clay1, "A"),
                new LinkDef(clay2, "B"),
                new LinkDef(clay3, "C")
            });

            c.Link(new LinkDef[] {
                new LinkDef(clay1, "A")
            });

            Assert(c._contacts.Count == 3, "Should have 3 connections");

            Assert(clay1._contacts["A"] == c, "Clay1 should have 1 connection with c");

            Assert(clay2._contacts["B"] == c, "Clay2 should have 1 connection with c");

            var test1 = c._contacts.FirstOrDefault(x => x.Clay == clay1 && x.ConnectPoint.Equals("A"));

            Assert(test1 != null, "Conduit supposed to have clay1 at point A");

            var test2 = c._contacts.FirstOrDefault(x => x.Clay == clay2 && x.ConnectPoint.Equals("B"));

            Assert(test2 != null, "Conduit supposed to have clay1 at point B");

            var test3 = c._contacts.FirstOrDefault(x => x.Clay == clay3 && x.ConnectPoint.Equals("C"));

            Assert(test3 != null, "Conduit supposed to have clay1 at point C");

            var testx = c._contacts.FirstOrDefault(x => x.Clay == clay2 && x.ConnectPoint.Equals("A"));

            Assert(testx == null, "Clay2 should not have point A in Conduit");


            c.Disconnect(clay2, "C");
            testx = c._contacts.FirstOrDefault(x => x.Clay == clay2 && x.ConnectPoint.Equals("B"));
            Assert(testx != null, "Clay2 should not be disconnected");

            c.Disconnect(clay2, "B");
            testx = c._contacts.FirstOrDefault(x => x.Clay == clay2 && x.ConnectPoint.Equals("B"));
            Assert(testx == null, "Clay2 should be disconnected");
        }
Exemplo n.º 2
0
    //public static Bounds GetActiveConduitBounds()
    //{
    //    return m_activeConduit.mesh.bounds;
    //}

    public static void LinkActiveConduit(Bend bend)
    {
        Debug.Log("ConduitManager: LinkActiveConduit()");
        // Remove any current Decorator component objects from Active Conduit
        AConduitDecorator decorator = m_activeConduit.GetComponentInChildren <AConduitDecorator>();

        if (decorator != null)
        {
            decorator.OnRemove();
            //Destroy( decorator.gameObject );
            m_activeConduit.transform.DestroyChildren();
        }

        m_activeConduit.Link(bend);

        // Set Decorator (if available)
        decorator = ConduitDecoratorFactory.Get(bend.type);
        if (decorator != null)
        {
            m_activeDecorator = Instantiate(decorator);
            m_activeDecorator.transform.SetParent(m_activeConduit.transform, false);
            m_activeDecorator.transform.localPosition = Vector3.zero; // @TODO - Redundant?
            m_activeDecorator.Set(m_activeConduit);
        }
        else
        {
            m_activeDecorator = null;
        }
    }
Exemplo n.º 3
0
        protected override void Run(string[] args)
        {
            AutoResetEvent waiter = new AutoResetEvent(false);
            int            data   = 0;
            var            clay1  = new RClay(new RAgreement
            {
                SensorPoints = new List <object> {
                    "IN"
                },
                Response = (center, clay, cp) =>
                {
                    center["OUT"] = (center.GetSignal <int>("IN") + 1);
                }
            });

            var clay2 = new RClay(new RAgreement
            {
                SensorPoints = new List <object> {
                    "IN"
                },
                Response = (center, clay, cp) =>
                {
                    center["OUT"] = (center.GetSignal <int>("IN") * 2);
                }
            });


            var clay3 = new RClay(new RAgreement
            {
                SensorPoints = new List <object> {
                    "A", "B"
                },
                Response = (center, clay, cp) =>
                {
                    data = center.GetSignal <int>("A") + center.GetSignal <int>("B");
                    waiter.Set();
                }
            });

            var start = new Starter();

            var con1 = Conduit.CreateLink(new LinkDef(clay1, "IN"), new LinkDef(clay2, "IN"));
            var con2 = new Conduit();

            con2.Link(new LinkDef(start, "OUT"));

            con1.Link(new LinkDef(con2, "X"));

            Conduit.CreateLink(new LinkDef(clay1, "OUT"), new LinkDef(clay3, "A"));
            Conduit.CreateLink(new LinkDef(clay2, "OUT"), new LinkDef(clay3, "B"));

            start.Test(3);

            waiter.WaitOne();
            Assert(data == 10, "Data supposed to be");
        }