public void Add(TimedSprite sprite) => _sprites.Add(sprite);
void DrawPlay() { if (game.PlanetExplodeCounter > 30 && game.Random.Next(6) == 0) { var color = new Color(game.Random.Next(0, 255), game.Random.Next(0, 255), game.Random.Next(0, 255)); spriteBatch.Draw(CoreGlobals.BlankTexture, new Rectangle(0, 0, game.ScreenSize.X, game.ScreenSize.Y), color); } int y = game.HUDHeight + 1; var origin = new Vector2(0.5f, 0.5f); int i; if (!game.SpaceMode) { Vector2 m2 = Vector2.Zero; for (i = 0; i < game.Mountains.Count; ++i) { var m1 = game.Mountains[i]; m1.X = game.GetScreenX(m1.X); m1.Y += y; m2 = game.Mountains[i + 1 == game.Mountains.Count ? 0 : i + 1]; m2.X = game.GetScreenX(m2.X); m2.Y += y; //if (i + 1 == game.Mountains.Count) // spriteBatch.Draw(CoreGlobals.BlankTexture, new Rectangle((int)m2.X, y, 1, game.ScreenSize.Y), Color.Red); if (m2.X > 0 && m1.X < game.ScreenSize.X) { spriteBatch.DrawLine(CoreGlobals.BlankTexture, 1, Color.RosyBrown, m1, m2); } } } spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, null); var p = new Particle(); Vector2 pos; int particleCount = game.PlayerSpawnTimer <= 0 ? game.Particles.Length : game.StarCount; for (i = 0; i < particleCount; ++i) { if (game.Particles[i].Age > 0) { p = game.Particles[i]; if (p.Position.Y - p.Size * 0.5f >= 2) { pos.X = game.GetScreenX(p.Position.X); pos.Y = p.Position.Y + y; Color c = p.Color; if (p.Age < 0.3f) { c.A = (byte)(MathHelper.Lerp(c.A / 255.0f, 0, (0.3f - p.Age) * 3.333f) * 255f); } spriteBatch.Draw(CoreGlobals.BlankTexture, pos, null, c, 0, origin, p.Size, SpriteEffects.None, 0); } } } spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, DepthStencilState.None, null); Entity entity; int entityCount = game.PlayerSpawnTimer <= 0 ? game.Entities.Length : game.HumanoidCount; for (i = 0; i < entityCount; ++i) { entity = game.Entities[i]; if (entity.Type != EntityType.None && entity.Type != EntityType.Player && entity.State != EntityState.Spawning) { pos.X = game.GetScreenX(entity.Position.X); pos.Y = entity.Position.Y + y; if (entity.Type != EntityType.EnemyBullet) { if (entity.Type == EntityType.Mutant && game.State == GameState.Play) { pos.X += (float)(game.Random.NextDouble() * 2.0 - 1.0); pos.Y += (float)(game.Random.NextDouble() * 2.0 - 1.0); } DrawAnimatedSprite(pos, entity.Rotation, entity.Type); } else { spriteBatch.Draw(CoreGlobals.BlankTexture, pos, null, Color.White, 0, origin, 2, SpriteEffects.None, 0); } } } Vector4 bullet; var rect = new Rectangle(); rect.Height = 1; for (i = 0; i < game.BulletsAlive.Length; ++i) { if (game.BulletsAlive[i]) { bullet = game.Bullets[i]; rect.X = (int)bullet.X; rect.Y = (int)bullet.Y + y; rect.Width = (int)bullet.Z; if (bullet.W < 1) { rect.X -= rect.Width; } spriteBatch.Draw(CoreGlobals.BlankTexture, rect, Color.Green); } } var player = game.Entities[game.PlayerIndex]; if (player.State == EntityState.Default) { SpriteAnimations[(int)EntityType.Player].Effects = game.PlayerDir > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; DrawAnimatedSprite(game.PlayerScreenPos + new Vector2(0, y), 0, EntityType.Player); } else if (player.State == EntityState.PlayerDeath) { Color color = ((game.PlayerDeathTimer / 10) % 2) == 0 ? Color.Red : Color.White; origin = new Vector2(playerDeathRect.Width * 0.5f, playerDeathRect.Height * 0.5f); spriteBatch.Draw(SpriteSheet, game.PlayerScreenPos + new Vector2(0, y), playerDeathRect, color, 0, origin, 1, game.PlayerDir > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0); } var sprite = new TimedSprite(); for (i = 0; i < game.TimedSprites.Length; ++i) { if (game.TimedSprites[i].Frame > 0) { sprite = game.TimedSprites[i]; var srcRect = sprite.SrcRects[sprite.Frame - 1]; var destRect = new Rectangle((int)sprite.Position.X, (int)sprite.Position.Y, srcRect.Width, srcRect.Height); spriteBatch.Draw(SpriteSheet, destRect, srcRect, Color.White); } } }