Beispiel #1
0
        public void Destroy()
        {
            if (null != m_animationsWithAttach)
            {
                var itor = m_animationsWithAttach.GetEnumerator();
                while (itor.MoveNext())
                {
                    Dictionary <RoleAnimationType, MeshAnimation> animDict = itor.Current.Value;
                    if (null != animDict)
                    {
                        var animItor = animDict.GetEnumerator();
                        while (animItor.MoveNext())
                        {
                            animItor.Current.Value.Destory();
                        }

                        animItor.Dispose();
                        animDict.Clear();
                    }
                }

                itor.Dispose();
                m_animationsWithAttach.Clear();
                m_animationsWithAttach = null;
            }

            m_animationsData = null;

            if (null != m_groupData)
            {
                m_groupData.Destory();
                m_groupData = null;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MeshAnimationGroup"/> class.
        /// </summary>
        /// <param name="pData">Mesh animation group data</param>
        public MeshAnimationGroup(MeshAnimationGroupData pData)
        {
            Fps         = pData.Fps;
            FrameLength = 1f / Fps;
            //ModelName = pData.ModelName;
            BoneNames = pData.BoneNames;

            m_groupData = pData;
            BuildAnimationsWithAttach(pData);
        }
Beispiel #3
0
        private void BuildAnimationsWithAttach(MeshAnimationGroupData pData)
        {
            m_animationsWithAttach = new Dictionary <int, Dictionary <RoleAnimationType, MeshAnimation> >();
            m_animationsData       = new Dictionary <RoleAnimationType, AnimationData>(new RoleAnimationTypeCompare());
            AttachCount            = pData.AttachCount;

            for (int i = 0; i < pData.AttachCount; i++)
            {
                Dictionary <string, MeshAnimationData> animDataDict;
                bool hasData = pData.AnimationsWithAttach.TryGetValue(i, out animDataDict);
                if (hasData)
                {
                    var itor = animDataDict.GetEnumerator();
                    Dictionary <RoleAnimationType, MeshAnimation> animDict =
                        new Dictionary <RoleAnimationType, MeshAnimation>(new RoleAnimationTypeCompare());
                    m_animationsWithAttach.Add(i, animDict);
                    while (itor.MoveNext())
                    {
                        Vector2[] pUv        = pData.Uv[i];
                        int[]     pTriangles = pData.Triangles[i];

                        MeshAnimation animation = new MeshAnimation(pUv, pTriangles, itor.Current.Value);
                        string        animName  = itor.Current.Key;

                        RoleAnimationType animType;
                        AnimationType.AnimationTypeConvert.TryGetValue(animName, out animType);

                        animDict.Add(animType, animation);

                        //只获取firstattach的数据
                        if (i == 0)
                        {
                            AnimationData data = new AnimationData();
                            data.Name       = animName;
                            data.FrameCount = itor.Current.Value.FrameCount;

                            data.Type = animType;
                            m_animationsData.Add(animType, data);
                        }
                    }

                    itor.Dispose();
                }
            }
        }
        public void LoadAnimationGroupSkinData(int pUnitId, string pActorName, MeshSkinData skinData,
                                               Action <MeshAnimationGroup> pCallback)
        {
            MeshAnimationGroup group;

            if (m_cachedGroups.TryGetValue(pUnitId, out group))
            {
                if (null != group && null != pCallback)
                {
                    pCallback(group);
                }
            }
            else
            {
                if (pCallback != null)
                {
                    m_callbacks.Add(pUnitId, pCallback);
                }

                MeshAnimationGroupData groupData = new MeshAnimationGroupData(skinData);
                groupData.BuildAnim(skinData);

                group = groupData.GetAnimationGroup();
                if (null == group)
                {
                    return;
                }

                m_cachedGroups[pUnitId] = group;
                if (m_callbacks.Count(pUnitId) > 0)
                {
                    foreach (Action <MeshAnimationGroup> callback in m_callbacks.Get(pUnitId))
                    {
                        if (callback != null)
                        {
                            callback(group);
                        }
                    }

                    m_callbacks.Clear(pUnitId);
                }
            }
        }