Пример #1
0
        public Item(string name, _Sprite sprite)
        {
            Id = ITEMS.ById.Count;
            ITEMS.ById.Add(this);
            ITEMS.ByName.Add(name, this);

            Sprite = sprite;
            Name   = name;
            _tags  = new List <ItemTag>();
        }
Пример #2
0
 public static void DrawSprite(this SpriteBatch spriteBatch, _Sprite sprite, Vector2 location, Vector2 scale, Color color, float rotation, Vector2 origin)
 {
     spriteBatch.Draw(
         sprite.Atlas.Texture,
         location,
         sprite.Bound,
         color,
         rotation,
         origin,
         scale,
         SpriteEffects.None,
         0);
 }
Пример #3
0
        public RendererCreature(_Sprite defaultSprite, _Sprite liftingSprite = null)
        {
            _defaultSprite = defaultSprite.WithGrid(3, 4);

            if (liftingSprite != null)
            {
                _liftingSprite = liftingSprite.WithGrid(3, 4);
            }
            else
            {
                _liftingSprite = _defaultSprite;
            }

            _waterEffect = Resources.Sprites["water"].WithGrid(4, 1);
        }
Пример #4
0
        public TNT()
        {
            _age   = 0;
            _delay = 3f;

            AddComponent(new ComponentBreakable());
            AddComponent(new ComponentCollider(new Rectangle(-6, -2, 12, 8)));
            AddComponent(new ComponentExplosive(false, 10f, 3f));
            AddComponent(new ComponentMove());
            AddComponent(new ComponentPickupable());
            AddComponent(new ComponentPushable());
            AddComponent(new ComponentCastShadow());

            _sprite = Resources.Sprites["entity/tnt"];
        }
Пример #5
0
        public Stairs()
        {
            SortingOffset = -16;
            var interaction = new ComponentInteractive();

            interaction.Interacted +=
                (sender, arg) =>
            {
                Level.RemoveEntity(arg.Entity);
                World.GetLevel(Destination).AddEntityAt(arg.Entity, Coordinates);
            };

            AddComponent(interaction);

            _spriteUp   = Resources.Sprites["entity/stair_up"];
            _spriteDown = Resources.Sprites["entity/stair_down"];
        }
Пример #6
0
 public static void DrawSprite(this SpriteBatch spriteBatch, _Sprite sprite, int x, int y, int height, int width, Color color)
 {
     spriteBatch.Draw(sprite.Atlas.Texture, new Rectangle(x, y, height, width), sprite.Bound, color);
 }
Пример #7
0
 public static void DrawSprite(this SpriteBatch spriteBatch, _Sprite sprite, float x, float y, float height, float width, Color color)
 {
     spriteBatch.DrawSprite(sprite, new Vector2(x, y), (Vector2.One / new Vector2(sprite.Width, sprite.Height)) * new Vector2(height, width), color);
 }
Пример #8
0
 public static void DrawSprite(this SpriteBatch spriteBatch, _Sprite sprite, Rectangle dest, Color color)
 {
     spriteBatch.Draw(sprite.Atlas.Texture, dest, sprite.Bound, color);
 }
Пример #9
0
 public static void DrawSprite(this SpriteBatch spriteBatch, _Sprite sprite, Vector2 location, Vector2 scale, Color color)
 {
     spriteBatch.DrawSprite(sprite, location, scale, color, 0.0f, Vector2.Zero);
 }
Пример #10
0
        public static void DrawBox(this SpriteBatch spriteBatch, _Sprite sprite, Rectangle dest, float scale, Color color)
        {
            sprite = sprite.WithGrid(3, 3);

            var topLeft = sprite.SubSprite(0, 0);

            spriteBatch.DrawSprite(
                topLeft,
                dest.X,
                dest.Y,
                topLeft.Width * scale,
                topLeft.Height * scale,
                color);

            var topRight = sprite.SubSprite(2, 0);

            spriteBatch.DrawSprite(
                topRight,
                dest.X + dest.Width - topRight.Width * scale,
                dest.Y,
                topRight.Width * scale,
                topRight.Height * scale,
                color);

            var bottomLeft = sprite.SubSprite(0, 2);

            spriteBatch.DrawSprite(
                bottomLeft,
                dest.X,
                dest.Y + dest.Height - bottomLeft.Height * scale,
                bottomLeft.Width * scale,
                bottomLeft.Height * scale,
                color);

            var bottomRight = sprite.SubSprite(2, 2);

            spriteBatch.DrawSprite(
                bottomRight,
                dest.X + dest.Width - bottomRight.Width * scale,
                dest.Y + dest.Height - bottomRight.Height * scale,
                bottomRight.Width * scale,
                bottomRight.Height * scale,
                color);

            var top = sprite.SubSprite(1, 0);

            spriteBatch.DrawSprite(
                top,
                dest.X + top.Width,
                dest.Y,
                dest.Width - top.Width * 2,
                top.Height * scale,
                color);

            var bottom = sprite.SubSprite(1, 2);

            spriteBatch.DrawSprite(
                bottom,
                dest.X + bottom.Width * scale,
                dest.Y + dest.Height - bottom.Width * scale,
                dest.Width - bottom.Width * 2 * scale,
                bottom.Height * scale,
                color);

            var left = sprite.SubSprite(0, 1);

            spriteBatch.DrawSprite(
                left,
                dest.X,
                dest.Y + left.Height * scale,
                left.Width * scale,
                dest.Height - left.Height * 2 * scale,
                color);

            var right = sprite.SubSprite(2, 1);

            spriteBatch.DrawSprite(
                right,
                dest.X + dest.Width - right.Width * scale,
                dest.Y + right.Height * scale,
                right.Width * scale,
                dest.Height - right.Height * 2 * scale,
                color);
        }
Пример #11
0
 public RendererSprite(_Sprite sprite, Vector2 offset)
 {
     Sprite = sprite;
     Offset = offset;
 }
Пример #12
0
 public RendererSprite(_Sprite sprite)
 {
     Sprite = sprite;
     Offset = Vector2.Zero;
 }