/// <summary>
 /// Fill out all the information stored and disable unnessercary code.
 /// </summary>
 void Awake()
 {
     if (FindObjectsOfType(GetType()).Length > 1)
     {
         Destroy(gameObject);
     }
     if (steamManager == null)
     {
         steamManager = GameObject.Find("SteamManager");
     }
     if (issteamversion == false)
     {
         Debug.Log("setupoculus");
         if (steamManager)
         {
             steamManager.SetActive(false);
         }
     }
     FleetBuilder = IORoot.findIO("fleet1");
     FleetBuilder.read();
     crosslevelholder           = GameObject.Find("MainMenuHolder").GetComponent <MainMenuValueHolder>();
     steamManager               = GameObject.Find("SteamManager");
     stkman                     = GetComponent <VRTK_SDKManager>();
     stkman.LoadedSetupChanged += new VRTK_SDKManager.LoadedSetupChangeEventHandler(Load);
     if (FleetBuilder.get <bool>("LeftMode"))
     {
         GameObject lefthand = stkman.scriptAliasLeftController;
         stkman.scriptAliasLeftController  = stkman.scriptAliasRightController;
         stkman.scriptAliasRightController = lefthand;
         FleetBuilder.read();
     }
 }
 /// <summary>
 /// gets the current player progress through the levels.
 /// </summary>
 void GetCompleted()
 {
     FleetBuilder = IORoot.findIO("fleet1");
     FleetBuilder.read();
     completedthrough = FleetBuilder.get <int>("Completednum");
     Debug.Log(completedthrough);
 }
Esempio n. 3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override async void LoadContent()
        {
            base.LoadContent();

            IO      = new IOComponent(this);
            Plugins = new PluginComponent(this);
            Network = new NetworkManager(this);

            await IO.Init();

            await IO.LoadConfig();

            await Network.Init();

            Content       = new ContentManager();
            TextureLoader = new TextureLoader(Graphics.GraphicsDevice);
            Content.LoadTextures(Path.Combine(IO.Directories["Content"], "Textures"), this);

            if (IO.Config.Client.Resolution.X == 0 && IO.Config.Client.Resolution.Y == 0)
            {
                Graphics.PreferredBackBufferWidth  = (int)(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width * .9);
                Graphics.PreferredBackBufferHeight =
                    (int)(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height * .8);
                Graphics.ApplyChanges();
                base.Window.Position =
                    new Point(
                        (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width - Graphics.PreferredBackBufferWidth) /
                        2,
                        (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height - Graphics.PreferredBackBufferHeight) /
                        2);
            }
            else
            {
                Graphics.PreferredBackBufferWidth  = IO.Config.Client.Resolution.X;
                Graphics.PreferredBackBufferHeight = IO.Config.Client.Resolution.Y;
                Graphics.ApplyChanges();
            }

            // Initialize MonoForce after loading skins.
            UI.Initialize();
            SpriteBatch = UI.Renderer.SpriteBatch; // Set the spritebatch to the Neoforce managed one


            // Create the main window for all content to be added to.
            Window = new MainWindow(UI, this);
            Window.Init();
            UI.Add(Window);
            Window.SendToBack();

            // Unlike the server, the clientside plugins must be loaded last.
            await Plugins.Init();

            // Now that all the textures have been loaded, set the block textures
            foreach (var block in BlockType.Blocks.Where(x => x.IsRenderable))
            {
                var str = "blocks." + (block.Category != null ? block.Category + "." : string.Empty) + block.Name;
                block.Texture = Content[str];
            }
        }
 /// <summary>
 /// initialise everything.
 /// </summary>
 void Start()
 {
     FleetBuilder = IORoot.findIO("fleet1");
     FleetBuilder.read();
     currentdisplaytext = currentdisplay.GetComponent <TextMesh>();
     retrievesetting();
     leftmode           = retrievelefthandmode();
     leftbuttontexttext = leftbuttontext.GetComponent <TextMesh>();
     leftdisplaytextext = leftdisplaytext.GetComponent <TextMesh>();
 }
Esempio n. 5
0
        void Update()
        {
            Vector3 heading   = target.transform.position - transform.position;
            float   distance  = heading.magnitude;
            var     direction = heading / distance;

            Debug.DrawRay(transform.position, direction);

            if (distance >= 0.000005 + 10)
            {
                IOComponent.TriggerInputRaw(direction);
            }
        }
 void Start()
 {
     if (PhotonNetwork.connectedAndReady)
     {
         crosslevelholder = GameObject.Find("CrossLevelVariables").GetComponent <CrossLevelVariableHolder>();
     }
     OnActive();
     // Get the game controller
     _gc          = GameObject.FindObjectOfType <GameController>();
     simObject    = this.GetComponent <DFNetwork.Simulation.SimulationLayer>();
     FleetBuilder = IORoot.findIO("fleet1");
     FleetBuilder.read();
 }
 // Use this for initialization
 void Start()
 {
     // ShipList.Add(new ShipContainer(Ships[0], 0.7f, "Capital Offense", Ships[0].transform.position));
     checkupdate();
     FleetBuilder = IORoot.findIO("fleet1");
     FleetBuilder.read();
     // displaycomponent = display.GetComponent<TextMesh>();
     // updatedisplay();
     StartCoroutine(Example());
     guncontroller = GetComponent <FleetNumControl>();
     countthrough  = 0;
     checkupdate();
 }
Esempio n. 8
0
        private bool LoadVersion1_1(XmlDocument doc)
        {
            try
            {
                Document = new IODocument();

                XmlElement circuitNode = doc.SelectSingleNode("/circuit") as XmlElement;
                if (circuitNode.HasAttribute("width") && circuitNode.HasAttribute("height"))
                    Document.Size = new System.Windows.Size(double.Parse(circuitNode.Attributes["width"].InnerText), double.Parse(circuitNode.Attributes["height"].InnerText));
                string application = null;
                string appVersion = null;
                if (circuitNode.HasAttribute("application"))
                {
                    application = circuitNode.Attributes["application"].InnerText;
                    if (circuitNode.HasAttribute("appversion"))
                        appVersion = circuitNode.Attributes["appversion"].InnerText;
                }
                else if (circuitNode.HasAttribute("cd-version"))
                {
                    application = "Circuit Diagram ";
                    appVersion = circuitNode.Attributes["cd-version"].InnerText;
                }

                XmlNodeList componentNodes = doc.SelectNodes("/circuit/component");
                foreach (XmlNode node in componentNodes)
                {
                    string type = node.Attributes["type"].InnerText;
                    double x = double.Parse(node.Attributes["x"].InnerText);
                    double y = double.Parse(node.Attributes["y"].InnerText);
                    double size = 10d;
                    if ((node as XmlElement).HasAttribute("size"))
                        size = double.Parse(node.Attributes["size"].InnerText);
                    bool horizontal = true;
                    if ((node as XmlElement).HasAttribute("orientation") && node.Attributes["orientation"].InnerText.ToLowerInvariant() == "vertical")
                        horizontal = false;
                    Guid guid = Guid.Empty;
                    if ((node as XmlElement).HasAttribute("guid"))
                        guid = new Guid(node.Attributes["guid"].InnerText);

                    // Check component type
                    string lType = type.ToLowerInvariant();

                    if (lType == "wire")
                    {
                        // Element is wire

                        IOWire wire = new IOWire();
                        wire.Location = new System.Windows.Point(x, y);
                        wire.Orientation = (horizontal ? Orientation.Horizontal : Orientation.Vertical);
                        wire.Size = size;

                        // Add to document
                        Document.Wires.Add(wire);
                    }
                    else
                    {
                        // Element is component

                        IOComponent component = new IOComponent();
                        component.Location = new System.Windows.Point(x, y);
                        component.Orientation = (horizontal ? Orientation.Horizontal : Orientation.Vertical);
                        component.Size = size;

                        // Other properties
                        Dictionary<string, object> properties = new Dictionary<string, object>(node.Attributes.Count);
                        foreach (XmlAttribute attribute in node.Attributes)
                            properties.Add(attribute.Name, attribute.InnerText);

                        // Read type parameter
                        string t = null;
                        if ((node as XmlElement).HasAttribute("t"))
                            t = node.Attributes["t"].InnerText;
                        if (t == null && lType == "logicgate" && (node as XmlElement).HasAttribute("logictype"))
                            t = node.Attributes["logictype"].InnerText;

                        if (properties.ContainsKey("flipped"))
                        {
                            component.IsFlipped = bool.Parse(properties["flipped"].ToString());
                            properties.Remove("flipped");
                        }

                        // Convert component name
                        string componentCollection;
                        string standardComponentName;
                        ConvertComponentName(lType, t, out componentCollection, out standardComponentName);

                        // Set properties
                        ConvertProperties(componentCollection, standardComponentName, properties);
                        foreach (var property in properties)
                            component.Properties.Add(new IOComponentProperty(property.Key, property.Value, true));

                        // Set type
                        component.Type = new IOComponentType(componentCollection, standardComponentName);
                        component.Type.Name = type;
                        component.Type.GUID = guid;

                        // Add to document
                        Document.Components.Add(component);
                    }
                }

                // Set metadata
                Document.Metadata.Application = application;
                Document.Metadata.AppVersion = appVersion;

                LoadResult = new DocumentLoadResult();
                LoadResult.Format = "XML (1.1)";
                LoadResult.Type = DocumentLoadResultType.Success;

                return true;
            }
            catch (Exception)
            {
                // Wrong format
                LoadResult = new DocumentLoadResult();
                LoadResult.Type = DocumentLoadResultType.FailIncorrectFormat;
                return false;
            }
        }
Esempio n. 9
0
        private bool LoadVersion1_0(XmlDocument doc)
        {
            try
            {
                DocumentLoadResult loadResult = new DocumentLoadResult();

                Document = new IODocument();

                XmlElement circuitNode = doc.SelectSingleNode("/circuit") as XmlElement;
                if (circuitNode.HasAttribute("width") && circuitNode.HasAttribute("height"))
                    Document.Size = new System.Windows.Size(double.Parse(circuitNode.Attributes["width"].InnerText), double.Parse(circuitNode.Attributes["height"].InnerText));
                string application = null;
                string appVersion = null;
                if (circuitNode.HasAttribute("application"))
                    application = circuitNode.Attributes["application"].InnerText;
                else if (circuitNode.HasAttribute("cd-version"))
                {
                    application = "Circuit Diagram ";
                    appVersion = circuitNode.Attributes["cd-version"].InnerText;
                }

                foreach (XmlNode node in circuitNode.ChildNodes)
                {
                    if (node.NodeType != XmlNodeType.Element)
                        continue;

                    string type = node.Name;
                    string location = node.Attributes["location"].InnerText;
                    string[] locationSplit = location.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                    // Snap points to grid
                    double x = Math.Round(double.Parse(locationSplit[0]) / 10d) * 10d;
                    double y = Math.Round(double.Parse(locationSplit[1]) / 10d) * 10d;
                    double endX = Math.Round(double.Parse(locationSplit[2]) / 10d) * 10d;
                    double endY = Math.Round(double.Parse(locationSplit[3]) / 10d) * 10d;
                    double size = endX - x;
                    bool horizontal = true;
                    if (endX == x)
                    {
                        size = endY - y;
                        horizontal = false;
                    }

                    // Other properties
                    Dictionary<string, object> properties = new Dictionary<string, object>(node.Attributes.Count);
                    foreach (XmlAttribute attribute in node.Attributes)
                        properties.Add(attribute.Name, attribute.InnerText);

                    string lType = type.ToLowerInvariant();

                    if (lType == "wire")
                    {
                        // Wire

                        IOWire wire = new IOWire();
                        wire.Location = new System.Windows.Point(x, y);
                        wire.Size = size;
                        wire.Orientation = (horizontal ? Orientation.Horizontal : Orientation.Vertical);

                        // Add to document
                        Document.Wires.Add(wire);
                    }
                    else
                    {
                        // Full component

                        IOComponent component = new IOComponent();
                        component.Location = new System.Windows.Point(x, y);
                        component.Size = size;
                        component.Orientation = (horizontal ? Orientation.Horizontal : Orientation.Vertical);

                        // Read type parameter
                        string t = null;
                        if ((node as XmlElement).HasAttribute("t"))
                            t = node.Attributes["t"].InnerText;
                        else if ((node as XmlElement).HasAttribute("type"))
                            t = node.Attributes["type"].InnerText;

                        if (properties.ContainsKey("t"))
                            properties.Remove("t");

                        // Convert component name
                        string componentCollection;
                        string standardComponentName;
                        ConvertComponentName(lType, t, out componentCollection, out standardComponentName);

                        // Set properties
                        ConvertProperties(componentCollection, standardComponentName, properties);
                        foreach (var property in properties)
                            component.Properties.Add(new IOComponentProperty(property.Key, property.Value, true));

                        // Set type
                        component.Type = new IOComponentType(componentCollection, standardComponentName);
                        component.Type.Name = type;

                        // Add to document
                        Document.Components.Add(component);
                    }
                }

                // Reset metadata
                Document.Metadata = new CircuitDocumentMetadata();
                LoadResult.Format = "XML (1.0)";
                Document.Metadata.Application = application;
                Document.Metadata.AppVersion = appVersion;

                LoadResult.Type = DocumentLoadResultType.Success;
                return true;
            }
            catch (Exception)
            {
                // Wrong format
                LoadResult = new DocumentLoadResult();
                LoadResult.Type = DocumentLoadResultType.FailIncorrectFormat;
                return false;
            }
        }
Esempio n. 10
0
        internal async Task Start()
        {
            Logger.Server = this;
            Events        = new EventManager();
            Players       = new List <Player>();
            Levels        = new List <Level>();

            // Setup server
            Console.BackgroundColor = ConsoleColor.Black;
            Console.Clear();
            start = DateTime.Now;
            input = string.Empty;
            clear = new string(' ', Console.WindowWidth);
            var stopwatch = Stopwatch.StartNew();

            Logger.WriteLine($"{Constants.Strings.ServerTitle}");
            Logger.WriteLine($"Server is starting now, on {DateTime.Now.ToString("U", new CultureInfo("en-US"))}");

            // Initialize Properties
            Commands = CommandParser.CreateNew().UsePrefix(string.Empty).OnError(OnParseError);
            RegisterCommands();

            // Initialize Components
            IO       = new IOComponent(this);
            Plugins  = new PluginComponent(this);
            Database = new DatabaseComponent(this);
            Net      = new NetworkComponent(this);

            await IO.Init();

            await Plugins.Init();

            await Database.Init();

            await Net.Init();

            // Create save timer
            saveTimer          = new Timer(IO.Config.Server.AutoSaveTime * 1000 * 60);
            saveTimer.Elapsed += async(sender, args) => await SaveAll();

            saveTimer.Start();

            stopwatch.Stop();
            Logger.WriteBreak();
            Logger.WriteLine("Ready. ({0}s) Type /help for commands.", Math.Round(stopwatch.Elapsed.TotalSeconds, 2));
            Logger.WriteBreak();

            WriteHeader();

            while (true) // Parse commands now that messaging has been handed off to another thread
            {
                input = string.Empty;
                WriteCommandCursor();

                // Read input and parse commands
                while (true)
                {
                    var key = Console.ReadKey(true);
                    if (key.Key == ConsoleKey.Backspace)
                    {
                        if (input.Length - 1 >= 0)
                        {
                            input = input.Substring(0, input.Length - 1);
                            Console.CursorLeft = 3 + input.Length - 1;
                            Console.Write(' ');
                            Console.CursorLeft = 3 + input.Length - 1;
                        }
                        continue;
                    }
                    if (key.Key == ConsoleKey.Enter)
                    {
                        Console.WriteLine("");
                        break;
                    }
                    input += key.KeyChar;
                    Console.Write(key.KeyChar);
                }

                Commands.Parse(input.Trim());

                WriteHeader();
            }
            // ReSharper disable once FunctionNeverReturns
        }
Esempio n. 11
0
        private bool LoadVersion1_1(XmlDocument doc)
        {
            try
            {
                Document = new IODocument();

                XmlElement circuitNode = doc.SelectSingleNode("/circuit") as XmlElement;
                if (circuitNode.HasAttribute("width") && circuitNode.HasAttribute("height"))
                {
                    Document.Size = new Size(double.Parse(circuitNode.Attributes["width"].InnerText), double.Parse(circuitNode.Attributes["height"].InnerText));
                }
                string application = null;
                string appVersion  = null;
                if (circuitNode.HasAttribute("application"))
                {
                    application = circuitNode.Attributes["application"].InnerText;
                    if (circuitNode.HasAttribute("appversion"))
                    {
                        appVersion = circuitNode.Attributes["appversion"].InnerText;
                    }
                }
                else if (circuitNode.HasAttribute("cd-version"))
                {
                    application = "Circuit Diagram ";
                    appVersion  = circuitNode.Attributes["cd-version"].InnerText;
                }

                XmlNodeList componentNodes = doc.SelectNodes("/circuit/component");
                foreach (XmlNode node in componentNodes)
                {
                    string type = node.Attributes["type"].InnerText;
                    double x    = double.Parse(node.Attributes["x"].InnerText);
                    double y    = double.Parse(node.Attributes["y"].InnerText);
                    double size = 10d;
                    if ((node as XmlElement).HasAttribute("size"))
                    {
                        size = double.Parse(node.Attributes["size"].InnerText);
                    }
                    bool horizontal = true;
                    if ((node as XmlElement).HasAttribute("orientation") && node.Attributes["orientation"].InnerText.ToLowerInvariant() == "vertical")
                    {
                        horizontal = false;
                    }
                    Guid guid = Guid.Empty;
                    if ((node as XmlElement).HasAttribute("guid"))
                    {
                        guid = new Guid(node.Attributes["guid"].InnerText);
                    }

                    // Check component type
                    string lType = type.ToLowerInvariant();

                    if (lType == "wire")
                    {
                        // Element is wire

                        IOWire wire = new IOWire();
                        wire.Location    = new Point(x, y);
                        wire.Orientation = (horizontal ? Orientation.Horizontal : Orientation.Vertical);
                        wire.Size        = size;

                        // Add to document
                        Document.Wires.Add(wire);
                    }
                    else
                    {
                        // Element is component

                        IOComponent component = new IOComponent();
                        component.Location    = new Point(x, y);
                        component.Orientation = (horizontal ? Orientation.Horizontal : Orientation.Vertical);
                        component.Size        = size;

                        // Other properties
                        Dictionary <string, object> properties = new Dictionary <string, object>(node.Attributes.Count);
                        foreach (XmlAttribute attribute in node.Attributes)
                        {
                            properties.Add(attribute.Name, attribute.InnerText);
                        }

                        // Read type parameter
                        string t = null;
                        if ((node as XmlElement).HasAttribute("t"))
                        {
                            t = node.Attributes["t"].InnerText;
                        }
                        if (t == null && lType == "logicgate" && (node as XmlElement).HasAttribute("logictype"))
                        {
                            t = node.Attributes["logictype"].InnerText;
                        }

                        if (properties.ContainsKey("flipped"))
                        {
                            component.IsFlipped = bool.Parse(properties["flipped"].ToString());
                            properties.Remove("flipped");
                        }

                        // Convert component name
                        string componentCollection;
                        string standardComponentName;
                        ConvertComponentName(lType, t, out componentCollection, out standardComponentName);

                        // Set properties
                        ConvertProperties(componentCollection, standardComponentName, properties);
                        foreach (var property in properties)
                        {
                            component.Properties.Add(new IOComponentProperty(property.Key, property.Value, true));
                        }

                        // Set type
                        component.Type      = new IOComponentType(componentCollection, standardComponentName);
                        component.Type.Name = type;
                        component.Type.GUID = guid;

                        // Add to document
                        Document.Components.Add(component);
                    }
                }

                // Set metadata
                Document.Metadata.Application = application;
                Document.Metadata.AppVersion  = appVersion;

                LoadResult        = new DocumentLoadResult();
                LoadResult.Format = "XML (1.1)";
                LoadResult.Type   = DocumentLoadResultType.Success;

                return(true);
            }
            catch (Exception)
            {
                // Wrong format
                LoadResult      = new DocumentLoadResult();
                LoadResult.Type = DocumentLoadResultType.FailIncorrectFormat;
                return(false);
            }
        }
Esempio n. 12
0
        private bool LoadVersion1_0(XmlDocument doc)
        {
            try
            {
                DocumentLoadResult loadResult = new DocumentLoadResult();

                Document = new IODocument();

                XmlElement circuitNode = doc.SelectSingleNode("/circuit") as XmlElement;
                if (circuitNode.HasAttribute("width") && circuitNode.HasAttribute("height"))
                {
                    Document.Size = new Size(double.Parse(circuitNode.Attributes["width"].InnerText), double.Parse(circuitNode.Attributes["height"].InnerText));
                }
                string application = null;
                string appVersion  = null;
                if (circuitNode.HasAttribute("application"))
                {
                    application = circuitNode.Attributes["application"].InnerText;
                }
                else if (circuitNode.HasAttribute("cd-version"))
                {
                    application = "Circuit Diagram ";
                    appVersion  = circuitNode.Attributes["cd-version"].InnerText;
                }

                foreach (XmlNode node in circuitNode.ChildNodes)
                {
                    if (node.NodeType != XmlNodeType.Element)
                    {
                        continue;
                    }

                    string   type          = node.Name;
                    string   location      = node.Attributes["location"].InnerText;
                    string[] locationSplit = location.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                    // Snap points to grid
                    double x          = Math.Round(double.Parse(locationSplit[0]) / 10d) * 10d;
                    double y          = Math.Round(double.Parse(locationSplit[1]) / 10d) * 10d;
                    double endX       = Math.Round(double.Parse(locationSplit[2]) / 10d) * 10d;
                    double endY       = Math.Round(double.Parse(locationSplit[3]) / 10d) * 10d;
                    double size       = endX - x;
                    bool   horizontal = true;
                    if (endX == x)
                    {
                        size       = endY - y;
                        horizontal = false;
                    }

                    // Other properties
                    Dictionary <string, object> properties = new Dictionary <string, object>(node.Attributes.Count);
                    foreach (XmlAttribute attribute in node.Attributes)
                    {
                        properties.Add(attribute.Name, attribute.InnerText);
                    }

                    string lType = type.ToLowerInvariant();

                    if (lType == "wire")
                    {
                        // Wire

                        IOWire wire = new IOWire();
                        wire.Location    = new Point(x, y);
                        wire.Size        = size;
                        wire.Orientation = (horizontal ? Orientation.Horizontal : Orientation.Vertical);

                        // Add to document
                        Document.Wires.Add(wire);
                    }
                    else
                    {
                        // Full component

                        var component = new IOComponent();
                        component.Location    = new Point(x, y);
                        component.Size        = size;
                        component.Orientation = (horizontal ? Orientation.Horizontal : Orientation.Vertical);

                        // Read type parameter
                        string t = null;
                        if ((node as XmlElement).HasAttribute("t"))
                        {
                            t = node.Attributes["t"].InnerText;
                        }
                        else if ((node as XmlElement).HasAttribute("type"))
                        {
                            t = node.Attributes["type"].InnerText;
                        }

                        if (properties.ContainsKey("t"))
                        {
                            properties.Remove("t");
                        }

                        // Convert component name
                        string componentCollection;
                        string standardComponentName;
                        ConvertComponentName(lType, t, out componentCollection, out standardComponentName);

                        // Set properties
                        ConvertProperties(componentCollection, standardComponentName, properties);
                        foreach (var property in properties)
                        {
                            component.Properties.Add(new IOComponentProperty(property.Key, property.Value, true));
                        }

                        // Set type
                        component.Type      = new IOComponentType(componentCollection, standardComponentName);
                        component.Type.Name = type;

                        // Add to document
                        Document.Components.Add(component);
                    }
                }

                // Reset metadata
                Document.Metadata             = new CircuitDocumentMetadata();
                LoadResult.Format             = "XML (1.0)";
                Document.Metadata.Application = application;
                Document.Metadata.AppVersion  = appVersion;

                LoadResult.Type = DocumentLoadResultType.Success;
                return(true);
            }
            catch (Exception)
            {
                // Wrong format
                LoadResult      = new DocumentLoadResult();
                LoadResult.Type = DocumentLoadResultType.FailIncorrectFormat;
                return(false);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IOPanel"/> class.
        /// </summary>
        public IOPanel()
        {
            InitializeComponent();
            _io = IOComponent.Instance;

            _outBits     = new LEDButton[24];
            _outBits[0]  = ledButton1;
            _outBits[1]  = ledButton2;
            _outBits[2]  = ledButton3;
            _outBits[3]  = ledButton4;
            _outBits[4]  = ledButton5;
            _outBits[5]  = ledButton6;
            _outBits[6]  = ledButton7;
            _outBits[7]  = ledButton8;
            _outBits[8]  = ledButton9;
            _outBits[9]  = ledButton10;
            _outBits[10] = ledButton11;
            _outBits[11] = ledButton12;
            _outBits[12] = ledButton13;
            _outBits[13] = ledButton14;
            _outBits[14] = ledButton15;
            _outBits[15] = ledButton16;
            _outBits[16] = ledButton17;
            _outBits[17] = ledButton18;
            _outBits[18] = ledButton19;
            _outBits[19] = ledButton20;
            _outBits[20] = ledButton21;
            _outBits[21] = ledButton22;
            _outBits[22] = ledButton23;
            _outBits[23] = ledButton24;

            _inBits     = new LEDButton[24];
            _inBits[0]  = ledButton25;
            _inBits[1]  = ledButton26;
            _inBits[2]  = ledButton27;
            _inBits[3]  = ledButton28;
            _inBits[4]  = ledButton29;
            _inBits[5]  = ledButton30;
            _inBits[6]  = ledButton31;
            _inBits[7]  = ledButton32;
            _inBits[8]  = ledButton33;
            _inBits[9]  = ledButton34;
            _inBits[10] = ledButton35;
            _inBits[11] = ledButton36;
            _inBits[12] = ledButton37;
            _inBits[13] = ledButton38;
            _inBits[14] = ledButton39;
            _inBits[15] = ledButton40;
            _inBits[16] = ledButton41;
            _inBits[17] = ledButton42;
            _inBits[18] = ledButton43;
            _inBits[19] = ledButton44;
            _inBits[20] = ledButton45;
            _inBits[21] = ledButton46;
            _inBits[22] = ledButton47;
            _inBits[23] = ledButton48;

            for (int i = 0; i < NUM_IO_DISPLAY; i++)
            {
                _inBits[i].Tag  = i;
                _outBits[i].Tag = i;
            }
        }
Esempio n. 14
0
 void Awake()
 {
     FleetBuilder = IORoot.findIO("fleet1");
 }
Esempio n. 15
0
        /// <summary>
        /// Converts a <see cref="CircuitDocument"/> to an <see cref="IODocument"/>.
        /// </summary>
        /// <param name="document">The CircuitDocument to convert.</param>
        /// <returns>An IODocument constructed from the CircuitDocument.</returns>
        public static IODocument ToIODocument(this CircuitDocument document, out IDictionary <IOComponentType, EmbedComponentData> embedComponents)
        {
            IODocument ioDocument = new IODocument();

            ioDocument.Size = document.Size;

            // Set metadata
            ioDocument.Metadata = document.Metadata;

            // Get connections
            Dictionary <Component, Dictionary <string, string> > connections = ConnectionHelper.RemoveWires(document);

            // Generate types
            Dictionary <ComponentIdentifier, IOComponentType> componentTypes = new Dictionary <ComponentIdentifier, IOComponentType>();

            foreach (Component component in document.Components)
            {
                if (ComponentHelper.IsWire(component))
                {
                    continue; // Skip wires
                }
                ComponentIdentifier identifier = new ComponentIdentifier(component.Description, component.Configuration());
                if (!componentTypes.ContainsKey(identifier))
                {
                    IOComponentType ioType = new IOComponentType(component.Description.Metadata.ImplementSet,
                                                                 (identifier.Configuration != null && !String.IsNullOrEmpty(identifier.Configuration.ImplementationName) ? identifier.Configuration.ImplementationName : component.Description.Metadata.ImplementItem));
                    ioType.Name = component.Description.ComponentName;
                    ioType.GUID = component.Description.Metadata.GUID;
                    componentTypes.Add(identifier, ioType);
                }
            }

            // Add visible components
            int idCounter = 0; // generate component IDs

            foreach (IComponentElement component in document.Elements.Where(component => component is IComponentElement && !ComponentHelper.IsWire(component)))
            {
                IOComponent ioComponent = new IOComponent();
                ioComponent.ID          = idCounter.ToString();
                ioComponent.Size        = component.Size;
                ioComponent.Location    = new Point(component.Location.X, component.Location.Y);
                ioComponent.IsFlipped   = component.IsFlipped;
                ioComponent.Orientation = component.Orientation;
                IOComponentType ioType = new IOComponentType(component.ImplementationCollection, component.ImplementationItem);

                if (component is Component)
                {
                    Component cComponent = component as Component;
                    ioType.Name      = cComponent.Description.ComponentName;
                    ioType.GUID      = cComponent.Description.Metadata.GUID;
                    ioComponent.Type = ioType;

                    // Set connections
                    if (connections.ContainsKey(cComponent))
                    {
                        foreach (var connection in connections[cComponent])
                        {
                            ioComponent.Connections.Add(connection.Key, connection.Value);
                        }
                    }
                }

                // Set properties
                foreach (var property in component.Properties)
                {
                    ioComponent.Properties.Add(new IOComponentProperty(property.Key, property.Value, true)); // TODO: implement IsStandard
                }
                ioDocument.Components.Add(ioComponent);

                idCounter++;
            }

            // Add unavailable components
            foreach (DisabledComponent component in document.DisabledComponents)
            {
                Point?location = null;
                if (component.Location.HasValue)
                {
                    location = new Point(component.Location.Value.X, component.Location.Value.Y);
                }

                IOComponent ioComponent = new IOComponent();
                ioComponent.ID          = idCounter.ToString();
                ioComponent.Location    = location;
                ioComponent.Size        = component.Size;
                ioComponent.IsFlipped   = component.IsFlipped;
                ioComponent.Orientation = component.Orientation;

                IOComponentType ioType = new IOComponentType(component.ImplementationCollection, component.ImplementationItem);

                // Set name
                if (!String.IsNullOrEmpty(component.Name))
                {
                    ioType.Name = component.Name;
                }

                // Set GUID
                if (component.GUID.HasValue)
                {
                    ioType.GUID = component.GUID.Value;
                }

                ioComponent.Type = ioType;

                // Set properties
                foreach (var property in component.Properties)
                {
                    ioComponent.Properties.Add(new IOComponentProperty(property.Key, property.Value, true));
                }

                ioDocument.Components.Add(ioComponent);

                idCounter++;
            }

            // Add wires
            foreach (IComponentElement wire in document.Components.Where(component => ComponentHelper.IsWire(component)))
            {
                IOWire ioWire = new IOWire(new Point(wire.Location.X, wire.Location.Y), wire.Size, wire.Orientation);
                ioDocument.Wires.Add(ioWire);
            }

            // Embed components
            embedComponents = new Dictionary <IOComponentType, EmbedComponentData>();
            foreach (EmbedDescription embedItem in document.Metadata.EmbedComponents.Where(item => item.IsEmbedded == true))
            {
                if (!String.IsNullOrEmpty(embedItem.Description.Source.Path) && System.IO.File.Exists(embedItem.Description.Source.Path))
                {
                    EmbedComponentData embedData = new EmbedComponentData();
                    embedData.Stream        = System.IO.File.OpenRead(embedItem.Description.Source.Path);
                    embedData.FileExtension = System.IO.Path.GetExtension(embedItem.Description.Source.Path);

                    switch (embedData.FileExtension)
                    {
                    case ".xml":
                        embedData.ContentType = "application/xml";
                        break;

                    case ".cdcom":
                        embedData.ContentType = IO.CDDX.ContentTypeNames.BinaryComponent;
                        break;
                    }

                    List <IOComponentType> associatedTypes = new List <IOComponentType>();
                    foreach (var item in componentTypes)
                    {
                        if (item.Key.Description == embedItem.Description && !embedComponents.ContainsKey(item.Value))
                        {
                            embedComponents.Add(item.Value, embedData);
                        }
                    }
                }
            }

            return(ioDocument);
        }