Пример #1
0
        protected void CollectGameFiles(DirectoryInfo root, IDictionary <string, string> files)
        {
            const string DataBundleName = DataName + AssetBundleExtension;
            string       dataBundlePath = Path.Combine(root.FullName, DataBundleName);

            if (MultiFileStream.Exists(dataBundlePath))
            {
                AddAssetBundle(files, DataBundleName, dataBundlePath);
            }

            string filePath = Path.Combine(root.FullName, GlobalGameManagerName);

            if (MultiFileStream.Exists(filePath))
            {
                AddFile(files, GlobalGameManagerName, filePath);
            }
            else
            {
                filePath = Path.Combine(root.FullName, MainDataName);
                if (MultiFileStream.Exists(filePath))
                {
                    AddFile(files, MainDataName, filePath);
                }
            }

            foreach (FileInfo levelFile in root.EnumerateFiles())
            {
                if (s_levelTemplate.IsMatch(levelFile.Name))
                {
                    string levelName = MultiFileStream.GetFileName(levelFile.Name);
                    AddFile(files, levelName, levelFile.FullName);
                }
            }
        }
Пример #2
0
        public MixedGameStructure(IEnumerable <string> pathes)
        {
            Dictionary <string, string> files      = new Dictionary <string, string>();
            Dictionary <string, string> assemblies = new Dictionary <string, string>();
            HashSet <string>            dataPathes = new HashSet <string>();

            foreach (string path in SelectUniquePathes(pathes))
            {
                if (MultiFileStream.Exists(path))
                {
                    string name = MultiFileStream.GetFileName(path);
                    AddFile(files, name, path);
                    string directory = Path.GetDirectoryName(path);
                    dataPathes.Add(directory);
                }
                else if (DirectoryUtils.Exists(path))
                {
                    DirectoryInfo directory = new DirectoryInfo(DirectoryUtils.ToLongPath(path));
                    CollectFromDirectory(directory, files, assemblies, dataPathes);
                }
                else
                {
                    throw new Exception($"Neither file nor directory at '{path}' exists");
                }
            }

            DataPathes = dataPathes.ToArray();
            Files      = files;
            Assemblies = assemblies;
            Name       = Files.Count == 0 ? string.Empty : Files.First().Key;
        }