using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Graphics;

namespace WindowsGame1.Scene
{
    public class GameOver : GameScene
    {
        SpriteBatch spriteBatch;
        Texture2D mySpriteTexture;
        private SpriteFont font;
        private Vector2 MessageVector;
        private string Message = "Game Over";
        public Vector2 Position;

        public GameOver(Game game)
            : base(game, "GameOver")
        {
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            mySpriteTexture = Game.Content.Load<Texture2D>("Images\\失落");
            font = Game1.DefaultFont;            
            Vector2 center = new Vector2(Game.GraphicsDevice.ScissorRectangle.Width / 2, Game.GraphicsDevice.ScissorRectangle.Height / 2);
            Vector2 size = font.MeasureString(Message) / 2;
            MessageVector = new Vector2((float)Math.Ceiling(400 - size.X), (float)Math.Ceiling(300 - size.Y));
            base.LoadContent();
        }

        public override void Update(GameTime gameTime)
        {
            KeyboardState ks = Keyboard.GetState();
            if (ks.IsKeyDown(Keys.Enter))
            {
                Game1.SceneManager.Back("MainMenu");
            }
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            Sprite.Begin();
            Vector2 pos = new Vector2(0, 0);
            Rectangle rec = new Rectangle(-10, 0, 810, 480);
            Sprite.Draw(mySpriteTexture, rec, Color.White); // Color.White 是過濾顏色 也就是完全不過濾
            Sprite.DrawString(font, "Game Over", MessageVector, Color.Red);
            Sprite.End();
            base.Draw(gameTime);
        }
    }
}
