Пример #1
0
        private static string Log(string entryPath, string bundlePath, StrategyNode node)
        {
            string outputPath = AssetPathHelper.GetOutputPath(bundlePath);
            string content    = string.Format("策略名称:{0}\n模式:{1}\n入口:{2}\nProcessor:{3}\nPattern:{4}\n输出:{5}\n体积:{6}KB",
                                              node.strategy, node.mode, entryPath, node.processor, node.pattern, bundlePath, GetFileSize(outputPath).ToString());

            Logger.GetLogger(AssetBundleExporter.LOGGER_NAME).Log(content);
            return(content);
        }
Пример #2
0
        private static string[] GetFolderModeAssetPaths(List <string> assetPathList, StrategyNode node)
        {
            string folderPath       = AssetPathHelper.GetFolderModeStartPath(assetPathList[0], node.pattern);
            string systemFolderPath = AssetPathHelper.ToFileSystemPath(folderPath);

            string[]      filePaths        = Directory.GetFiles(systemFolderPath, "*.*", SearchOption.AllDirectories);
            List <string> filteredPathList = new List <string>();

            for (int i = 0; i < filePaths.Length; i++)
            {
                filePaths[i] = filePaths[i].Replace(@"\", @"/");
                if (filePaths[i].Contains(".mata") == false && node.pattern.IsMatch(filePaths[i]) == true)
                {
                    filteredPathList.Add(AssetPathHelper.ToAssetPath(filePaths[i]));
                }
            }
            return(filteredPathList.ToArray());
        }
Пример #3
0
    public void SetStrategy(StrategyNode p_strategy)
    {
        if (p_strategy == null)
        {
            tacticsHandler = null;
            eventHandler.SetUp(null);
            return;
        }

        currentStrategy = p_strategy;
        if (currentStrategy.tacticsNode.GetType() == typeof(TacticsRepeatNode))
        {
            tacticsHandler = new TacticsRepeat(this, currentStrategy.tacticsNode);
        }
        else if (currentStrategy.tacticsNode.GetType() == typeof(TacticsPursueNode))
        {
            // tacticsHandler = new TacticsRepeat(this, currentStrategy.tacticsNode);
        }

        eventHandler.SetUp(currentStrategy.eventNodes);
    }
Пример #4
0
        public void CloneStrategy_JustRoot()
        {
            StrategyNode foo = new StrategyNode(new WeighPoint(null, null));

            StrategyNode clone = new StrategyNode(null, foo);
        }
Пример #5
0
        private static Dictionary <string, string> BuildSelectionMode(string entryPath, List <string> assetPathList, StrategyNode node)
        {
            Dictionary <string, string> result = new Dictionary <string, string>();
            string bundlePath = AssetPathHelper.GetSelectionModeBundlePath(entryPath, assetPathList, node.pattern);

            foreach (string s in assetPathList)
            {
                result.Add(s, bundlePath);
            }

            if (CanBuild(entryPath, bundlePath) == false)
            {
                return(result);
            }
            //TODO: 验证Selection中存在不同路径下,同类型同名但是内容不同时可能引起的问题
            VerifySelectionAssets(assetPathList);
            AddAssetBundleBuildWrapper(entryPath, bundlePath, assetPathList.ToArray(), node);
            return(result);
        }
Пример #6
0
        private static Dictionary <string, string> BuildSingleNode(string entryPath, List <string> assetPathList, StrategyNode node)
        {
            Dictionary <string, string> result = new Dictionary <string, string>();

            for (int i = 0; i < assetPathList.Count; i++)
            {
                string assetPath  = assetPathList[i];
                string bundlePath = AssetPathHelper.GetSingleModeBundlePath(assetPath);
                result.Add(assetPath, bundlePath);
                if (CanBuild(entryPath, bundlePath) == false)
                {
                    continue;
                }
                AddAssetBundleBuildWrapper(assetPath, bundlePath, new string[] { assetPath }, node);
            }
            return(result);
        }
Пример #7
0
        public static Dictionary <string, string> Add(string entryPath, List <string> assetPathList, StrategyNode node)
        {
            Dictionary <string, string> result = new Dictionary <string, string>();

            if (assetPathList.Count == 0)
            {
                return(result);
            }
            switch (node.mode)
            {
            case PackageMode.SINGLE:
                result = BuildSingleNode(entryPath, assetPathList, node);
                break;

            case PackageMode.SELECTION:
                result = BuildSelectionMode(entryPath, assetPathList, node);
                break;

            case PackageMode.FOLDER:
                result = BuildFolderMode(entryPath, assetPathList, node);
                break;
            }
            return(result);
        }
Пример #8
0
        private static void AddAssetBundleBuildWrapper(string entryPath, string bundlePath, string[] assetNames, StrategyNode node)
        {
            AssetBundleBuild build = new AssetBundleBuild();

            build.assetBundleName = bundlePath;
            build.assetNames      = assetNames;
            AssetBundleBuildWrapper wrapper = new AssetBundleBuildWrapper();

            wrapper.bulid      = build;
            wrapper.bundlePath = bundlePath;
            wrapper.entryPath  = entryPath;
            wrapper.node       = node;
            _assetBundleBuildDict.Add(bundlePath, wrapper);
        }
Пример #9
0
        /// <summary>
        /// Folder模式下,匹配结果根据正则表达式中子模式的path值的不同,可以分为多组
        /// </summary>
        /// <param name="assetPathList"></param>
        /// <param name="node"></param>
        /// <returns></returns>
        private static Dictionary <string, List <string> > SplitAssetPathList(List <string> assetPathList, StrategyNode node)
        {
            Dictionary <string, List <string> > result = new Dictionary <string, List <string> >();

            foreach (string s in assetPathList)
            {
                GroupCollection gc   = node.pattern.Match(s).Groups;
                string          path = gc["path"].Value;
                if (result.Keys.Contains(path) == false)
                {
                    result.Add(path, new List <string>()
                    {
                        s
                    });
                }
                else
                {
                    result[path].Add(s);
                }
            }
            return(result);
        }
Пример #10
0
        private static Dictionary <string, string> BuildFolderMode(string entryPath, List <string> assetPathList, StrategyNode node)
        {
            Dictionary <string, string>         result            = new Dictionary <string, string>();
            Dictionary <string, List <string> > splitPathListDict = SplitAssetPathList(assetPathList, node);

            foreach (string k in splitPathListDict.Keys)
            {
                string   bundlePath       = AssetPathHelper.GetFolderModeBundlePath(splitPathListDict[k], node.pattern);
                string[] folderAssetPaths = GetFolderModeAssetPaths(splitPathListDict[k], node);
                foreach (string s in folderAssetPaths)
                {
                    result.Add(s, bundlePath);
                }
                if (CanBuild(entryPath, bundlePath) == false)
                {
                    continue;
                }
                AddAssetBundleBuildWrapper(entryPath, bundlePath, folderAssetPaths, node);
            }
            return(result);
        }