
#Title[「フルーツオブライフ」]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
    let name    = "「フルーツオブライフ」";
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/patchouli_dot.png"; 
    let imgFam  = csd ~ "..\img\familiar.png";
SetRateScoreSystemEnable(false);
    // 初期位置
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 160;
	let wIni = 60;
	let count=-wIni;
	let DrawY=330;

	#include_function ".\..\txt\SpellCardBonusDefine.txt"
	let SpellTimer=50;
    @Initialize {
	StartSpellHistory(104);
        SetLife(1600);
        SetDamageRate(5, 5);
        LoadGraphic(imgBoss);
        LoadGraphic(imgFam);
        SetTexture(imgBoss);
	InitializeAction();
        TMain;
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
        yield;
    }

    @DrawLoop {
        DrawGraphic(GetX, GetY);
	DrawBoss( imgBoss );
	DrawSpellHistory;
    }

    @Finalize {
        DeleteGraphic(imgBoss);
	EndSpellHistory(104);
    }

    // メインタスク
task TMain 
{
	yield;
	standBy;
	spell;
	Trate;
	shot;
}

task Trate
{
	wait(120);
        SetDamageRate(50, 50);
}




sub standBy//初期位置へ
{
	SetAction(ACT_MOVE, 60);
	let wIni = 60;
	SetMovePosition02(xIni, yIni, wIni);
	SetInvincibility(wIni);
	wait(wIni);
}

sub spell//発動モーション
{
        CutIn(YOUMU, name, "", 0, 0, 0, 0);
        SetTimer(80);
        SetScore(22000000/3);
	SetAction(ACT_SPELL,90);
	wait(90);
}




task shot
{
let angle;
loop
{
	angle=rand(0,360);
	fruit(GetX,GetY,0,angle,RED02,RED05,0);
	ascent(let i in 0..6)
	{
		fruit(GetX,GetY,3,angle+i*60,PURPLE02,PURPLE05,0);
		fruit(GetX,GetY,1.5,angle+i*60,BLUE02,BLUE05,0);
	}
	wait(240);
}
}

task fruit(let x, let y, let speed,let angle, let graphic,let graphic2, let delay)
{
	let count=0;
	let count1=0;
	let length=200;
	let obj = Obj_Create(OBJ_SHOT);
	Obj_SetPosition(obj, x, y);
	Obj_SetSpeed(obj, speed);
	Obj_SetAngle(obj, angle);
	ObjShot_SetGraphic(obj, graphic);
	ObjShot_SetDelay(obj, delay);
	ObjShot_SetBombResist(obj,true);
	wait(45);
	Obj_SetSpeed(obj, 0);
	circleshot(Obj_GetX(obj),Obj_GetY(obj),graphic2);
	wait(60);
if(graphic2==PURPLE05)
{
	CreateLaser01(Obj_GetX(obj),Obj_GetY(obj),2,angle+120,length,6,GREEN01,0);
	CreateLaser01(Obj_GetX(obj),Obj_GetY(obj),2,angle-120,length,6,GREEN01,0);
	CreateLaser01(Obj_GetX(obj),Obj_GetY(obj),2,angle+150,length,6,BLUE01,0);
	CreateLaser01(Obj_GetX(obj),Obj_GetY(obj),2,angle-150,length,6,BLUE01,0);
	CreateLaser01(Obj_GetX(obj),Obj_GetY(obj),2,angle-180,length,6,BLUE01,0);
	CreateLaser01(Obj_GetX(obj),Obj_GetY(obj),2,angle+180+acos(2.5/7^0.5),length,6,BLUE01,0);
	CreateLaser01(Obj_GetX(obj),Obj_GetY(obj),2,angle+180-acos(2.5/7^0.5),length,6,BLUE01,0);
}
if(graphic2==BLUE05)
{
	CreateLaser01(Obj_GetX(obj),Obj_GetY(obj),2,angle+150,length,6,BLUE01,0);
	CreateLaser01(Obj_GetX(obj),Obj_GetY(obj),2,angle-150,length,6,BLUE01,0);
	CreateLaser01(Obj_GetX(obj),Obj_GetY(obj),2,angle+120,length,6,GREEN01,0);
	CreateLaser01(Obj_GetX(obj),Obj_GetY(obj),2,angle-120,length,6,GREEN01,0);
	CreateLaser01(Obj_GetX(obj),Obj_GetY(obj),2,angle-120-acos(2.5/7^0.5),length,6,BLUE01,0);
	CreateLaser01(Obj_GetX(obj),Obj_GetY(obj),2,angle+120+acos(2.5/7^0.5),length,6,BLUE01,0);
}
Obj_Delete(obj);
}

function circleshot(let x,let y,let graphic)
{
let angle=rand(0,360);
	ascent(let i in 0..18)
	{
		CreateShotA(1,x,y,30);
		SetShotDataA(1,0,3,angle+i*20,0,0,0,graphic);
		SetShotDataA(1,10,0,NULL,0,0,0,graphic);
		SetShotDataA(1,120,2,NULL,0,0,0,graphic);
		//SetShotKillTime(1,180);
		FireShot(1);
	}
}

#include_function ".\..\txt/data.txt"
#include_function ".\..\txt\Spelldata.txt"
#include_function ".\..\lib/lib_anime_Patchouli.txt"
}
