Пример #1
0
        public void loadSeparatedAssets(string projectPath, bool locked)
        {
            _projectPath = projectPath;

            Assets.items.Clear();

            string[] packs = Directory.GetFiles(Path.Combine(projectPath), "*.pak");

            for (int i = 0; i < packs.Length; i++)
            {
                AssetList list = new AssetList();

                if (locked)
                {
                    byte[] key = ByteConverter.GetBytes("dfy3hfi3789y478yhge7y578yrhgiudhr8967498u839udhkjghjk");
                    RC4    rc4 = new RC4(key);

                    byte[] file = File.ReadAllBytes(packs[i]);
                    file = rc4.Decode(file, file.Length);

                    MemoryStream ms = new MemoryStream();
                    ms.Write(file, 0, file.Length);
                    ms.Seek(0, SeekOrigin.Begin);

                    list = (AssetList)Serialization.deserialize(ms);

                    ms.Dispose();
                }
                else
                {
                    list = (AssetList)Serialization.deserialize(packs[i]);
                }

                for (int j = 0; j < list.Count; j++)
                {
                    Assets.items.Add(list[j]);
                }
            }

            if (Assets.items.Count > 0)
            {
                setReferences();
            }
        }
Пример #2
0
        public void saveAssetsSeparately(string projectPath, bool locked)
        {
            if (Assets.items != null)
            {
                List <AssetList> packages = new List <AssetList>();

                for (int i = 0; i < Assets.items.Count; i++)
                {
                    Asset     asset   = Assets.items[i];
                    AssetList package = findPackage(packages, asset.package);

                    if (package == null)
                    {
                        package      = new AssetList();
                        package.name = asset.package;
                        packages.Add(package);
                    }

                    if (package.name == null)
                    {
                        package.name = "Unnamed";
                    }

                    package.Add(asset);
                }

                for (int i = 0; i < packages.Count; i++)
                {
                    string name = Path.Combine(projectPath, packages[i].name.Replace(" ", "_") + ".pak");
                    Serialization.serialize(name, packages[i]);

                    if (locked)
                    {
                        byte[] key  = ByteConverter.GetBytes("dfy3hfi3789y478yhge7y578yrhgiudhr8967498u839udhkjghjk");
                        RC4    rc4  = new RC4(key);
                        byte[] file = File.ReadAllBytes(name);
                        file = rc4.Encode(file, file.Length);
                        File.WriteAllBytes(name, file);
                    }
                }
            }
        }