#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
#endregion

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

        ScreenManager screenManager;
        InputSystem input;

        private AudioEngine _audio;
        private WaveBank _wavebank;
        public SoundBank soundbank;

        public static int ScreenWidth = 1024;
        public static int ScreenHeight = 768;
        public static int LevelTop = 68;

        public const float DEGREES_TO_RADIANS = 0.7853981625f; //45.0f * 0.0174532925f;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);

            graphics.PreferredBackBufferWidth = Game1.ScreenWidth;
            graphics.PreferredBackBufferHeight = Game1.ScreenHeight;

            _audio = new AudioEngine("Chapter5sounds.xgs");
            _wavebank = new WaveBank(_audio, "Content/Wave Bank.xwb");
            soundbank = new SoundBank(_audio, "Content/Sound Bank.xsb");

            //SoundManager soundManager = new SoundManager(this);
            //Components.Add(soundManager);

            //soundManager.Initialize();

            //this.Services.AddService(typeof(ISoundManager), soundManager);

            screenManager = new ScreenManager(this,graphics);

            screenManager.Initialize();

            // Activate the first screens.
            screenManager.AddScreen(new MainMenuScreen());

            Components.Add(screenManager);

            input = new InputSystem(this);

            //we don't want to use this until we play the game or configure the controls
            input.Enabled = false;

            input.AddAction("Move", Control.LeftStick, ActionType.Move, null);
            input.AddAction("Move Foward", Control.DPadUp, ActionType.MoveForward, null);
            input.AddAction("Move Backward", Control.DPadDown, ActionType.MoveBackward, null);
            input.AddAction("Move Left", Control.DPadLeft, ActionType.MoveLeft, null);
            input.AddAction("Move Right", Control.DPadRight, ActionType.MoveRight, null);
            input.AddAction("Fire", Control.RightTrigger, ActionType.Fire, null);
            input.AddAction("Rotate", Control.RightStick, ActionType.Rotate, null);

            Components.Add(input);

            this.Services.AddService(typeof(IInputSystem), input);

        }

        protected override void Update(GameTime gameTime)
        {
            _audio.Update();
            base.Update(gameTime);
        }
        protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.Black);

            // The real drawing happens inside the screen manager component.
            base.Draw(gameTime);
        }
    }
}
