예제 #1
0
    private static void OrderLoadList_Keyframe(List <LoadNodeInfo> loadList, PPSectionInfo sectionInfo, int parentID, List <PPKeyFrameInfo> keyframeInfos)
    {
        //1. determine the parent of each node
        //	all section nodes will be added into loadList in advance, because sections will be all created before blocks.
        Dictionary <int, LoadNodeInfo> dict = new Dictionary <int, LoadNodeInfo>();

        PrepareLoadNodeInfos(loadList, dict, sectionInfo, parentID);

        //2. order by keyframes.
        HashSet <int> indexSet = new HashSet <int>();

        foreach (PPKeyFrameInfo keyframe in keyframeInfos)
        {
            foreach (PPFrameItemInfo keyframeItem in keyframe.itemInfos)
            {
                if (!dict.ContainsKey(keyframeItem.targetId))
                {
                    continue;
                }

                if (indexSet.Contains(keyframeItem.targetId))
                {
                    loadList.RemoveAt(loadList.FindIndex(l => l.nodeInfo.Id == keyframeItem.targetId));
                }

                indexSet.Add(keyframeItem.targetId);
                loadList.Add(dict[keyframeItem.targetId]);
            }
        }

        //3. load blocks not in keyframes, and load hide blocks
        dict.Values.Where(info => !indexSet.Contains(info.nodeInfo.Id) || ((PPBlockInfo)info.nodeInfo).Hide).ForEach(loadList.Add);
    }
예제 #2
0
 public PPBlockConfigInfo()
 {
     AnimNodeInfos = new Dictionary <int, PPAnimNodeInfo>();
     SectionInfo   = new PPSectionInfo();
     KeyfameInfos  = new List <PPKeyFrameInfo>();
     PrefabInfos   = new List <PPPrefabInfo>();
 }
예제 #3
0
    private static void ProcessNodes(XmlNode node, Dictionary <int, PPAnimNodeInfo> animNodeInfos, PPSectionInfo parentSection)
    {
        XmlNodeList sections = node.SelectNodes("section");

        for (int i = 0; i < sections.Count; i++)
        {
            XmlNode       sectionNode = sections[i];
            PPSectionInfo sectionInfo = new PPSectionInfo();
            sectionInfo.Index = sectionInfo.Id = int.Parse(sectionNode.Attributes["id"].Value);
            sectionInfo.Name  = sectionNode.Attributes["name"] != null ? sectionNode.Attributes["name"].Value : "section_" + sectionInfo.Index;
            sectionInfo.Type  = NodeType.Section;

            XmlNode editorNode = sectionNode.SelectSingleNode("editor");
            editorNode.GetPosInfo(out sectionInfo.EditorPos)
            .GetAngleInfo(out sectionInfo.EditorAngle);

            //for versatile
            PBVersatileInterface.LoadFromXml(sectionNode, sectionInfo.VersatileInfo);

            animNodeInfos.Add(sectionInfo.Index, sectionInfo);
            parentSection.AddSubNode(sectionInfo);

            ProcessNodes(sectionNode, animNodeInfos, sectionInfo);
        }

        XmlNodeList blocks = node.SelectNodes("block");

        for (int i = 0; i < blocks.Count; i++)
        {
            XmlNode     blockNode  = blocks[i];
            PPBlockInfo blockInfo  = new PPBlockInfo();
            XmlNode     editorNode = blockNode.SelectSingleNode("editor");
            editorNode.GetPosInfo(out blockInfo.EditorPos)
            .GetAngleInfo(out blockInfo.EditorAngle);

            blockInfo.Prefab = blockNode.Attributes["type"].Value;
            blockInfo.Thumb  = blockNode.Attributes["thumb"] != null ? blockNode.Attributes["thumb"].Value : blockInfo.Prefab;
            blockInfo.Detail = blockNode.Attributes["partDetail"] != null ? blockNode.Attributes["partDetail"].Value : "";
            blockInfo.Count  = blockNode.Attributes["count"] != null?int.Parse(blockNode.Attributes["count"].Value) : 1;

            blockInfo.Hide  = blockNode.Attributes["hide"] != null && blockNode.Attributes["hide"].Value.Equals("1");
            blockInfo.Type  = NodeType.Block;
            blockInfo.Index = blockInfo.Id = int.Parse(blockNode.Attributes["id"].Value);

            //for textures
            blockInfo.ParseTextures(blockNode.SelectNodes("texture"));

            //for versatile blocks
            PBVersatileInterface.LoadFromXml(blockNode, blockInfo.VersatileInfo);

            animNodeInfos.Add(blockInfo.Index, blockInfo);
            parentSection.AddSubNode(blockInfo);
        }
    }
예제 #4
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);
    }
예제 #5
0
    private GameObject InnerLoadSection(PPSectionInfo nodeInfo, Transform parent)
    {
        GameObject section = new GameObject(nodeInfo.Name);

        section.transform.SetParent(parent, false);

        PBSection pbsection = section.AddComponent <PBSection>();

        pbsection.animNodeInfo = nodeInfo;
        pbsection.Init();

        mAnimNodes.Add(nodeInfo.Id, section);
        return(section);
    }
예제 #6
0
 private static void OrderLoadList_Default(List <LoadNodeInfo> loadList, PPSectionInfo sectionInfo, int parentID)
 {
     foreach (PPAnimNodeInfo nodeInfo in sectionInfo.NodeInfos)
     {
         if (nodeInfo.Type == NodeType.Section)
         {
             loadList.Add(new LoadNodeInfo {
                 nodeInfo = nodeInfo, parentID = parentID
             });
             OrderLoadList_Default(loadList, (PPSectionInfo)nodeInfo, nodeInfo.Id);
         }
         else if (nodeInfo.Type == NodeType.Block)
         {
             loadList.Add(new LoadNodeInfo {
                 nodeInfo = nodeInfo, parentID = parentID
             });
         }
     }
 }
예제 #7
0
    private static List <PPBlockInfo> GetBlockInfoBySection(PPSectionInfo sectionInfo)
    {
        List <PPBlockInfo> res = new List <PPBlockInfo>();

        List <PPAnimNodeInfo> nodeInfos = sectionInfo.NodeInfos;
        int length = nodeInfos.Count;

        for (int i = 0; i < length; i++)
        {
            if (nodeInfos[i].Type == NodeType.Block)
            {
                res.Add(nodeInfos[i] as PPBlockInfo);
            }
            else
            {
                res.AddRange(GetBlockInfoBySection(nodeInfos[i] as PPSectionInfo));
            }
        }
        return(res);
    }
예제 #8
0
    private static List <LoadNodeInfo> OrderLoadList(LoadConfig config, PPSectionInfo sectionInfo)
    {
        List <LoadNodeInfo> loadList = new List <LoadNodeInfo>();

        switch (config.loadOrder)
        {
        case LoadOrder.Keyframe:
            if (config.keyframeInfos.Count > 0)
            {
                OrderLoadList_Keyframe(loadList, sectionInfo, -1, config.keyframeInfos);
            }
            else
            {
                OrderLoadList_Default(loadList, sectionInfo, -1);
                Debug.Log("<color=yellow>Config没有搭建动画!</color>");
            }
            break;

        default:
            OrderLoadList_Default(loadList, sectionInfo, -1);
            break;
        }
        return(loadList);
    }
예제 #9
0
 private static void PrepareLoadNodeInfos(List <LoadNodeInfo> loadList, Dictionary <int, LoadNodeInfo> blockInfoDict, PPSectionInfo sectionInfo, int parentID)
 {
     foreach (PPAnimNodeInfo nodeInfo in sectionInfo.NodeInfos)
     {
         if (nodeInfo.Type == NodeType.Section)
         {
             loadList.Add(new LoadNodeInfo {
                 nodeInfo = nodeInfo, parentID = parentID
             });
             PrepareLoadNodeInfos(loadList, blockInfoDict, (PPSectionInfo)nodeInfo, nodeInfo.Id);
         }
         else if (nodeInfo.Type == NodeType.Block)
         {
             blockInfoDict.Add(nodeInfo.Id, new LoadNodeInfo {
                 nodeInfo = nodeInfo, parentID = parentID
             });
         }
     }
 }
예제 #10
0
    /// <summary>
    /// 非开放接口
    /// </summary>
    private static void LoadBlockInfo(XmlDocument xml, Dictionary <int, PPAnimNodeInfo> animNodeInfos, PPSectionInfo parentSection)
    {
        var node = xml.SelectSingleNode("config").SelectSingleNode("section");

        ProcessNodes(node, animNodeInfos, parentSection);
    }
예제 #11
0
 public PPEffectConfigInfo()
 {
     AnimNodeInfos = new Dictionary <int, PPAnimNodeInfo>();
     SectionInfo   = new PPSectionInfo();
     EffectInfos   = new List <PPEffectInfo>();
 }