コード例 #1
0
        private void DrawItem(Furniture furniture, SpriteBatch spriteBatch, Vector2 viewPosition, float alpha, float scaleSize, DepthProvider depthProvider)
        {
            var tileScaledSize = Game1.tileSize / 2f * (scaleSize * Config.Layout.Scale / Game1.pixelZoom);

            spriteBatch.Draw(
                furnitureTexture,
                viewPosition + new Vector2(tileScaledSize, tileScaledSize * furniture.defaultSourceRect.Height / spriteSheetTileSize),
                furniture.defaultSourceRect,
                Color.White * alpha,
                0,
                new Vector2(spriteSheetTileSize, furniture.defaultSourceRect.Height) / 2f,
                scaleSize * Config.Layout.Scale,
                SpriteEffects.None,
                depthProvider.GetDepth());
        }
コード例 #2
0
        private void DrawItem(Tool tool, SpriteBatch spriteBatch, Vector2 viewPosition, float alpha, float scaleSize, DepthProvider depthProvider)
        {
            bool IsWeapon() => (tool is MeleeWeapon) || (tool is Slingshot);

            var textureInfo    = IsWeapon()? TextureInfo.Weapons : TextureInfo.Tools;
            var rotation       = GetItemRotation(tool) * MathHelper.PiOver4;
            var tileScaledSize = Game1.tileSize / 2f * (scaleSize * Config.Layout.Scale / Game1.pixelZoom);

            spriteBatch.Draw(
                textureInfo.Texture,
                viewPosition + new Vector2(tileScaledSize, tileScaledSize * GetRotationScale(rotation)),
                textureInfo.GetSourceRect(tool.indexOfMenuItemView),
                Color.White * alpha,
                rotation,
                new Vector2(spriteSheetTileSize, spriteSheetTileSize) / 2f,
                scaleSize * Config.Layout.Scale / GetRotationScale(rotation),
                SpriteEffects.None,
                depthProvider.GetDepth());
        }
コード例 #3
0
        private void DrawItemShadow(Item item, SpriteBatch spriteBatch, Vector2 viewPosition, float alpha, float scaleSize, DepthProvider depthProvider)
        {
            if (!(item is Object) || (item is Furniture))
            {
                return;
            }
            var tileScaledSize = Game1.tileSize / 2f * (scaleSize * Config.Layout.Scale / Game1.pixelZoom);

            spriteBatch.Draw(
                Game1.shadowTexture,
                viewPosition + new Vector2(tileScaledSize, tileScaledSize * 1.5f),
                Game1.shadowTexture.Bounds,
                Color.White * 0.4f * alpha,
                0,
                Game1.shadowTexture.Bounds.Center.ToVector(),
                scaleSize * Config.Layout.Scale * 0.9f,
                SpriteEffects.None,
                depthProvider.GetDepth());
        }
コード例 #4
0
        private void UpdateItemGlow(Item item, SpriteBatch spriteBatch, Vector2 viewPosition, float alpha, float scaleSize, DepthProvider depthProvider)
        {
            var color = GetItemGlowColor(item);

            if (color == null)
            {
                return;
            }

            var isDarkItem = (color == Color.Black);

            if (GlowConfig.ShowGlows)
            {
                var colorAlpha = isDarkItem ? 0.8f : 0.6f;
                spriteBatch.Draw(
                    GlowTexture,
                    viewPosition + TileSize / 2 * (scaleSize * Config.Layout.Scale / Game1.pixelZoom),
                    GlowTexture.Bounds,
                    color.Value * colorAlpha * alpha,
                    0,
                    GlowTexture.Bounds.Center.ToVector(),
                    4f * (scaleSize * Config.Layout.Scale / Game1.pixelZoom),
                    SpriteEffects.None,
                    depthProvider.GetDepth());
            }

            if (isDarkItem || !GlowConfig.ShowLights)
            {
                return;
            }

            if (!LightSources.TryGetValue(item, out var light))
            {
                light = new LightSource(LightSource.lantern, Vector2.Zero, 32f / Game1.options.lightingQuality);
                LightSources.Add(item, light);
            }
            light.position = viewPosition + new Vector2(Game1.viewport.X, Game1.viewport.Y) + TileSize / 2;
        }
コード例 #5
0
        private void DrawItem(Object item, SpriteBatch spriteBatch, Vector2 viewPosition, float alpha, float scaleSize, DepthProvider depthProvider)
        {
            var rotation       = GetItemRotation(item) * MathHelper.PiOver4;
            var tileScaledSize = Game1.tileSize / 2f * (scaleSize * Config.Layout.Scale / Game1.pixelZoom);

            void DrawObjectSprite(int spriteIndex, Color color) => spriteBatch.Draw(
                Game1.objectSpriteSheet,
                viewPosition + new Vector2(tileScaledSize, tileScaledSize * GetRotationScale(rotation)),
                TextureInfo.Objects.GetSourceRect(spriteIndex),
                color * alpha,
                rotation,
                new Vector2(spriteSheetTileSize, spriteSheetTileSize) / 2f,
                scaleSize * Config.Layout.Scale / GetRotationScale(rotation),
                SpriteEffects.None,
                depthProvider.GetDepth());

            DrawObjectSprite(item.ParentSheetIndex, Color.White);
            if (!(item is ColoredObject coloredObject))
            {
                return;
            }
            DrawObjectSprite(item.ParentSheetIndex + 1, coloredObject.color);
        }
コード例 #6
0
        private void DrawFurniture(SpriteBatch spriteBatch, Vector2 viewPosition, float alpha, float scaleSize, SpriteInfo sprite, Color color, ShowcaseDrawMode drawMode, DepthProvider depthProvider)
        {
            var currentSourceRect = GetDefaultSourceRect(sprite, defaultSourceRect.Width, defaultSourceRect.Height);

            if (drawMode != ShowcaseDrawMode.Icon)
            {
                currentSourceRect.X     += (sourceRect.X - defaultSourceRect.X);
                currentSourceRect.Y     += (sourceRect.Y - defaultSourceRect.Y);
                currentSourceRect.Height = sourceRect.Height;
                currentSourceRect.Width  = sourceRect.Width;
            }

            spriteBatch.Draw(
                GetTexture(sprite),
                viewPosition,
                currentSourceRect,
                color * alpha,
                0,
                Vector2.Zero,
                scaleSize,
                (flipped && drawMode != ShowcaseDrawMode.Icon) ? SpriteEffects.FlipHorizontally : SpriteEffects.None,
                depthProvider.GetDepth());
        }