Пример #1
0
    public Cabin init(StatusScreen statusScreen)
    {
        this.statusScreen = statusScreen;

        terminalBtn = transform.Find("Terminal Button").GetComponent <Button>().init();
        restBtn     = transform.Find("Rest Button").GetComponent <Button>().init();
        stasisBtn   = transform.Find("Stasis Button").GetComponent <Button>().init();

        terminal       = transform.Find("Player Terminal").GetComponent <PlayerTerminal>().init(this);
        chambersHolder = transform.Find("Chambers").GetComponent <StasisChambersHolder>().init(this);

        return(this);
    }
Пример #2
0
        public List <Node> DownloadDatabase()
        {
            List <Node> nodeList = new List <Node>();

            using (MySqlConnection conn = new MySqlConnection(GetConnectionString()))
            {
                conn.Open();

                MySqlCommand sqlCommand = new MySqlCommand("SELECT * FROM computers", conn);
                using (MySqlConnection cn1 = new MySqlConnection(GetConnectionString()))
                {
                    cn1.Open();
                    using (MySqlDataReader reader = sqlCommand.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                Node newNode = null;
                                int  type    = reader.GetInt32(3);
                                if (type == 4)
                                {
                                    newNode = new PlayerTerminal();
                                    ((PlayerTerminal)newNode).ownerId = reader.GetInt32(2);
                                }
                                else
                                {
                                    newNode = new Node();
                                }
                                newNode.id      = reader.GetInt32(0);
                                newNode.ip      = reader.GetString(1);
                                newNode.ownerId = reader.GetInt32(2);

                                MySqlCommand fileCommand = new MySqlCommand("SELECT * FROM files WHERE computerId = @0", cn1);
                                fileCommand.Parameters.Add(new MySqlParameter("0", newNode.id));
                                List <File> computerFiles = new List <File>();

                                using (MySqlDataReader fileReader = fileCommand.ExecuteReader())
                                {
                                    if (fileReader.HasRows)
                                    {
                                        while (fileReader.Read())
                                        {
                                            int    fileType = fileReader.GetByte(3);
                                            string fileName = fileReader.GetString(1);

                                            Console.WriteLine($"Creating file {fileName} with id {fileReader.GetInt32(0)}");

                                            File newFile = newNode.fileSystem.CreateFile(fileReader.GetInt32(0), newNode, newNode.fileSystem.rootFile, fileName);

                                            newFile.isFolder = fileType == 1;

                                            newFile.ParentId  = fileReader.GetInt32(2);
                                            newFile.ReadPriv  = (Group)fileReader.GetInt32(8);
                                            newFile.WritePriv = (Group)fileReader.GetInt32(7);
                                            newFile.Content   = fileReader.GetString(5);
                                            newFile.SetType(fileReader.GetInt32(4));

                                            computerFiles.Add(newFile);

                                            if (newFile.ParentId == 0)
                                            {
                                                newNode.SetRoot(newFile);
                                            }
                                        }
                                    }
                                }

                                ComputerManager.FixFolder(computerFiles, newNode.fileSystem.rootFile);
                                nodeList.Add(newNode);
                            }
                        }
                    }
                }
            }

            return(nodeList);
        }