using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using MLEM.Extensions; using MLEM.Textures; namespace TouchyTickets; public class RainingTicket { private static readonly Random Random = new(); private readonly Vector2 speed; private readonly float rotationSpeed; private float rotation; private Vector2 position; public RainingTicket() { this.position = new Vector2(RainingTicket.Random.NextSingle(), -0.15F); this.speed = new Vector2(RainingTicket.Random.NextSingle() * 0.0005F - 0.00025F, 0.005F + RainingTicket.Random.NextSingle() * 0.01F); this.rotationSpeed = MathHelper.ToRadians(RainingTicket.Random.NextSingle() * 5); } public bool Update() { this.rotation += this.rotationSpeed; this.position += this.speed; return this.position.Y >= 1.15F; } public void Draw(SpriteBatch batch, Vector2 viewport, float scale, Color color) { var tex = Assets.UiTexture[2, 0]; batch.Draw(tex, this.position * viewport, color, this.rotation, tex.Size.ToVector2() / 2, scale, SpriteEffects.None, 0); } }