コード例 #1
0
        protected override void Awake()
        {
            base.Awake();
            InConnectors.AddRange(Enumerable.Repeat <SPConnector>(null, 1));
            OutConnectors.AddRange(Enumerable.Repeat <SPConnector>(null, 2));

            // Set up connectors
            InConnector = Instantiate(SPInConnectorPrefab, gameObject.transform, false);
            Assert.IsNotNull(InConnector);
            InConnector.gameObject.name         = "InConnector";
            InConnector.transform.localPosition = new Vector3(-1, 0, -1);
            InConnector.Register(this, SPConnectorType.SPInConnector, 0);

            OutConnectorTop = Instantiate(SPOutConnectorPrefab, gameObject.transform, false);
            Assert.IsNotNull(OutConnectorTop);
            OutConnectorTop.gameObject.name         = "OutConnectorTop";
            OutConnectorTop.transform.localPosition = new Vector3(1, 1, -1);
            OutConnectorTop.Register(this, SPConnectorType.SPOutConnector, 0);

            OutConnectorBottom = Instantiate(SPOutConnectorPrefab, gameObject.transform, false);
            Assert.IsNotNull(OutConnectorBottom);
            OutConnectorBottom.gameObject.name         = "OutConnectorBottom";
            OutConnectorBottom.transform.localPosition = new Vector3(1, -1, -1);
            OutConnectorBottom.Register(this, SPConnectorType.SPOutConnector, 1);

            LogicComponent = new Splitter();
            Canvas.Circuit.AddComponent(LogicComponent);
        }
コード例 #2
0
        protected override void Awake()
        {
            base.Awake();
            Debug.Log("In numbered output awake");
            InConnectors.AddRange(Enumerable.Repeat <SPConnector>(null, 1));

            // Set up connector
            InConnector = Instantiate(SPInConnectorPrefab, gameObject.transform, false);
            Assert.IsNotNull(InConnector);
            InConnector.gameObject.name         = "InConnector";
            InConnector.transform.localPosition = new Vector3(-1, 0, -1);
            InConnector.Register(this, SPConnectorType.SPInConnector, 0);

            LogicComponent = new Output();
            try
            {
                this.id = Canvas.AddNumberedComponent(this);
            }
            catch (NoMoreIdsException)
            {
                // Failed to add this component as a numbered component.
                // Just leave its id as 0.
                this.id = 0;
                Canvas.Circuit.AddComponent(LogicComponent);
            }
        }
コード例 #3
0
        protected override void Awake()
        {
            base.Awake();
            OutConnectors.AddRange(Enumerable.Repeat <SPConnector>(null, 1));

            // Set up renderer
            SpriteRenderer     = gameObject.GetComponent <SpriteRenderer>();
            CurrentSpriteIndex = 0;

            // Set up connectors
            OutConnector = Instantiate(SPOutConnectorPrefab, gameObject.transform, false);
            Assert.IsNotNull(OutConnector);
            OutConnector.gameObject.name         = "OutConnector";
            OutConnector.transform.localPosition = new Vector3(1, 0, -1);
            OutConnector.Register(this, SPConnectorType.SPOutConnector, 0);

            MessageBoxFactory = new UIMessageBoxFactory();

            // Load the message box config for save ciruit
            TextAsset configAsset = Resources.Load <TextAsset>(CLOCK_MESSAGE_BOX_CONFIG_RESOURCE);

            Assert.IsNotNull(configAsset);
            ClockMessageBoxConfig = JsonUtility.FromJson <MessageBoxConfig>(configAsset.text);

            LogicComponent = new Clock(DEFAULT_CLOCK_RATE);
            Canvas.Circuit.AddComponent(LogicComponent);

            Assert.AreEqual(CLOCK_SPRITES_COUNT, UnselectedClockSprites.Count);
            Assert.AreEqual(CLOCK_SPRITES_COUNT, SelectedClockSprites.Count);
        }
コード例 #4
0
        public void AddStartingConnector(SPConnector connector)
        {
            Assert.IsFalse(Finalised);
            Assert.IsNull(AnchorConnector);

            Assert.IsNotNull(connector);

            AnchorConnector = connector;
        }
コード例 #5
0
        public void AddFinishingConnector(SPConnector connector)
        {
            Assert.IsFalse(Finalised);
            Assert.IsNotNull(AnchorConnector);

            Assert.IsNotNull(connector);

            if (AnchorConnector.ConnectorType == connector.ConnectorType)
            {
                // Can't join connectors of the same type (must be in-to-out or out-to-in)
                throw new ArgumentException();
            }
            if (connector.ConnectedEdge != null)
            {
                throw new ArgumentException();
            }

            if (AnchorConnector.ConnectorType == SPConnectorType.SPInConnector)
            {
                OutConnector = (SPOutConnector)connector;
                InConnector  = (SPInConnector)AnchorConnector;
            }
            else
            {
                OutConnector = (SPOutConnector)AnchorConnector;
                InConnector  = (SPInConnector)connector;
            }

            // Register edge with connector endpoints
            OutConnector.ConnectedEdge = this;
            InConnector.ConnectedEdge  = this;

            var outConnectorComponent = OutConnector.ParentComponent;
            var inConnectorComponent  = InConnector.ParentComponent;

            Assert.IsNotNull(outConnectorComponent);
            Assert.IsNotNull(inConnectorComponent);

            // Update backend
            BackendConnection = new Connection();
            Canvas.Circuit.AddComponent(BackendConnection);
            Canvas.Circuit.Connect(
                outConnectorComponent.LogicComponent, OutConnector.ConnectorId,
                BackendConnection, 0);
            Canvas.Circuit.Connect(
                BackendConnection, 0,
                inConnectorComponent.LogicComponent, InConnector.ConnectorId);

            // Update canvas
            Canvas.Edges.Add(this);

            AnchorConnector = null;
        }
コード例 #6
0
        protected override void Awake()
        {
            base.Awake();
            InConnectors.AddRange(Enumerable.Repeat <SPConnector>(null, 1));

            // Set up connector
            InConnector = Instantiate(SPInConnectorPrefab, gameObject.transform, false);
            Assert.IsNotNull(InConnector);
            InConnector.gameObject.name         = "InConnector";
            InConnector.transform.localPosition = new Vector3(-1, 0, -1);
            InConnector.Register(this, SPConnectorType.SPInConnector, 0);

            LogicComponent = new Output();
            Canvas.Circuit.AddComponent(LogicComponent);

            spriteRenderer = gameObject.GetComponent <SpriteRenderer>();
        }
コード例 #7
0
 public void StartEdge(SPConnector connector)
 {
     CurrentEdge = Instantiate(SPEdgePrefab, Foreground.transform);
     Assert.IsNotNull(CurrentEdge);
     CurrentEdge.AddStartingConnector(connector);
 }
コード例 #8
0
 public void FinishEdge(SPConnector connector)
 {
     // this may throw ArgumentException, let SPConnector.OnPointerClick handle that
     CurrentEdge.AddFinishingConnector(connector);
     CurrentEdge = null;
 }