예제 #1
0
    public void Deserialize(string animName)
    {
        XmlSerializer xmlSerializer = new XmlSerializer(typeof(UiAnimation.UiSourceAnimation));

        xmlSerializer.add_UnknownNode(new XmlNodeEventHandler(this.serializer_UnknownNode));
        xmlSerializer.add_UnknownAttribute(new XmlAttributeEventHandler(this.serializer_UnknownAttribute));
        TextAsset sourceData = UiAnimMgr.instance.GetSourceData(animName);

        if (sourceData == null)
        {
            Debug.Log("Could not find asset " + animName);
            return;
        }
        MemoryStream memoryStream = new MemoryStream(sourceData.get_bytes());

        UiAnimation.UiSourceAnimation uiSourceAnimation = xmlSerializer.Deserialize(memoryStream) as UiAnimation.UiSourceAnimation;
        memoryStream.Close();
        if (uiSourceAnimation == null)
        {
            Debug.Log("No ui animation.");
            return;
        }
        this.m_frame = uiSourceAnimation.frame;
        using (List <UiAnimation.UiSourceAnimGroup> .Enumerator enumerator = uiSourceAnimation.frame.animation.groups.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                UiAnimation.UiSourceAnimGroup current     = enumerator.get_Current();
                UiAnimation.UiAnimGroup       uiAnimGroup = new UiAnimation.UiAnimGroup();
                uiAnimGroup.m_parentKey  = current.parentKey;
                uiAnimGroup.m_bounceBack = false;
                if (current.looping == null)
                {
                    uiAnimGroup.m_looping = false;
                    uiAnimGroup.m_bounce  = false;
                }
                else if (current.looping == "REPEAT")
                {
                    uiAnimGroup.m_looping = true;
                    uiAnimGroup.m_bounce  = false;
                }
                else if (current.looping == "BOUNCE")
                {
                    uiAnimGroup.m_looping = true;
                    uiAnimGroup.m_bounce  = true;
                }
                using (List <UiAnimation.UiScale> .Enumerator enumerator2 = current.m_scales.GetEnumerator())
                {
                    while (enumerator2.MoveNext())
                    {
                        UiAnimation.UiScale current2 = enumerator2.get_Current();
                        if (current2.m_childKey != null)
                        {
                            current2.SetSmoothing();
                            uiAnimGroup.m_elements.Add(current2);
                        }
                    }
                }
                using (List <UiAnimation.UiAlpha> .Enumerator enumerator3 = current.m_alphas.GetEnumerator())
                {
                    while (enumerator3.MoveNext())
                    {
                        UiAnimation.UiAlpha current3 = enumerator3.get_Current();
                        if (current3.m_childKey != null)
                        {
                            current3.SetSmoothing();
                            uiAnimGroup.m_elements.Add(current3);
                        }
                    }
                }
                using (List <UiAnimation.UiRotation> .Enumerator enumerator4 = current.m_rotations.GetEnumerator())
                {
                    while (enumerator4.MoveNext())
                    {
                        UiAnimation.UiRotation current4 = enumerator4.get_Current();
                        if (current4.m_childKey != null)
                        {
                            current4.SetSmoothing();
                            uiAnimGroup.m_elements.Add(current4);
                        }
                    }
                }
                using (List <UiAnimation.UiTranslation> .Enumerator enumerator5 = current.m_translations.GetEnumerator())
                {
                    while (enumerator5.MoveNext())
                    {
                        UiAnimation.UiTranslation current5 = enumerator5.get_Current();
                        if (current5.m_childKey != null)
                        {
                            current5.SetSmoothing();
                            uiAnimGroup.m_elements.Add(current5);
                        }
                    }
                }
                this.m_groups.Add(uiAnimGroup);
            }
        }
        using (List <UiAnimation.UiLayer> .Enumerator enumerator6 = uiSourceAnimation.frame.layers.GetEnumerator())
        {
            while (enumerator6.MoveNext())
            {
                UiAnimation.UiLayer current6 = enumerator6.get_Current();
                using (List <UiAnimation.UiSourceTexture> .Enumerator enumerator7 = current6.textures.GetEnumerator())
                {
                    UiAnimation.UiSourceTexture texture;
                    while (enumerator7.MoveNext())
                    {
                        texture = enumerator7.get_Current();
                        if (texture.m_parentKey != null)
                        {
                            UiAnimation.UiTexture uiTexture;
                            this.m_textures.TryGetValue(texture.m_parentKey, ref uiTexture);
                            if (uiTexture != null)
                            {
                                Debug.Log("Found duplicate texture " + texture.m_parentKey);
                            }
                            else
                            {
                                int textureAtlasMemberID = 0;
                                StaticDB.uiTextureAtlasMemberDB.EnumRecords(delegate(UiTextureAtlasMemberRec memberRec)
                                {
                                    if (memberRec.CommittedName != null && texture.m_atlas != null && memberRec.CommittedName.ToLower() == texture.m_atlas.ToLower())
                                    {
                                        textureAtlasMemberID = memberRec.ID;
                                        return(false);
                                    }
                                    return(true);
                                });
                                if (textureAtlasMemberID > 0)
                                {
                                    Sprite sprite = TextureAtlas.GetSprite(textureAtlasMemberID);
                                    if (sprite != null)
                                    {
                                        UiAnimation.UiTexture uiTexture2 = new UiAnimation.UiTexture();
                                        uiTexture2.m_alpha     = texture.m_alpha;
                                        uiTexture2.m_alphaMode = texture.m_alphaMode;
                                        uiTexture2.m_anchor    = ((texture.m_anchors.get_Count() <= 0) ? null : texture.m_anchors.ToArray()[0]);
                                        uiTexture2.m_atlas     = texture.m_atlas;
                                        uiTexture2.m_hidden    = texture.m_hidden;
                                        uiTexture2.m_parentKey = texture.m_parentKey;
                                        uiTexture2.m_sprite    = sprite;
                                        this.m_textures.Add(texture.m_parentKey, uiTexture2);
                                    }
                                    else
                                    {
                                        Debug.Log(string.Concat(new object[]
                                        {
                                            "Could not find sprite for textureAtlasMemberID ",
                                            textureAtlasMemberID,
                                            " in Ui Animation ",
                                            animName
                                        }));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        List <UiAnimation.UiAnimElement> list = new List <UiAnimation.UiAnimElement>();

        using (List <UiAnimation.UiAnimGroup> .Enumerator enumerator8 = this.m_groups.GetEnumerator())
        {
            while (enumerator8.MoveNext())
            {
                UiAnimation.UiAnimGroup current7 = enumerator8.get_Current();
                current7.m_maxTime = 0f;
                using (List <UiAnimation.UiAnimElement> .Enumerator enumerator9 = current7.m_elements.GetEnumerator())
                {
                    while (enumerator9.MoveNext())
                    {
                        UiAnimation.UiAnimElement current8   = enumerator9.get_Current();
                        UiAnimation.UiTexture     uiTexture3 = null;
                        this.m_textures.TryGetValue(current8.m_childKey, ref uiTexture3);
                        if (uiTexture3 != null)
                        {
                            current8.m_texture = uiTexture3;
                            float totalTime = current8.GetTotalTime();
                            if (totalTime > current7.m_maxTime)
                            {
                                current7.m_maxTime = totalTime;
                            }
                        }
                        else
                        {
                            list.Add(current8);
                            Debug.Log("Removing element with childKey " + current8.m_childKey + ", no associated texture was found.");
                        }
                    }
                }
                using (List <UiAnimation.UiAnimElement> .Enumerator enumerator10 = list.GetEnumerator())
                {
                    while (enumerator10.MoveNext())
                    {
                        UiAnimation.UiAnimElement current9 = enumerator10.get_Current();
                        current7.m_elements.Remove(current9);
                    }
                }
            }
        }
    }
예제 #2
0
    public void Deserialize(string animName)
    {
        XmlSerializer xmlSerializer = new XmlSerializer(typeof(UiAnimation.UiSourceAnimation));

        xmlSerializer.UnknownNode      += this.serializer_UnknownNode;
        xmlSerializer.UnknownAttribute += this.serializer_UnknownAttribute;
        TextAsset sourceData = UiAnimMgr.instance.GetSourceData(animName);

        if (sourceData == null)
        {
            Debug.Log("Could not find asset " + animName);
            return;
        }
        MemoryStream memoryStream = new MemoryStream(sourceData.bytes);

        UiAnimation.UiSourceAnimation uiSourceAnimation = xmlSerializer.Deserialize(memoryStream) as UiAnimation.UiSourceAnimation;
        memoryStream.Close();
        if (uiSourceAnimation == null)
        {
            Debug.Log("No ui animation.");
            return;
        }
        this.m_frame = uiSourceAnimation.frame;
        foreach (UiAnimation.UiSourceAnimGroup uiSourceAnimGroup in uiSourceAnimation.frame.animation.groups)
        {
            UiAnimation.UiAnimGroup uiAnimGroup = new UiAnimation.UiAnimGroup();
            uiAnimGroup.m_parentKey  = uiSourceAnimGroup.parentKey;
            uiAnimGroup.m_bounceBack = false;
            if (uiSourceAnimGroup.looping == null)
            {
                uiAnimGroup.m_looping = false;
                uiAnimGroup.m_bounce  = false;
            }
            else if (uiSourceAnimGroup.looping == "REPEAT")
            {
                uiAnimGroup.m_looping = true;
                uiAnimGroup.m_bounce  = false;
            }
            else if (uiSourceAnimGroup.looping == "BOUNCE")
            {
                uiAnimGroup.m_looping = true;
                uiAnimGroup.m_bounce  = true;
            }
            foreach (UiAnimation.UiScale uiScale in uiSourceAnimGroup.m_scales)
            {
                if (uiScale.m_childKey != null)
                {
                    uiScale.SetSmoothing();
                    uiAnimGroup.m_elements.Add(uiScale);
                }
            }
            foreach (UiAnimation.UiAlpha uiAlpha in uiSourceAnimGroup.m_alphas)
            {
                if (uiAlpha.m_childKey != null)
                {
                    uiAlpha.SetSmoothing();
                    uiAnimGroup.m_elements.Add(uiAlpha);
                }
            }
            foreach (UiAnimation.UiRotation uiRotation in uiSourceAnimGroup.m_rotations)
            {
                if (uiRotation.m_childKey != null)
                {
                    uiRotation.SetSmoothing();
                    uiAnimGroup.m_elements.Add(uiRotation);
                }
            }
            foreach (UiAnimation.UiTranslation uiTranslation in uiSourceAnimGroup.m_translations)
            {
                if (uiTranslation.m_childKey != null)
                {
                    uiTranslation.SetSmoothing();
                    uiAnimGroup.m_elements.Add(uiTranslation);
                }
            }
            this.m_groups.Add(uiAnimGroup);
        }
        foreach (UiAnimation.UiLayer uiLayer in uiSourceAnimation.frame.layers)
        {
            using (List <UiAnimation.UiSourceTexture> .Enumerator enumerator7 = uiLayer.textures.GetEnumerator())
            {
                while (enumerator7.MoveNext())
                {
                    UiAnimation.< Deserialize > c__AnonStorey0 <Deserialize> c__AnonStorey = new UiAnimation.< Deserialize > c__AnonStorey0();