2 - Slightly more red color for Fright 3 - Early structure for soul suction concept
53 lines
1.8 KiB
C#
53 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using Terraria;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Particles
|
|
{
|
|
public class SquareParticle : Particle
|
|
{
|
|
public Color InitialColor;
|
|
public bool AffectedByGravity;
|
|
public float ExtraRotation;
|
|
public override bool SetLifetime => true;
|
|
public override bool UseCustomDraw => true;
|
|
public override bool UseAdditiveBlend => true;
|
|
|
|
public override string Texture => "CalamityMod/Particles/Square";
|
|
|
|
public SquareParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color color, float extraRotation = 0f)
|
|
{
|
|
Position = relativePosition;
|
|
Velocity = velocity;
|
|
AffectedByGravity = affectedByGravity;
|
|
Scale = scale;
|
|
Lifetime = lifetime;
|
|
Color = InitialColor = color;
|
|
ExtraRotation = extraRotation;
|
|
}
|
|
|
|
public override void Update()
|
|
{
|
|
Scale *= 0.95f;
|
|
Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D));
|
|
Velocity *= 0.95f;
|
|
if (Velocity.Length() < 12f && AffectedByGravity)
|
|
{
|
|
Velocity.X *= 0.94f;
|
|
Velocity.Y += 0.25f;
|
|
}
|
|
Rotation = Velocity.ToRotation() + MathHelper.PiOver2 + ExtraRotation;
|
|
}
|
|
|
|
public override void CustomDraw(SpriteBatch spriteBatch)
|
|
{
|
|
Texture2D texture = ModContent.Request<Texture2D>(Texture).Value;
|
|
|
|
spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, Scale, 0, 0f);
|
|
}
|
|
}
|
|
}
|