コード例 #1
0
        protected override void HandleUseReqest(GraphicsDevice device, SpriteBatch spriteBatch)
        {
            Asset <Texture2D> val = TextureAssets.Extra[171];

            PrepareARenderTarget_AndListenToEvents(ref _target, device, val.Width(), val.Height(), RenderTargetUsage.PreserveContents);
            device.SetRenderTarget(_target);
            device.Clear(Color.Transparent);
            DrawData value = new DrawData(val.get_Value(), Vector2.Zero, Color.White);

            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
            GameShaders.Misc["HallowBoss"].Apply(value);
            value.Draw(spriteBatch);
            spriteBatch.End();
            device.SetRenderTarget(null);
            _wasPrepared = true;
        }
コード例 #2
0
        protected override void HandleUseReqest(GraphicsDevice device, SpriteBatch spriteBatch)
        {
            Asset <Texture2D> asset = TextureAssets.Extra[171];

            this.PrepareARenderTarget_AndListenToEvents(ref this._target, device, asset.Width(), asset.Height(), RenderTargetUsage.PreserveContents);
            device.SetRenderTarget(this._target);
            device.Clear(Color.Transparent);
            DrawData drawData = new DrawData(asset.Value, Vector2.Zero, Color.White);

            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
            GameShaders.Misc["HallowBoss"].Apply(new DrawData?(drawData));
            drawData.Draw(spriteBatch);
            spriteBatch.End();
            device.SetRenderTarget((RenderTarget2D)null);
            this._wasPrepared = true;
        }
コード例 #3
0
        protected override void HandleUseReqest(GraphicsDevice device, SpriteBatch spriteBatch)
        {
            Asset <Texture2D> asset = TextureAssets.Extra[204];

            this._target = new RenderTarget2D(device, asset.Width(), asset.Height(), false, device.PresentationParameters.BackBufferFormat, DepthFormat.None, 0, RenderTargetUsage.PreserveContents);
            device.SetRenderTarget(this._target);
            device.Clear(Color.Transparent);
            DrawData drawData = new DrawData(asset.get_Value(), Vector2.Zero, Color.White);

            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
            GameShaders.Misc["QueenSlime"].Apply(new DrawData?(drawData));
            drawData.Draw(spriteBatch);
            spriteBatch.End();
            device.SetRenderTarget((RenderTarget2D)null);
            this._wasPrepared = true;
        }
コード例 #4
0
        public static PlayerLayer CreateShaderLayer(string name, PlayerLayer parent, Func <PlayerDrawInfo, DrawDataInfo> getDataFunc)
        {
            return(new PlayerLayer("ModLoaderMod", name, parent, (drawInfo) => {
                if (drawInfo.shadow != 0f || drawInfo.drawPlayer.invis)
                {
                    return;
                }

                DrawDataInfo drawDataInfo = getDataFunc.Invoke(drawInfo);
                Player drawPlayer = drawInfo.drawPlayer;
                DeveloperPlayer devPlayer = DeveloperPlayer.GetPlayer(drawPlayer);
                SpriteEffects effects = SpriteEffects.None;
                if (drawPlayer.direction == -1)
                {
                    effects |= SpriteEffects.FlipHorizontally;
                }

                if (drawPlayer.gravDir == -1)
                {
                    effects |= SpriteEffects.FlipVertically;
                }

                DrawData data = new DrawData(
                    drawDataInfo.Texture,
                    drawDataInfo.Position,
                    drawDataInfo.Frame,
                    Color.White * Main.essScale * devPlayer.AndromedonEffect.LayerStrength * devPlayer.AndromedonEffect.ShaderStrength,
                    drawDataInfo.Rotation,
                    drawDataInfo.Origin,
                    1f,
                    effects,
                    0);

                BeginShaderBatch(Main.spriteBatch);
                ShaderId = ShaderId ?? GameShaders.Armor.GetShaderIdFromItemId(ItemID.LivingRainbowDye);
                GameShaders.Armor.Apply(ShaderId.Value, drawPlayer, data);
                var centerPos = data.position;

                for (int i = 0; i < ShaderNumSegments; i++)
                {
                    data.position = centerPos + GetDrawOffset(i);
                    data.Draw(Main.spriteBatch);
                }

                data.position = centerPos;
            }));
        }
コード例 #5
0
        public override void Draw(ref ParticleRendererSettings settings, SpriteBatch spritebatch)
        {
            Color   color  = new Color(120, 120, 120, 60) * Utils.GetLerpValue(1f, FadeOutNormalizedTime, _timeSinceSpawn / _timeTolive, clamped: true);
            Vector2 value  = settings.AnchorPosition + LocalPosition;
            ulong   seed   = Main.TileFrameSeed ^ (((ulong)LocalPosition.X << 32) | (uint)LocalPosition.Y);
            Player  player = Main.player[_indexOfPlayerWhoSpawnedThis];

            for (int i = 0; i < 4; i++)
            {
                DrawData drawData = new DrawData(position: value + new Vector2(Utils.RandomInt(ref seed, -2, 3), Utils.RandomInt(ref seed, -2, 3)) * Scale, texture: _texture.get_Value(), sourceRect: _frame, color: color, rotation: Rotation, origin: _origin, scale: Scale, effect: SpriteEffects.None, inactiveLayerDepth: 0);
                drawData.shader = _packedShaderIndex;
                DrawData cdd = drawData;
                PlayerDrawHelper.SetShaderForData(player, 0, ref cdd);
                cdd.Draw(spritebatch);
            }
            Main.pixelShader.CurrentTechnique.Passes[0].Apply();
        }
コード例 #6
0
        protected override void HandleUseReqest(GraphicsDevice device, SpriteBatch spriteBatch)
        {
            Main.instance.LoadProjectile(908);
            Asset <Texture2D> val = TextureAssets.Projectile[908];

            UpdateSettingsForRendering(0.6f, 0f, Main.GlobalTimeWrappedHourly, 0.3f);
            _target = new RenderTarget2D(device, val.Width(), val.Height(), mipMap: false, device.PresentationParameters.BackBufferFormat, DepthFormat.None, 0, RenderTargetUsage.PreserveContents);
            device.SetRenderTarget(_target);
            device.Clear(Color.Transparent);
            DrawData value = new DrawData(val.get_Value(), Vector2.Zero, Color.White);

            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
            _shaderData.Apply(value);
            value.Draw(spriteBatch);
            spriteBatch.End();
            device.SetRenderTarget(null);
            _wasPrepared = true;
        }
        // Overriding PreDraw to draw around NPC origin, instead of some arbitrary value.
        // Important to make sure the NPC is being drawn correctly around its own center, so it looks like it's half behind tiles.
        public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor)
        {
            Texture2D texture = Main.npcTexture[npc.type];
            Vector2   origin  = npc.frame.Size() / 2;

            SpriteEffects effects = npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;

            Main.spriteBatch.End();
            Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix);

            DrawData data = new DrawData(texture, npc.Center - Main.screenPosition, npc.frame, drawColor * npc.Opacity, npc.rotation, origin, npc.scale, effects, 0);

            data.Draw(spriteBatch);

            //spriteBatch.Draw(texture, npc.Center - Main.screenPosition, npc.frame, drawColor, npc.rotation, origin, npc.scale, SpriteEffects.None, 0f);

            return(false);
        }
コード例 #8
0
        protected override void Draw(ref PlayerDrawSet drawInfo)
        {
            DrawDataInfo  drawDataInfo = GetData(drawInfo);
            Player        drawPlayer   = drawInfo.drawPlayer;
            var           devPlayer    = drawPlayer.GetModPlayer <DeveloperPlayer>();
            SpriteEffects effects      = SpriteEffects.None;

            if (drawPlayer.direction == -1)
            {
                effects |= SpriteEffects.FlipHorizontally;
            }

            if (drawPlayer.gravDir == -1)
            {
                effects |= SpriteEffects.FlipVertically;
            }

            var data = new DrawData(
                drawDataInfo.Texture,
                drawDataInfo.Position,
                drawDataInfo.Frame,
                Color.White * Main.essScale * devPlayer.AndromedonEffect.LayerStrength * devPlayer.AndromedonEffect.ShaderStrength,
                drawDataInfo.Rotation,
                drawDataInfo.Origin,
                1f,
                effects,
                0);

            BeginShaderBatch(Main.spriteBatch);

            ShaderId ??= GameShaders.Armor.GetShaderIdFromItemId(ItemID.LivingRainbowDye);

            GameShaders.Armor.Apply(ShaderId.Value, drawPlayer, data);

            var centerPos = data.position;

            for (int i = 0; i < ShaderNumSegments; i++)
            {
                data.position = centerPos + GetDrawOffset(i);
                data.Draw(Main.spriteBatch);
            }

            data.position = centerPos;
        }
コード例 #9
0
        public override void Draw(ref ParticleRendererSettings settings, SpriteBatch spritebatch)
        {
            Color   color     = new Color(120, 120, 120, 60) * Utils.GetLerpValue(1f, this.FadeOutNormalizedTime, this._timeSinceSpawn / this._timeTolive, true);
            Vector2 vector2_1 = settings.AnchorPosition + this.LocalPosition;
            ulong   seed      = Main.TileFrameSeed ^ ((ulong)this.LocalPosition.X << 32 | (ulong)(uint)this.LocalPosition.Y);
            Player  player    = Main.player[this._indexOfPlayerWhoSpawnedThis];

            for (int index = 0; index < 4; ++index)
            {
                Vector2  vector2_2 = new Vector2((float)Utils.RandomInt(ref seed, -2, 3), (float)Utils.RandomInt(ref seed, -2, 3));
                DrawData cdd       = new DrawData(this._texture.Value, vector2_1 + vector2_2 * this.Scale, new Rectangle?(this._frame), color, this.Rotation, this._origin, this.Scale, SpriteEffects.None, 0)
                {
                    shader = this._packedShaderIndex
                };
                PlayerDrawHelper.SetShaderForData(player, 0, ref cdd);
                cdd.Draw(spritebatch);
            }
            Main.pixelShader.CurrentTechnique.Passes[0].Apply();
        }
コード例 #10
0
ファイル: NovaPillar.cs プロジェクト: raydeejay/Tremor
        public override void PostDraw(SpriteBatch spriteBatch, Color drawColor)
        {
            TremorUtils.DrawNPCGlowMask(spriteBatch, npc, mod.GetTexture("NovaPillar/NovaPillar_GlowMask"));
            float num88 = NovaHandler.ShieldStrength / (float)NPC.ShieldStrengthTowerMax;

            if (NovaHandler.ShieldStrength > 0)
            {
                Main.spriteBatch.End();
                Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone);

                var   center = npc.Center - Main.screenPosition;
                float num89  = 0f;
                if (npc.ai[3] > 0f && npc.ai[3] <= 30f)
                {
                    num89 = 1f - npc.ai[3] / 30f;
                }
                Filters.Scene["Tremor:Nova"].GetShader().UseIntensity(1f + num89).UseProgress(0f);
                DrawData drawData = new DrawData(TextureManager.Load("Images/Misc/Perlin"), center - new Vector2(0, 10), new Rectangle(0, 0, 600, 600), Color.White * (num88 * 0.8f + 0.2f), npc.rotation, new Vector2(300f, 300f), npc.scale * (1f + num89 * 0.05f), SpriteEffects.None, 0);
                GameShaders.Misc["ForceField"].UseColor(new Vector3(1f + num89 * 0.5f));
                GameShaders.Misc["ForceField"].Apply(drawData);
                drawData.Draw(Main.spriteBatch);
                Main.spriteBatch.End();
                Main.spriteBatch.Begin();
                return;
            }
            if (npc.ai[3] > 0f)
            {
                Main.spriteBatch.End();
                Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone);
                var   center = npc.Center - Main.screenPosition;
                float num90  = npc.ai[3] / 120f;
                float num91  = Math.Min(npc.ai[3] / 30f, 1f);
                Filters.Scene["Tremor:Nova"].GetShader().UseIntensity(Math.Min(5f, 15f * num90) + 1f).UseProgress(num90);
                DrawData drawData = new DrawData(TextureManager.Load("Images/Misc/Perlin"), center - new Vector2(0, 10), new Rectangle(0, 0, 600, 600), new Color(new Vector4(1f - (float)Math.Sqrt(num91))), npc.rotation, new Vector2(300f, 300f), npc.scale * (1f + num91), SpriteEffects.None, 0);
                GameShaders.Misc["ForceField"].UseColor(new Vector3(2f));
                GameShaders.Misc["ForceField"].Apply(drawData);
                drawData.Draw(Main.spriteBatch);
                Main.spriteBatch.End();
                Main.spriteBatch.Begin();
                return;
            }
            Filters.Scene["Tremor:Nova"].GetShader().UseIntensity(0f).UseProgress(0f);
        }
コード例 #11
0
        public override bool PreDrawCloseBackground(SpriteBatch spriteBatch)
        {
            StarSailorMod sm = (StarSailorMod)mod;
            //return true;
            DrawData d = new DrawData(sm.pixel, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black);

            d.Draw(spriteBatch);
            spriteBatch.End();
            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix);
            //spriteBatch.Draw(sm.sun0, new Rectangle(Main.screenWidth * 11 / 16, 165, 160, 160), Color.White);

            sm.DrawStars(spriteBatch, (int)velocity, ((StarSailorMod)mod).forbiddenStarRegions);

            spriteBatch.End();
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.TransformationMatrix);


            return(false);
        }
コード例 #12
0
ファイル: EyeLantern.cs プロジェクト: DarthHA/Twilight
        private void DrawLantern()
        {
            Texture2D tex  = Main.projectileTexture[projectile.type];
            Texture2D tex2 = mod.GetTexture("Projectiles/EyeLantern1");

            DrawUtils.AnotherDraw(BlendState.NonPremultiplied);
            //Main.spriteBatch.End();
            //Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.EffectMatrix);
            Main.spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, Color.White * 0.5f * projectile.Opacity, 0, tex.Size() / 2, projectile.scale * 1.5f, SpriteEffects.None, 0);

            //Main.spriteBatch.End();
            //Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.EffectMatrix);
            DrawUtils.AnotherDraw(BlendState.AlphaBlend);
            DrawUtils.AnotherDraw(SpriteSortMode.Immediate);
            Vector2 ScreenPos = projectile.Center - Main.screenPosition;

            for (int i = 0; i < 6; i++)
            {
                if (CircleR[i] > 0)
                {
                    float R   = CircleR[i];
                    float ops = CircleAlpha[i] * 0.4f;

                    DrawData data = new DrawData(TextureManager.Load("Images/Misc/Perlin"), ScreenPos, new Rectangle?(new Rectangle(0, 0, (int)(R * 2), (int)(R * 2))), Color.Orange * ops * projectile.Opacity, projectile.rotation, new Vector2(R, R), new Vector2(1, 0.67f), SpriteEffects.None, 0);
                    GameShaders.Misc["ForceField"].UseColor(new Vector3(2f));
                    GameShaders.Misc["ForceField"].Apply(new DrawData?(data));
                    data.Draw(Main.spriteBatch);
                }
            }
            DrawUtils.AnotherDraw(SpriteSortMode.Deferred);
            //Main.spriteBatch.End();
            //Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.EffectMatrix);
            for (int i = 0; i < 6; i++)
            {
                if (CircleR[i] > 0)
                {
                    float scale = CircleR[i] / 500;
                    float ops   = CircleAlpha[i];
                    Main.spriteBatch.Draw(tex2, projectile.Center - Main.screenPosition, null, Color.White * ops, 0, tex2.Size() / 2, scale, SpriteEffects.None, 0);
                }
            }
        }
コード例 #13
0
        public override void PostDraw(SpriteBatch spriteBatch, Color drawColor)
        {
            if (Phase == (int)OvergrowBossPhase.Struggle)
            {
                spriteBatch.End();
                spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.TransformationMatrix);

                for (int k = 0; k < 3; k++)
                {
                    float sin = (float)Math.Sin(StarlightWorld.rottime + k * (6.28f / 6));

                    DrawData data = new DrawData(TextureManager.Load("Images/Misc/Perlin"), npc.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, 300, 200)), new Color(255, 255, 200) * 0.6f, npc.rotation, new Vector2(150, 100), 2 + sin * 0.1f, 0, 0);

                    GameShaders.Misc["ForceField"].UseColor(new Vector3(1.1f - (sin * 0.4f)));
                    GameShaders.Misc["ForceField"].Apply(new DrawData?(data));
                    data.Draw(spriteBatch);
                }

                spriteBatch.End();
                spriteBatch.Begin(default, default, default, default, default, default, Main.GameViewMatrix.TransformationMatrix);
コード例 #14
0
ファイル: Obsidious.cs プロジェクト: ISalliga/ElementsAwoken
        public override void PostDraw(SpriteBatch spriteBatch, Color drawColor)
        {
            if (shielded)
            {
                Main.spriteBatch.End();
                Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone);

                var   center    = npc.Center - Main.screenPosition;
                float intensity = 0f;
                if (npc.ai[3] > 0f && npc.ai[3] <= 30f)
                {
                    intensity = 1f - npc.ai[3] / 30f;
                }
                //Filters.Scene["Nebula"].GetShader().UseIntensity(1f + intensity).UseProgress(0f);
                DrawData drawData = new DrawData(TextureManager.Load("Images/Misc/Perlin"), center - new Vector2(0, 10), new Rectangle(0, 0, 500, 500), Color.White, npc.rotation, new Vector2(250f, 250f), npc.scale * (1f + intensity * 0.05f), SpriteEffects.None, 0);
                GameShaders.Misc["ForceField"].UseColor(new Vector3(1f + intensity * 0.5f));
                GameShaders.Misc["ForceField"].Apply(drawData);
                drawData.Draw(Main.spriteBatch);
                Main.spriteBatch.End();
                Main.spriteBatch.Begin();
                return;
            }

            /*if (npc.ai[3] > 0f)
             * {
             *  Main.spriteBatch.End();
             *  Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone);
             *  var center = npc.Center - Main.screenPosition;
             *  float num90 = npc.ai[3] / 120f;
             *  float num91 = Math.Min(npc.ai[3] / 30f, 1f);
             *  Filters.Scene["Nebula"].GetShader().UseIntensity(Math.Min(5f, 15f * num90) + 1f).UseProgress(num90);
             *  DrawData drawData = new DrawData(TextureManager.Load("Images/Misc/Perlin"), center - new Vector2(0, 10), new Rectangle(0, 0, 600, 600), new Color(new Vector4(1f - (float)Math.Sqrt(num91))), npc.rotation, new Vector2(300f, 300f), npc.scale * (1f + num91), SpriteEffects.None, 0);
             *  GameShaders.Misc["ForceField"].UseColor(new Vector3(2f));
             *  GameShaders.Misc["ForceField"].Apply(drawData);
             *  drawData.Draw(Main.spriteBatch);
             *  Main.spriteBatch.End();
             *  Main.spriteBatch.Begin();
             *  return;
             * }*/
            Filters.Scene["Nebula"].GetShader().UseIntensity(0f).UseProgress(0f);
        }
コード例 #15
0
        private void RenderDrawData(Player drawPlayer)
        {
            Effect pixelShader = Main.pixelShader;

            _ = Main.projectile;
            SpriteBatch spriteBatch = Main.spriteBatch;

            for (int i = 0; i < _drawData.Count; i++)
            {
                DrawData cdd = _drawData[i];
                if (!cdd.sourceRect.HasValue)
                {
                    cdd.sourceRect = cdd.texture.Frame();
                }
                PlayerDrawHelper.SetShaderForData(drawPlayer, drawPlayer.cHead, ref cdd);
                if (cdd.texture != null)
                {
                    cdd.Draw(spriteBatch);
                }
            }
            pixelShader.CurrentTechnique.Passes[0].Apply();
        }
コード例 #16
0
        public override void PostDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            spriteBatch.End();
            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix);
            float percent = Clamp((totalDur - projectile.timeLeft) / (float)growDur, 0, 1);
            float scale   = 0;

            if (projectile.timeLeft < collapseDur)
            {
                scale = (collapseDur - projectile.timeLeft) / (collapseDur / 2f);
            }
            DrawData data = new DrawData(Origins.instance.GetTexture("Projectiles/Pixel"), projectile.Center - Main.screenPosition, new Rectangle(0, 0, 1, 1), new Color(0, 0, 0, 255), 0, new Vector2(0.5f, 0.5f), new Vector2(160, 160) * (projectile.scale - scale), SpriteEffects.None, 0);

            Origins.blackHoleShade.UseOpacity(0.985f);
            Origins.blackHoleShade.UseSaturation(3f + percent);
            Origins.blackHoleShade.UseColor(0, 0, 0);
            Origins.blackHoleShade.Shader.Parameters["uScale"].SetValue(0.5f);
            Origins.blackHoleShade.Apply(data);
            data.Draw(spriteBatch);
            spriteBatch.End();
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.Transform);
        }
コード例 #17
0
        private void RenderDrawData(Player drawPlayer)
        {
            Effect pixelShader = Main.pixelShader;

            Projectile[] projectile  = Main.projectile;
            SpriteBatch  spriteBatch = Main.spriteBatch;

            for (int index = 0; index < this._drawData.Count; ++index)
            {
                DrawData cdd = this._drawData[index];
                if (!cdd.sourceRect.HasValue)
                {
                    cdd.sourceRect = new Rectangle?(cdd.texture.Frame(1, 1, 0, 0, 0, 0));
                }
                PlayerDrawHelper.SetShaderForData(drawPlayer, drawPlayer.cHead, ref cdd);
                if (cdd.texture != null)
                {
                    cdd.Draw(spriteBatch);
                }
            }
            pixelShader.CurrentTechnique.Passes[0].Apply();
        }
コード例 #18
0
        public override void PostDraw(SpriteBatch spriteBatch, Color drawColor)
        {
            if (npc.ai[0] == 9 && npc.ai[1] < 420)
            {
                return;
            }

            spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.ZoomMatrix);

            Texture2D star   = mod.GetTexture("Effects/LifeStar");
            Rectangle rect   = new Rectangle(0, 0, star.Width, star.Height);
            float     scale  = npc.localAI[3] == 0 ? npc.ai[2] * Main.rand.NextFloat(1f, 2.5f) : (Main.cursorScale + 0.3f) * Main.rand.NextFloat(0.8f, 1.2f);
            Vector2   origin = new Vector2((star.Width / 2) + scale, (star.Height / 2) + scale);

            spriteBatch.Draw(star, npc.Center - Main.screenPosition, new Rectangle?(rect), Color.HotPink, 0, origin, scale, SpriteEffects.None, 0);
            DrawData starDraw = new DrawData(star, npc.Center - Main.screenPosition, new Rectangle?(rect), Color.White, 0, origin, scale, SpriteEffects.None, 0);

            GameShaders.Misc["LCWingShader"].UseColor(Color.Goldenrod).UseSecondaryColor(Color.HotPink);
            GameShaders.Misc["LCWingShader"].Apply(starDraw);
            starDraw.Draw(spriteBatch);

            spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.ZoomMatrix);
        }
コード例 #19
0
        private static void DrawAltHairLayer(Player player, short hairDye, ref Color color, ref Vector2 drawOrigin, float scale, SpriteEffects spriteEffects)
        {
            Rectangle bodyFrame3 = player.bodyFrame;

            bodyFrame3.Y -= 336;
            if (bodyFrame3.Y < 0)
            {
                bodyFrame3.Y = 0;
            }
            if (!player.invis)
            {
                Texture2D hairAltTex = Main.playerHairAltTexture[player.hair];
                var       pos        = new Vector2(player.position.X - Main.screenPosition.X - (float)(player.bodyFrame.Width / 2) + (float)(player.width / 2),
                                                   player.position.Y - Main.screenPosition.Y + (float)player.height - (float)player.bodyFrame.Height + 4f
                                                   ) + player.headPosition + drawOrigin;

                DrawData draw = new DrawData(hairAltTex, pos, new Rectangle?(bodyFrame3), color, player.headRotation, drawOrigin, scale, spriteEffects, 0);

                GameShaders.Hair.Apply(hairDye, player, new DrawData?(draw));
                draw.Draw(Main.spriteBatch);
                Main.pixelShader.CurrentTechnique.Passes[0].Apply();
            }
        }
コード例 #20
0
ファイル: EyeBulletShot.cs プロジェクト: DarthHA/Twilight
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Texture2D TrailTex = mod.GetTexture("Projectiles/EyeBulletTrail");
            Texture2D tex2     = mod.GetTexture("Projectiles/EyeBullet2");
            Texture2D tex3     = mod.GetTexture("Projectiles/EyeBullet3");

            //spriteBatch.End();
            //spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.EffectMatrix);
            DrawUtils.AnotherDraw(BlendState.Additive);
            for (int i = 0; i < ProjectileID.Sets.TrailCacheLength[projectile.type] - 1; i++)
            {
                //int i2 = (int)(i + projectile.ai[0]) % (ProjectileID.Sets.TrailCacheLength[projectile.type] - 1);
                Rectangle rectangle = new Rectangle(0, 5 * i, 84, 5 * (i + 1));  //10 84
                float     len       = (projectile.oldPos[i + 1] - projectile.oldPos[i]).Length();
                if (projectile.oldPos[i + 1] == Vector2.Zero || projectile.oldPos[i] == Vector2.Zero)
                {
                    continue;
                }
                Vector2 scale     = new Vector2(0.2f, len / 10);
                float   ops       = (50f - i) / 50f;
                Vector2 MidCenter = (projectile.oldPos[i] + projectile.oldPos[i + 1]) / 2 + projectile.Size / 2;
                spriteBatch.Draw(TrailTex, MidCenter - Main.screenPosition, rectangle, Color.Orange * ops, projectile.oldRot[i], rectangle.Size() / 2, scale, SpriteEffects.None, 0);
            }

            //spriteBatch.End();
            //spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.EffectMatrix);
            DrawUtils.AnotherDraw(BlendState.NonPremultiplied);
            spriteBatch.Draw(tex2, projectile.Center - Main.screenPosition, null, Color.White, projectile.rotation, tex2.Size() / 2, projectile.scale * 0.3f, SpriteEffects.None, 0);
            //spriteBatch.End();
            //spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.EffectMatrix);
            DrawUtils.AnotherDraw(BlendState.Additive);
            spriteBatch.Draw(tex3, projectile.Center - Main.screenPosition, null, Color.White * 0.75f, 0, tex3.Size() / 2, projectile.scale * 0.45f, SpriteEffects.None, 0);

            if (projectile.ai[0] < 30)
            {
                if (Twilight.FindBody() != -1)
                {
                    Vector2 Pos       = new Vector2(projectile.localAI[0], projectile.localAI[1]);
                    Vector2 ScreenPos = Pos + Main.npc[Twilight.FindBody()].Center - Main.screenPosition;
                    float   R         = projectile.ai[0] * 6f;
                    float   ops       = 1;
                    if (projectile.ai[0] >= 15)
                    {
                        ops = (30 - projectile.ai[0]) / 15;
                    }
                    //Main.spriteBatch.End();
                    //Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.EffectMatrix);
                    DrawUtils.AnotherDraw(SpriteSortMode.Immediate);
                    DrawData data = new DrawData(TextureManager.Load("Images/Misc/Perlin"), ScreenPos, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, 0, (int)(R * 2), (int)(R * 2))), Color.Orange * ops, projectile.rotation, new Vector2(R, R), new Vector2(1, 0.67f), SpriteEffects.None, 0);
                    GameShaders.Misc["ForceField"].UseColor(new Vector3(2f));
                    GameShaders.Misc["ForceField"].Apply(new DrawData?(data));
                    data.Draw(spriteBatch);
                    DrawUtils.AnotherDraw(SpriteSortMode.Deferred);
                    //Main.spriteBatch.End();
                    //Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.EffectMatrix);
                }
            }
            DrawUtils.AnotherDraw(BlendState.AlphaBlend);
            //spriteBatch.End();
            //spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.EffectMatrix);
            return(false);
        }
コード例 #21
0
        /*public override Color? GetAlpha(Color drawColor)
         * {
         *  return Color.White * npc.Opacity;
         * }*/

        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Texture2D texture2D13 = Main.npcTexture[npc.type];
            //int num156 = Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type]; //ypos of lower right corner of sprite to draw
            //int y3 = num156 * npc.frame.Y; //ypos of upper left corner of sprite to draw
            Rectangle rectangle = npc.frame;//new Rectangle(0, y3, texture2D13.Width, num156);
            Vector2   origin2   = rectangle.Size() / 2f;

            Color color26 = lightColor;

            color26 = npc.GetAlpha(color26);

            SpriteEffects effects = SpriteEffects.None; /*npc.spriteDirection > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
                                                         *
                                                         * for (int i = 0; i < NPCID.Sets.TrailCacheLength[npc.type]; i++)
                                                         * {
                                                         * Color color27 = color26 * 0.5f;
                                                         * color27 *= (float)(NPCID.Sets.TrailCacheLength[npc.type] - i) / NPCID.Sets.TrailCacheLength[npc.type];
                                                         * Vector2 value4 = npc.oldPos[i];
                                                         * float num165 = npc.rotation; //npc.oldRot[i];
                                                         * Main.spriteBatch.Draw(texture2D13, value4 + npc.Size / 2f - Main.screenPosition + new Vector2(0, npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color27, num165, origin2, npc.scale, effects, 0f);
                                                         * }*/

            Main.spriteBatch.Draw(texture2D13, npc.Center - Main.screenPosition + new Vector2(0f, npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), npc.GetAlpha(lightColor), npc.rotation, origin2, npc.scale, effects, 0f);

            //spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.ZoomMatrix);

            int       currentFrame  = npc.frame.Y / (texture2D13.Height / Main.npcFrameCount[npc.type]);
            Texture2D wing          = mod.GetTexture("NPCs/Champions/LifeChampion_Wings");
            Texture2D wingGlow      = mod.GetTexture("NPCs/Champions/LifeChampion_WingsGlow");
            int       wingHeight    = wing.Height / Main.npcFrameCount[npc.type];
            Rectangle wingRectangle = new Rectangle(0, currentFrame * wingHeight, wing.Width, wingHeight);
            Vector2   wingOrigin    = wingRectangle.Size() / 2f;

            Color glowColor = Color.White * npc.Opacity;

            spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.ZoomMatrix);
            for (int i = 0; i < NPCID.Sets.TrailCacheLength[npc.type]; i++)
            {
                Vector2  value4        = npc.oldPos[i];
                float    num165        = 0; //npc.oldRot[i];
                DrawData wingTrailGlow = new DrawData(wing, value4 + npc.Size / 2f - Main.screenPosition + new Vector2(0, npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(wingRectangle), glowColor * (0.5f / i), num165, wingOrigin, npc.scale * 2, effects, 0);
                GameShaders.Misc["LCWingShader"].UseColor(new Color(1f, 0.647f, 0.839f)).UseSecondaryColor(Color.CornflowerBlue);
                GameShaders.Misc["LCWingShader"].Apply(wingTrailGlow);
                wingTrailGlow.Draw(spriteBatch);
            }

            spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.ZoomMatrix);

            spriteBatch.Draw(wing, npc.Center - Main.screenPosition + new Vector2(0f, npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(wingRectangle), glowColor, 0, wingOrigin, npc.scale * 2, effects, 0f);

            spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.ZoomMatrix);

            DrawData wingGlowData = new DrawData(wingGlow, npc.Center - Main.screenPosition + new Vector2(0f, npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(wingRectangle), glowColor, 0, wingOrigin, npc.scale * 2, effects, 0);

            GameShaders.Misc["LCWingShader"].UseColor(new Color(1f, 0.647f, 0.839f)).UseSecondaryColor(Color.Goldenrod);
            GameShaders.Misc["LCWingShader"].Apply(wingGlowData);
            wingGlowData.Draw(spriteBatch);

            spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.ZoomMatrix);
            return(false);
        }
コード例 #22
0
        public static PlayerHeadLayer DrawHeadLayer(string equip, string texturePath, string name = "Mask", int useShader = 0)
        {
            return(new PlayerHeadLayer("QwertysRandomContent", "Mask", delegate(PlayerHeadDrawInfo drawInfo)
            {
                Mod mod = ModLoader.GetMod("QwertysRandomContent");
                Player drawPlayer = drawInfo.drawPlayer;
                Vector2 vector = new Vector2((float)drawPlayer.legFrame.Width * 0.5f, (float)drawPlayer.legFrame.Height * 0.4f);
                bool drawIt = false;

                float mapScale;
                byte b = (byte)(255f * Main.mapOverlayAlpha);
                float X = 0;
                float Y = 0;
                float num = 0f;
                float num2 = 0f;
                float num3 = num;
                float num4 = num2;
                float num6 = 10f;
                float num7 = 10f;
                float num8 = (float)(Main.maxTilesX - Lighting.offScreenTiles - 1);
                float num9 = (float)(Main.maxTilesY - Lighting.offScreenTiles - 42);
                float num10 = 0f;
                float num11 = 0f;
                num8 = (float)(Main.maxTilesX - 10);
                num9 = (float)(Main.maxTilesY - 10);
                float num12 = 0f;
                float num13 = 0f;
                float num14 = num8 - 1f;
                float num15 = num9 - 1f;
                num = 200f;
                num2 = 300f;
                if (!Main.mapFullscreen && Main.mapStyle == 2)
                {
                    mapScale = Main.mapOverlayScale;
                    float num32 = (Main.screenPosition.X + (float)(Main.screenWidth / 2)) / 16f;
                    float num33 = (Main.screenPosition.Y + (float)(Main.screenHeight / 2)) / 16f;
                    num32 *= mapScale;
                    num33 *= mapScale;
                    num = -num32 + (float)(Main.screenWidth / 2);
                    num2 = -num33 + (float)(Main.screenHeight / 2);
                    num += num6 * mapScale;
                    num2 += num7 * mapScale;


                    float num56 = (drawPlayer.position.X + (float)(drawPlayer.width / 2)) / 16f * mapScale;
                    float num57 = drawPlayer.position.Y / 16f * mapScale;
                    num56 += num;
                    num57 += num2;
                    num56 -= 6f;
                    num57 -= 2f;
                    num57 -= 2f - mapScale / 5f * 2f;
                    num56 -= 10f * mapScale;
                    num57 -= 10f * mapScale;
                    X = num56;
                    Y = num57;
                    drawIt = true;
                }
                if (!Main.mapFullscreen && Main.mapStyle == 1)
                {
                    num = (float)Main.miniMapX;
                    num2 = (float)Main.miniMapY;
                    num3 = num;
                    num4 = num2;
                    mapScale = Main.mapMinimapScale;
                    float num28 = (Main.screenPosition.X + (float)(PlayerInput.RealScreenWidth / 2)) / 16f;
                    float num29 = (Main.screenPosition.Y + (float)(PlayerInput.RealScreenHeight / 2)) / 16f;
                    num14 = (float)Main.miniMapWidth / mapScale;
                    num15 = (float)Main.miniMapHeight / mapScale;
                    num12 = (float)((int)num28) - num14 / 2f;
                    num13 = (float)((int)num29) - num15 / 2f;
                    float num78 = ((drawPlayer.position.X + (float)(drawPlayer.width / 2)) / 16f - num12) * mapScale;
                    float num79 = ((drawPlayer.position.Y + drawPlayer.gfxOffY + (float)(drawPlayer.height / 2)) / 16f - num13) * mapScale;
                    num78 += num3;
                    num79 += num4;
                    num78 -= 6f;
                    num79 -= 6f;
                    num79 -= 2f - mapScale / 5f * 2f;
                    num78 += num10;
                    num79 += num11;
                    if (Main.screenPosition.X != Main.leftWorld + 640f + 16f && Main.screenPosition.X + (float)Main.screenWidth != Main.rightWorld - 640f - 32f && Main.screenPosition.Y != Main.topWorld + 640f + 16f && Main.screenPosition.Y + (float)Main.screenHeight <= Main.bottomWorld - 640f - 32f && drawPlayer.whoAmI == Main.myPlayer && Main.zoomX == 0f && Main.zoomY == 0f)
                    {
                        num78 = num3 + (float)(Main.miniMapWidth / 2);
                        num79 = num4 + (float)(Main.miniMapHeight / 2);
                        num79 -= 3f;
                        num78 -= 4f;
                    }
                    if (!drawPlayer.dead && num78 > (float)(Main.miniMapX + 6) && num78 < (float)(Main.miniMapX + Main.miniMapWidth - 16) && num79 > (float)(Main.miniMapY + 6) && num79 < (float)(Main.miniMapY + Main.miniMapHeight - 14))
                    {
                        X = num78;
                        Y = num79;
                        drawIt = true;
                    }
                }
                if (Main.mapFullscreen)
                {
                    mapScale = Main.mapFullscreenScale;
                    float num20 = Main.mapFullscreenPos.X;
                    float num21 = Main.mapFullscreenPos.Y;
                    if (Main.resetMapFull)
                    {
                        num20 = (Main.screenPosition.X + (float)(Main.screenWidth / 2)) / 16f;
                        num21 = (Main.screenPosition.Y + (float)(Main.screenHeight / 2)) / 16f;
                    }
                    num20 *= mapScale;
                    num21 *= mapScale;
                    num = -num20 + (float)(Main.screenWidth / 2);
                    num2 = -num21 + (float)(Main.screenHeight / 2);
                    num += num6 * mapScale;
                    num2 += num7 * mapScale;



                    float num137 = (((drawPlayer.position.X + drawPlayer.width / 2)) / 16f - num12) * mapScale;
                    float num138 = ((drawPlayer.position.Y + drawPlayer.gfxOffY + (float)(drawPlayer.height / 2)) / 16f - num13) * mapScale;
                    num137 += num;
                    num138 += num2;
                    num137 -= 6f;
                    num138 -= 2f;
                    num138 -= 2f - mapScale / 5f * 2f;
                    num137 -= 10f * mapScale;
                    num138 -= 10f * mapScale;


                    X = num137;
                    Y = num138;
                    drawIt = true;
                }
                Vector2 drawPos = Main.screenPosition;
                drawPos.X += X;
                drawPos.Y += Y;
                drawPos.X -= 6f;
                drawPos.Y -= 4f;
                float mountOff = (float)drawPlayer.mount.PlayerHeadOffset;
                drawPos.Y = drawPos.Y - mountOff;
                if (drawPlayer.head == mod.GetEquipSlot(equip, EquipType.Head) && drawIt)
                {
                    Texture2D texture = mod.GetTexture(texturePath);
                    DrawData data = new DrawData(texture,
                                                 new Vector2(drawPos.X - Main.screenPosition.X - (float)(drawPlayer.bodyFrame.Width / 2) + (float)(drawPlayer.width / 2), drawPos.Y - Main.screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f) + drawPlayer.headPosition + vector,
                                                 texture.Frame(), drawInfo.armorColor, 0f, drawInfo.drawOrigin, drawInfo.scale, drawInfo.spriteEffects, 0);
                    GameShaders.Armor.Apply(drawPlayer.dye[useShader].dye, drawPlayer, new DrawData?(data));
                    data.Draw(Main.spriteBatch);
                }
            }));
        }
コード例 #23
0
        public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
        {
            if (NPC.alpha != 0 && !NPC.IsABestiaryIconDummy) //proceed anyway for bestiary
            {
                return(false);
            }

            Texture2D texture2D13 = Terraria.GameContent.TextureAssets.Npc[NPC.type].Value;
            //int num156 = Terraria.GameContent.TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type]; //ypos of lower right corner of sprite to draw
            //int y3 = num156 * NPC.frame.Y; //ypos of upper left corner of sprite to draw
            Rectangle rectangle = NPC.frame;//new Rectangle(0, y3, texture2D13.Width, num156);
            Vector2   origin2   = rectangle.Size() / 2f;

            Color color26 = drawColor;

            color26 = NPC.IsABestiaryIconDummy ? Color.White : NPC.GetAlpha(color26);

            SpriteEffects effects = SpriteEffects.None; /*NPC.spriteDirection > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
                                                         *
                                                         * for (int i = 0; i < NPCID.Sets.TrailCacheLength[NPC.type]; i++)
                                                         * {
                                                         * Color color27 = color26 * 0.5f;
                                                         * color27 *= (float)(NPCID.Sets.TrailCacheLength[NPC.type] - i) / NPCID.Sets.TrailCacheLength[NPC.type];
                                                         * Vector2 value4 = NPC.oldPos[i];
                                                         * float num165 = NPC.rotation; //NPC.oldRot[i];
                                                         * Main.EntitySpriteDraw(texture2D13, value4 + NPC.Size / 2f - screenPos + new Vector2(0, NPC.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color27, num165, origin2, NPC.scale, effects, 0);
                                                         * }*/

            Main.EntitySpriteDraw(texture2D13, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color26, NPC.rotation, origin2, NPC.scale, effects, 0);

            //spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.ZoomMatrix);

            int       currentFrame  = NPC.frame.Y / (texture2D13.Height / Main.npcFrameCount[NPC.type]);
            Texture2D wing          = FargowiltasSouls.Instance.Assets.Request <Texture2D>("NPCs/Champions/LifeChampion_Wings", ReLogic.Content.AssetRequestMode.ImmediateLoad).Value;
            Texture2D wingGlow      = FargowiltasSouls.Instance.Assets.Request <Texture2D>("NPCs/Champions/LifeChampion_WingsGlow", ReLogic.Content.AssetRequestMode.ImmediateLoad).Value;
            int       wingHeight    = wing.Height / Main.npcFrameCount[NPC.type];
            Rectangle wingRectangle = new Rectangle(0, currentFrame * wingHeight, wing.Width, wingHeight);
            Vector2   wingOrigin    = wingRectangle.Size() / 2f;

            Color glowColor = Color.White;

            if (!NPC.IsABestiaryIconDummy)
            {
                glowColor *= NPC.Opacity;
            }
            float wingBackScale = 2 * NPC.scale * ((Main.mouseTextColor / 200f - 0.35f) * 0.1f + 0.95f);

            if (!NPC.IsABestiaryIconDummy)
            {
                spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.ZoomMatrix);
            }

            for (int i = 0; i < NPCID.Sets.TrailCacheLength[NPC.type]; i++)
            {
                Vector2  value4        = NPC.oldPos[i];
                float    num165        = 0; //NPC.oldRot[i];
                DrawData wingTrailGlow = new DrawData(wing, value4 + NPC.Size / 2f - screenPos + new Vector2(0, NPC.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(wingRectangle), glowColor * (0.5f / i), num165, wingOrigin, wingBackScale, effects, 0);
                GameShaders.Misc["LCWingShader"].UseColor(new Color(1f, 0.647f, 0.839f)).UseSecondaryColor(Color.CornflowerBlue);
                GameShaders.Misc["LCWingShader"].Apply(wingTrailGlow);
                wingTrailGlow.Draw(spriteBatch);
            }

            if (!NPC.IsABestiaryIconDummy)
            {
                spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.ZoomMatrix);
            }

            Main.EntitySpriteDraw(wing, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(wingRectangle), glowColor, 0, wingOrigin, NPC.scale * 2, effects, 0);

            if (!NPC.IsABestiaryIconDummy)
            {
                spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.ZoomMatrix);
            }

            DrawData wingGlowData = new DrawData(wingGlow, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(wingRectangle), glowColor * 0.5f, 0, wingOrigin, NPC.scale * 2, effects, 0);

            GameShaders.Misc["LCWingShader"].UseColor(new Color(1f, 0.647f, 0.839f)).UseSecondaryColor(Color.Goldenrod);
            GameShaders.Misc["LCWingShader"].Apply(wingGlowData);
            wingGlowData.Draw(spriteBatch);
            return(false);
        }
コード例 #24
0
ファイル: Solweaver.cs プロジェクト: Tyfyter/EpikV2
        /// <summary>
        /// The core function of drawing a laser
        /// </summary>
        public void DrawLaser(SpriteBatch spriteBatch, Texture2D texture, Vector2 start, Vector2 unit, float step, Vector2?uScale = null, float maxDist = 200f, Color color = default)
        {
            Vector2 scale    = uScale ?? new Vector2(0.66f, 0.66f);
            Vector2 origin   = start;
            float   maxl     = (_targetPos - start).Length();
            float   r        = unit.ToRotation(); // + rotation??(float)(Math.PI/2);
            float   l        = unit.Length();     //*2.5f;
            int     t        = projectile.timeLeft > 10?25 - projectile.timeLeft:projectile.timeLeft;
            float   s        = Math.Min(t / 15f, 1f);
            Vector2 perpUnit = unit.RotatedBy(MathHelper.PiOver2);
            //Dust dust;
            DrawData data;
            int      dustTimer = 48;

            for (float i = 0; i <= maxDist; i += step)
            {
                if ((i * l) > maxl)
                {
                    break;
                }
                origin = start + i * unit;
                //*
                if (maxl - (i * l) < 16 && !(Collision.CanHitLine(origin - unit, lcs, lcs, origin, lcs, lcs) ||
                                             Collision.CanHitLine(origin + perpUnit, lcs, lcs, origin - unit, lcs, lcs) ||
                                             Collision.CanHitLine(origin - perpUnit, lcs, lcs, origin - unit, lcs, lcs)
                                             ))
                {
                    break;
                }
                //*/

                /*spriteBatch.Draw(texture, origin - Main.screenPosition,
                 *  new Rectangle((int)i%44, 0, 1, 32), Color.OrangeRed, r,
                 *  new Vector2(0, 16+(float)Math.Sin(i/4f)*2), scale*new Vector2(1,s), 0, 0);*/
                data = new DrawData(texture, origin - Main.screenPosition,
                                    new Rectangle((int)(i - (3 * Main.GameUpdateCount % 44)) % 44, 0, 1, 32), Color.OrangeRed, r,
                                    new Vector2(0, 16 + (float)(Math.Sin(i / 6f) * Math.Cos((i * Main.GameUpdateCount) / 4.5f) * 3)),
                                    scale * new Vector2(1, (float)(s * Math.Min(1, Math.Sqrt(i / 10)))), 0, 0);
                EpikV2.fireMiscShader.Apply(data);
                data.Draw(spriteBatch);
                //dust = Dust.NewDustPerfect(origin, 6, null, Scale:2);
                //dust.shader = EpikV2.fireDyeShader;
                //dust.noGravity = true;
                Lighting.AddLight(origin, 1 * s, 0.25f * s, 0);
                if (Main.rand.Next(++dustTimer) > 48)
                {
                    Dust.NewDustPerfect(origin + (perpUnit * Main.rand.NextFloat(-8, 8)), 6, unit * 5).noGravity = true;
                    dustTimer = Main.rand.NextBool()?16:0;
                }
            }
            Dust.NewDustPerfect(origin + (perpUnit * Main.rand.NextFloat(-8, 8)), 6, unit * 5).noGravity = true;

            /**Toblerone Renderer
             * for (float i = 0; i <= maxDist; i += step){
             *  if((i*unit).Length()>maxl)break;
             *  origin = start + i * unit;
             *  if(!Collision.CanHitLine(origin-unit, 1, 1, origin, 1, 1))break;
             *  spriteBatch.Draw(texture, origin - Main.screenPosition - new Vector2(0,i),
             *      new Rectangle((int)i%43, 0, (int)i%43+2, 32), Color.OrangeRed, r,
             *      new Vector2(i%43, 16), scale*new Vector2(1,s), 0, 0);
             *  //dust = Dust.NewDustPerfect(origin, 6, null, Scale:2);
             *  //dust.shader = EpikV2.fireDyeShader;
             *  //dust.noGravity = true;
             *  Lighting.AddLight(origin, 1*s, 0.25f*s, 0);
             * }
             */
        }
コード例 #25
0
        private static void DrawArmorLayer(Player player, int shaderId, short hairDye, ref Color color1, ref Color color2, ref Vector2 drawOrigin, float scale, SpriteEffects spriteEffects)
        {
            if (player.head == 23)
            {
                Rectangle bodyFrameOffset = player.bodyFrame;
                bodyFrameOffset.Y -= 336;
                if (bodyFrameOffset.Y < 0)
                {
                    bodyFrameOffset.Y = 0;
                }
                DrawData draw;
                if (!player.invis)
                {
                    Texture2D hairTex = Main.playerHairTexture[player.hair];
                    var       hairPos = new Vector2(player.position.X - Main.screenPosition.X - (float)(player.bodyFrame.Width / 2) + (float)(player.width / 2),
                                                    player.position.Y - Main.screenPosition.Y + (float)player.height - (float)player.bodyFrame.Height + 4f
                                                    ) + player.headPosition + drawOrigin;

                    draw = new DrawData(hairTex, hairPos, new Rectangle?(bodyFrameOffset), color1, player.headRotation, drawOrigin, scale, spriteEffects, 0);

                    GameShaders.Hair.Apply(hairDye, player, new DrawData?(draw));
                    draw.Draw(Main.spriteBatch);
                    Main.pixelShader.CurrentTechnique.Passes[0].Apply();
                }

                Texture2D armorHeadTex = Main.armorHeadTexture[player.head];
                var       armorPos     = new Vector2(player.position.X - Main.screenPosition.X - (float)(player.bodyFrame.Width / 2) + (float)(player.width / 2), player.position.Y - Main.screenPosition.Y + (float)player.height - (float)player.bodyFrame.Height + 4f) + player.headPosition + drawOrigin;

                draw = new DrawData(armorHeadTex, armorPos, new Rectangle?(player.bodyFrame), color2, player.headRotation, drawOrigin, scale, spriteEffects, 0);

                GameShaders.Armor.Apply(shaderId, player, new DrawData?(draw));
                draw.Draw(Main.spriteBatch);
                Main.pixelShader.CurrentTechnique.Passes[0].Apply();
            }
            else if (player.head == 14 || player.head == 56 || player.head == 158)
            {
                Rectangle bodyFrameOffset = player.bodyFrame;
                if (player.head == 158)
                {
                    bodyFrameOffset.Height -= 2;
                }
                int frameYOffset = 0;
                if (bodyFrameOffset.Y == bodyFrameOffset.Height * 6)
                {
                    bodyFrameOffset.Height -= 2;
                }
                else if (bodyFrameOffset.Y == bodyFrameOffset.Height * 7)
                {
                    frameYOffset = -2;
                }
                else if (bodyFrameOffset.Y == bodyFrameOffset.Height * 8)
                {
                    frameYOffset = -2;
                }
                else if (bodyFrameOffset.Y == bodyFrameOffset.Height * 9)
                {
                    frameYOffset = -2;
                }
                else if (bodyFrameOffset.Y == bodyFrameOffset.Height * 10)
                {
                    frameYOffset = -2;
                }
                else if (bodyFrameOffset.Y == bodyFrameOffset.Height * 13)
                {
                    bodyFrameOffset.Height -= 2;
                }
                else if (bodyFrameOffset.Y == bodyFrameOffset.Height * 14)
                {
                    frameYOffset = -2;
                }
                else if (bodyFrameOffset.Y == bodyFrameOffset.Height * 15)
                {
                    frameYOffset = -2;
                }
                else if (bodyFrameOffset.Y == bodyFrameOffset.Height * 16)
                {
                    frameYOffset = -2;
                }
                bodyFrameOffset.Y += frameYOffset;

                Texture2D armorHeadTex = Main.armorHeadTexture[player.head];
                var       armorPos     = new Vector2(player.position.X - Main.screenPosition.X - (float)(player.bodyFrame.Width / 2) + (float)(player.width / 2), player.position.Y - Main.screenPosition.Y + (float)player.height - (float)player.bodyFrame.Height + 4f + (float)frameYOffset) + player.headPosition + drawOrigin;

                DrawData draw = new DrawData(armorHeadTex, armorPos, new Rectangle?(bodyFrameOffset), color2, player.headRotation, drawOrigin, scale, spriteEffects, 0);

                GameShaders.Armor.Apply(shaderId, player, new DrawData?(draw));
                draw.Draw(Main.spriteBatch);
                Main.pixelShader.CurrentTechnique.Passes[0].Apply();
            }
            else if (player.head > 0 && player.head < 214 && player.head != 28)
            {
                Texture2D armorHeadTex = Main.armorHeadTexture[player.head];
                var       armorPos     = new Vector2(player.position.X - Main.screenPosition.X - (float)(player.bodyFrame.Width / 2) + (float)(player.width / 2),
                                                     player.position.Y - Main.screenPosition.Y + (float)player.height - (float)player.bodyFrame.Height + 4f
                                                     ) + player.headPosition + drawOrigin;

                DrawData draw = new DrawData(armorHeadTex, armorPos, new Rectangle?(player.bodyFrame), color2, player.headRotation, drawOrigin, scale, spriteEffects, 0);

                GameShaders.Armor.Apply(shaderId, player, new DrawData?(draw));
                draw.Draw(Main.spriteBatch);
                Main.pixelShader.CurrentTechnique.Passes[0].Apply();
            }
            else
            {
                Rectangle bodyFrameOffset = player.bodyFrame;
                bodyFrameOffset.Y -= 336;
                if (bodyFrameOffset.Y < 0)
                {
                    bodyFrameOffset.Y = 0;
                }

                Texture2D hairTex = Main.playerHairTexture[player.hair];
                var       hairPos = new Vector2(player.position.X - Main.screenPosition.X - (float)(player.bodyFrame.Width / 2) + (float)(player.width / 2),
                                                player.position.Y - Main.screenPosition.Y + (float)player.height - (float)player.bodyFrame.Height + 4f
                                                ) + player.headPosition + drawOrigin;

                DrawData draw = new DrawData(hairTex, hairPos, new Rectangle?(bodyFrameOffset), color1, player.headRotation, drawOrigin, scale, spriteEffects, 0);

                GameShaders.Hair.Apply(hairDye, player, new DrawData?(draw));
                draw.Draw(Main.spriteBatch);
                Main.pixelShader.CurrentTechnique.Passes[0].Apply();
            }
        }