public static ClientEntity ClientEntityFactory(EntityMessage em, BFBContentManager content)
        {
            IGraphicsComponent graphicsComponent = null;

            switch (em.EntityType)
            {
            case EntityType.Item:
                graphicsComponent = new ItemGraphicsComponent(content.GetAtlasTexture(em.TextureKey));
                break;

            case EntityType.Mob:
            case EntityType.Player:
            case EntityType.Projectile:
            case EntityType.Particle:
                graphicsComponent = new AnimationComponent(content.GetAnimatedTexture(em.TextureKey));
                break;
            }

            return(new ClientEntity(em.EntityId,
                                    new EntityOptions
            {
                Dimensions = em.Dimensions,
                Position = em.Position,
                Rotation = em.Rotation,
                Origin = em.Origin,
                EntityType = em.EntityType
            }, graphicsComponent));
        }
示例#2
0
        public override void Render()
        {
            if (item != null)
            {
                var region = item.Region;
                var s      = Math.Min(13f / region.Width, 13f / region.Height);

                Graphics.Render(region, Center + new Vector2(0, ItemGraphicsComponent.CalculateMove(t) / 5.5f), (float)Math.Cos(t * 1.8f) * 0.2f, region.Center, new Vector2(s, s));
            }

            base.Render();
        }