Exemple #1
0
        public override bool Update(EntityWorld world, Entity entity)
        {
            if (_complete)
                return true;

            float delta = (float)world.GameTime.ElapsedGameTime.TotalSeconds;

            if (Time == 0)
                Begin(world, entity);
            Time += delta;

            _complete = Time >= Duration;
            float percent = 1;

            if (!_complete) {
                percent = Time / Duration;
                if (Interpolation != null)
                    percent = Interpolation.Apply(percent);
            }

            Update(world, entity, IsReverse ? 1 - percent : percent);
            if (_complete)
                End(world, entity);

            return _complete;
        }
        public override void Render(SpriteBatch spriteBatch, EntityWorld world, Entity e, Renderable position)
        {
            DirectionComponent directionCom = null;
            ActivityComponent activityCom = null;

            foreach (IComponent com in world.EntityManager.GetComponents(e)) {
                if (com is DirectionComponent)
                    directionCom = com as DirectionComponent;
                if (com is ActivityComponent)
                    activityCom = com as ActivityComponent;
            }

            if (directionCom != null && directionCom.Direction != _sprite.CurrentDirection) {
                _sprite.CurrentDirection = directionCom.Direction;
                _sprite.CurrentSequence.Restart();
            }

            if (activityCom != null && activityCom.Activity != _sprite.CurrentAnimationSet) {
                if (_record.ActivityMap.ContainsKey(activityCom.Activity))
                    _sprite.CurrentAnimationSet = _record.ActivityMap[activityCom.Activity];
                else
                    _sprite.CurrentAnimationSet = _record.DefaultAnimation;
                _sprite.CurrentSequence.Restart();
            }

            _sprite.Update(world.GameTime);

            _sprite.Draw(spriteBatch, new PointFP(position.RenderX, position.RenderY));
        }
        public void Initialize(EntityWorld world)
        {
            world.SystemManager.SystemAdded += HandleSystemAdded;

            foreach (BaseSystem system in world.SystemManager.Systems) {
                HandleSystemAdded(system);
            }
        }
        protected override void Begin(EntityWorld world, Entity entity)
        {
            RenderSystem = world.SystemManager.GetSystem<RenderSystem>();
            if (RenderSystem == null) {
                Finish();
                return;
            }

            IRenderEffects renderEffects = GetRenderEffects(world.EntityManager.GetComponent<Renderable>(entity));
            if (renderEffects == null) {
                Finish();
                return;
            }

            Begin(renderEffects);
        }
        public override void Render(SpriteBatch spriteBatch, EntityWorld world, Entity e, Renderable position)
        {
            DirectionComponent directionCom = null;

            foreach (IComponent com in world.EntityManager.GetComponents(e)) {
                if (com is DirectionComponent) {
                    directionCom = com as DirectionComponent;
                    break;
                }
            }

            if (directionCom != null && directionCom.Direction != _sprite.CurrentDirection) {
                _sprite.CurrentDirection = directionCom.Direction;
                _sprite.CurrentSequence.Restart();
            }

            _sprite.Update(world.GameTime);

            _sprite.Draw(spriteBatch, new PointFP(position.RenderX, position.RenderY));
        }
        public SpriteRenderLayer(EntityWorld world, SpriteBatch spriteBatch)
        {
            _manager = new SpriteRenderManager(world, spriteBatch);

            InitOptions();
        }
        public SpriteRenderLayer(EntityWorld world)
        {
            _manager = new SpriteRenderManager(world);

            InitOptions();
        }
Exemple #8
0
 protected virtual void Begin(EntityWorld world, Entity entity)
 {
 }
 protected override void Update(EntityWorld world, Entity entity, float percent)
 {
     IRenderEffects renderEffects = GetRenderEffects(world.EntityManager.GetComponent<Renderable>(entity));
     if (renderEffects != null)
         Update(renderEffects, percent);
 }
Exemple #10
0
        public override void Render(SkeletonRenderer skeletonRenderer, EntityWorld world, Entity entity, Renderable position)
        {
            ActivityComponent activityCom = null;
            DirectionComponent directionCom = null;

            foreach (IComponent com in world.EntityManager.GetComponents(entity)) {
                if (com is ActivityComponent)
                    activityCom = com as ActivityComponent;
                else if (com is DirectionComponent)
                    directionCom = com as DirectionComponent;
            }

            if (activityCom != null && activityCom.Activity != _activity) {
                _activity = activityCom.Activity;

                string animationKey = null;
                if (!_record.ActivityMap.TryGetValue(activityCom.Activity, out animationKey))
                    animationKey = _record.DefaultAnimation;

                string animation = "";
                bool flipX = false;
                bool flipY = false;

                if (animationKey != null) {
                    if (directionCom != null && _record.DirectedAnimationMap.ContainsKey(animationKey)) {
                        if (_record.DirectedAnimationMap[animationKey].ContainsKey(directionCom.Direction)) {
                            ISpineDirectionElement element = _record.DirectedAnimationMap[animationKey][directionCom.Direction];
                            animation = element.Animation;
                            flipX = element.FlipX;
                            flipY = element.FlipY;
                        }
                        else if (_record.DefaultAnimationMap.ContainsKey(animationKey))
                            animation = _record.DefaultAnimationMap[animationKey];
                    }
                    else if (_record.DefaultAnimationMap.ContainsKey(animationKey))
                        animation = _record.DefaultAnimationMap[animationKey];
                }

                if (_animation == null || animation != _animation.Name) {
                    _animation = _skeleton.Data.FindAnimation(animation);
                    _time = 0;
                }

                if (_animation == null && _skeleton.Data.Animations.Count > 0) {
                    _animation = _skeleton.Data.Animations[0];
                    _time = 0;
                }

                _skeleton.FlipX = flipX;
                _skeleton.FlipY = flipY;
            }

            if (_animation != null) {
                _time += (float)world.GameTime.ElapsedGameTime.TotalSeconds;
                _animation.Apply(_skeleton, _time, true);
            }

            _skeleton.RootBone.X = (float)position.RenderX;
            _skeleton.RootBone.Y = (float)position.RenderY;
            _skeleton.UpdateWorldTransform();

            skeletonRenderer.Draw(_skeleton);
        }
 public SpriteRenderManager(EntityWorld world)
     : this(world, new SpriteBatch(world.Frame.Engine.GraphicsDevice))
 {
 }
 public DrawRenderManager(EntityWorld world)
     : this(world, new DrawBatch(world.Frame.Engine.GraphicsDevice))
 {
 }
 public SpineRenderManager(EntityWorld world, SkeletonRenderer skeletonRenderer)
 {
     World = world;
     SkeletonRenderer = skeletonRenderer;
 }
 public SpineRenderManager(EntityWorld world)
     : this(world, new SkeletonRenderer(world.Frame.Engine.GraphicsDevice))
 {
 }
Exemple #15
0
 public EntityFrame()
     : base()
 {
     _entityWorld = new EntityWorld();
     _entityWorld.Frame = this;
 }
Exemple #16
0
 protected abstract void Update(EntityWorld world, Entity entity, float percent);
Exemple #17
0
 protected virtual void End(EntityWorld world, Entity entity)
 {
 }
Exemple #18
0
 public abstract void Render(SpriteBatch spriteBatch, EntityWorld world, Entity entity, Renderable position);
Exemple #19
0
 public abstract bool Update(EntityWorld world, Entity entity);
 public DrawRenderManager(EntityWorld world, DrawBatch drawBatch)
 {
     World = world;
     DrawBatch = drawBatch;
 }
 public SpriteRenderManager(EntityWorld world, SpriteBatch spriteBatch)
 {
     World = world;
     SpriteBatch = spriteBatch;
 }
Exemple #22
0
 public TagManager(EntityWorld world)
 {
     _world = world;
     _entities = new Dictionary<string, Entity>();
 }
Exemple #23
0
        public DrawRenderLayer(EntityWorld world, DrawBatch drawBatch)
        {
            _manager = new DrawRenderManager(world, drawBatch);

            InitOptions();
        }
 public abstract void Update(EntityWorld world, Entity entity);
Exemple #25
0
        public DrawRenderLayer(EntityWorld world)
        {
            _manager = new DrawRenderManager(world);

            InitOptions();
        }
Exemple #26
0
 public EntityFrame(Engine engine)
     : base(engine)
 {
     _entityWorld = new EntityWorld();
     _entityWorld.Frame = this;
 }
 public override void Render(DrawBatch drawBatch, EntityWorld world, Entity entity, Renderable position)
 {
     if (Command != null)
         Command(drawBatch, position);
 }
 public override void Render(SpriteBatch spriteBatch, EntityWorld world, Entity e, Renderable position)
 {
     _sprite.Update(world.GameTime);
     _sprite.Draw(spriteBatch, new PointFP(position.RenderX, position.RenderY));
 }
Exemple #29
0
 public abstract void Render(SkeletonRenderer skeletonRenderer, EntityWorld world, Entity entity, Renderable position);
 public SpineRenderLayer(EntityWorld world, SkeletonRenderer skeletonRenderer)
 {
     _manager = new SpineRenderManager(world, skeletonRenderer);
     _options = new SpineRenderManagerOptions();
 }