Пример #1
0
        public EditorCircuitActor(EditorLevel level, XElement data)
            : base(level, data)
        {
            _circuit     = level.controller.editorController.circuitController.getCircuit(data.Attribute("circuit_uid").Value);
            _position    = Loader.loadVector2(data.Attribute("position"), Vector2.Zero);
            _connections = new List <CircuitConnection>();
            foreach (XElement connectionData in data.Elements("CircuitConnection"))
            {
                EditorActor actor          = level.getActor(int.Parse(connectionData.Attribute("actor_id").Value));
                Gate        gate           = _circuit.getGate(int.Parse(connectionData.Attribute("gate_id").Value));
                string      connectionType = connectionData.Attribute("type").Value;

                if (connectionType == "input")
                {
                    GameEventType listenToEvent = (GameEventType)Loader.loadEnum(typeof(GameEventType), connectionData.Attribute("listen_to_event"), 0);
                    _connections.Add(new CircuitInputConnection(this, actor, gate, listenToEvent));
                }
                else if (connectionType == "output")
                {
                    GameEventType onEnabledEvent  = (GameEventType)Loader.loadEnum(typeof(GameEventType), connectionData.Attribute("on_enabled_event"), 0);
                    GameEventType onDisabledEvent = (GameEventType)Loader.loadEnum(typeof(GameEventType), connectionData.Attribute("on_disabled_event"), 0);
                    _connections.Add(new CircuitOutputConnection(this, actor, gate, onEnabledEvent, onDisabledEvent));
                }
            }
            initializeGateControls();
        }
Пример #2
0
 public EditorCircuitActor(EditorLevel level, string circuitUID)
     : base(level, ActorType.Circuit, level.controller.getUnusedActorID())
 {
     _circuit     = level.controller.editorController.circuitController.getCircuit(circuitUID);
     _position    = _level.controller.worldMouse;
     _connections = new List <CircuitConnection>();
     _layerDepth  = 0.1f;
     initializeGateControls();
     selectAllGateControls();
 }
Пример #3
0
 // selectCircuit
 public void selectCircuit(EditorCircuit circuit)
 {
     circuitsList.SelectedIndex = _controller.circuits.IndexOf(circuit);
 }
Пример #4
0
 // Create circuit button clicked
 private void circuitCreateButton_Click(object sender, EventArgs e)
 {
     CreateResourceView resourceView = new CreateResourceView();
     if (resourceView.ShowDialog() == DialogResult.OK)
     {
         EditorCircuit circuit = new EditorCircuit(resourceView.uid);
         _controller.circuits.Add(circuit);
         selectCircuit(circuit);
     }
 }