using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
#if ANDROID || IOS
using Microsoft.Xna.Framework.Input.Touch;
#endif

namespace ShootingHero.Scene
{
	public class SynopsisScene : DrawableGameComponent
	{
		Texture2D synopBackground, ufo;
		float y;

		public SynopsisScene ( Game game )
			: base ( game )
		{
		
		}

		public override void Initialize ()
		{
			y = -100;
			base.Initialize ();
		}

		protected override void LoadContent ()
		{
			synopBackground = Game.Content.Load<Texture2D> ( "Synopsis/synopsis" );
			ufo = Game.Content.Load<Texture2D> ( "Synopsis/ufo1" );
			base.LoadContent ();
		}

		protected override void UnloadContent ()
		{
			base.UnloadContent ();
		}

		public override void Update ( GameTime gameTime )
		{
			GamePadState gamePad = GamePad.GetState ( PlayerIndex.One );
#if ANDROID || IOS
			TouchCollection touches = TouchPanel.GetState ();
#else
			MouseState mouse = Mouse.GetState();
#endif

			y += gameTime.ElapsedGameTime.Milliseconds / 10.0f;

			if ( y >= 150 || gamePad.Buttons.Back == ButtonState.Pressed ||
#if ANDROID || IOS
				touches.Count > 0 && touches[0].State == TouchLocationState.Pressed
#else
				mouse.LeftButton == ButtonState.Pressed
#endif
 )
				( Game.Components [ 0 ] as Transitor ).Transition ( new CharacterSelectScene ( Game, false ) );

			base.Update ( gameTime );
		}

		public override void Draw ( GameTime gameTime )
		{
			SpriteBatch spriteBatch = ( Game as ShootingHero ).SpriteBatch;

			spriteBatch.Draw ( synopBackground, new Vector2 ( 0, 0 ), Color.White );
			spriteBatch.Draw ( ufo, new Vector2 ( -50, y - ufo.Height / 2 ), Color.White );

			base.Draw ( gameTime );
		}
	}
}
