public GameOverComponent(Game1 game) { this.game = game; fontLarge = game.Content.Load <SpriteFont>("PithazardLarge"); gradientTexture = CreateRedGradientTexture(game.GraphicsDevice, 1000, 600, reverse: true); menu = new MenuComponent(game); menu.AddOption("Retry", () => { game.Restart(); }); menu.AddOption("Exit", () => { game.Exit(); }); }
public SuccessComponent(Game1 game) { this.game = game; gradientTexture = new Texture2D(game.GraphicsDevice, 1, 1); gradientTexture = CreateGreenGradientTexture(game.GraphicsDevice, 1000, 600, reverse: true, 8); fontLarge = game.Content.Load <SpriteFont>("ArialLarge"); var stringLength = fontLarge.MeasureString(titleText); var screenCenter = Constants.ScreenWidth / 2; var titleX = screenCenter - stringLength.X / 2; var titleY = 100; titlePosition = new Vector2(titleX, titleY); var textures = new List <Texture2D> { game.Content.Load <Texture2D>("star"), game.Content.Load <Texture2D>("diamond"), }; ParticleEngine CreateEmitter(float x, float y) { return(new ParticleEngine(textures, new Vector2(x, y), 240, null, 2)); } emitters = new List <ParticleEngine> { CreateEmitter(titlePosition.X, titleY), CreateEmitter(titlePosition.X + fontLarge.MeasureString(titleText).X / 2, titleY), CreateEmitter(titlePosition.X + fontLarge.MeasureString(titleText).X, titleY), }; menu = new MenuComponent(game); menu.AddOption("Play Game", () => { game.Restart(); }); menu.AddOption("Exit", () => { game.Exit(); }); }