Example #1
0
        public FoodGraphicsComponent(IFoodEntity food, IGraphicsSystem graphicsSystem)
        {
            _food           = food ?? throw new ArgumentNullException(nameof(food));
            _graphicsSystem = graphicsSystem ?? throw new ArgumentNullException(nameof(graphicsSystem));

            var textureRegion = _graphicsSystem.TextureManager.TextureRegions["Fruit"];

            _transform = new Transform2(
                position: _food.Position,
                rotation: _food.Rotation,
                scale: new Vector2(_food.Size.Width / (float)textureRegion.Bounds.Width,
                                   _food.Size.Height / (float)textureRegion.Bounds.Height));

            _sprite = new Sprite(textureRegion)
            {
                Color  = Color.White,
                Origin = new Vector2(textureRegion.Width / 2f, textureRegion.Height / 2f),
                Effect = SpriteEffects.None
            };
        }
Example #2
0
 public FoodComponent(IFoodEntity food, IGraphics2DComponent graphicsComponent, string id)
 {
     _food = food;
     ID    = id;
     _graphicsComponent = graphicsComponent;
 }