#include "./functions.txt"

task ObjEffect_Shadow(spin)
{
	ascent(i in 0..3)
		{
		TOrb(i*120);
		}
	TGundam(1);
	TGundam(-1);
	task TGundam(dir)
		{
		let img = GetCurrentScriptDirectory ~ "system/img/Sprite_Kanako_Gundam.png";
		let obj = ObjPrim_Create(OBJ_SPRITE_2D);
		ObjPrim_SetTexture(obj,img);
		ObjSprite2D_SetSourceRect(obj,0,0,90,64);
		Obj_SetRenderPriorityI(obj,26);	
		let dist = 30;
		let angle = 90+dir*90;
		ObjRender_SetScaleX(obj,-dir);
		if(spin == false)
			{
			dist = GetStgFrameWidth*2;
			}
		while(ObjEnemy_GetInfo(objEnemy,INFO_LIFE) > 0)
			{
			if(dist > 30)
				{
				dist-=10;
				}	
			else
				{
				dist = 30;
				}
			ObjRender_SetPosition(obj,enmx-dist*cos(angle),enmy-12.5,0);
			ObjSprite2D_SetDestCenter(obj);
			yield;
			}
		Obj_Delete(obj);
		}
	task TOrb(color)
		{
		let dist = 48;
		let scale = 0.66;
		let glow = 0;
		let angle = color+180;
		let speed = 180;
		if(spin == false)
			{
			scale = 0;
			speed = 0;
			}
		let img = GetCurrentScriptDirectory ~ "system/img/Sprite_Kanako_Orb.png";
		let obj = ObjPrim_Create(OBJ_SPRITE_2D);
		ObjPrim_SetTexture(obj,img);
		ObjSprite2D_SetSourceRect(obj,0,0,241,241);
		ObjRender_SetColorHSV(obj,color,175,255);
		ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
		Obj_SetRenderPriorityI(obj,25);
		while(ObjEnemy_GetInfo(objEnemy,INFO_LIFE) > 0)
			{	
			glow+=5;
			speed+=1;
			if(spin == false && scale < 0.75)
				{
				scale+=0.75/45;
				ObjRender_SetScaleY(obj,0.75);
				}
			if(spin == true)
				{
				color+=1;
				angle+=2;
				ObjRender_SetScaleY(obj,0.66);
				}
			ObjRender_SetAlpha(obj,100+cos(glow)*10);
			ObjRender_SetScaleX(obj,scale);
			ObjRender_SetPosition(obj,enmx+dist*cos(color)+dist*cos(angle),enmy+dist*sin(color)+dist*sin(angle),0);	
			ObjSprite2D_SetDestCenter(obj);
			yield;
			}
		Obj_Delete(obj);
		}
}

task ObjEnemy_Render
{
	let imgBoss = GetCurrentScriptDirectory ~ "system/img/Sprite_Kanako.png";
	let x = 0; 
	let y = 0;
	let anim = 0;
	let move = 0;
	let spell = 0;

	while(!Obj_IsDeleted(objEnemy))
		{
		anim+=0.125;
		if(EnemySpell3 == true)
			{
			imgBoss = GetCurrentScriptDirectory ~ "system/img/Sprite_Kanako_Invis.png"
			}
		else
			{
			imgBoss = GetCurrentScriptDirectory ~ "system/img/Sprite_Kanako.png";
			}		
		if(EnemyMotion == true && ObjMove_GetSpeed(objEnemy) > 0.1)
			{
			anim = 0;
			spell = 0;
			if(move < 2)
				{
				move+=0.175;
				}
			x = 64*floor(move);
			y = 64;
			}
		else if(EnemySpell2 == true)
			{
			move = 0;
			spell = 0;
			x = 64*floor(anim);
			y = 64*3;
			}
		else if(EnemySpell == true)
			{
			anim = 0;
			move = 0;
			if(spell < 3)
				{
				spell+=0.175;
				}
			x = 64*floor(spell);
			y = 64*2;
			}
		else
			{
			move = 0;
			spell = 0;
			x = 64*floor(anim);
			y = 0;
			}
		if(cos(ObjMove_GetAngle(objEnemy)) < 0)
			{
			ObjRender_SetScaleX(objEnemy,-absolute(ObjRender_GetScaleX(objEnemy)));
			}
		else
			{
			ObjRender_SetScaleX(objEnemy,absolute(ObjRender_GetScaleX(objEnemy)));
			}
		ObjPrim_SetTexture(objEnemy,imgBoss);
		ObjSprite2D_SetSourceRect(objEnemy,x,y,x+64,y+64);
		ObjSprite2D_SetDestCenter(objEnemy);
		yield;
		}
}