コード例 #1
0
        private IRenderEffects GetRenderEffects(Renderable renderCom)
        {
            if (renderCom == null)
                return null;

            return RenderSystem.SpatialManager.GetSpatial(renderCom.SpatialRef) as IRenderEffects;
        }
コード例 #2
0
        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
ファイル: SpriteSpatial.cs プロジェクト: jaquadro/Amphibian
        public override void Render(IRenderManager renderManager, Entity entity, Renderable position)
        {
            SpriteRenderManager spriteRenderManager = renderManager as SpriteRenderManager;
            if (spriteRenderManager == null)
                throw new ArgumentException("renderManager must be of type SpriteRenderManager");

            Render(spriteRenderManager.SpriteBatch, spriteRenderManager.World, entity, position);
        }
コード例 #4
0
ファイル: DrawSpatial.cs プロジェクト: jaquadro/Amphibian
        public override void Render(IRenderManager renderManager, Entity entity, Renderable position)
        {
            DrawRenderManager drawRenderManager = renderManager as DrawRenderManager;
            if (drawRenderManager == null)
                throw new ArgumentException("renderManager must be of type DrawRenderManager");

            Render(drawRenderManager.DrawBatch, drawRenderManager.World, entity, position);
        }
コード例 #5
0
        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
ファイル: DebugCue.cs プロジェクト: jaquadro/Amphibian
        public static Entity Create(Engine engine, SystemManager sysManager, PointFP location)
        {
            RenderSystem renderSys = sysManager.GetSystem(typeof(RenderSystem)) as RenderSystem;
            if (renderSys == null)
                return new Entity();

            Entity ent = sysManager.World.EntityManager.Create();

            Amphibian.Systems.Rendering.Spatial spat = new DebugCueSpatial();
            spat.Initialize(engine.Content);
            Amphibian.Systems.Rendering.SpatialRef potSR = renderSys.SpatialManager.Add(spat);

            Renderable entRC = new Renderable();
            entRC.SpatialRef = potSR;
            entRC.RenderX = location.X;
            entRC.RenderY = location.Y;

            RemovalTimeout entRT = new RemovalTimeout(0.5f);

            sysManager.World.EntityManager.AddComponent(ent, entRC);
            sysManager.World.EntityManager.AddComponent(ent, entRT);

            return ent;
        }
コード例 #7
0
 public override void Render(DrawBatch drawBatch, EntityWorld world, Entity entity, Renderable position)
 {
     if (Command != null)
         Command(drawBatch, position);
 }
コード例 #8
0
ファイル: SkeletonSpatial.cs プロジェクト: jaquadro/Amphibian
        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);
        }
コード例 #9
0
ファイル: Spatial.cs プロジェクト: jaquadro/Amphibian
 public abstract void Render(IRenderManager renderManager, Entity entity, Renderable position);
コード例 #10
0
ファイル: SpriteSpatial.cs プロジェクト: jaquadro/Amphibian
 public abstract void Render(SpriteBatch spriteBatch, EntityWorld world, Entity entity, Renderable position);
コード例 #11
0
ファイル: SpineSpatial.cs プロジェクト: jaquadro/Amphibian
 public abstract void Render(SkeletonRenderer skeletonRenderer, EntityWorld world, Entity entity, Renderable position);
コード例 #12
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));
 }
コード例 #13
0
ファイル: DebugCue.cs プロジェクト: jaquadro/Amphibian
 public override void Render(SpriteBatch spriteBatch, EntityWorld world, Entity entity, Renderable position)
 {
     //Rectangle area = new Rectangle((int)position.RenderX - (int)_radius, (int)position.RenderY - (int)_radius, (int)_radius * 2, (int)_radius * 2);
     //Drawing.Draw2D.DrawRectangle(spriteBatch, area, _pen);
 }
コード例 #14
0
ファイル: DrawSpatial.cs プロジェクト: jaquadro/Amphibian
 public abstract void Render(DrawBatch drawBatch, EntityWorld world, Entity entity, Renderable position);
コード例 #15
0
ファイル: BackdropSpatial.cs プロジェクト: jaquadro/Amphibian
        public override void Render(SpriteBatch spriteBatch, EntityWorld world, Entity entity, Renderable position)
        {
            if (_dimX.AutoScroll) {
                _dimX.AutoPosition += _dimX.AutoSpeed * (float)world.GameTime.ElapsedGameTime.TotalSeconds;
            }
            if (_dimY.AutoScroll) {
                _dimY.AutoPosition += _dimY.AutoSpeed * (float)world.GameTime.ElapsedGameTime.TotalSeconds;
            }

            if (_spriteTexture == null)
                return;

            CameraSystem camera = world.SystemManager.GetSystem(typeof(CameraSystem)) as CameraSystem;
            Rectangle window = (camera != null)
                ? camera.Bounds : world.Frame.Engine.GraphicsDevice.Viewport.Bounds;

            int originX = _dimX.Origin(window.X, window.Width, world.Frame.Width);
            int originY = _dimY.Origin(window.Y, window.Height, world.Frame.Height);

            int tileX = 1;
            int tileY = 1;

            if (_dimX.Repeat) {
                tileX = (window.X + window.Width - originX + _dimX.Length) / _dimX.Length;
            }
            if (_dimY.Repeat) {
                tileY = (window.Y + window.Height - originY + _dimY.Length) / _dimY.Length;
            }

            for (int x = 0; x < tileX; x++) {
                int xStart = originX + (x * _dimX.Length);
                for (int y = 0; y < tileY; y++) {
                    int yStart = originY + (y * _dimY.Length);
                    spriteBatch.Draw(_spriteTexture,
                        new Rectangle(xStart, yStart, _dimX.Length, _dimY.Length),
                        new Rectangle(0, 0, _spriteTexture.Width, _spriteTexture.Height),
                        Color.White);
                }
            }
        }