//東方弾幕風
//てんしトーク
#ScriptVersion[2]

script_enemy_main{

#include_function".\lib\include_std.txt"
#include_function".\system\include_enemy_boss.txt"

let animation_counter = 0;



let boss_state = _STATE_STAND;

@Initialize{
	SetLife(1000000);

	SetDamageRate(100,100);
	system_SetEnemyTexture("KANAME");
	system_SetEnemyType(4);
	once_system_LoadResourceBoss();
	system_SetEnemyLife(1000000);
	system_SetEnemyWeight(0);
	system_SetEnemyRadius(48);
	LoadUserShotData(GetCurrentScriptDirectory() ~ "UserShot_tenshi.txt");
	once_MainRoutine();

}

@MainLoop{

	SetCollisionA(GetX(), GetY(), 24);
	animation_counter++;
	yield;
}

@DrawLoop{
	if(system_IsInvisible()){return;}

	SetTexture(img_Enemy);
	SetGraphicScale(1.5,1.5);
	system_SetGraphicRect(["ROCK_MAIN01","ROCK_MAIN02","ROCK_MAIN03","ROCK_MAIN04"][trunc(animation_counter/5)%4]);
	DrawGraphic(GetX(), GetY());
}

@Finalize{

}


task once_MainRoutine(){
	boss_state = _STATE_STAND;
	once_system_TaskDrawTenshi();
	once_system_TaskSphereParameterChecker();
	once_system_TaskSphereHitTest();
	once_system_EnemyMain();
	once_MoveRoutine();
}


task once_MoveRoutine(){

	boss_state = _STATE_JUMP;

	loop(10){yield;}

	ascent(i in 0..70){
		let angle = (i*48);
		effect_Burst(angle);
		effect_Burst(angle/2);
		loop(2){yield;}
	}
	
	system_SetEnemyLife(0);
	loop(24){yield;}
	SetMovePosition03(GetCenterX(), GetClipMinY()-70, 6, 12);
	

}//end task


task effect_Burst(let angle){

	let obj = REMY_CreateEffectObject(img_Enemy, 4, 6);
	ObjEffect_SetRenderState(obj, ADD);
	let rect = system_GetGraphicRect("ROCK_MAIN01");
	REMY_SetObjectVertexSquare(obj, rect, 0, 0, 200, 255, 255, 255);
	
	Obj_SetSpeed(obj,rand(3,5));
	Obj_SetAngle(obj,angle);
	Obj_SetPosition(obj, GetX(), GetY()-60);
	ascent(i in 0..40){
		REMY_SetObjectColorSquare(obj, 200 * (1-i/40), 255, 255, 255);
		yield;
	}
	Obj_Delete(obj);
}





}//end script

