public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            if (Main.netMode == NetmodeID.Server)
            {
                return;
            }

            Main.PlaySound(SpiritMod.Instance.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, "Sounds/EnergyImpact").WithPitchVariance(0.1f).WithVolume(0.6f), target.Center);
            float scale = Main.rand.NextFloat(0.8f, 1f);

            DrawAberration.DrawChromaticAberration(BeamDirection, 2f, delegate(Vector2 offset, Color colorMod)
            {
                Color color = new Color(99, 255, 229).MultiplyRGB(colorMod);

                ParticleHandler.SpawnParticle(new PulseCircle(target.Center + offset, color * 0.4f, scale * 100, (int)(LASER_TIME * 0.66f),
                                                              PulseCircle.MovementType.OutwardsSquareRooted)
                {
                    Angle     = BeamDirection.ToRotation(),
                    ZRotation = 0.6f,
                    RingColor = color,
                    Velocity  = BeamDirection
                });
            });

            ParallelParticles(target.Center, BeamDirection * Main.rand.NextFloat(10, 15), 25, Main.rand.NextFloat(1.5f, 2f), Main.rand.Next(7, 10));
        }
Beispiel #2
0
        public override void CustomDraw(SpriteBatch spriteBatch)
        {
            Texture2D baseTex = ParticleHandler.GetTexture(Type);

            DrawAberration.DrawChromaticAberration(Vector2.UnitX.RotatedBy(Rotation), 1.5f, delegate(Vector2 offset, Color colorMod)
            {
                spriteBatch.Draw(baseTex, Position + offset - Main.screenPosition, Frame, Color.MultiplyRGB(colorMod) * opacity, Rotation, Frame.Size() / 2, Scale / 2f, SpriteEffects.None, 0);
            });
        }
        /// <summary>
        /// Mostly visual effects, called upon the laser being first fired
        /// </summary>
        private void OnLaserFire()
        {
            Owner.GetModPlayer <MyPlayer>().Shake = 8;

            projectile.velocity = (projectile.direction > 0) ? projectile.velocity.RotatedBy(-MathHelper.Pi / 5) : projectile.velocity.RotatedBy(MathHelper.Pi / 5);             //recoil effect

            if (Main.netMode == NetmodeID.Server)
            {
                return;
            }

            Main.PlaySound(SpiritMod.Instance.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/GranitechLaserBlast").WithPitchVariance(0.1f).WithVolume(0.8f), projectile.Center);

            float beamLengthLerp = MathHelper.Clamp(BeamLength / 800f, 0, 1);
            int   maxRings       = 3;
            float minRingDist    = 20 * beamLengthLerp;
            float maxRingDist    = 150 * beamLengthLerp;
            float sizeModifier   = MathHelper.Lerp(0.5f, 1f, beamLengthLerp);

            float minRingSize = 1f;
            float maxRingSize = 2.5f;
            float RingSpeed   = 1.25f;

            DrawAberration.DrawChromaticAberration(BeamDirection, 2f, delegate(Vector2 offset, Color colorMod)
            {
                for (int i = 0; i < maxRings; i++)                 //multiple rings
                {
                    float progress = i / (float)(maxRings - 1);
                    Color color    = Color.Lerp(lightCyan, darkBlue, progress).MultiplyRGB(colorMod);

                    float scale = MathHelper.Lerp(minRingSize, maxRingSize, progress) * sizeModifier;
                    float speed = sizeModifier * RingSpeed;

                    Vector2 velNormal = Vector2.Normalize(BeamDirection);
                    Vector2 spawnPos  = Vector2.Lerp(projectile.Center + StaffTipDirection + Vector2.Normalize(BeamDirection) * minRingDist,
                                                     projectile.Center + StaffTipDirection + Vector2.Normalize(BeamDirection) * maxRingDist, progress) + offset;

                    ParticleHandler.SpawnParticle(new PulseCircle(projectile, color * 0.4f, scale * 100, (int)(LASER_TIME * 0.66f),
                                                                  PulseCircle.MovementType.OutwardsSquareRooted, spawnPos)
                    {
                        Angle     = BeamDirection.ToRotation(),
                        ZRotation = 0.6f,
                        RingColor = color,
                        Velocity  = velNormal * speed
                    });
                }
            });

            for (int j = -1; j <= 1; j++)             //repeat multiple times with different offset and color, for chromatic aberration effect
            {
                Vector2 posOffset = Vector2.Normalize(BeamDirection).RotatedBy(j * MathHelper.PiOver2) * 2f;
                Color   colorMod  = (j == -1) ? new Color(255, 0, 0, 100) : ((j == 0) ? new Color(0, 255, 0, 100) : new Color(0, 0, 255, 100));
            }

            ParallelParticles(projectile.Center + StaffTipDirection, BeamDirection * Main.rand.NextFloat(30, 40), 35, Main.rand.NextFloat(1.5f, 3f), Main.rand.Next(14, 18));
        }
        public override void AI()
        {
            projectile.rotation = projectile.velocity.ToRotation() - MathHelper.Pi;
            Lighting.AddLight(projectile.Center, Color.Yellow.ToVector3() / 2);
            if (spawnRings && projectile.ai[0]++ == 0 && !Main.dedServ)
            {
                int maxRings = 3;
                DrawAberration.DrawChromaticAberration(Vector2.Normalize(projectile.velocity), 1, delegate(Vector2 offset, Color colorMod)
                {
                    for (int i = 0; i < maxRings; i++)                     //multiple rings
                    {
                        float progress = i / (float)maxRings;
                        Color color    = Color.Lerp(new Color(222, 111, 127), new Color(239, 241, 80), progress).MultiplyRGBA(colorMod);

                        float scale = (i == 0) ? 0.5f :     //small
                                      (i == 1) ? 0.75f :    //med
                                      1f;                   //big

                        float speed = (i == 0) ? 3.5f :
                                      (i == 1) ? 1.8f :
                                      0.5f;

                        Vector2 velNormal = Vector2.Normalize(projectile.velocity);
                        Vector2 spawnPos  = Vector2.Lerp(projectile.Center, projectile.Center + Vector2.Normalize(projectile.velocity) * 90, progress) + offset;
                        ParticleHandler.SpawnParticle(new PulseCircle(spawnPos, color * 0.4f, scale * 100, 20, PulseCircle.MovementType.OutwardsSquareRooted)
                        {
                            Angle     = projectile.velocity.ToRotation(),
                            ZRotation = 0.6f,
                            RingColor = color,
                            Velocity  = velNormal * speed
                        });
                    }
                });
            }

            //accelerate over time, with a cap
            const float maxSpeed = 18f;

            if (projectile.velocity.Length() < maxSpeed)
            {
                projectile.velocity *= 1.02f;
            }
            else
            {
                projectile.velocity = Vector2.Normalize(projectile.velocity) * maxSpeed;
            }

            //randomize the aberration offset, at random intervals
            if (Main.rand.NextBool(10))
            {
                aberrationOffset = Main.rand.NextFloat(1, 2f);
            }

            //fade in quickly
            projectile.alpha = (int)MathHelper.Max(projectile.alpha - 10, 0);
        }
        public override void CustomDraw(SpriteBatch spriteBatch)
        {
            Texture2D tex       = ParticleHandler.GetTexture(Type);
            var       DrawFrame = new Rectangle(0, _frame * tex.Height / _numFrames, tex.Width, tex.Height / _numFrames);

            DrawAberration.DrawChromaticAberration(Vector2.UnitX.RotatedBy(Rotation), 1.5f, delegate(Vector2 offset, Color colorMod)
            {
                spriteBatch.Draw(tex, Position + offset - Main.screenPosition, DrawFrame, colorMod, Rotation, DrawFrame.Size() / 2, Scale, (_direction > 0) ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0);
            });
        }
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            if (projectile.timeLeft > 2)             //bandaid fix for flickering
            {
                return(false);
            }

            float  opacity = projectile.Opacity;
            float  xMod    = (1 + (Distance / 250) + (SwingRadians / GranitechSaberProjectile.SwingRadians));
            Effect effect  = mod.GetEffect("Effects/GSaber");

            effect.Parameters["baseTexture"].SetValue(mod.GetTexture("Textures/GeometricTexture_2"));
            effect.Parameters["baseColor"].SetValue(new Color(25, 132, 247).ToVector4());
            effect.Parameters["overlayTexture"].SetValue(mod.GetTexture("Textures/GeometricTexture_1"));
            effect.Parameters["overlayColor"].SetValue(new Color(99, 255, 229).ToVector4());

            effect.Parameters["xMod"].SetValue(1.5f * xMod);             //scale with the total length of the strip
            effect.Parameters["yMod"].SetValue(2.5f);

            float slashProgress = EaseFunction.EaseCircularInOut.Ease(Timer / SwingTime);

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

            Vector2 pos = BasePosition - Main.screenPosition;

            List <PrimitiveSlashArc> slashArcs = new List <PrimitiveSlashArc>();

            DrawAberration.DrawChromaticAberration(Vector2.UnitX, 4, delegate(Vector2 offset, Color colorMod)
            {
                PrimitiveSlashArc slash = new PrimitiveSlashArc
                {
                    BasePosition  = pos,
                    StartDistance = offset.X + Distance - projectile.Size.Length() / 2 * SwingDirection,
                    EndDistance   = offset.X + Distance + projectile.Size.Length() / 2 * SwingDirection,
                    AngleRange    = new Vector2(SwingRadians / 2 * SwingDirection, -SwingRadians / 2 * SwingDirection),
                    DirectionUnit = InitialVelocity,
                    Color         = colorMod * opacity * 0.5f,
                    SlashProgress = slashProgress
                };
                slashArcs.Add(slash);
            });
            PrimitiveRenderer.DrawPrimitiveShapeBatched(slashArcs.ToArray(), effect);

            Texture2D     tex           = Main.projectileTexture[projectile.type];
            SpriteEffects spriteEffects = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;

            DrawAberration.DrawChromaticAberration(projectile.velocity, 3, delegate(Vector2 offset, Color colorMod)
            {
                spriteBatch.Draw(tex, projectile.Center + offset - Main.screenPosition, null, colorMod * opacity, projectile.rotation, tex.Size() / 2, projectile.scale, spriteEffects, 0);
            });

            return(false);
        }
Beispiel #7
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Texture2D tex         = Main.projectileTexture[projectile.type];
            int       frameHeight = tex.Height / Main.projFrames[projectile.type];
            Rectangle frame       = new Rectangle(0, frameHeight * projectile.frame, tex.Width, frameHeight);

            DrawAberration.DrawChromaticAberration(Vector2.UnitY, 2f, delegate(Vector2 offset, Color colorMod)
            {
                spriteBatch.Draw(tex, projectile.Center + offset - Main.screenPosition, frame, Color.White.MultiplyRGBA(colorMod), projectile.rotation, new Vector2(tex.Width, frameHeight) / 2, projectile.scale, SpriteEffects.None, 0f);
            });
            return(false);
        }
        public override void PostDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            projectile.QuickDrawGlow(spriteBatch);
            float opacity = (float)Math.Pow(Math.Sin(Timer * MathHelper.Pi / swingTime), 0.75f);

            Texture2D     tex           = ModContent.GetTexture(Texture + "_glow");
            SpriteEffects spriteEffects = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;

            DrawAberration.DrawChromaticAberration(projectile.velocity, 2f, delegate(Vector2 offset, Color colorMod)
            {
                spriteBatch.Draw(tex, projectile.Center + offset - Main.screenPosition, null, colorMod * opacity, projectile.rotation, tex.Size() / 2, projectile.scale, spriteEffects, 0);
            });
        }
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix);

            float  opacity = (float)Math.Pow(Math.Sin(Timer * MathHelper.Pi / swingTime), 1.5f) * 0.75f;
            Effect effect  = mod.GetEffect("Effects/GSaber");

            effect.Parameters["baseTexture"].SetValue(mod.GetTexture("Textures/GeometricTexture_2"));
            effect.Parameters["baseColor"].SetValue(new Color(25, 132, 247).ToVector4());
            effect.Parameters["overlayTexture"].SetValue(mod.GetTexture("Textures/GeometricTexture_1"));
            effect.Parameters["overlayColor"].SetValue(new Color(99, 255, 229).ToVector4());

            effect.Parameters["xMod"].SetValue(1.5f);
            effect.Parameters["yMod"].SetValue(2.5f);

            float slashProgress = EaseFunction.EaseCircularInOut.Ease(Timer / swingTime);

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

            Vector2 pos = Owner.MountedCenter - Main.screenPosition;
            List <PrimitiveSlashArc> slashArcs = new List <PrimitiveSlashArc>();

            DrawAberration.DrawChromaticAberration(Vector2.UnitX, 2, delegate(Vector2 offset, Color colorMod)
            {
                PrimitiveSlashArc slash = new PrimitiveSlashArc
                {
                    BasePosition  = pos,
                    StartDistance = offset.X + projectile.Size.Length() * 0.33f,
                    EndDistance   = offset.X + projectile.Size.Length(),
                    AngleRange    = new Vector2(SwingRadians / 2 * SwingDirection, -SwingRadians / 2 * SwingDirection),
                    DirectionUnit = initialVelocity,
                    Color         = colorMod * opacity,
                    SlashProgress = slashProgress
                };
                slashArcs.Add(slash);
            });
            PrimitiveRenderer.DrawPrimitiveShapeBatched(slashArcs.ToArray(), effect);


            spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix);
            return(base.PreDraw(spriteBatch, lightColor));
        }
        public override bool PreDraw(SpriteBatch sb, Color lightColor)
        {
            Texture2D glow = mod.GetTexture("Items/Sets/GranitechSet/GranitechGun/GranitechGunBullet_Glow");

            DrawAberration.DrawChromaticAberration(Vector2.Normalize(projectile.velocity), aberrationOffset, delegate(Vector2 offset, Color colorMod)
            {
                Vector2 drawPosition = projectile.Center + offset - Main.screenPosition;
                for (int i = 1; i < ProjectileID.Sets.TrailCacheLength[projectile.type]; i++)
                {
                    float progress        = (ProjectileID.Sets.TrailCacheLength[projectile.type] - i) / (float)ProjectileID.Sets.TrailCacheLength[projectile.type];
                    Color trailColor      = Color.Lerp(new Color(222, 111, 127), new Color(178, 105, 140), progress).MultiplyRGBA(colorMod) * progress;
                    Vector2 trailPosition = projectile.oldPos[i] + offset + projectile.Size / 2 - Main.screenPosition;
                    sb.Draw(glow, trailPosition, null, projectile.GetAlpha(trailColor), projectile.rotation, glow.Size() / 2, projectile.scale, SpriteEffects.None, 0f);
                }

                sb.Draw(Main.projectileTexture[projectile.type], drawPosition, null, projectile.GetAlpha(colorMod), projectile.rotation, glow.Size() / 2, projectile.scale, SpriteEffects.None, 0f);
            });

            return(false);
        }
Beispiel #11
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Texture2D aura = ModContent.GetTexture(Texture + "_Aura");

            if (DamageAura)
            {
                spriteBatch.Draw(aura, projectile.Center - Main.screenPosition, null, Color.White * 0.3f, projectile.rotation, new Vector2(aura.Width, aura.Height) / 2, projectile.scale, SpriteEffects.None, 0f);
            }

            Texture2D tex         = Main.projectileTexture[projectile.type];
            int       frameHeight = tex.Height / Main.projFrames[projectile.type];
            Rectangle frame       = new Rectangle(0, frameHeight * projectile.frame, tex.Width, frameHeight);

            if (DamageAura)
            {
                float startScale = 1f;
                float endScale   = 1.3f;
                tex = ModContent.GetTexture(Texture + "_Core");
                for (int i = 0; i < 15; i++)
                {
                    spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, frame, Color.Lerp(Color.White * 0.5f, Color.White * 0.2f, i / 15f), projectile.rotation, new Vector2(tex.Width, frameHeight) / 2, projectile.scale * MathHelper.Lerp(startScale, endScale, i / 15f), SpriteEffects.None, 0f);
                }
            }

            tex = Main.projectileTexture[projectile.type];
            spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, frame, lightColor, projectile.rotation, new Vector2(tex.Width, frameHeight) / 2, projectile.scale, SpriteEffects.None, 0f);

            tex = ModContent.GetTexture(Texture + "_Glow");
            DrawAberration.DrawChromaticAberration(Vector2.UnitY, 2.5f, delegate(Vector2 offset, Color colorMod)
            {
                spriteBatch.Draw(tex, projectile.Center + offset - Main.screenPosition, frame, Color.White.MultiplyRGBA(colorMod),
                                 projectile.rotation, projectile.DrawFrame().Size() / 2, projectile.scale, SpriteEffects.None, 0);
            });

            return(false);
        }
        public void AdditiveCall(SpriteBatch spriteBatch)
        {
            Texture2D projTex     = Main.projectileTexture[projectile.type];
            int       trailLength = ProjectileID.Sets.TrailCacheLength[projectile.type];

            DrawAberration.DrawChromaticAberration(Vector2.Normalize(projectile.velocity), 2f, delegate(Vector2 offset, Color colorMod)
            {
                Color color = lightCyan.MultiplyRGB(colorMod);
                for (int i = 0; i < trailLength; i++)
                {
                    float progress = i / (float)trailLength;
                    float opacity  = 1 - progress;
                    opacity       *= 0.66f;
                    var trailColor = Color.Lerp(midBlue, darkBlue, progress);

                    spriteBatch.Draw(projTex, projectile.oldPos[i] + (projectile.Size / 2) + offset - Main.screenPosition, null, trailColor * opacity,
                                     projectile.velocity.ToRotation(), projTex.Size() / 2, projectile.scale, SpriteEffects.None, 0);
                }
                ;

                spriteBatch.Draw(projTex, projectile.Center + offset - Main.screenPosition, null, color,
                                 projectile.velocity.ToRotation(), projTex.Size() / 2, projectile.scale, SpriteEffects.None, 0);
            });
        }