using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using ShootingHero.Components.Manager;
using ShootingHero.Components.Bullets.BossBullet;

namespace ShootingHero.Components.Monsters.Bosses
{
	public class HugeUfo : Boss
	{
		static Texture2D texture;

		float lrMover = 3.141592f / 2;
		int bulletMode = 0;
		Timer timer;
		float shootAngle;

		public HugeUfo ( Game game, float timeUnit )
			: base ( game, timeUnit, 1200 )
		{
			if ( texture == null || texture.IsDisposed )
				texture = Game.Content.Load<Texture2D> ( "Boss/ufo" );
			Texture = texture;
			TadaPosition = 120;
			Width = texture.Height / 2 - 40;
			Timer.Delay = 200;
			bulletMode = ( Game as ShootingHero ).Random.Next ( 0, 5 );
			timer = new Timer ( 3000 );
		}

		protected override void ShootBullet ( BulletManager bulletManager )
		{
			switch ( bulletMode )
			{
				case 0:
					bulletManager.Add ( new ChickenBullet ( Game, X, Y, Microsoft.Xna.Framework.MathHelper.ToRadians ( 180 + -25 ) ) );
					bulletManager.Add ( new ChickenBullet ( Game, X, Y, Angle + Microsoft.Xna.Framework.MathHelper.ToRadians ( 180 + 25 ) ) );
					break;
				case 1:
					bulletManager.Add ( new SquirrelBullet ( Game, X, Y, shootAngle ) );
					bulletManager.Add ( new SquirrelBullet ( Game, X, Y, shootAngle + 3.141592f / 2 ) );
					bulletManager.Add ( new SquirrelBullet ( Game, X, Y, shootAngle + 3.141592f ) );
					bulletManager.Add ( new SquirrelBullet ( Game, X, Y, shootAngle + 3.141592f + 3.141592f / 2 ) );
					break;
				case 2:
					bulletManager.Add ( new SharkBullet ( Game, X, Y ) );
					break;
				case 3:
					for ( int i = 0; i < 360; i += 30 )
						bulletManager.Add ( new SpiderBullet ( Game, X, Y, shootAngle + Microsoft.Xna.Framework.MathHelper.ToRadians ( i ) ) );
					break;
				case 4:
					bulletManager.Add ( new KomodoBullet ( Game, X, Y ) );
					break;
			}
		}

		protected override void MoveLogic ( GameTime gameTime )
		{
			lrMover += gameTime.ElapsedGameTime.Milliseconds / 2000.0f;
			X += ( float ) Math.Sin ( lrMover );
		}

		public override void Update ( GameTime gameTime )
		{
			shootAngle += gameTime.ElapsedGameTime.Milliseconds / 250.0f;
			timer.Update ( gameTime );
			if ( timer.CheckTimer )
			{
				bulletMode = ( Game as ShootingHero ).Random.Next ( 0, 5 );
				timer.Reset ();
			}
			base.Update ( gameTime );
		}
	}
}
