#東方弾幕風
#Title[混色「赤と緑の追跡」]
#Text[試作]
#ScriptVersion[2]
script_enemy_main
{
	let count=0;
	let cx=GetCenterX();//STGシーンの中心x座標を取得
	let cy=GetCenterY();//STGシーンの中心y座標を取得
	let doll=0;
	let imgExRumia=GetCurrentScriptDirectory~"img\ExRumia.png";
	let imgExRumiaBack=GetCurrentScriptDirectory~"img\ExRumiaBack.png";
	LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");
	@Initialize
	{
		SetScore(30000);
		SetLife(200);
		SetDamageRate(10,10);
		SetMovePosition02(cx,cy-120,60);
		SetTimer(80);
		SetGraphicRect(1,1,64,64);
		SetInvincibility(180);
		LoadGraphic(imgExRumia);
		SetTexture(imgExRumia);	
		shottask;
		CutIn(YOUMU,"混色「赤と緑の追跡」",0,0,0,0,0);//スペルカード名表示
	}
	@MainLoop
	{
		yield;
		SetCollisionA(GetX(),GetY(),24);//当たり判定(自弾)登録
		SetCollisionB(GetX(),GetY(),24);//当たり判定(体当たり)登録
	}
	@Finalize
	{
		loop(8)
		{
			CreateItem(ITEM_SCORE,cx+rand(-100,100),rand(20,100));
		}
	}
	@DrawLoop
	{
		SetGraphicRect(1,1,64,64);
		SetAlpha(255);
		DrawGraphic(GetX(),GetY());
	}
	task shottask
	{
		let s=0;
		wait(120);
		CreateEnemyFromScript("inv",GetClipMaxX,GetClipMinY,0,0,0);
		CreateEnemyFromScript("frog",GetX,GetY,0,0,0);
		wait(120);
	}
	task shottask2
	{
		let s=0;
		loop
		{	
			yield;
		}
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}
script_enemy inv
{
	LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");
	@Initialize
	{
		SetLife(500);
		SetDamageRate(0,0);
		SetInvincibility(60);
		shottask;
		movetask;
	}
	@MainLoop
	{
		yield;
	}
	@Finalize
	{
	}
	@DrawLoop
	{
	}
	task shottask
	{
		let s=0;
		let color=0;
		loop
		{
			loop(120)
			{
				color=rand_int(1,4)*8-4;
				CreateShotA(s,rand(GetX-20,GetX+20),rand(GetY-20,GetY+20),0);
				SetShotDataA(s,0,0,0,0,0,0,color);
				FireShot(s);
				wait(5);
			}
			wait(120);
			DeleteEnemyShot(CHILD);
			SetX(GetClipMaxX);
			SetY(GetClipMinY);
			Concentration01(60);
			wait(120);
		}
	}
	task movetask
	{
		loop
		{
			loop(600)
			{
				SetSpeed(2);
				SetAngle(GetAngleToPlayer);
				yield;
			}
			wait(240);
		}
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}
script_enemy frog
{
	LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");
	@Initialize
	{
		SetLife(500);
		SetDamageRate(0,0);
		SetInvincibility(60);
		SetTexture(GetCurrentScriptDirectory~"img\ExRumia.png");	
		shottask;
		movetask;
	}
	@MainLoop
	{
		yield;
	}
	@Finalize
	{
	}
	@DrawLoop
	{
		SetGraphicRect(1,1,64,64);
		SetAlpha(255);
		DrawGraphic(GetX(),GetY());
	}
	task shottask
	{
		let s=0;
		let color=0;
		wait(60);
		loop
		{
			wait(3);
			loop(6)
			{
				CreateShotA(s,GetX,GetY,0);
				SetShotDataA(s,0,0,rand(0,360),0,0,0,73);
				SetShotDataA(s,200,5,rand(0,360),0,0,0,73);
				SetShotKillTime(s,220);
				FireShot(s);
			}
		}
	}
	task movetask
	{
		let x=0;
		let y=0;
		wait(60);
		loop
		{
			x=GetX+240*cos(GetAngleToPlayer);
			y=GetY+240*sin(GetAngleToPlayer);
			loop(30)
			{
				SetMovePosition02(x,y,20);
				yield;
			}
			wait(60);
		}
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}