using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using FlatRedBall;
using TomShane.Neoforce.Controls;
using FlatRedBall.Audio;

namespace Wizard_Duel
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
     //   SpriteBatch spriteBatch;
        

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        /// 
        public static Manager Manager
        {
            get;
            set; // could make this private if we don't want anyone but the Screen to set this
        }

       
        protected override void Initialize()
        {
            FlatRedBallServices.InitializeFlatRedBall(this, graphics);
            base.Initialize();
            Manager = new Manager(this, graphics, "Default", false);
            

            Manager.RenderTargetUsage = RenderTargetUsage.DiscardContents;
          

            // Uncomment the following line and add your Screen's fully qualified name
            // if using Screens in your project.  If not, or if you don't know what it means,
            // just ignore the following line for now.
            // For more information on Screens see the Screens wiki article on FlatRedBall.com.
            
            
           
          
            Manager.Initialize();

            Manager.RenderTarget = new RenderTarget2D(GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, 1, SurfaceFormat.Color, Manager.RenderTargetUsage);
            Manager.TargetFrames = 60;

            AudioManager.Initialize(@"Content\Audio\Wizard_Duel.xgs",
@"Content\Audio\Wave Bank.xwb", @"Content\Audio\Sound Bank.xsb");

            Screens.ScreenManager.Start(typeof(Wizard_Duel.Screens.NetworkScreen).FullName);
        }


        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            FlatRedBallServices.Update(gameTime);
            Screens.ScreenManager.Activity();
            
            // TODO: Add your update logic here
            base.Update(gameTime);

            Manager.Update(gameTime);
        }

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            
            Manager.BeginDraw(gameTime);
            graphics.GraphicsDevice.Clear(Color.White);

            base.Draw(gameTime);

            FlatRedBallServices.Draw();
            
            
            Manager.EndDraw();
        }

      
     

        

       
            

         
      
        

    }
    

}