東方弾幕風[Single]
#ScriptVersion[2]
#Title[ザコ4]

script_enemy_main{
	
	@Initialize{
		//アイテム変更
		point_num *= 20;
		spower_num = 0;
		lpower_num = 5;
		
		//魔方陣サイズ変更
		magic_size = 0.75;
		
		//データ初期化
		InitializeData();
		Initialize_Fairy( LARGE_FLOWER );
		
		//画像設定
		imgBoss = imgFairy_Red;
		
		//ライフ設定
		SetLife( 1500 );
		
		//当たり判定設定
		SetCollisionEx( 32, 16, false, 180 );
		
		//メインタスク開始
		TMain();
	}
	
	@MainLoop{
		//yieldループ
		yield;
	}
	
	@DrawLoop{
		//妖精さん画像描画
		DrawFairy( imgBoss );
	}
	
	@Finalize{
		//自分の弾をアイテムに変える
		DeleteEnemyShotToItem( CHILD );
		
		//最終処理
		FinalizeData();
		
		//ボムアイテム
		CreateUserItem( GetX(), GetY(), UI_BOMB );
	}
	
	/**
	 * メインタスク
	 */
	task TMain(){
		//40F(約0.66秒)待つ
		FWait( 40 );
		
		//停止
		SetSpeed( 0 );
		ColorConcentration( 120, 255, 255, 255 );
		PlaySE( seCharge );
		FWait( 120 );
		
		//攻撃分岐
		alternative( difficult )
			case( "Easy" ){
				Atack_Easy();
			}
			case( "Normal" ){
				Atack_Normal();
			}
			case( "Panic" ){
				Atack_Panic();
			}
		
		FWait( 180 + 600 );
		
		//敵自動消去
		VanishEnemy();
	}
	
	/**
	 * Easy 攻撃メインタスク
	 */
	task Atack_Easy(){
	}
	
	/**
	 * Normal 攻撃メインタスク
	 */
	task Atack_Normal(){
	}
	
	/**
	 * Panic 攻撃メインタスク
	 */
	task Atack_Panic(){
		Atack1();
		FWait( 180 );
		
		Atack2();
	}
	
	/**
	 * 弾幕タスク1
	 */
	task Atack1(){
		let speed = 5.2;
		let span = 2;
		let roll = 22;
		let angle = 180;
		let way = 12;
		let leng = 24;
		let dangle = 120;
		let tangle = 0;
		
		loop{
			ascent( i in 0..way ){
				tangle = angle + i * 360 / way;
				CreateShot01( GetGapX( GetX(), leng, tangle ), GetGapY( GetY(), leng, tangle ), speed, angle         , US_BALL_F_PURPLE, 0 );
				CreateShot01( GetGapX( GetX(), leng, tangle ), GetGapY( GetY(), leng, tangle ), speed, angle - dangle, US_BALL_F_PURPLE, 0 );
			}
			
			angle += roll;
			
			FWait( span );
		}
	}
	
	/**
	 * 弾幕タスク2
	 */
	task Atack2(){
		let speed = 6.4;
		let span = 4;
		let roll = -24;
		let angle = 0;
		let way = 7;
		let dx = 0;
		let dy = 0;
		let leng = 24;
		
		loop{
			dx = -leng;
			dy = -leng;
			loop( way ){
				CreateShot01( GetX() + dx, GetY() + dy, speed, angle      , US_BALL_F_RED, 0 );
				CreateShot01( GetX() + dx, GetY() + dy, speed, angle - 180, US_BALL_F_RED, 0 );
				
				dx += leng * 2 / (way - 1);
				dy += leng * 2 / (way - 1);
			}
			
			dx =  leng;
			dy = -leng;
			loop( way ){
				CreateShot01( GetX() + dx, GetY() + dy, speed, angle      , US_BALL_F_RED, 0 );
				CreateShot01( GetX() + dx, GetY() + dy, speed, angle - 180, US_BALL_F_RED, 0 );
				
				dx -= leng * 2 / (way - 1);
				dy += leng * 2 / (way - 1);
			}
			
			angle += roll;
			
			FWait( span );
		}
	}
	
	//スクリプトのインクルード
	#include_function ".\..\..\initialize_zako.txt"
	
	#include_function ".\..\..\..\Library\lib_effect.txt"
}