Esempio n. 1
0
 public UIAnimationPlayer(string filePath)
 {
     base.Clip = true;
     if (filePath != null)
     {
         UIAnimationPlayer.UIAnimationData uIAnimationData = new UIAnimationPlayer.UIAnimationData();
         uIAnimationData.ReadFromFile(filePath);
         this.SetSize(uIAnimationData.header.width, uIAnimationData.header.height);
         this.BackgroundColor = new UIColor(uIAnimationData.header.backgroundColorR / 255f, uIAnimationData.header.backgroundColorG / 255f, uIAnimationData.header.backgroundColorB / 255f, 1f);
         if (uIAnimationData.rootSymbol != null && uIAnimationData.rootSymbol.timeLines != null && uIAnimationData.rootSymbol.timeLines[0] != null && uIAnimationData.rootSymbol.timeLines[0].layers != null)
         {
             this.rootLayer = new UIAnimationPlayer.Layer();
             this.rootLayer.timeLineForChildren.FrameRate = uIAnimationData.header.frameRate;
             this.rootLayer.AnimationStopped += new EventHandler <EventArgs>(this.OnRootLayoutAnimationStoped);
             using (List <UIAnimationPlayer.UIAnimationData.Layer> .Enumerator enumerator = uIAnimationData.rootSymbol.timeLines[0].layers.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     UIAnimationPlayer.UIAnimationData.Layer current = enumerator.Current;
                     UIAnimationPlayer.Layer layer = new UIAnimationPlayer.Layer();
                     uint num = layer.InitLayer(this.rootLayer, current, 0f, 0f, uIAnimationData);
                     this.rootLayer.transformRoot.AddChildLast(layer);
                     this.rootLayer.childLayers.Add(layer);
                     if (this.rootLayer.timeLineForChildren.Duration < num)
                     {
                         this.rootLayer.timeLineForChildren.Duration = num;
                     }
                 }
             }
             this.rootLayer.Repeating = uIAnimationData.header.repeating;
             this.Width  = uIAnimationData.header.width;
             this.Height = uIAnimationData.header.height;
             this.AddChildLast(this.rootLayer);
         }
     }
 }
Esempio n. 2
0
            public uint InitLayer(UIAnimationPlayer.Layer parent, UIAnimationPlayer.UIAnimationData.Layer layerData, float x, float y, UIAnimationPlayer.UIAnimationData data)
            {
                uint        num       = 0u;
                List <uint> list      = new List <uint>();
                List <uint> list2     = new List <uint>();
                UIMotion    uIMotion  = null;
                UIMotion    uIMotion2 = null;

                this.timeLineForChildren.FrameRate = data.header.frameRate;
                this.SetPosition(x, y);
                using (List <UIAnimationPlayer.UIAnimationData.Frame> .Enumerator enumerator = layerData.frames.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        UIAnimationPlayer.UIAnimationData.Frame current = enumerator.Current;
                        if (current.instance != null)
                        {
                            UIAnimationPlayer.UIAnimationData.Instance instance = current.instance;
                            if (instance.header.hasBitmap && !list.Contains(instance.header.bitmapId))
                            {
                                this.SetPosition(x + instance.header.translationX + instance.header.matrix41, y + instance.header.translationY + instance.header.matrix42);
                                Widget widget = this.CreateBitmap(data.bitmaps[(int)instance.header.bitmapId]);
                                widget.SetSize(widget.Width * instance.header.scaleX, widget.Height * instance.header.scaleY);
                                this.transformRoot.AddChildLast(widget);
                                list.Add(instance.header.bitmapId);
                            }
                            if (instance.header.hasSymbol && !list2.Contains(instance.header.symbolId))
                            {
                                this.transformRoot.SetPosition(instance.header.transPointX, instance.header.transPointY);
                                this.SetPosition(x + instance.header.translationX + instance.header.matrix41, y + instance.header.translationY + instance.header.matrix42);
                                UIAnimationPlayer.UIAnimationData.Symbol symbol = data.symbols[(int)instance.header.symbolId];
                                using (List <UIAnimationPlayer.UIAnimationData.Layer> .Enumerator enumerator2 = symbol.timeLines[0].layers.GetEnumerator())
                                {
                                    while (enumerator2.MoveNext())
                                    {
                                        UIAnimationPlayer.UIAnimationData.Layer current2 = enumerator2.Current;
                                        UIAnimationPlayer.Layer layer = new UIAnimationPlayer.Layer();
                                        uint num2 = layer.InitLayer(this, current2, -instance.header.transPointX, -instance.header.transPointY, data);
                                        this.transformRoot.AddChildLast(layer);
                                        this.childLayers.Add(layer);
                                        if (this.timeLineForChildren.Duration < num2)
                                        {
                                            this.timeLineForChildren.Duration = num2;
                                        }
                                    }
                                }
                                list2.Add(instance.header.symbolId);
                            }
                            if (current.header.hasMotion)
                            {
                                UIMotion uIMotion3 = new UIMotion(this.transformRoot, current.motion);
                                this.motions.Add(uIMotion3);
                                if (uIMotion != null)
                                {
                                    uIMotion.EffectStopped -= new EventHandler <EventArgs>(this.OnEffectStopped);
                                }
                                uIMotion3.EffectStopped += new EventHandler <EventArgs>(this.OnEffectStopped);
                                this.motionStartTimes.Add(uIMotion3, this.timeLineForChildren.GetTimeFromFrameIndex(current.header.index));
                                uIMotion2 = uIMotion3;
                                uIMotion  = uIMotion3;
                            }
                            else
                            {
                                uIMotion = null;
                            }
                            this.instanceName = instance.name;
                            this.timeLineForChildren.Repeating = instance.header.repeating;
                            uint num3 = current.header.index + current.header.duration;
                            if (num < num3)
                            {
                                num = num3;
                            }
                        }
                    }
                }
                if (uIMotion2 != null)
                {
                    uIMotion2.EffectStopped -= new EventHandler <EventArgs>(this.OnEffectStopped);
                }
                this.initialTransform3Droot  = this.Transform3D;
                this.initialTransform3Dtroot = this.transformRoot.Transform3D;
                return(num);
            }