let LightMode=false;
#include_function ".\..\Config.txt"

let SetBulletColor=["RED","ORANGE","YELLOW","GREEN","CYAN","BLUE","PURPLE","WHITE"];

let SULeng=length(StepUp);
let StepUpNum1=0;
let StepUpNum2=0;
let StepUpNum3=0;
let StepUpNum4=0;
let StepUpNum5=0;
let StepUpNum6=0;
let StepUpNum7=0;
let StepUpNum8=0;
let StepUpNum9=0;
if(SULeng>=1){StepUpNum1=StepUp[0]*500;}
if(SULeng>=2){StepUpNum2=StepUp[1]*500;}
if(SULeng>=3){StepUpNum3=StepUp[2]*500;}
if(SULeng>=4){StepUpNum4=StepUp[3]*500;}
if(SULeng>=5){StepUpNum5=StepUp[4]*500;}
if(SULeng>=6){StepUpNum6=StepUp[5]*500;}
if(SULeng>=7){StepUpNum7=StepUp[6]*500;}
if(SULeng>=8){StepUpNum8=StepUp[7]*500;}
if(SULeng>=9){StepUpNum9=StepUp[8]*500;}

let StepUp1=false;
let StepUp2=false;
let StepUp3=false;
let StepUp4=false;
let StepUp5=false;
let StepUp6=false;
let StepUp7=false;
let StepUp8=false;
let StepUp9=false;

//////////////////////////////////////////////////////////////////////////////////////

let SetEnemyLife=GetCommonData("EnemyLife")+1000;

task StepUpJudg
{//Lifeが一定以下になったらStepUp系をtrueに更新
loop
{
if(GetLife<=SetEnemyLife-StepUpNum1){StepUp1=true;}
if(GetLife<=SetEnemyLife-StepUpNum2){StepUp2=true;}
if(GetLife<=SetEnemyLife-StepUpNum3){StepUp3=true;}
if(GetLife<=SetEnemyLife-StepUpNum4){StepUp4=true;}
if(GetLife<=SetEnemyLife-StepUpNum5){StepUp5=true;}
if(GetLife<=SetEnemyLife-StepUpNum6){StepUp6=true;}
if(GetLife<=SetEnemyLife-StepUpNum7){StepUp7=true;}
if(GetLife<=SetEnemyLife-StepUpNum8){StepUp8=true;}
if(GetLife<=SetEnemyLife-StepUpNum9){StepUp9=true;}
yield;
}
}

////////////////////////////////////////////////////////////////////////////////////////////

function BasePoint(Base)
{//ベースポイントを更新
	SetCommonData("BasePoint",GetCommonDataDefault("BasePoint",0)+Base);
}

function BulletColor(color)
{//色により共通データを更新
	alternative(color)
	case("RED"){SetCommonData("RedShot",GetCommonDataDefault("RedShot",0)+1);}
	case("BLUE"){SetCommonData("BlueShot",GetCommonDataDefault("BlueShot",0)+1)}
	case("GREEN"){SetCommonData("GreenShot",GetCommonDataDefault("GreenShot",0)+1);}
	case("YELLOW"){SetCommonData("YellowShot",GetCommonDataDefault("YellowShot",0)+1);}
	case("PURPLE"){SetCommonData("PurpleShot",GetCommonDataDefault("PurpleShot",0)+1);}
	case("CYAN"){SetCommonData("CyanShot",GetCommonDataDefault("CyanShot",0)+1);}
	case("ORANGE"){SetCommonData("OrangeShot",GetCommonDataDefault("OrangeShot",0)+1);}
	case("WHITE"){SetCommonData("WhiteShot",GetCommonDataDefault("WhiteShot",0)+1);}
}
////////////////////////////////////////////////////////////////////////////////////////////////
let DoubleSpoilerStopCount=0;
let DefeatBossAction=false;
function DoubleSpoilerYield//Mainloopのyield時止め対応版
{
	if(GetCommonDataDefault("TimeStop",false)==true)
	{
		DoubleSpoilerStopCount+=1;
		if(DoubleSpoilerStopCount>=30)
		{
			SetCommonData("TimeStop",false);
		}
	}
	else if(GetCommonDataDefault("DefeatBoss",false)==true)
	{
		yield;
		DoubleSpoilerStopCount+=1;
		if(DoubleSpoilerStopCount>=30)
		{
			SetCommonData("TimeStop",false);
			VanishEnemy;
		}
	}
	else
	{
		yield;
		DoubleSpoilerStopCount=0;
	}
}

task DoubleSpoilerSetMovePosition02(X,Y,frame)
{//時止め対応版。自機の位置に移動

	let GX=GetX;
	let GY=GetY;

	loop(frame)
	{
		SetX(GetX+(X-GX)/frame);
		SetY(GetY+(Y-GY)/frame);
		if(GetCommonDataDefault("DefeatBoss",false)==true)
		{
			break;
		}
		yield;
	}
}

task DoubleSpoilermoveToPlayer(xMove, yAdd, frame, left, top, right, bottom)
{//時止め対応版moveToPlayer
	let x;
	let y;

	if(GetPlayerX < GetX)
	{
		x = GetX - xMove;
		if(x < left)
		{
			x = GetX + xMove;
		}
	}
	else
	{
		x = GetX + xMove;
		if(right < x)
		{
			x = GetX - xMove;
		}
	}

        y = GetY + yAdd;
        if(y < top) {
            y = top;
        } else if(bottom < y) {
            y = bottom;
        }

	let X=GetX;
	let Y=GetY;
	if(X-x<=0)
	{
	//	SetAction(ACT_MOVE_R,frame);
	}
	else
	{
	//	SetAction(ACT_MOVE_L,frame);
	}
	loop(frame)
	{
		SetX(GetX+(x-X)/frame);
		SetY(GetY+(y-Y)/frame);
		if(GetCommonDataDefault("DefeatBoss",false)==true)
		{
			break;
		}
		yield;
	}
}

task DoubleSpoilerSetMovePosition03(let X, let Y, let weight,let MaxSpeed)
{
let angle=atan2(Y-GetY,X-GetX);
let PX=GetX;
let PY=GetY;
let Frame=0;
let speed=0;
let CorX=0;
let CorY=0;

while(GetX!=X && GetY!=Y)
{

if(CsdDistanceToPlayer(PX,PY,X,Y)>weight*MaxSpeed)
{
	if(CsdDistanceToPlayer(GetX,GetY,X,Y)>weight*MaxSpeed)
	{
		speed=MaxSpeed;
	}
	else
	{
		Frame++;
		speed=8*exp^(-Frame/weight);
	}
}
else
{
	Frame++;
	speed=CsdDistanceToPlayer(PX,PY,X,Y)/weight*exp^(-Frame/weight);
} 

SetSpeed(speed);
SetAngle(angle);
yield;

}

}
///////////////////////////////////////////////////////////////////////////////////////////

#include_function ".\..\txt/CreateShotData.txt"