using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ShootingHero.Scene;

namespace ShootingHero.Components.Bullets.BossBullet
{
	public class ChickenBullet : MonsterBullet
	{
		static Texture2D texture;

		Timer splitTimer = new Timer ( 1200 );

		public ChickenBullet ( Game game, float x, float y, float angle )
			: base ( game, x, y, angle, 1 )
		{
			if ( texture == null || texture.IsDisposed )
				texture = Game.Content.Load<Texture2D> ( "Bullet/bullet_cock" );
			Texture = texture;
			AttackPoint = 5;
		}

		public override void Update ( GameTime gameTime )
		{
			base.Update ( gameTime );

			GameScene gameScene = ( Game.Components [ 0 ] as Transitor ).CurrentScene as GameScene;

			splitTimer.Update ( gameTime );
			if ( splitTimer.CheckTimer )
			{
				gameScene.BulletManager.Remove ( this );
				gameScene.BulletManager.Add ( new ChickenBullet ( Game, X, Y, Angle + Microsoft.Xna.Framework.MathHelper.ToRadians ( -25 ) ) );
				gameScene.BulletManager.Add ( new ChickenBullet ( Game, X, Y, Angle + Microsoft.Xna.Framework.MathHelper.ToRadians ( 25 ) ) );
				splitTimer.Reset ();
			}
		}
	}
}
