Exemplo n.º 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));
        }
Exemplo n.º 3
0
        public void Initialize(EntityWorld world)
        {
            world.SystemManager.SystemAdded += HandleSystemAdded;

            foreach (BaseSystem system in world.SystemManager.Systems) {
                HandleSystemAdded(system);
            }
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 6
0
        public SpriteRenderLayer(EntityWorld world, SpriteBatch spriteBatch)
        {
            _manager = new SpriteRenderManager(world, spriteBatch);

            InitOptions();
        }
Exemplo n.º 7
0
        public SpriteRenderLayer(EntityWorld world)
        {
            _manager = new SpriteRenderManager(world);

            InitOptions();
        }
Exemplo n.º 8
0
 protected virtual void Begin(EntityWorld world, Entity entity)
 {
 }
Exemplo n.º 9
0
 protected override void Update(EntityWorld world, Entity entity, float percent)
 {
     IRenderEffects renderEffects = GetRenderEffects(world.EntityManager.GetComponent<Renderable>(entity));
     if (renderEffects != null)
         Update(renderEffects, percent);
 }
Exemplo n.º 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);
        }
Exemplo n.º 11
0
 public SpriteRenderManager(EntityWorld world)
     : this(world, new SpriteBatch(world.Frame.Engine.GraphicsDevice))
 {
 }
Exemplo n.º 12
0
 public DrawRenderManager(EntityWorld world)
     : this(world, new DrawBatch(world.Frame.Engine.GraphicsDevice))
 {
 }
Exemplo n.º 13
0
 public SpineRenderManager(EntityWorld world, SkeletonRenderer skeletonRenderer)
 {
     World = world;
     SkeletonRenderer = skeletonRenderer;
 }
Exemplo n.º 14
0
 public SpineRenderManager(EntityWorld world)
     : this(world, new SkeletonRenderer(world.Frame.Engine.GraphicsDevice))
 {
 }
Exemplo n.º 15
0
 public EntityFrame()
     : base()
 {
     _entityWorld = new EntityWorld();
     _entityWorld.Frame = this;
 }
Exemplo n.º 16
0
 protected abstract void Update(EntityWorld world, Entity entity, float percent);
Exemplo n.º 17
0
 protected virtual void End(EntityWorld world, Entity entity)
 {
 }
Exemplo n.º 18
0
 public abstract void Render(SpriteBatch spriteBatch, EntityWorld world, Entity entity, Renderable position);
Exemplo n.º 19
0
 public abstract bool Update(EntityWorld world, Entity entity);
Exemplo n.º 20
0
 public DrawRenderManager(EntityWorld world, DrawBatch drawBatch)
 {
     World = world;
     DrawBatch = drawBatch;
 }
Exemplo n.º 21
0
 public SpriteRenderManager(EntityWorld world, SpriteBatch spriteBatch)
 {
     World = world;
     SpriteBatch = spriteBatch;
 }
Exemplo n.º 22
0
 public TagManager(EntityWorld world)
 {
     _world = world;
     _entities = new Dictionary<string, Entity>();
 }
Exemplo n.º 23
0
        public DrawRenderLayer(EntityWorld world, DrawBatch drawBatch)
        {
            _manager = new DrawRenderManager(world, drawBatch);

            InitOptions();
        }
Exemplo n.º 24
0
 public abstract void Update(EntityWorld world, Entity entity);
Exemplo n.º 25
0
        public DrawRenderLayer(EntityWorld world)
        {
            _manager = new DrawRenderManager(world);

            InitOptions();
        }
Exemplo n.º 26
0
 public EntityFrame(Engine engine)
     : base(engine)
 {
     _entityWorld = new EntityWorld();
     _entityWorld.Frame = this;
 }
Exemplo n.º 27
0
 public override void Render(DrawBatch drawBatch, EntityWorld world, Entity entity, Renderable position)
 {
     if (Command != null)
         Command(drawBatch, position);
 }
Exemplo n.º 28
0
 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));
 }
Exemplo n.º 29
0
 public abstract void Render(SkeletonRenderer skeletonRenderer, EntityWorld world, Entity entity, Renderable position);
Exemplo n.º 30
0
 public SpineRenderLayer(EntityWorld world, SkeletonRenderer skeletonRenderer)
 {
     _manager = new SpineRenderManager(world, skeletonRenderer);
     _options = new SpineRenderManagerOptions();
 }