public void AdditiveCall(SpriteBatch sb)
        {
            Texture2D WhiteMask        = ModContent.GetTexture(Texture + "_Mask");
            float     whiteMaskOpacity = 1 - (Timer / PRE_LAUNCH_TIME);

            whiteMaskOpacity = Math.Max(whiteMaskOpacity, 0);
            whiteMaskOpacity = EaseFunction.EaseQuadOut.Ease(whiteMaskOpacity);

            sb.Draw(WhiteMask, projectile.Center - Main.screenPosition, projectile.DrawFrame(), Color.White * whiteMaskOpacity * projectile.Opacity, projectile.rotation,
                    projectile.DrawFrame().Size() / 2, projectile.scale, SpriteEffects.None, 0);

            float blurLength = 200 * projectile.scale * whiteMaskOpacity * projectile.Opacity;
            float blurWidth  = 25 * projectile.scale * whiteMaskOpacity * projectile.Opacity;

            Effect          blurEffect = mod.GetEffect("Effects/BlurLine");
            SquarePrimitive blurLine   = new SquarePrimitive()
            {
                Position = projectile.Center - Main.screenPosition,
                Height   = blurWidth,
                Length   = blurLength,
                Rotation = 0,
                Color    = Color.White * whiteMaskOpacity * projectile.Opacity
            };

            PrimitiveRenderer.DrawPrimitiveShape(blurLine, blurEffect);
        }
Exemple #2
0
        public override void Draw(Effect effect, BasicEffect effect2, GraphicsDevice device)
        {
            if (Dead)
            {
                return;
            }

            //set the parameters for the shader
            Effect noiseTrailEffect = SpiritMod.Instance.GetEffect("Effects/MotionNoiseTrail");

            noiseTrailEffect.Parameters["uTexture"].SetValue(SpiritMod.Instance.GetTexture("Textures/voronoiLooping"));
            noiseTrailEffect.Parameters["uColor"].SetValue(_color.ToVector4());
            noiseTrailEffect.Parameters["progress"].SetValue(Main.GlobalTime * -1.5f);
            float length = (_startPoint - _endPoint).Length();

            noiseTrailEffect.Parameters["xMod"].SetValue(length / 800f);
            noiseTrailEffect.Parameters["yMod"].SetValue(0.66f);

            Vector2         center          = Vector2.Lerp(_startPoint, _endPoint, 0.5f);
            float           rotation        = (_startPoint - _endPoint).ToRotation();
            Color           lightColor      = Lighting.GetColor((int)center.X / 16, (int)center.Y / 16);
            SquarePrimitive squarePrimitive = new SquarePrimitive
            {
                Height   = _width,
                Length   = length,
                Color    = lightColor * _opacity,
                Position = center - Main.screenPosition,
                Rotation = rotation
            };

            PrimitiveRenderer.DrawPrimitiveShape(squarePrimitive, noiseTrailEffect);
        }
        public override void CustomDraw(SpriteBatch spriteBatch)
        {
            Texture2D texture   = ParticleHandler.GetTexture(Type);
            var       drawFrame = new Rectangle(0, _frame * texture.Height / 2, texture.Width, texture.Height / 2);

            Effect effect = SpiritMod.ShaderDict["PrimitiveTextureMap"];

            effect.Parameters["uTexture"].SetValue(SpiritMod.Instance.GetTexture("NPCs/Boss/Occultist/SoulTrail"));
            Vector2[] vertices = _chain.VerticesArray();
            vertices.IterateArray(delegate(ref Vector2 vertex, int index, float progress) { IterateVerticesSine(ref vertex, progress); });
            var strip = new PrimitiveStrip
            {
                Color         = Color.White * _opacity,
                Width         = 13 * Scale,
                PositionArray = vertices,
                TaperingType  = StripTaperType.None,
            };

            PrimitiveRenderer.DrawPrimitiveShape(strip, effect);

            var origin = new Vector2(drawFrame.Width / 2, drawFrame.Height);

            spriteBatch.Draw(texture, _chain.StartPosition - Main.screenPosition, drawFrame, Color.White * _opacity, Rotation, origin, Scale, SpriteEffects.None, 0);

            Texture2D bloom = SpiritMod.Instance.GetTexture("Effects/Ripple");

            spriteBatch.Draw(bloom, _chain.StartPosition - Main.screenPosition, null, Color.Red * _opacity, 0, bloom.Size() / 2, 0.75f, SpriteEffects.None, 0);
        }
        public void AdditiveCall(SpriteBatch spriteBatch)
        {
            Texture2D Bloom        = mod.GetTexture("Effects/Masks/CircleGradient");
            Color     color        = BloomColor;
            float     bloomopacity = 0.75f;
            float     bloomscale   = 0.4f;
            float     starScale    = 15f;

            if (Timer > 15 && Timer < 45)
            {
                color        = Color.Lerp(color, Color.White, 0.75f * ScaleProgress());
                bloomopacity = MathHelper.Lerp(bloomopacity, 2f, ScaleProgress());
                bloomscale   = MathHelper.Lerp(bloomscale, 0.25f, ScaleProgress());
                starScale    = MathHelper.Lerp(starScale, 7f, ScaleProgress());
            }

            if (LastStar >= 0)
            {
                Projectile laststar = Main.projectile[(int)LastStar];
                if (laststar.active && laststar.type == projectile.type && laststar.ai[0] == projectile.ai[0] + 1 && laststar.owner == projectile.owner)
                {
                    Texture2D Beam    = mod.GetTexture("Textures/Trails/Trail_4");
                    Vector2   scale   = new Vector2(projectile.Distance(laststar.Center) / Beam.Width, projectile.scale * 30 / Beam.Height);
                    float     opacity = 0.8f * projectile.Opacity * laststar.Opacity;
                    Vector2   origin  = new Vector2(0, Beam.Height / 2);
                    spriteBatch.Draw(Beam, projectile.Center - Main.screenPosition, null, Color.Lerp(Color.White, color, 0.75f) * opacity, projectile.AngleTo(laststar.Center), origin, scale, SpriteEffects.None, 0);
                }
            }

            int bloomstodraw = 3;

            for (int i = 0; i < bloomstodraw; i++)
            {
                float progress = i / (float)bloomstodraw;
                spriteBatch.Draw(Bloom, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(color * bloomopacity) * MathHelper.Lerp(1f, 0.5f, 1 - progress), 0,
                                 Bloom.Size() / 2, projectile.scale * bloomscale * MathHelper.Lerp(0.75f, 1.2f, progress), SpriteEffects.None, 0);
            }


            StarPrimitive star = new StarPrimitive
            {
                Color          = Color.White * projectile.Opacity,
                TriangleHeight = starScale * projectile.scale,
                TriangleWidth  = starScale * projectile.scale * 0.3f,
                Position       = projectile.Center - Main.screenPosition,
                Rotation       = projectile.rotation
            };

            PrimitiveRenderer.DrawPrimitiveShape(star);
        }
Exemple #5
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor)
        {
            StarPrimitive star = new StarPrimitive
            {
                Color          = Color.White,
                TriangleHeight = 12 * projectile.scale,
                TriangleWidth  = 4 * projectile.scale,
                Position       = projectile.Center - Main.screenPosition,
                Rotation       = projectile.rotation
            };

            PrimitiveRenderer.DrawPrimitiveShape(star);
            return(false);
        }
Exemple #6
0
        public void AdditiveCall(SpriteBatch sb)
        {
            float blurLength = 100 * projectile.scale * projectile.Opacity;
            float blurWidth  = 25 * projectile.scale * projectile.Opacity;

            Effect          blurEffect = mod.GetEffect("Effects/BlurLine");
            SquarePrimitive blurLine   = new SquarePrimitive()
            {
                Position = projectile.Center - Main.screenPosition,
                Height   = blurWidth,
                Length   = blurLength,
                Rotation = projectile.velocity.X * .1f,
                Color    = new Color(181, 245, 255) * .5f
            };

            PrimitiveRenderer.DrawPrimitiveShape(blurLine, blurEffect);
        }
        public void AdditiveCall(SpriteBatch sB)
        {
            Vector2 drawPosition = npc.Center + (Vector2.UnitY * npc.height / 4);

            if (LockedOn && npc.Distance(Target.Center) < FOLLOW_MAXRANGE)
            {
                Effect effect = mod.GetEffect("Effects/EmpowermentBeam");
                effect.Parameters["uTexture"].SetValue(mod.GetTexture("Textures/Trails/Trail_2"));
                effect.Parameters["progress"].SetValue(Main.GlobalTime / 3);
                effect.Parameters["uColor"].SetValue(new Color(245, 59, 164).ToVector4());
                effect.Parameters["uSecondaryColor"].SetValue(new Color(255, 138, 212).ToVector4());

                Vector2 dist = Target.Center - drawPosition;

                TrianglePrimitive tri = new TrianglePrimitive()
                {
                    TipPosition = drawPosition - Main.screenPosition,
                    Rotation    = dist.ToRotation(),
                    Height      = 100 + dist.Length() * 1.5f,
                    Color       = Color.White * BeamStrength,
                    Width       = 80 + ((Target.width + Target.height) * 0.5f)
                };

                PrimitiveRenderer.DrawPrimitiveShape(tri, effect);
            }

            float blurLength = 250;
            float blurWidth  = 25;

            Effect          blurEffect = mod.GetEffect("Effects/BlurLine");
            SquarePrimitive blurLine   = new SquarePrimitive()
            {
                Position = drawPosition - Main.screenPosition,
                Height   = blurWidth * flickerStrength,
                Length   = blurLength * flickerStrength,
                Rotation = npc.rotation,
                Color    = new Color(255, 138, 212) * flickerStrength
            };

            PrimitiveRenderer.DrawPrimitiveShape(blurLine, blurEffect);

            sB.Draw(ModContent.GetTexture(Texture + "_Glow"), npc.Center - Main.screenPosition, npc.frame, Color.White,
                    npc.rotation, npc.frame.Size() / 2, npc.scale, npc.spriteDirection < 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0);
        }
Exemple #8
0
        protected void DrawBeam(Color lightColor, Color darkColor)
        {
            Effect effect = SpiritMod.Instance.GetEffect("Effects/EmpowermentBeam");

            effect.Parameters["uTexture"].SetValue(SpiritMod.Instance.GetTexture("Textures/Trails/Trail_2"));
            effect.Parameters["progress"].SetValue(Main.GlobalTime / 3);
            effect.Parameters["uColor"].SetValue(darkColor.ToVector4());
            effect.Parameters["uSecondaryColor"].SetValue(lightColor.ToVector4());

            Vector2 dist = SigilPosition - npc.Bottom;

            TrianglePrimitive tri = new TrianglePrimitive()
            {
                TipPosition = SigilPosition - Main.screenPosition,
                Rotation    = MathHelper.PiOver2,
                Height      = 100 + dist.Length() * 1.5f,
                Color       = Color.White * 0.33f,
                Width       = 100 + ((npc.width + npc.height) * 0.5f)
            };

            PrimitiveRenderer.DrawPrimitiveShape(tri, effect);
        }
        public void DrawBoonBeam(Vector2 targetPos)
        {
            Effect effect = SpiritMod.Instance.GetEffect("Effects/EmpowermentBeam");

            effect.Parameters["uTexture"].SetValue(SpiritMod.Instance.GetTexture("Textures/Trails/Trail_2"));
            effect.Parameters["progress"].SetValue(Main.GlobalTime / 3);
            effect.Parameters["uColor"].SetValue(new Color(247, 117, 42, 0).ToVector4());
            effect.Parameters["uSecondaryColor"].SetValue(new Color(247, 195, 92, 0).ToVector4());

            Vector2 dist = SigilPosition - targetPos;

            TrianglePrimitive tri = new TrianglePrimitive()
            {
                TipPosition = SigilPosition - Main.screenPosition,
                Rotation    = (SigilPosition - targetPos).ToRotation() + MathHelper.Pi,
                Height      = 100 + dist.Length() * 1.5f,
                Color       = Color.White * 0.33f,
                Width       = 100 + ((npc.width + npc.height) * 0.5f)
            };

            PrimitiveRenderer.DrawPrimitiveShape(tri, effect);
        }
Exemple #10
0
        public void AdditiveCall(SpriteBatch sB)
        {
            StarPrimitive star = new StarPrimitive
            {
                Color          = Color.White * projectile.Opacity,
                TriangleHeight = 12 * projectile.scale,
                TriangleWidth  = 4 * projectile.scale,
                Position       = projectile.Center - Main.screenPosition,
                Rotation       = projectile.rotation
            };

            PrimitiveRenderer.DrawPrimitiveShape(star);

            Texture2D bloom = mod.GetTexture("Effects/Masks/CircleGradient");

            sB.Draw(bloom, projectile.Center - Main.screenPosition, null, Color.Goldenrod * 0.8f * projectile.Opacity, 0, bloom.Size() / 2, 0.25f * projectile.scale, SpriteEffects.None, 0);
            sB.Draw(bloom, projectile.Center - Main.screenPosition, null, Color.Goldenrod * projectile.Opacity, 0, bloom.Size() / 2, 0.2f * projectile.scale, SpriteEffects.None, 0);

            Texture2D beam         = mod.GetTexture("Textures/Ray");
            float     beamProgress = (float)Math.Pow(Timer / (float)CHANNELTIME, 2);
            float     opacity      = MathHelper.Lerp(0.5f, 1f, beamProgress) * projectile.Opacity;

            for (int i = 0; i < 5; i++)
            {
                float   angle  = TargetAngle + (MathHelper.TwoPi * (i / 5f)) - MathHelper.PiOver2;
                float   length = MathHelper.Lerp(30, 150, beamProgress);
                Vector2 scale  = new Vector2(projectile.scale, length / beam.Height);
                sB.Draw(beam, projectile.Center - Main.screenPosition, null, Color.Goldenrod * opacity, angle, new Vector2(beam.Width / 2, 0), scale, SpriteEffects.None, 0);
            }

            for (int i = 0; i < 5; i++)
            {
                float   angle  = TargetAngle + (MathHelper.TwoPi * ((i + 0.5f) / 5f)) - MathHelper.PiOver2;
                float   length = MathHelper.Lerp(15, 100, beamProgress);
                Vector2 scale  = new Vector2(projectile.scale, length / beam.Height);
                sB.Draw(beam, projectile.Center - Main.screenPosition, null, Color.Goldenrod * opacity, angle, new Vector2(beam.Width / 2, 0), scale, SpriteEffects.None, 0);
            }
        }
        private void PreDrawOrbExtras(SpriteBatch sB, float scale, Color color)
        {
            Texture2D Lu1 = mod.GetTexture("Textures/T_Lu_Noise_31");
            Texture2D Lu2 = mod.GetTexture("Textures/T_Lu_Noise_32");

            void DrawMask(Texture2D tex, float opacity, float maskScale, float rotationDirection) =>
            sB.Draw(tex, projectile.Center - Main.screenPosition, null, color * opacity, Main.GlobalTime * rotationDirection, tex.Size() / 2, scale * maskScale, SpriteEffects.None, 0);

            float rotationSpeed = 2f + Charge;

            DrawMask(Lu2, 0.15f, 0.06f, -rotationSpeed);
            DrawMask(Lu1, 0.15f, 0.06f, rotationSpeed);
            DrawMask(Lu2, 0.3f, 0.05f, -rotationSpeed);
            DrawMask(Lu1, 0.3f, 0.05f, rotationSpeed);

            DrawGodray.DrawGodrays(sB, projectile.Center - Main.screenPosition, color, 20 * scale * projectile.Opacity, 8 * scale * projectile.Opacity, 16);


            //not ideal, basically only stable because no sprites are drawn after this in the duration of the current spritebatch, as the current spritebatch is ended
            //convert to spritebatch drawing later if a suitable additive mask for a blur line is found?
            //alternatively just literally use the same ray texture godrays use they look basically the same when obscured
            float  blurLength      = 130 * scale * projectile.Opacity;
            float  blurWidth       = 9 * scale * projectile.Opacity;
            float  flickerStrength = (((float)Math.Sin(Main.GlobalTime * 12) % 1) * 0.1f) + 1f;
            Effect blurEffect      = mod.GetEffect("Effects/BlurLine");

            var blurLine = new SquarePrimitive()
            {
                Position = projectile.Center - Main.screenPosition,
                Height   = blurWidth * flickerStrength,
                Length   = blurLength * flickerStrength,
                Rotation = 0,
                Color    = color * flickerStrength
            };

            PrimitiveRenderer.DrawPrimitiveShape(blurLine, blurEffect);
        }
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            if (_chain != null)
            {
                Effect effect = SpiritMod.ShaderDict["PrimitiveTextureMap"];
                effect.Parameters["uTexture"].SetValue(mod.GetTexture("NPCs/Boss/Occultist/SoulTrail"));

                Vector2[] vertices = _chain.VerticesArray();
                vertices.IterateArray(delegate(ref Vector2 vertex, int index, float progress) { IterateVerticesSine(ref vertex, progress); });
                var strip = new PrimitiveStrip
                {
                    Color         = Color.White * projectile.Opacity,
                    Width         = 13 * projectile.scale,
                    PositionArray = vertices,
                    TaperingType  = StripTaperType.None,
                };
                PrimitiveRenderer.DrawPrimitiveShape(strip, effect);

                Texture2D projTexture = Main.projectileTexture[projectile.type];
                var       origin      = new Vector2(projectile.DrawFrame().Width / 2, projectile.DrawFrame().Height + 2);
                spriteBatch.Draw(projTexture, _chain.StartPosition - Main.screenPosition, projectile.DrawFrame(), projectile.GetAlpha(Color.White), _chain.StartRotation + MathHelper.PiOver2, origin, projectile.scale, SpriteEffects.None, 0);
            }
            return(false);
        }
        //Temp, planning on moving sword trails to vertex strip system for convenience and lasting after projectile death
        private void DrawTrail(SpriteBatch spriteBatch, Color drawColor, float progress, float opacity)
        {
            spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix);

            Effect effect = mod.GetEffect("Effects/AstralSpellblade");

            effect.Parameters["baseTexture"].SetValue(mod.GetTexture("Textures/noise"));
            effect.Parameters["baseColorDark"].SetValue(new Color(67, 37, 143).ToVector4());
            effect.Parameters["baseColorLight"].SetValue(new Color(230, 55, 166).ToVector4());
            effect.Parameters["overlayTexture"].SetValue(mod.GetTexture("Textures/voronoiLooping"));
            effect.Parameters["overlayColor"].SetValue(new Color(255, 245, 245).ToVector4() * 3);

            effect.Parameters["xMod"].SetValue(0.5f);
            effect.Parameters["yMod"].SetValue(0.6f);
            effect.Parameters["overlayCoordMods"].SetValue(new Vector2(1f, 0.2f));

            effect.Parameters["timer"].SetValue(-Main.GlobalTime * 1.5f);
            effect.Parameters["progress"].SetValue(progress);

            Vector2           pos   = Owner.MountedCenter - Main.screenPosition;
            PrimitiveSlashArc slash = new PrimitiveSlashArc
            {
                BasePosition   = pos,
                StartDistance  = projectile.Size.Length() * 0.33f,
                EndDistance    = projectile.Size.Length() * 0.95f,
                AngleRange     = new Vector2(TOTAL_RADIANS / 2 * SwingDirection, -TOTAL_RADIANS / 2 * SwingDirection),
                DirectionUnit  = initialVelocity,
                Color          = Color.White * opacity,
                SlashProgress  = progress,
                RectangleCount = 30
            };

            PrimitiveRenderer.DrawPrimitiveShape(slash, effect);

            spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix);
        }
        private void DrawBeam()
        {
            float progress = AiTimer / LASER_TIME;

            float PowF(float power) => (float)Math.Pow(progress, power);

            Vector2 scale = new Vector2(BeamLength, MathHelper.Lerp(60, 10, PowF(0.75f)));

            float ColorLerp = PowF(2.5f);

            Color color = Color.Lerp(midBlue, darkBlue, ColorLerp);

            color  *= 1 - PowF(2.5f) * 0.33f;
            color.A = 10;
            Vector2 position = projectile.Center + StaffTipDirection + (BeamDirection * BeamLength / 2) - Main.screenPosition;             //Center between staff tip and beam end

            //Draw the beam and apply shader parameters
            Effect beamEffect = mod.GetEffect("Effects/Laser");

            beamEffect.Parameters["uTexture"].SetValue(mod.GetTexture("Textures/Trails/Trail_1"));
            beamEffect.Parameters["Progress"].SetValue(Main.GlobalTime * 3f);
            beamEffect.Parameters["xMod"].SetValue(BeamLength / 150f);
            beamEffect.Parameters["yMod"].SetValue(2f);
            beamEffect.CurrentTechnique.Passes[0].Apply();

            SquarePrimitive beam = new SquarePrimitive
            {
                Height   = scale.Y,
                Length   = scale.X,
                Rotation = BeamDirection.ToRotation(),
                Position = position,
                Color    = color
            };

            PrimitiveRenderer.DrawPrimitiveShape(beam, beamEffect);

            //Draw a visual effect for hitting tiles
            if (HittingTile)
            {
                float     scaleMod = scale.Y / 60;
                Texture2D bloom    = mod.GetTexture("Effects/Masks/CircleGradient");
                Vector2   endPos   = projectile.Center + StaffTipDirection + BeamDirection * BeamLength;
                Main.spriteBatch.Draw(bloom, endPos - Main.screenPosition, null, darkBlue, 0, bloom.Size() / 2, 0.5f * scaleMod, SpriteEffects.None, 0);

                float  blurLength      = 400 * scaleMod;
                float  blurWidth       = 12 * scaleMod;
                float  flickerStrength = (((float)Math.Sin(Main.GlobalTime * 20) % 1) * 0.3f) + 1f;
                Effect blurEffect      = mod.GetEffect("Effects/BlurLine");

                for (int i = -1; i <= 1; i++)
                {
                    float           rotation = BeamDirection.ToRotation() + MathHelper.PiOver2 + (MathHelper.Pi / 6) * i;
                    float           size     = 1 - Math.Abs(i * 0.5f);
                    SquarePrimitive blurLine = new SquarePrimitive()
                    {
                        Position = endPos - Main.screenPosition,
                        Height   = blurWidth * flickerStrength * size,
                        Length   = blurLength * flickerStrength * size,
                        Rotation = rotation,
                        Color    = Color.Lerp(lightCyan, Color.White, 0.25f) * (1 - ColorLerp)
                    };
                    PrimitiveRenderer.DrawPrimitiveShape(blurLine, blurEffect);
                }
            }
        }