using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Content;
using xna_finall._2D;

namespace xna_finall
{
    class GameComponen_About : Microsoft.Xna.Framework.DrawableGameComponent
    {
        Texture2D Texture;
        GraphicsDevice device;
        Game game;
        SpriteBatch sBatch;
        public GameComponen_About(Game game, Texture2D texture2D)
            : base(game)
        {
            // TODO: Construct any child components here
            this.game = game;
            device = game.GraphicsDevice;
            Texture = texture2D;
        }
        public override void Initialize()
        {
            // TODO: Add your initialization code here

            base.Initialize();
        }
        protected override void LoadContent()
        {

            base.LoadContent();
        }
        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here
            if (GameStateClass.currentGameState != GameStateClass.GameState.about)
                return;

            KeyboardState newState;  // 宣告一個KeyboardState 結構的變數
            newState = Keyboard.GetState();  //得到目前鍵盤每一個按鍵的狀況
            if (newState.IsKeyDown(Keys.Escape)) //Escape -> 轉回 主選單
                GameStateClass.changeState(GameStateClass.GameState.Menu, game);

            base.Update(gameTime);
        }
        public override void Draw(GameTime gameTime)
        {
            if (GameStateClass.currentGameState != GameStateClass.GameState.about)
                return;

            device.Clear(Color.CornflowerBlue);

            sBatch = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch));
            if (sBatch == null) return;

            sBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);

            Vector2 pos = new Vector2(0, 0);
            sBatch.Draw(Texture, pos, Color.White);
            sBatch.End();
        }
    }
}
