Exemplo n.º 1
0
        public override void Process(GameTime gameTime)
        {
            foreach (var animation in Renderer.Game.AnimationEngine.Animations)
            {
                var animInfo = Finder.Cache.GetAnimation(
                    animation.SpriteInfo.FrameName, animation.SpriteInfo.SheetName);
                //Check if the animation has ended (or rather, if it will end one frame from now
                var info = animation.SpriteInfo;
                Finder.IncrementAnimation(ref info, gameTime);
                if (animInfo != null && animInfo.Length.TotalMilliseconds * animation.SpriteInfo.LoopCount
                    < info.PositionInAnimation.TotalMilliseconds)
                {
                    Renderer.Game.AnimationEngine.MarkAnimationCompleted(animation);
                }

                info = animation.SpriteInfo;
                Compositor.AddDrawable(new DrawableObject
                {
                    Mask           = animation.Mask,
                    Rotation       = animation.Rotation,
                    Size           = animation.Size,
                    RotationOrigin = animation.RotationOrigin,
                    Scale          = new Vector2(1),
                    Position       = animation.Position,
                    Rectangle      = new Engine.Core.RectangleF(0, 0, animation.Size.X, animation.Size.Y),
                    Texture        = Finder.RetrieveAsset(ref info)
                }, animation.DrawLayer);
                Finder.IncrementAnimation(ref info, gameTime);
                animation.SpriteInfo = info;
            }
        }
Exemplo n.º 2
0
        public override void Process(GameTime gameTime)
        {
            foreach (var obj in Game.GameObjects)
            {
                foreach (var component in obj.Components.Values)
                {
                    var info  = component.SpriteInfo;
                    var asset = Finder.RetrieveAsset(ref info);
                    if (info.IsAnimation)
                    {
                        Finder.IncrementAnimation(ref info, gameTime);
                        component.SpriteInfo = info;
                    }

                    var physCompensation =
                        new Vector2(Renderer.PhysicsCompensation, Renderer.PhysicsCompensation) /
                        (obj.Scale * component.Scale);

                    Color mask;
                    if (component.IgnoresObjectMask)
                    {
                        mask = component.Mask;
                    }
                    else
                    {
                        mask = new Color(component.Mask.ToVector4() * obj.ColorMask.ToVector4());
                    }

                    Compositor.AddDrawable(new DrawableObject
                    {
                        Mask           = mask,
                        Position       = obj.Position,
                        Rotation       = component.Rotation,
                        ObjectRotation = obj.Rotation,
                        RotationOrigin = component.RotationOrigin + component.Offset,
                        Scale          = obj.Scale * component.Scale,
                        Rectangle      = new RectangleF(component.Offset.X - physCompensation.X,
                                                        component.Offset.Y - physCompensation.Y,
                                                        component.Size.X + physCompensation.X * 2, component.Size.Y + physCompensation.Y * 2),
                        Size    = obj.DefaultSize,
                        Texture = asset
                    }, component.DrawLayer + obj.DrawLayer);
                }
            }
        }