
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Nue_AnimeLib.txt";
	
	tex_enemy=filedir~"Nue_Main.png";
	let tex_sub=filedir~"Nue_Sub.png";
	
	@Initialize
	{
		SetLife(1);
		EnemyBossInitialize;
		LoadGraphic(tex_sub);
		SetAnimetion(tex_enemy);
		invincible=true;
	}
	@MainLoop{EnemyBossMainLoopSystem(0,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{DeleteGraphic(tex_sub);EnemyBossFinalize;}
	
	
	
	task MainThread_Standard{}
	task MainThread_Advanced{}
	
	
	task MainThread_Unlimited
	{
		yield;
		SetMovePositionHermite(cenX,minY+120,500,220,1200,0,240);
		EnemyBossDrawSub;
		wait(240);
		invincible=false;
		wait(80);
		AddLife(-1);
		
		task EnemyBossDrawSub
		{
			let rect=[0,0,128,128];
			let obj=SetEffectObject(tex_sub,3);
			SetEffectObjectRect(obj,rect[0],rect[1],rect[2],rect[3]);
			ObjEffect_SetRenderState(obj,ALPHA);
			let alpha=192;
			let angle=0;
			let scale=0.75;
			let count=0;
			while(!Obj_BeDeleted(obj))
			{
				let color=255;
				ascent(a in 0..4)
				{
					ObjEffect_SetVertexColor(obj,a,alpha,color,color,color);
				}
				Obj_SetPosition(obj,GetX,GetY);
				ObjEffect_SetAngle(obj,0,0,angle);
				ObjEffect_SetScale(obj,scale,scale);
				
				if(!invincible)
				{
					scale+=0.04;
					alpha-=6;
					if(alpha<5){Obj_Delete(obj);}
				}
				else{Effect(angle);}
				
				angle+=44;
				count++;
				yield;
			}
			
			task Effect(let angle)
			{
				let rect=[0,0,128,128];
				let obj=SetEffectObject(tex_sub,2);
				SetEffectObjectRect(obj,rect[0],rect[1],rect[2],rect[3]);
				ObjEffect_SetRenderState(obj,ADD);
				Obj_SetPosition(obj,GetX,GetY);
				ObjEffect_SetAngle(obj,0,0,angle);
				let alpha=24;
				let scale=0.75;
				let count=0;
				while(!Obj_BeDeleted(obj))
				{
					let color=255;
					ascent(a in 0..4)
					{
						ObjEffect_SetVertexColor(obj,a,alpha,color,color,color);
					}
					
					ObjEffect_SetScale(obj,scale,scale);
					
					scale+=0.03;
					alpha-=2;
					if(alpha<5){Obj_Delete(obj);}
					
					count++;
					yield;
				}
			}
		}
	}
	
}