Exemple #1
0
    /// <summary>
    /// 根据步骤获取当前步所有是零件的名称
    /// </summary>
    /// <param name="blockConfigInfo"></param>
    /// <param name="step"></param>
    /// <returns></returns>
    public static List <string> GetPartNameByStep(this PPBlockConfigInfo blockConfigInfo, int step)
    {
        List <string> result = new List <string>();

        if (step < 0 || step >= blockConfigInfo.KeyfameInfos.Count)
        {
            return(null);
        }

        var tarId = blockConfigInfo.KeyfameInfos[step].itemInfos
                    .Where(t => t.IsUnit)
                    .Select(t => t.targetId)
                    .ToList();

        foreach (int index in tarId)
        {
            string name = ((PPBlockInfo)blockConfigInfo.AnimNodeInfos[index]).Prefab;
            if (!result.Contains(name))
            {
                result.Add(name);
            }
        }

        return(result);
    }
        private void InitBlockInfo(string configFile)
        {
            Init();
            if (transform.childCount > 0)
            {
                transform.DestroyAllChild();
            }
            mBlockConfigInfo = PBBlockConfigManager.LoadBlockInfos(configFile);
            mBlocksPartList  = mBlockConfigInfo.GetAllPartInfo();

            mAnimNodes = new Dictionary <int, GameObject>();
        }
    public static void LoadGlobalInfo(XmlDocument xml, PPBlockConfigInfo configInfo)
    {
        configInfo.BoundBox = ReadBoundInfo(xml.SelectSingleNode("config/boundbox"));

        XmlNode xn = xml.SelectSingleNode("config/cameraoffset");

        configInfo.CameraOffsetY = xn != null?float.Parse(xn.Attributes["y"].Value) : PPConstant.CAMERA_OFFSET_Y;

        configInfo.CameraOffsetDepth = xn != null?float.Parse(xn.Attributes["depth"].Value) : PPConstant.CAMERA_OFFSET_DEPTH;

        xn = xml.SelectSingleNode("config/lighting");
        configInfo.LightName = xn != null ? xn.Attributes["data"].Value : PBLighting.DEFAULT;
    }
    /// <summary>
    /// 开放接口:加载block config info
    /// </summary>
    public static void LoadPrefabInfo(XmlDocument xml, PPBlockConfigInfo configInfo)
    {
        var node = xml.SelectSingleNode("config").SelectSingleNode("blocks");

        if (node == null)
        {
            Debug.Log("<color=cyan>【注意】====>当前配置文件不是3.0.0!</color>");
            return;
        }
        ProcessBlockNode(node, configInfo.PrefabInfos);
        ProcessStickerNode(node, configInfo.PrefabInfos);
        ProcessTextureNode(node, configInfo.PrefabInfos);
    }
Exemple #5
0
    /// <summary>
    /// 根据动画帧索引获取帧内block信息
    /// </summary>
    /// <param name="blockConfigInfo"></param>
    /// <param name="frameIndex">帧索引</param>
    /// <returns></returns>
    public static List <PBPartInfo> GetPartInfo(this PPBlockConfigInfo blockConfigInfo, int frameIndex)
    {
        List <PBPartInfo>    resList     = new List <PBPartInfo>();
        Action <PPBlockInfo> addPartInfo = (blockInfo) =>
        {
            if (blockInfo.Hide)
            {
                return;
            }
            PBPartInfo info = resList.Find(p => p.ThumbName.Equals(blockInfo.Thumb));
            if (info == null)
            {
                resList.Add(new PBPartInfo(blockInfo, blockInfo.Count));
            }
            else
            {
                info.Count += blockInfo.Count;
            }
        };

        //获取当前帧所有是零件的targetId
        var tarId = blockConfigInfo.KeyfameInfos[frameIndex].itemInfos
                    .Where(t => t.IsUnit)
                    .Select(t => t.targetId)
                    .ToList();

        foreach (int i in tarId)
        {
            PPAnimNodeInfo pni;
            if (!blockConfigInfo.AnimNodeInfos.TryGetValue(i, out pni))
            {
                continue;
            }

            if (pni.Type == NodeType.Block)
            {
                addPartInfo(pni as PPBlockInfo);
            }
            else
            {
                PPSectionInfo      psi        = pni as PPSectionInfo;
                List <PPBlockInfo> blockInfos = GetBlockInfoBySection(psi);
                foreach (PPBlockInfo blockInfo in blockInfos)
                {
                    addPartInfo(blockInfo);
                }
            }
        }

        return(resList);
    }
        /// <summary>
        /// 搭建获取零件特殊处理 slider会跳值 零件显示当前步骤没有零件不刷新
        /// </summary>
        /// <param name="blockConfigInfo"></param>
        /// <param name="frameIndex"></param>
        /// <returns></returns>
        private List <PBPartInfo> GetPartInfo4BuildBlock(PPBlockConfigInfo blockConfigInfo, int frameIndex)
        {
            List <PBPartInfo> info = null;

            for (int i = frameIndex; i >= 0; --i)
            {
                info = blockConfigInfo.GetPartInfo(i);
                if (info.Count > 0)
                {
                    return(info);
                }
            }
            return(info);
        }
        private static bool CreateBuildingThumbConfigFile(string filePath, List <ResItem> thumbInfoItems, string outputDir, bool isOnline)
        {
            var fileName = Path.GetFileNameWithoutExtension(filePath);

            if (EXCLUDE_BUILDINGS.Contains(fileName))
            {
                return(false);
            }

#if BLOCK_EDITOR
            PPBlockConfigInfo configInfo = PBBlockConfigManager.LoadBlockInfosWithoutAnim(filePath);
#elif BLOCK_MODEL
            var path       = "./" + BlockServerUtil.GetBuildAnimPath(isOnline) + "/" + fileName + ".txt";
            var configText = File.Exists(path) ? File.ReadAllText(path, Encoding.UTF8) : string.Empty;
            PPBlockConfigInfo configInfo = PBBlockConfigManager.LoadBlockInfosWithoutAnim(fileName + ".txt", configText);
            if (configInfo == null)
            {
                Debug.LogError(path + ">>>" + (File.Exists(path) ? "搭建文件内容有问题!" : "搭建文件不存在!"));
                return(false);
            }
#endif
            var buildingThumbs = new ResConfig {
                resversion = "100", items = new List <ResItem>()
            };

            foreach (var item in configInfo.BlockInfos)
            {
                var equal = item.BlockInfo.IsStamp ? item.BlockInfo.GetStampThumb : item.ThumbName;
                if (thumbInfoItems.Any(s => s.name.Equals(equal)))
                {
                    var t = thumbInfoItems.FirstOrDefault(s => s.name.Equals(equal));
                    buildingThumbs.items.Add(t);
                }
                else
                {
                    if (item.ThumbName != "diban")
                    {
                        if (!mThumbErrors.Contains(fileName))
                        {
                            mThumbErrors.Add(fileName);
                        }
                        Debug.LogError(item.ThumbName + ">>>>*找不到缩率图******" + equal + ".png");
                    }
                }
            }

            var config = JsonUtility.ToJson(buildingThumbs, true);
            File.WriteAllText(Path.Combine(outputDir, fileName), config);
            return(true);
        }
Exemple #8
0
    /// <summary>
    /// 根据步骤获取当前步骤所有是零件的ID
    /// </summary>
    /// <param name="blockConfigInfo"></param>
    /// <param name="step"></param>
    /// <returns></returns>
    public static List <int> GetPartIDByStep(this PPBlockConfigInfo blockConfigInfo, int step)
    {
        if (step < 0 || step >= blockConfigInfo.KeyfameInfos.Count)
        {
            return(null);
        }
        List <int> result = new List <int>();

        result = blockConfigInfo.KeyfameInfos[step].itemInfos
                 .Where(t => t.IsUnit)
                 .Select(t => t.targetId)
                 .ToList();

        return(result);
    }
    public static PPObjLoader LoadBlocks(PPBlockConfigInfo blockConfigInfo, Transform parent, Dictionary <int, GameObject> animNodes, LoadConfig loadConfig, Action onFinish = null)
    {
        GameObject obj = new GameObject("PPObjLoader");

        obj.transform.SetParent(RootObj);
        PPObjLoader loader = obj.AddComponent <PPObjLoader>();

        loader.mBlockConfigInfo = blockConfigInfo;
        loader.sectionInfo      = loader.mBlockConfigInfo.SectionInfo;
        loader.parent           = parent;
        loader.mAnimNodes       = animNodes;
        loader.loadConfig       = loadConfig;
        loader.onFinish         = onFinish;
        loader.StartCoroutine(loader.AsyncLoadBlocks());
        return(loader);
    }
    private void CheckConfigs(string prefabName)
    {
        var dirInfo       = new DirectoryInfo(ROOTDIR_BUILDINGANIM);
        var files         = dirInfo.GetFiles("*.txt", SearchOption.TopDirectoryOnly);
        int finishedCount = 0;
        int totalCount    = files.Length;

        if (prefabName.EndsWith(".txt"))
        {
            prefabName = Path.GetFileNameWithoutExtension(prefabName);
        }


        foreach (var file in files)
        {
            string fileName = Path.GetFileNameWithoutExtension(file.FullName);

            if (ResPublisher.EXCLUDE_BUILDINGS.Contains(fileName))
            {
                continue;
            }

            var         configText      = File.ReadAllText(file.FullName);
            var         blockConfigInfo = new PPBlockConfigInfo();
            XmlDocument xml             = new XmlDocument();
            xml.LoadXml(configText);
            PPLiteracy.LoadBlockInfo(xml, blockConfigInfo);

            var configFile = blockConfigInfo.BlockInfos.FirstOrDefault(s => s.PrefabName == prefabName);
            if (configFile != null)
            {
                checkResult.Add(fileName);
            }

            bool result = EditorUtility.DisplayCancelableProgressBar("配置文件过滤", string.Format(fileName + "检测中....{0}/{1}", finishedCount, totalCount), finishedCount * 1.0f / totalCount);
            if (result)
            {
                break;
            }
            finishedCount++;
        }
        EditorUtility.ClearProgressBar();

        EditorUtility.DisplayDialog("配置文件过滤", "完成", "确认");
    }
        private static PPBlockConfigInfo InnerLoadBlockInfos(string configName, string configText, bool loadAnim)
        {
            PPBlockConfigInfo blockConfigInfo = new PPBlockConfigInfo();

            XmlDocument xml = new XmlDocument();

            xml.LoadXml(configText);

            blockConfigInfo.ConfigName = configName;
            PPLiteracy.LoadGlobalInfo(xml, blockConfigInfo);
            PPLiteracy.LoadBlockInfo(xml, blockConfigInfo);
            PBPrefabLiteracy.LoadPrefabInfo(xml, blockConfigInfo);

            if (loadAnim)
            {
                PPLiteracy.LoadFrameInfo(xml, blockConfigInfo);
            }

            xml = null;
            return(blockConfigInfo);
        }
 /// <summary>
 /// 开放接口:加载block config info
 /// </summary>
 public static void LoadBlockInfo(XmlDocument xml, PPBlockConfigInfo configInfo)
 {
     LoadBlockInfo(xml, configInfo.AnimNodeInfos, configInfo.SectionInfo);
 }
        private static bool CreateBuildingModeResFile(string filePath, List <ResItem> modelAbInfoItems, List <ResItem> textureInfoItems, List <PEMaterialUtl.MaterialInfo> materialInfos, string outputDir, bool isOnline)
        {
            var fileName = Path.GetFileNameWithoutExtension(filePath);

            if (ResPublisher.EXCLUDE_BUILDINGS.Contains(fileName))
            {
                return(false);
            }

                        #if BLOCK_EDITOR
            PPBlockConfigInfo configInfo = PBBlockConfigManager.LoadBlockInfosWithoutAnim(filePath);
                        #elif BLOCK_MODEL
//			var path = "./" + BlockServerUtil.GetBuildAnimPath(isOnline) + "/" + fileName + ".txt";
            var path       = "./" + BlockServerUtil.GetBuildAnimPath(isOnline) + "/" + fileName + ".txt";      //here change later
            var configText = File.Exists(path) ? File.ReadAllText(path, Encoding.UTF8) : string.Empty;
            PPBlockConfigInfo configInfo = PBBlockConfigManager.LoadBlockInfosWithoutAnim(fileName, configText);
            if (configInfo == null)
            {
                Debug.LogError(path + ">>>" + (File.Exists(path) ? "搭建文件内容有问题!" : "搭建文件不存在!"));
                return(false);
            }
                        #endif
            var buildingModelResConfig = new ResConfig {
                resversion = "100", items = new List <ResItem>()
            };

            foreach (var item in configInfo.BlockInfos)
            {
                //地板特殊处理,配置表里面没有地板
                if (item.PrefabName == "diban")
                {
                    AddResItem("diban", "Assets/blockres/lowpolygon/category_1/block_fbxs/diban", buildingModelResConfig.items, modelAbInfoItems);
                    continue;
                }

                if (item.PrefabName.StartsWith("sticker"))
                {
                    CreateStickerItem(item.PrefabName, buildingModelResConfig.items, modelAbInfoItems, textureInfoItems);
                    continue;
                }

                var blockData = PBDataBaseManager.Instance.GetDataWithPrefabName(item.PrefabName) as BlockData;

                Category category = (Category)Enum.Parse((typeof(Category)), blockData.category);

                string fbxDir = (BlockPath.Fbx(category, PolygonType.LOW));
                string matDir = (BlockPath.Material(category, PolygonType.LOW));

                AddResItem(blockData.model, (Path.Combine(fbxDir, blockData.model)), buildingModelResConfig.items, modelAbInfoItems);

                CreateMaterials(blockData.material, matDir, buildingModelResConfig.items, modelAbInfoItems, textureInfoItems, materialInfos);

                CreateTextures(item, buildingModelResConfig.items, modelAbInfoItems, textureInfoItems);
            }

            var config = JsonUtility.ToJson(buildingModelResConfig, true);

            File.WriteAllText(Path.Combine(outputDir, fileName), config);

            return(true);
        }
        /// <summary>
        /// 获取config的所有零件列表
        /// </summary>
        public static List <PBPartInfo> GetAllItems(string configFile)
        {
            PPBlockConfigInfo blockConfig = LoadBlockInfos(configFile);

            return(blockConfig.BlockInfos);
        }
 public static PPObjLoader LoadBlocks(PPBlockConfigInfo blockConfigInfo, Transform parent, Dictionary <int, GameObject> animNodes, Action onFinish = null)
 {
     return(LoadBlocks(blockConfigInfo, parent, animNodes, new LoadConfig(), onFinish));
 }
Exemple #16
0
 /// <summary>
 /// 获取全部零件的名称和使用个数信息
 /// </summary>
 public static List <PBPartInfo> GetAllPartInfo(this PPBlockConfigInfo blockConfigInfo)
 {
     return(blockConfigInfo.BlockInfos);
 }
 /// <summary>
 /// 开放接口:加载动画frame info
 /// </summary>
 public static void LoadFrameInfo(XmlDocument xml, PPBlockConfigInfo configInfo)
 {
     LoadFrameInfo(xml, configInfo.KeyfameInfos, configInfo.AnimNodeInfos);
 }
Exemple #18
0
    private static void GetSkuMainConfig_BlockNum_AnimSteps()
    {
        var       content   = File.ReadAllText(PATH_CSV_SKU);
        SkuConfig skuConfig = SkuConfig.LoadConfig(content) as SkuConfig;

        content = File.ReadAllText(PATH_CSV_SKUCAR);
        SkuCarConfig skuCarConfig = SkuCarConfig.LoadConfig(content) as SkuCarConfig;

        List <SkuMainConfig_BlockNum_AnimSteps_Data> dataList = new List <SkuMainConfig_BlockNum_AnimSteps_Data>();

        foreach (SkuItem sku in skuConfig.Items)
        {
            SkuMainConfig_BlockNum_AnimSteps_Data data = new SkuMainConfig_BlockNum_AnimSteps_Data();
            data.SkuID = sku.SkuId;

            if (sku.SkuId == 1002)
            {
                data.Config = "config_01002_sdlr_01_mk";
            }
            else if (sku.SkuId == 1003)
            {
                data.Config = "config_01003_01_Xmas_set";
            }
            else
            {
                SkuCarItem mainCar = skuCarConfig.Items.Find(carItem => carItem.SkuType == sku.ConfigFile && carItem.ConfigFile.EndsWith("01"));
                if (mainCar == null)
                {
                    Debug.LogFormat("<color=yellow> sku {0} 找不到主搭建config!</color>", sku.SkuId);
                    continue;
                }
                data.Config = mainCar.ConfigFile;
            }

            PPBlockConfigInfo configInfo = PBBlockConfigManager.LoadBlockInfos(data.Config + ".txt");
            if (configInfo == null)
            {
                Debug.LogFormat("<color=red> {0} 不存在! </color>", data.Config);
                continue;
            }

            data.BlockNum  = configInfo.BlockNum;
            data.AnimSteps = configInfo.KeyfameInfos.Count - 1;

            dataList.Add(data);
        }

        string exportPath = Application.dataPath.Substring(0, Application.dataPath.IndexOf("Assets")) + "sku统计.xlsx";

        using (ExcelPackage package = new ExcelPackage(new FileInfo(exportPath)))
        {
            ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("info");

            worksheet.Cells[1, 1].Value = "SkuID";
            worksheet.Cells[1, 2].Value = "Config";
            worksheet.Cells[1, 3].Value = "零件数";
            worksheet.Cells[1, 4].Value = "步骤数";

            int rowIndex = 2;
            foreach (SkuMainConfig_BlockNum_AnimSteps_Data data in dataList)
            {
                worksheet.Cells[rowIndex, 1].Value = data.SkuID;
                worksheet.Cells[rowIndex, 2].Value = data.Config;
                worksheet.Cells[rowIndex, 3].Value = data.BlockNum;
                worksheet.Cells[rowIndex, 4].Value = data.AnimSteps;
                rowIndex++;
            }

            package.Save();
        }
    }