protected override void LoadContent() { // ============================== // -- Prepare graphic systems // ============================== spriteBatch = new SpriteBatch(GraphicsDevice); particleSystem = new ParticleSystem(); primitiveRenderer = new PrimitiveRenderer(spriteBatch); // ============================== // -- Object pre-initialization // ============================== particle = new Particle(particle1SpriteSheet); beam = new Particle(beam1SpriteSheet); // ============================== // -- Load fonts // ============================== sysFont = Content.Load <SpriteFont>(@"Fonts\System"); // ============================== // -- Load graphics // ============================== fighterSpriteSheet.Texture = Content.Load <Texture2D>(@"Sprites\Fighter1"); particle1SpriteSheet.Texture = Content.Load <Texture2D>(@"Particles\Particle1"); beam1SpriteSheet.Texture = Content.Load <Texture2D>(@"Particles\Beam1"); bulletSpriteSheet.Texture = Content.Load <Texture2D>(@"Sprites\bullet"); // ============================== // -- Object post-initialization // ============================= LoadTracks(); State = new TitleState(this, sysFont); }
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 Draw(SpriteBatch Sb, PrimitiveRenderer Pr) { Ps.Draw(Sb); Sb.Begin(); // Draw enemy projectiles // Draw player projectiles foreach (Bullet bullet in BulletList) { if (bullet.isAlive) { bullet.Sprite.Draw(Sb, bullet.position, bullet.Angle, bullet.Scale, Color.White); } } // Draw enemy slaves // Draw player slaves // Draw fighters foreach (Fighter fighter in Fighters) { if (fighter.CurrentState == Fighter.State.Defend) { Pr.DrawCircle(fighter.Position, 50, 1.0f, Color.White * fighter.ShieldStrength); } fighter.Sprite.Draw(Sb, fighter.Position, fighter.Angle, fighter.Scale, Color.White); } Sb.End(); Rr.Draw(Pr, Sb); }
public void AdditiveCall(SpriteBatch spriteBatch) { float blurLength = 100 * projectile.scale; float blurWidth = 5 * projectile.scale; float flickerStrength = (((float)Math.Sin(Main.GlobalTime * 10) % 1) * 0.1f) + 1f; Effect blurEffect = mod.GetEffect("Effects/BlurLine"); IPrimitiveShape[] blurLines = new IPrimitiveShape[] { //Horizontal new SquarePrimitive() { Position = projectile.Center - Main.screenPosition, Height = blurWidth * flickerStrength, Length = blurLength * flickerStrength, Rotation = 0, Color = Color.White * flickerStrength * projectile.Opacity }, //Vertical, lower length new SquarePrimitive() { Position = projectile.Center - Main.screenPosition, Height = blurWidth * flickerStrength, Length = blurLength * flickerStrength * 0.5f, Rotation = MathHelper.PiOver2, Color = Color.White * flickerStrength * projectile.Opacity }, }; PrimitiveRenderer.DrawPrimitiveShapeBatched(blurLines, blurEffect); }
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); }
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 CartesianFieldRenderer(CartesianField field, FieldRendererControl renderControl) { Field = field; RenderControl = renderControl; FieldOfView = new Camera(new Vector2(-5, -5), new Vector2(10, 10)); P_Renderer = new PrimitiveRenderer(renderControl); }
public TablatureRenderer(PrimitiveRenderer primitiveRenderer, TablatureStyle style, CoreTablature tablature) : base(null, tablature) { this.Tablature = tablature; this.PrimitiveRenderer = primitiveRenderer; this.Style = style; _rendererLookup = new Dictionary <ElementBase, ElementRenderer>(); _barRenderers = new List <BarRenderer>(); }
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); }
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix); Vector2 pos = Player.MountedCenter - Main.screenPosition; float progress = GetProgress(); List <PrimitiveSlashArc> slashArcs = new List <PrimitiveSlashArc>(); Effect effect = mod.GetEffect("Effects/NemesisBoonShader"); effect.Parameters["white"].SetValue(Color.OrangeRed.ToVector4()); effect.Parameters["opacity"].SetValue((float)Math.Sqrt(1 - progress)); PrimitiveSlashArc slash = new PrimitiveSlashArc { BasePosition = Player.Center - Main.screenPosition, StartDistance = (projectile.width * 0.3f) * projectile.scale, EndDistance = (projectile.width * 0.85f) * (((projectile.scale - 1) * 0.5f) + 1), AngleRange = new Vector2(SwingRadians / 2 * SwingDirection, -SwingRadians / 2 * SwingDirection), DirectionUnit = direction, Color = Color.Red, SlashProgress = progress }; slashArcs.Add(slash); PrimitiveRenderer.DrawPrimitiveShapeBatched(slashArcs.ToArray(), effect); spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix); Texture2D tex2 = Main.projectileTexture[projectile.type]; Texture2D tex3 = ModContent.GetTexture(Texture + "_Glow"); if (flip) { if (Empowered) { spriteBatch.Draw(tex3, Player.Center - Main.screenPosition, null, Color.Red * (float)Math.Sqrt(1 - progress) * 0.3f, rotation + 2.355f, new Vector2(tex3.Width, tex3.Height), projectile.scale, SpriteEffects.FlipHorizontally, 0f); } spriteBatch.Draw(tex2, Player.Center - Main.screenPosition, null, lightColor * .5f, rotation + 2.355f, new Vector2(tex2.Width, tex2.Height), projectile.scale, SpriteEffects.FlipHorizontally, 0f); } else { if (Empowered) { spriteBatch.Draw(tex3, Player.Center - Main.screenPosition, null, Color.Red * (float)Math.Sqrt(1 - progress) * 0.3f, rotation + 0.785f, new Vector2(0, tex3.Height), projectile.scale, SpriteEffects.None, 0f); } spriteBatch.Draw(tex2, Player.Center - Main.screenPosition, null, lightColor, rotation + 0.785f, new Vector2(0, tex2.Height), projectile.scale, SpriteEffects.None, 0f); } return(false); }
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); }
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); }
public override void CustomDraw(SpriteBatch spriteBatch) { //Draw a bloom underneath the circle Texture2D bloom = SpiritMod.Instance.GetTexture("Effects/Masks/CircleGradient"); Vector2 drawCenter = Position - Main.screenPosition; Vector2 bloomScale = new Vector2(Scale, Scale * (1 - _zRotation)); bloomScale *= 2.5f; Rectangle destRect = new Rectangle((int)(drawCenter.X - (bloomScale.X / 2)), (int)(drawCenter.Y - (bloomScale.Y / 2)), (int)bloomScale.X, (int)bloomScale.Y); spriteBatch.Draw(bloom, destRect, Color.Lerp(Color, Color.White, 0.25f) * _opacity * 0.4f); //Draw the circle itself Effect effect = SpiritMod.Instance.GetEffect("Effects/MagicCircle"); effect.Parameters["rotation"].SetValue(_rotation); Color additiveColor = Color; additiveColor.A = 0; effect.Parameters["uTexture"].SetValue(ParticleHandler.GetTexture(Type)); List <SquarePrimitive> primList = new List <SquarePrimitive>(); PulseDraw.DrawPulseEffect(PulseDraw.BloomConstant, 6, 6, delegate(Vector2 posOffset, float bloomOpacity) { primList.Add(new SquarePrimitive { Color = additiveColor * _opacity * bloomOpacity * 0.25f, Height = Scale, Length = Scale * (1 - _zRotation), Position = Position - Main.screenPosition + posOffset, Rotation = _angle, ColorXCoordMod = 1 - _zRotation }); }); primList.Add(new SquarePrimitive { Color = additiveColor * _opacity, Height = Scale, Length = Scale * (1 - _zRotation), Position = Position - Main.screenPosition, Rotation = _angle, ColorXCoordMod = 1 - _zRotation }); PrimitiveRenderer.DrawPrimitiveShapeBatched(primList.ToArray(), effect); }
public RenderSystem(GraphicsDevice graphicsDevice, PondSimState pond, Texture2D frogSprite, SpriteFont uiFont, FrogAnimationData animationData) { mRenderer = new PrimitiveRenderer(); mRenderer.Setup(graphicsDevice); mFrogRenderer = new FrogRenderer(); mFrogRenderer.Setup(graphicsDevice, frogSprite, animationData); mUIFont = uiFont; mPond = pond; mDevice = graphicsDevice; SetupCamera(graphicsDevice, pond); mUISpriteBatch = new SpriteBatch(mDevice); }
public override void Draw(SpriteBatch Sb, PrimitiveRenderer Pr) { StringBuilder str = new StringBuilder(); // Draw track list str.AppendLine("Track List:"); foreach (Track track in Tracks) { str.AppendLine(track.Name); } Sb.Begin(); Sb.DrawString(Font, str, trackSelectListPosition, Color.White); // BEGIN ================================== for (int i = 0; i < noPlayers; ++i) { str.Clear(); str.AppendLine(Tracks[TrackSelected[i]].Name); // Draw diff list foreach (TrackData diff in Tracks[TrackSelected[i]].Diffs) { str.AppendLine(diff.Name); } Sb.DrawString(Font, str, diffSelectListPosition[i], Color.Pink); // Draw selected list str.Clear(); str.AppendLine("Selected:"); foreach (TrackSelection selection in SelectionList[i]) { str.AppendFormat("{0} ({1})\n", selection.Track.Name, selection.Diff.Name); } Sb.DrawString(Font, str, selectionListPosition[i], Color.Pink); // Draw track selected box Rectangle selectedRect = new Rectangle((int)trackSelectListPosition.X - 15 * (noPlayers - i), (int)trackSelectListPosition.Y + (1 + TrackSelected[i]) * Font.LineSpacing, 10, Font.LineSpacing); Pr.DrawRectFilled(selectedRect, 1, Color.Red, Color.Pink); // Draw diff selected box selectedRect = new Rectangle((int)diffSelectListPosition[i].X - 15, (int)diffSelectListPosition[i].Y + (1 + DiffSelected[i]) * Font.LineSpacing, 10, Font.LineSpacing); Pr.DrawRectFilled(selectedRect, 1, Color.Red, Color.Pink); } // END ================================== Sb.End(); }
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); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { RasterizerState rs = new RasterizerState(); rs.CullMode = CullMode.None; mGraphics.GraphicsDevice.RasterizerState = rs; PrimitiveRenderer primitiveRenderer = new PrimitiveRenderer(); primitiveRenderer.Setup(mGraphics.GraphicsDevice, kArenaWidth, kArenaHeight); mMTSCRenderer = new MTSCombatRenderer(primitiveRenderer); mMTSGame = new MTSCombatGame(2, kArenaWidth, kArenaHeight); SpawnVehicles(); base.Initialize(); }
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); }
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 void Draw(Effect effect, BasicEffect effect2, GraphicsDevice device) { if (Dead || _points.Count <= 1) { return; } //set the parameters for the shader Effect flametrailEffect = SpiritMod.Instance.GetEffect("Effects/FlameTrail"); flametrailEffect.Parameters["uTexture"].SetValue(SpiritMod.Instance.GetTexture("Textures/Trails/Trail_3")); flametrailEffect.Parameters["uTexture2"].SetValue(SpiritMod.Instance.GetTexture("Textures/Trails/Trail_4")); flametrailEffect.Parameters["Progress"].SetValue(Main.GlobalTime * -1f); flametrailEffect.Parameters["xMod"].SetValue(1.5f); flametrailEffect.Parameters["StartColor"].SetValue(_startColor.ToVector4()); flametrailEffect.Parameters["MidColor"].SetValue(_midColor.ToVector4()); flametrailEffect.Parameters["EndColor"].SetValue(_endColor.ToVector4()); float getWidthMod(float progress = 0) => ((float)Math.Sin((Main.GlobalTime - progress) * MathHelper.TwoPi * 1.5f) * 0.33f + 1.33f) / (float)Math.Pow(1 - progress, 0.1f); IPrimitiveShape[] shapesToDraw = new IPrimitiveShape[] { new CirclePrimitive { Color = Color.White * _deathProgress, Radius = _width * _deathProgress * getWidthMod(), Position = _points[0] - Main.screenPosition, MaxRadians = MathHelper.TwoPi }, new PrimitiveStrip { Color = Color.White * _deathProgress, Width = _width * _deathProgress, PositionArray = _points.ToArray(), TaperingType = StripTaperType.TaperEnd, WidthDelegate = delegate(float progress) { return(getWidthMod(progress)); } } }; PrimitiveRenderer.DrawPrimitiveShapeBatched(shapesToDraw, flametrailEffect); }
public async Task <double> MeasureMinSize(PrimitiveRenderer primitiveRenderer) { if (_minSize != null) { return(_minSize.Value); } var minDuration = this.Element.Columns.Min(c => c.GetDuration()); var size = 0.0; // ReSharper disable once LoopCanBeConvertedToQuery foreach (var column in this.Element.Columns) { size += await this.GetColumnMinWidthInBar(primitiveRenderer, column, minDuration); } _minSize = size; return(_minSize.Value); }
private async Task <double> GetColumnMinWidthInBar(PrimitiveRenderer primitiveRenderer, BarColumn column, PreciseDuration minDurationInBar) { var columnRegularWidth = Math.Min(this.Style.MaximumBeatSizeWithoutLyrics, this.Style.MinimumBeatSize * column.GetDuration() / minDurationInBar); double columnMinWidth; if (column.Lyrics == null) { columnMinWidth = this.Style.MinimumBeatSize; } else { var lyricsBounds = await primitiveRenderer.MeasureLyrics(column.Lyrics.Text); columnMinWidth = Math.Max(this.Style.MinimumBeatSize, lyricsBounds.Width); } return(Math.Max(columnRegularWidth, columnMinWidth)); }
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); }
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); }
public void AdditiveCall(SpriteBatch sB) { float blurLength = 180 * projectile.scale; float blurWidth = 8 * projectile.scale; float flickerStrength = (((float)Math.Sin(Main.GlobalTime * 12) % 1) * 0.1f) + 1f; Effect blurEffect = mod.GetEffect("Effects/BlurLine"); IPrimitiveShape[] blurLines = new IPrimitiveShape[] { //Horizontal new SquarePrimitive() { Position = projectile.Center - Main.screenPosition, Height = blurWidth * flickerStrength, Length = blurLength * flickerStrength, Rotation = 0, Color = Color.White * flickerStrength * projectile.Opacity }, //Vertical, lower length new SquarePrimitive() { Position = projectile.Center - Main.screenPosition, Height = blurWidth * flickerStrength, Length = blurLength * flickerStrength * 0.75f, Rotation = MathHelper.PiOver2, Color = Color.White * flickerStrength * projectile.Opacity }, }; PrimitiveRenderer.DrawPrimitiveShapeBatched(blurLines, blurEffect); Texture2D bloom = mod.GetTexture("Effects/Masks/CircleGradient"); sB.Draw(bloom, projectile.Center - Main.screenPosition, null, Color.White * projectile.Opacity, 0, bloom.Size() / 2, 0.25f * projectile.scale, SpriteEffects.None, 0); }
//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); } } }