#東方弾幕風
#Title[No.058　魅了・氷精「魅に囚われた者 -チルノ-　-Normal-」]
#Text[]
#Image[]
#BackGround[]
#PlayLevel[]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
#include_function ".\弾幕集.txt"

	let name    = "魅了・氷精「魅に囚われた者 -チルノ-　-Normal-」";

	//初期位置
	let xini    =GetCenterX;
	let yini    =GetCenterY;

	@Initialize{
	SetCommonData("ON_SPELL",1);
	CutIn(YOUMU,name,"",0,0,0,0);
	SetX(GetCenterX);
	SetY(GetClipMinY + 120);
	SetLife(2000);
	SetTimer(59);
	SetScore(5500000 + spellbonus * 2);
	SetDamageRate(50,10);
	SetInvincibility(120);

	LoadGraphic(imgboss1);
	SetTexture(imgboss1);
	SetGraphicRect(0,0,127,127);
	DeleteEnemyShotToItem(ALL);
	Shot(1);
	Move();
	}

	@MainLoop{
	ChackBonus;
	SetCollisionA(GetX,GetY,24);
	SetCollisionB(GetX,GetY,24);

	yield;
	}

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}

	@Finalize{
	DeleteGraphic(imgboss1);
	MasicPointAddSpellCard;
	loop(40 + scorebonus){
	let x = rand(GetX-32,GetX+32);
	let y = rand(GetY-32,GetY+32);
	CreateItem(ITEM_SCORE,x,y);}
	SetCommonData("ON_SPELL",0);
	}

	task Move(){
	loop{
	yield;
	}
	}

	task IceTowerShot(x,y,level){
	LoadUserShotData(GetCurrentScriptDirectory~"HAL_ice.txt");
	let obj	= Obj_Create(OBJ_SHOT);
	let count;
	Obj_SetX(obj, x);
	Obj_SetY(obj, y);
	Obj_SetSpeed(obj, 1);
	Obj_SetAngle(obj, 90);
	ObjShot_SetGraphic(obj, 1);
	ObjShot_SetDelay(obj, 20);

	count = 0;
	loop(100 - level * 20){yield;}
	while( !Obj_BeDeleted(obj) ){
	if(count <= level + 2){
	AllshotXY(Obj_GetX(obj),Obj_GetY(obj),1.5,90,12 + level * 6,2,20);
	}
	loop(20){yield;}
	yield;
	count++;
	}
	}

	task Shot(level){
	function Wait(time){loop(time){yield;}}
	CirnoShotE(level);
	let angle = 0;
	loop{
	if(OnBomb == false){
	IceTowerShot(rand(GetClipMinX,GetClipMaxX),GetY,level);
	}
	loop(60 - level * 5){yield;}
	}
	}
}