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

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

            InitOptions();
        }
예제 #7
0
        public SpriteRenderLayer(EntityWorld world)
        {
            _manager = new SpriteRenderManager(world);

            InitOptions();
        }
예제 #8
0
 protected virtual void Begin(EntityWorld world, Entity entity)
 {
 }
예제 #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);
 }
예제 #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);
        }
예제 #11
0
 public SpriteRenderManager(EntityWorld world)
     : this(world, new SpriteBatch(world.Frame.Engine.GraphicsDevice))
 {
 }
예제 #12
0
 public DrawRenderManager(EntityWorld world)
     : this(world, new DrawBatch(world.Frame.Engine.GraphicsDevice))
 {
 }
예제 #13
0
 public SpineRenderManager(EntityWorld world, SkeletonRenderer skeletonRenderer)
 {
     World = world;
     SkeletonRenderer = skeletonRenderer;
 }
예제 #14
0
 public SpineRenderManager(EntityWorld world)
     : this(world, new SkeletonRenderer(world.Frame.Engine.GraphicsDevice))
 {
 }
예제 #15
0
파일: Frame.cs 프로젝트: jaquadro/Amphibian
 public EntityFrame()
     : base()
 {
     _entityWorld = new EntityWorld();
     _entityWorld.Frame = this;
 }
예제 #16
0
 protected abstract void Update(EntityWorld world, Entity entity, float percent);
예제 #17
0
 protected virtual void End(EntityWorld world, Entity entity)
 {
 }
예제 #18
0
 public abstract void Render(SpriteBatch spriteBatch, EntityWorld world, Entity entity, Renderable position);
예제 #19
0
 public abstract bool Update(EntityWorld world, Entity entity);
예제 #20
0
 public DrawRenderManager(EntityWorld world, DrawBatch drawBatch)
 {
     World = world;
     DrawBatch = drawBatch;
 }
예제 #21
0
 public SpriteRenderManager(EntityWorld world, SpriteBatch spriteBatch)
 {
     World = world;
     SpriteBatch = spriteBatch;
 }
예제 #22
0
 public TagManager(EntityWorld world)
 {
     _world = world;
     _entities = new Dictionary<string, Entity>();
 }
예제 #23
0
        public DrawRenderLayer(EntityWorld world, DrawBatch drawBatch)
        {
            _manager = new DrawRenderManager(world, drawBatch);

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

            InitOptions();
        }
예제 #26
0
파일: Frame.cs 프로젝트: jaquadro/Amphibian
 public EntityFrame(Engine engine)
     : base(engine)
 {
     _entityWorld = new EntityWorld();
     _entityWorld.Frame = this;
 }
예제 #27
0
 public override void Render(DrawBatch drawBatch, EntityWorld world, Entity entity, Renderable position)
 {
     if (Command != null)
         Command(drawBatch, position);
 }
예제 #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));
 }
예제 #29
0
 public abstract void Render(SkeletonRenderer skeletonRenderer, EntityWorld world, Entity entity, Renderable position);
예제 #30
0
 public SpineRenderLayer(EntityWorld world, SkeletonRenderer skeletonRenderer)
 {
     _manager = new SpineRenderManager(world, skeletonRenderer);
     _options = new SpineRenderManagerOptions();
 }