task PlayerNoticeCheck
{
let ItemCheck=0;
let XY=[];
loop
{
	ItemCheck=length(GetCommonDataDefault("PLAYERACHIEVEMENT",[]));
	if(ItemCheck>0)
	{
			XY=GetCommonDataDefault("PLAYERACHIEVEMENT",[]);

			AchievementNotice(XY[0]);

			XY=erase(XY, 0);

			if(length(XY)==0)
			{
				SetCommonData("PLAYERACHIEVEMENT",[]);
			}
			else
			{
				SetCommonData("PLAYERACHIEVEMENT",XY);
			}
	}
yield;
}
}

task AchievementNotice(num)
{
	yield;
	//while(AchievementDrawing){yield;}
	if(IsReplay){return;}
	if(GetCommonDataDefault("TitleMenu",false)){return;}
	if(GetCommonDataDefaultEx(NsScore,NsAchievement[num],0)==1){return;}
	SetCommonDataEx(NsScore,NsAchievement[num],1);
	AchievementDrawing+=1;
	PlaySE(Ah_SE);
	let YAd=0;
	ascent(i in 0..10)
	{
	if(AchievementDrawingArray[i]==0)
	{
		AchievementDrawingArray[i]=1;
		YAd=i;
		break;
	}
	}
	let x=210;
	let y=20+20*YAd;
	let Alpha=0;
	let AlphaRate=1;
	T_AlphaAdjust;
	let time=60;
	loop(30)
	{
		DrawAchievement(num,205+x,70+y,Alpha*AlphaRate);
		DrawAchievementBlack(num,205+x,70+y,Alpha*AlphaRate);
		x-=3.5*2;
		Alpha+=255/30;
		yield;
	}
	loop(150)
	{
		DrawAchievement(num,205+x,70+y,Alpha*AlphaRate);
		DrawAchievementBlack(num,205+x,70+y,Alpha*AlphaRate);
		//Alpha+=255/30;
		yield;
	}
	loop(60)
	{
		DrawAchievement(num,205+x,70+y,Alpha*AlphaRate);
		DrawAchievementBlack(num,205+x,70+y,Alpha*AlphaRate);
		x+=3.5;
		Alpha-=255/60;
		yield;
	}
	AchievementDrawingArray[YAd]=0;
	AchievementDrawing-=1;
	task T_AlphaAdjust
	{
		loop(240)
		{
		if((GetPlayerY<GetClipMinY+150))
		{
			AlphaRate=(255+300/2*(GetPlayerY-(GetClipMinY+150))/(GetClipMinY+150))/255;
		}
		yield;
		}
	}
}

function HueDifine(HueCount)
{
let ColorRed=0;
let ColorGreen=0;
let ColorBlue=0;
let MinColor=0;
while(HueCount>360){HueCount-=360;}
while(HueCount<=0){HueCount+=360;}
	if(0<HueCount && HueCount<=60)
	{
		ColorRed=255;
		ColorGreen=255*(HueCount)/60;
		ColorBlue=0;
	}
	else if(HueCount<=120)
	{
		ColorRed=255*(120-HueCount)/60;
		ColorGreen=255;
		ColorBlue=0;
	}
	else if(HueCount<=180)
	{
		ColorRed=0;
		ColorGreen=255;
		ColorBlue=255*(HueCount-120)/60;
	}
	else if(HueCount<=240)
	{
		ColorRed=0;
		ColorGreen=255*(240-HueCount)/60;
		ColorBlue=255;
	}
	else if(HueCount<=300)
	{
		ColorRed=255*(HueCount-240)/60;
		ColorGreen=0;
		ColorBlue=255;
	}
	else if(HueCount<=360)
	{
		ColorRed=255;
		ColorGreen=0;
		ColorBlue=255*(360-HueCount)/60;
	}
	return([ColorRed,ColorGreen,ColorBlue]);
}

task LoadMenufile
{
	LoadGraphic(imgTitle);
	LoadGraphic(imgBG);
	LoadGraphic(imgWhite);
	LoadGraphic(imgBlack);
      	LoadGraphic(imgMenuLetter);
	//LoadGraphic(imgBer2);
      	LoadGraphic(imgNumber);
      	//LoadGraphic(imgStatusLetter);
	LoadGraphic(imgAchievement);
	LoadGraphic(imgTitleSquareLine);

	LoadGraphic(imgCircleLine);
	LoadGraphic(imgCrossLine);
	LoadGraphic(imgSquareLine);
	LoadGraphic(imgMinusLine);
	LoadGraphic(imgDeltaLine);
	LoadGraphic(imgDoubleCircleLine);
	LoadGraphic(imgStarLine);
	LoadGraphic(imgCircleCrossLine);
}

task LoadStagefile
{
	if(GetCommonDataDefault("DemoPlay",false))
	{
	LoadGraphic(imgExplain);
	LoadGraphic(imgBlack);
	}
	LoadGraphic(imgStageAchievement);
	LoadGraphic(imgTitle);
	LoadGraphic(imgWhite);
	//LoadGraphic(imgBG);
      	//LoadGraphic(imgMenuLetter);
      	LoadGraphic(imgBer2);
      	LoadGraphic(imgNumber);
      	LoadGraphic(imgStatusLetter);
      	LoadGraphic(imgStatusStar);
	LoadGraphic(imgCircleEffect);
	LoadGraphic(imgBreakCircleEffect);
      	LoadGraphic(imgItem);
      	LoadGraphic(imgDoll);
	if(BGDrawing==1)
	{
		LoadGraphic(csd~"img\White.png");
		LoadGraphic(csd~"img\Black.png");

		if(!StagePractice || StageProgress==1)
		{
		LoadGraphic(csd~"img\sky.png");
		LoadGraphic(csd~"img\mountains.png");
		LoadGraphic(csd~"img\st1bg1.png");
		LoadGraphic(csd~"img\cloud.png");
		}

		if(!StagePractice || StageProgress==2)
		{
		LoadGraphic(csd~"img\st2bg2.png");
		LoadGraphic(csd~"img\MountainChip.png");
		LoadGraphic(csd~"img\0024.png");
		LoadGraphic(csd~"img\moon.png");
		LoadGraphic(csd~"img\st4bg1.png");
		}

		if(!StagePractice || StageProgress==3)
		{
		LoadGraphic(csd~"img\cloud2.png");
		LoadGraphic(csd~"img\st3bg1.png");
		LoadGraphic(csd~"img\MountainChip2.png");
		LoadGraphic(csd~"img\st3cloudshadow.png");
		LoadGraphic(csd~"img\st3cloud.png");
		}

		if(!StagePractice || StageProgress==4)
		{
		LoadGraphic(csd~"img\st4bg1.png");
		}

		if(!StagePractice || StageProgress==5)
		{
		LoadGraphic(csd~"img\st5bg1.png");
		LoadGraphic(csd~"img\MagicDust.png");
		LoadGraphic(csd~"img\s0145.png");
		LoadGraphic(csd~"img\circle.png");
		LoadGraphic(csd~"img\Sphere.png");
		LoadGraphic(csd~"img\Pillar1.png");
		LoadGraphic(csd~"img\Pillar2.png");
		LoadGraphic(csd~"img\circlelight.png");
		}
	}
	LoadGraphic(imgBer);
	if(IsReplay)
	{
      	LoadGraphic(imgSpell);
	}
	LoadGraphic(imgIneDeltaLine);
	LoadGraphic(imgTitleSquareLine);
	LoadGraphic(imgMagicEffect);
	LoadGraphic(imgLight);
	LoadGraphic(imgCircleBorder);
	LoadGraphic(imgEffects);
}


task DeleteStagefile(num)
{
alternative(num)
case(1)
{
	DeleteGraphic(csd~"img\sky.png");
	DeleteGraphic(csd~"img\mountains.png");
	DeleteGraphic(csd~"img\st1bg1.png");
	DeleteGraphic(csd~"img\cloud.png");
}
case(2)
{
	DeleteGraphic(csd~"img\st2bg2.png");
	DeleteGraphic(csd~"img\MountainChip.png");
	DeleteGraphic(csd~"img\0024.png");
	DeleteGraphic(csd~"img\moon.png");
}
case(3)
{
	DeleteGraphic(csd~"img\cloud2.png");
	DeleteGraphic(csd~"img\st3bg1.png");
	DeleteGraphic(csd~"img\MountainChip2.png");
	DeleteGraphic(csd~"img\st3cloudshadow.png");
	DeleteGraphic(csd~"img\st3cloud.png");
}
case(4)
{

}

case(5)
{
	DeleteGraphic(csd~"img\st5bg1.png");
	DeleteGraphic(csd~"img\MagicDust.png");
	DeleteGraphic(csd~"img\s0145.png");
	DeleteGraphic(csd~"img\circle.png");
	DeleteGraphic(csd~"img\Sphere.png");
	DeleteGraphic(csd~"img\Pillar1.png");
	DeleteGraphic(csd~"img\Pillar2.png");
	DeleteGraphic(csd~"img\circlelight.png");
}

}


task DeleteUsedFile//もう使わないファイルをメモリから削除
{
	wait(10);
	DeleteSE(MenuSE[0]);//もう使わないから破棄
	DeleteSE(MenuSE[1]);//もう使わないから破棄
}	



///////////////////////////////////////////////////////////////////////////////////////
////////////////////////////ステージエフェクト、残機調整部////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////

sub ClearBonus
{
	LoadGraphic(imgMenuLetter);
	LoadGraphic(csd~"img\Clear.png");
	let OptionPenalty=1;
	let DifficultBonus=1;
	alternative(SelectedDifficult)
	case("Moderate"){DifficultBonus=1.0;}
	case("Extream"){DifficultBonus=1.5;}
	case("Apocalypse"){DifficultBonus=2.0;}
	if(InitialLife>3 || InitialBomb>3){OptionPenalty=0.1;}
	let Fragment=GetCommonDataDefault("MAGICFRAGMENT",MSDScoreItemCount);
	let FragmentScore=Fragment*10*OptionPenalty*DifficultBonus;
	let RestPlayerScore=400000*OptionPenalty*DifficultBonus;
	let RestBombScore=40000*OptionPenalty*DifficultBonus;

	let TotalScore=FragmentScore+RestPlayerScore*(GetPlayerLife-1)+(RestBombScore*GetPlayerBomb);

	if(GetCommonDataDefault("MSDPlayer",false)==false)
	{
		TotalScore*=0.01;
		TotalScore=floor(TotalScore);
	}

	Display;
	let PlusNum1=TotalScore%1000000;
	let PlusNum2=floor(TotalScore/1000000);
	wait(60);

	loop(100)
	{
		ScoreNumber1+=PlusNum1*100;
		ScoreNumber2+=PlusNum2*100;
		yield;
	}
	wait(80);


	wait(120);
	task Display
	{
		ascent(i in 0..30)
		{
			if(GetCommonDataDefault("TrueBossFlag",false))
			{
			TrueClearDisplay(GetCenterX,GetCenterY-135,255*i/30,255,255,255);
			}
			else
			{
			ClearDisplay(GetCenterX,GetCenterY-135,255*i/30,255,255,255);
			}
			ClearBonusDisplay(GetCenterX,GetCenterY-90,255*i/30,255,255,255);

			ClearBonusDisPlayScoreNumber(GetCenterX,GetCenterY-45,TotalScore,255*i/30);

			yield;
		}

		loop(180)
		{
			if(GetCommonDataDefault("TrueBossFlag",false))
			{
			TrueClearDisplay(GetCenterX,GetCenterY-135,255,255,255,255);
			}
			else
			{
			ClearDisplay(GetCenterX,GetCenterY-135,255,255,255,255);
			}
			ClearBonusDisplay(GetCenterX,GetCenterY-90,255,255,255,255);

			ClearBonusDisPlayScoreNumber(GetCenterX,GetCenterY-45, TotalScore,255);

			yield;
		}
		descent(i in 0..30)
		{
			if(GetCommonDataDefault("TrueBossFlag",false))
			{
			TrueClearDisplay(GetCenterX,GetCenterY-135,255*i/30,255,255,255);
			}
			else
			{
			ClearDisplay(GetCenterX,GetCenterY-135,255*i/30,255,255,255);
			}
			ClearBonusDisplay(GetCenterX,GetCenterY-90,255*i/30,255,255,255);

			ClearBonusDisPlayScoreNumber(GetCenterX,GetCenterY-45,TotalScore,255*i/30);

			yield;
		}
	}

}

sub StageTitleDisplay//メニュー画面の表示、SecretSpell部分でも呼び出して再起している。
{
	SetCommonData("TitleMenu",true);

	if(GetCommonData(NsIsReplayJudgment) == false && GetCommonDataDefaultEx(NsScore,"SelectedDifficult","None")=="None")
	{
		PlayMusic(BGM[0]);
		LoadMenufile;
		TitleEffect;
		loop
		{
			alternative(StageState)	
			case(Menu)
			{
				TASK_MENU;
		 	}
			case(Exit)
			{//メニュー画面で設定した値の保存
				FadeOutMusic(BGM[0],20);
				StageState=Loading;
				StageStartSignal=true;
				StageStartEffect;
				wait(120);

				SetCommonDataEx(NsScore,"SelectedDifficult",SelectedDifficult);
				SetCommonDataEx(NsScore,"StagePractice",StagePractice);
				SetCommonDataEx(NsScore,"StageProgress",StageProgress);
				SetCommonDataEx(NsScore,"StagePhaseProgress",StagePhaseProgress);

				wait(1);
				Retry;
		 	}
			others{}
		yield;
		}
	}
	else
	{
		LoadStagefile;
		PlayStartWhite;
		StageState=Start;
		if(GetCommonData(NsIsReplayJudgment) == false)
		{
			SelectedDifficult=GetCommonDataDefaultEx(NsScore,"SelectedDifficult","None");
			StagePractice=GetCommonDataDefaultEx(NsScore,"StagePractice",false);
			StageProgress=GetCommonDataDefaultEx(NsScore,"StageProgress",1);
			StagePhaseProgress=GetCommonDataDefaultEx(NsScore,"StagePhaseProgress",0);

			SetCommonDataEx(NsScore,"SelectedDifficult",SelectedDifficult);
			SetCommonData("SelectedDifficult",SelectedDifficult);
			SetCommonDataEx(NsScore,"StagePractice",StagePractice);
			SetCommonData("StagePractice",StagePractice);
			SetCommonDataEx(NsScore,"StageProgress",StageProgress);
			SetCommonData("StageProgress",StageProgress);
			SetCommonDataEx(NsScore,"StagePhaseProgress",StagePhaseProgress);
			SetCommonData("StagePhaseProgress",StagePhaseProgress);

			SetCommonDataEx(NsScore,"AutoBombMode",AutoBombMode);
			SetCommonData("AutoBombMode",AutoBombMode);
			SetCommonDataEx(NsScore,"InitialLife",InitialLife);
			SetCommonData("InitialLife",InitialLife);
			SetCommonDataEx(NsScore,"InitialBomb",InitialBomb);
			SetCommonData("InitialBomb",InitialBomb);


			if(StagePractice)
			{
				if(StageProgress==1 && StagePhaseProgress==0)
				{
					SetCommonData("PracticeStartBurstCounter",0);
					SetCommonData("PracticeStartMagicCounter",0);
					SetCommonData("PracticeStartBurstRank",0);
					SetCommonData("PracticeStartRushGauge",0);
				}
				else
				{
				SetCommonData("PracticeStartBurstCounter",PracticeStartBurstCounter);
				SetCommonData("PracticeStartMagicCounter",PracticeStartMagicCounter);
				SetCommonData("PracticeStartBurstRank",PracticeStartBurstRank);
				SetCommonData("PracticeStartRushGauge",PracticeStartRushGauge);
				}
			}
			else
			{
				SetCommonData("PracticeStartBurstCounter",0);
				SetCommonData("PracticeStartMagicCounter",0);
				SetCommonData("PracticeStartBurstRank",0);
				SetCommonData("PracticeStartRushGauge",0);
			}
//SetCommonData("DemoPlay",true);
			SaveCommonDataInReplayFile;
			SetCommonDataEx(NsScore,"SelectedDifficult","None");
			SetCommonDataEx(NsScore,"StagePractice","None");
			SetCommonDataEx(NsScore,"StageProgress","None");
			SetCommonDataEx(NsScore,"StagePhaseProgress",0);
		}

		else
		{
			SelectedDifficult=GetCommonDataDefault("SelectedDifficult","None");
			StagePractice=GetCommonDataDefault("StagePractice","None");
			StageProgress=GetCommonDataDefault("StageProgress",1);
			StagePhaseProgress=GetCommonDataDefault("StagePhaseProgress",0);

			AutoBombMode=GetCommonDataDefault("AutoBombMode",0);
			InitialLife=GetCommonDataDefault("InitialLife",0);
			InitialBomb=GetCommonDataDefault("InitialBomb",0);

			SetCommonData(NsIsReplayJudgment,false);
		}
	}
	ForbidShot(false);
	SetCommonData("TitleMenu",false);


	ForbidBomb(false);

	SetCommonData("LightMode",LightMode);

	if(LightMode==1)
	{
		LightMode_HiscoreDraw=1;
		LightMode_PlayerIntervalEffect=1;
		LightMode_ShotEffect=1;
		LightMode_BombEffect=1;
		LightMode_PlayerBlur=1;
		LightMode_BossBlur=1;
		LightMode_ElementalBlur=1;
		LightMode_SpecialEffect=1;
		LightMode_BreakEffect=1;
	}

	SetCommonData("LightMode_PlayerIntervalEffect",LightMode_PlayerIntervalEffect);
	SetCommonData("LightMode_BombEffect",LightMode_BombEffect);
	SetCommonData("LightMode_ShotEffect",LightMode_ShotEffect);
	SetCommonData("LightMode_PlayerBlur",LightMode_PlayerBlur);
	SetCommonData("LightMode_BossBlur",LightMode_BossBlur);
	SetCommonData("LightMode_ElementalBlur",LightMode_ElementalBlur);
	SetCommonData("LightMode_SpecialEffect",LightMode_SpecialEffect);
	SetCommonData("LightMode_BreakEffect",LightMode_BreakEffect);

	SetCommonData("MSDSetting",true);

}

task StageRestart
{
let RestartCount=0;
let TempStageProgress=StageProgress;
let TempStagePhaseProgress=StagePhaseProgress;
loop
{
	if(GetKeyState(VK_SKIP)==KEY_HOLD)
	{
		RestartCount+=1;
	}
	else
	{
		RestartCount=0;
	}
	if(RestartCount>=60)
	{
		StageStartWhite;
		CreateEnemyFromFile(csd~"SystemEnemy/Invincibility.txt",GetClipMaxX+16,GetCenterY-128,2,90,1);
		wait(58);
		SetCommonDataEx(NsScore,"SelectedDifficult",SelectedDifficult);
		SetCommonDataEx(NsScore,"StagePractice",StagePractice);
		SetCommonDataEx(NsScore,"StageProgress",TempStageProgress);
		SetCommonDataEx(NsScore,"StagePhaseProgress",TempStagePhaseProgress);
		wait(2);
		Retry;
	}
yield;
}
}

task ExtendSystem//エクステンドの設定
{
	while(ScoreNumber2<10000 || MSDClear){yield;}
	if(StageProgress==1)
	{
		AchievementNotice(56);
	}
	if(GetPlayerLife==1 && GetPlayerBomb==0)
	{
		AchievementNotice(81);
	}
	Ah_DoubleExtendCheck;
	ExtendNum+=1;
	ExtendPlayer(1);
	PlaySE("se\se1UP.wav");
	while(ScoreNumber2<40000 || MSDClear){yield;}
	if(GetPlayerLife==1 && GetPlayerBomb==0)
	{
		AchievementNotice(81);
	}
	Ah_DoubleExtendCheck;
	ExtendNum+=1;
	ExtendPlayer(1);
	PlaySE("se\se1UP.wav");
	while(ScoreNumber2<90000 || MSDClear){yield;}
	if(GetPlayerLife==1 && GetPlayerBomb==0)
	{
		AchievementNotice(81);
	}
	Ah_DoubleExtendCheck;
	ExtendNum+=1;
	ExtendPlayer(1);
	PlaySE("se\se1UP.wav");
	while(ScoreNumber2<160000 || MSDClear){yield;}
	if(GetPlayerLife==1 && GetPlayerBomb==0)
	{
		AchievementNotice(81);
	}
	Ah_DoubleExtendCheck;
	ExtendNum+=1;
	ExtendPlayer(1);
	PlaySE("se\se1UP.wav");
	while(ScoreNumber2<250000 || MSDClear){yield;}
	if(GetPlayerLife==1 && GetPlayerBomb==0)
	{
		AchievementNotice(81);
	}
	Ah_DoubleExtendCheck;
	ExtendNum+=1;
	ExtendPlayer(1);
	PlaySE("se\se1UP.wav");
}

task LifeExtendEffectSystem
{
	LifeExtendEffect;
}

task LifeExtendEffect
{
	let obj = Obj_Create(OBJ_EFFECT);
	ObjEffect_SetTexture(obj,imgLight);
	ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
	ObjEffect_SetRenderState(obj, ADD);
	ObjEffect_CreateVertex(obj, 4);

	ObjEffect_SetVertexXY(obj, 0, -32, -32);
	ObjEffect_SetVertexXY(obj, 1,32, -32);
	ObjEffect_SetVertexXY(obj, 2, 32, 32);
	ObjEffect_SetVertexXY(obj, 3, -32, 32);
		
	ObjEffect_SetVertexUV(obj, 0,  0,  0);
	ObjEffect_SetVertexUV(obj, 1,  64, 0);
	ObjEffect_SetVertexUV(obj, 2, 64, 64);
	ObjEffect_SetVertexUV(obj, 3, 0,  64);

	let Alpha=255;
	let R=255;let G=50;let B=50;
	ascent(let i in 0..4)
	{
		ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
	}

	let x=GetClipMaxX+96+8+(GetPlayerLife-1)*16;
	Obj_SetPosition(obj,x,165);

	ObjEffect_SetLayer(obj,8);

	let Zangle=rand(0,360);
	ObjEffect_SetAngle(obj,0,0,Zangle);

	let Scale=0.0;

	OnLifeExtend=true;
	loop(30)
	{
		ObjEffect_SetScale(obj, Scale, Scale);
		ObjEffect_SetAngle(obj,0,0,Zangle);
		Zangle+=6;
		Scale+=0.5/30;
		yield;
	}
	OnLifeExtend=false;
	loop(30)
	{
		ObjEffect_SetScale(obj, Scale, Scale);
		ObjEffect_SetAngle(obj,0,0,Zangle);
		ascent(let i in 0..4)
		{
			ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
		}
		Zangle+=6;
		Scale+=0.5/30;
		Alpha-=255/30;
		yield;
	}
	Obj_Delete(obj);
}

task TimeBonus
{
let x=GetCenterX;
let y=GetCenterY-64;
loop
{
	if(GetCommonDataDefault("TimeBonus",0)>0)
	{
		let BossRate=GetCommonDataDefault("BossRate",0)/10000;
		let Rate=GetCommonDataDefault("TimeBonus",0);
		let MagicCounter=GetCommonDataDefault("SECTIONMAGICFRAGMENT",0);
		if(GetCommonDataDefault("MSDPlayer",false)==true && GetCommonDataDefault("SELECTEDDIFFICULT","None")!="Arrange")
		{
			BossDefeatAddScore(BossRate*Rate*MagicCounter);
		}
		else if(GetCommonDataDefault("MSDPlayer",false)==false && GetCommonDataDefault("SELECTEDDIFFICULT","None")!="Arrange")
		{
			BossRate/=100;
			BossDefeatAddScore(BossRate*Rate*MSDSectionScoreItemCount);
		}
		else if(GetCommonDataDefault("SELECTEDDIFFICULT","None")=="Arrange")
		{
			BossDefeatAddScore(BossRate*Rate*StageMultiply);
		}
//////////////////////////////////////////////////////
TimeBonusDisplay(x,y-40,255,255,255,255);

		ascent(let i in 0..15)
		{
	//	TimeBonusDisplay(x,y-40,255*i/30,255,255,255);
		BossRateNumDisplay(x-40,y,BossRate*10000,255*i/15,255,255,255,2-i/15,1);
		TimeBonusNumDisplay(x+60,y,Rate*100000,255*i/15,255,255,255,2-i/15,1);
		KakeruDisplay(x-20,y,255*i/15,255,255,255,2-i/15,1);
		PercentDisplay(x+80,y,255*i/15,255,255,255,2-i/15,1);
		y-=0.2;
		yield;
		}
		loop(90)
		{
	//	TimeBonusDisplay(x,y-40,255,255,255,255);
		BossRateNumDisplay(x-40,y,BossRate*10000,255,255,255,255,1,1);
		TimeBonusNumDisplay(x+60,y,Rate*100000,255,255,255,255,1,1);
		KakeruDisplay(x-20,y,255,255,255,255,1,1);
		PercentDisplay(x+80,y,255,255,255,255,1,1);
		y-=0.2;
		yield;

		}	
		descent(let i in 0..15)
		{
	//	TimeBonusDisplay(x,y-40,255*i/30,255,255,255);
		BossRateNumDisplay(x-40,y,BossRate*10000,255*i/15,255,255,255,2-i/15,i/15);
		TimeBonusNumDisplay(x+60,y,Rate*100000,255*i/15,255,255,255,2-i/15,i/15);
		KakeruDisplay(x-20,y,255*i/15,255,255,255,2-i/15,i/15);
		PercentDisplay(x+80,y,255*i/15,255,255,255,2-i/15,i/15);
		y-=0.2;
		yield;
		}
///////////////////////////////////////////////////////////////////
	SetCommonData("TimeBonus",0);
	x=GetCenterX;
	y=GetCenterY-64;
	}
yield;
}
	task BossDefeatAddScore(Score)
	{
		let ScorePlus=0;
		let Score2Plus=0;
		if(Score>=10000)
		{
			Score2Plus=trunc(Score/10000)
		}
		ScorePlus=Score%10000;
		loop(100)
		{
			AddScore(ScorePlus*100*FragmentMultiply);
			ScoreNumber2+=Score2Plus*FragmentMultiply;
			yield;
		}
	}
}

task TimeBonusDisplay(x,y,Alpha,R,G,B)//Apocalypseを表示
{
		let Alpha=0;
		let scx=2.0;
		let scy=1.0;
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgStatusLetter);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -101, -10);
		ObjEffect_SetVertexXY(obj, 1,101,  -10);
		ObjEffect_SetVertexXY(obj, 2,101, 10);
		ObjEffect_SetVertexXY(obj, 3,  -101,  10);
		
		ObjEffect_SetVertexUV(obj, 0,  1,  58);
		ObjEffect_SetVertexUV(obj, 1,  203, 58);
		ObjEffect_SetVertexUV(obj, 2, 203, 78);
		ObjEffect_SetVertexUV(obj, 3, 1, 78);

		ascent(i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
		}

		ObjEffect_SetLayer(obj,7);
		Obj_SetPosition(obj,x,y+5);

		ObjEffect_SetScale(obj, scx,scy);

		loop(15)
		{
		Obj_SetPosition(obj,x,y+5);
		ObjEffect_SetScale(obj, scx,scy);
		ascent(i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
		}
		y-=0.2;
		Alpha+=255/15;
		scx-=1/15;
		yield;
		}
		loop(90)
		{
		Obj_SetPosition(obj,x,y+5);
		ObjEffect_SetScale(obj, scx,scy);
		y-=0.2;
		yield;
		}
		loop(15)
		{
		Obj_SetPosition(obj,x,y+5);
		ObjEffect_SetScale(obj, scx,scy);
		ascent(i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
		}
		y-=0.2;
		Alpha-=255/15;
		scx+=1/15;
		scy-=1/15;
		yield;
		}
		Obj_Delete(obj);
}


task BalanceCheckMain
{
loop
{
	if(GetKeyState(VK_USER)==KEY_PUSH)
	{
		BalanceCheck;
	}
	yield;
}

task BalanceCheck
{
	let CheckFlag=true;
	let EraseShot=0;

	wait(180);
	CheckShot;
	wait(600);
	CheckFlag=false;

task CheckShot
{
	let obj = Obj_Create(OBJ_SHOT);
	Obj_SetPosition(obj, GetPlayerX, GetPlayerY);
	//Obj_SetSpeed(obj, speed);
	//Obj_SetAngle(obj, angle);
	ObjShot_SetGraphic(obj, 9);
	//ObjShot_SetDelay(obj, delay);
	//ObjShot_SetBombResist(obj,true);

	//Obj_SetAutoDelete(obj,false);
	Obj_SetCollisionToPlayer(obj,false);
	Obj_SetAlpha(obj,0);
	ObjShot_ToItem(obj,false);
	while(!Obj_BeDeleted(obj))
	{
	Obj_SetPosition(obj, GetPlayerX, GetPlayerY);
		yield;
	}
	EraseShot+=1;
	if(EraseShot>=120)
	{
		SetCommonData("BalanceBreak",true);
	}

	if(CheckFlag==true && !OnBomb && GetTimeOfPlayerInvincibility==0)
	{
		CheckShot;
	}
}

}

}

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

task CheckExtendItem
{
let ItemCheck=0;//共通データの配列の長さをチェックする変数
let XY=[];//共通データの書き換えにワンクッション置くための変数
//let ItemPerFrame=60;//１フレームあたりの最大アイテム生成数（処理落ち対策）
loop
{
	ItemCheck=length(GetCommonDataDefault("ExtendItem",[]));//毎フレーム共通データの長さチェック
	if(ItemCheck>0)
	{//配列に中身がある（アイテム発生フラグ立っている）場合の処理
		loop
		{
			XY=GetCommonDataDefault("ExtendItem",[]);//共通データ内容を変数に渡す

			CreateExtendItem(XY[0],XY[1],XY[2]);//アイテム生成。順番にX座標、Y座標、アイテムの種類
	
			loop(3)
			{
				XY=erase(XY, 0);
			}//生成したのでその要素を配列から削除
			if(length(XY)==0)
			{//削除後の配列が空になった場合
				SetCommonData("ExtendItem",[]);//共通データを空にして
				break;//アイテム生成ループ脱出
		
			}
			else
			{
				SetCommonData("ExtendItem",XY);
			}//配列が空でない場合共通データに変更後の配列を渡す
		}
	}
yield;
}
}

task CreateExtendItem(x,y,type)
{
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgItem);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		//ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		Obj_SetPosition(obj,x,y);

		if(type==1)
		{
			ObjEffect_SetVertexXY(obj, 0, -8, -8);
			ObjEffect_SetVertexXY(obj, 1, 8,  -8);
			ObjEffect_SetVertexXY(obj, 2, 8, 8);
			ObjEffect_SetVertexXY(obj, 3,  -8,  8);
		
			ObjEffect_SetVertexUV(obj, 0,  0,  0);
			ObjEffect_SetVertexUV(obj, 1,  16, 0);
			ObjEffect_SetVertexUV(obj, 2, 16,  16);
			ObjEffect_SetVertexUV(obj, 3, 0, 16);
		}
		if(type==2)
		{
			ObjEffect_SetVertexXY(obj, 0, -8, -8);
			ObjEffect_SetVertexXY(obj, 1, 8,  -8);
			ObjEffect_SetVertexXY(obj, 2, 8, 8);
			ObjEffect_SetVertexXY(obj, 3,  -8,  8);
		
			ObjEffect_SetVertexUV(obj, 0,  16,  0);
			ObjEffect_SetVertexUV(obj, 1,  32, 0);
			ObjEffect_SetVertexUV(obj, 2, 32,  16);
			ObjEffect_SetVertexUV(obj, 3, 16, 16);
		}

		let dx=0;
		let dy=0;
		let dya=-2;
		let angle=0;
		let speed=-2;
		let count=0;
		while(!Obj_BeDeleted(obj))
		{
			let sangle=90;
			Obj_SetPosition(obj,Obj_GetX(obj)+speed*cos(sangle),Obj_GetY(obj)+speed*sin(sangle));
			ObjEffect_SetAngle(obj, 0,0,angle);
			if(count<60)
			{
				speed+=4/120;
			}
			if(count<60)
			{
				angle+=30;
			}
			if(count>=60){break;}
			dy=dy+dya;
			count++;
			ExtendItemEffect(Obj_GetX(obj),Obj_GetY(obj),angle,type);
			yield;
		}
		while(!Obj_BeDeleted(obj))
		{
			speed+=0.2;	
			let sangle=atan2(GetPlayerY-Obj_GetY(obj),GetPlayerX-Obj_GetX(obj));
			Obj_SetAngle(obj,0);
			Obj_SetPosition(obj,Obj_GetX(obj)+speed*cos(sangle),Obj_GetY(obj)+speed*sin(sangle));
			if(((Obj_GetX(obj)-GetPlayerX)^2+(Obj_GetY(obj)-GetPlayerY)^2)^0.5<10)
			{
				if(GetPlayerLife==1 && GetPlayerBomb==0)
				{
					AchievementNotice(81);
				}
				if(type==1)
				{
					ExtendNum+=1;
					ExtendPlayer(1);
					PlaySE("se\se1UP.wav");
					AchievementNotice(55);
				}
				if(type==2)
				{
					Ah_DoubleExtendCheck;
					AddBomb(1);
					PlaySE("se\se1UP.wav");
					AchievementNotice(57);
				}
				Obj_Delete(obj);
			}
			ExtendItemEffect(Obj_GetX(obj),Obj_GetY(obj),angle,type);
			yield;
		}

	task ExtendItemEffect(x,y,angle,type)
	{
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgItem);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		Obj_SetPosition(obj,x,y);

		if(type==1)
		{
			ObjEffect_SetVertexXY(obj, 0, -8, -8);
			ObjEffect_SetVertexXY(obj, 1, 8,  -8);
			ObjEffect_SetVertexXY(obj, 2, 8, 8);
			ObjEffect_SetVertexXY(obj, 3,  -8,  8);
		
			ObjEffect_SetVertexUV(obj, 0,  0,  0);
			ObjEffect_SetVertexUV(obj, 1,  16, 0);
			ObjEffect_SetVertexUV(obj, 2, 16,  16);
			ObjEffect_SetVertexUV(obj, 3, 0, 16);
		}
		if(type==2)
		{
			ObjEffect_SetVertexXY(obj, 0, -8, -8);
			ObjEffect_SetVertexXY(obj, 1, 8,  -8);
			ObjEffect_SetVertexXY(obj, 2, 8, 8);
			ObjEffect_SetVertexXY(obj, 3,  -8,  8);
		
			ObjEffect_SetVertexUV(obj, 0,  16,  0);
			ObjEffect_SetVertexUV(obj, 1,  32, 0);
			ObjEffect_SetVertexUV(obj, 2, 32,  16);
			ObjEffect_SetVertexUV(obj, 3, 16, 16);
		}
		let scale=1.0;
		let alpha=100;
		ObjEffect_SetLayer(obj,2);
		Obj_SetAlpha(obj,alpha);
		ObjEffect_SetScale(obj,scale,scale);
		ObjEffect_SetAngle(obj, 0,0,angle);
		loop(5)
		{
			Obj_SetAlpha(obj,alpha);
			ObjEffect_SetScale(obj,scale,scale);
			alpha-=20;
			scale+=0.02;
			yield;
		}
		Obj_Delete(obj);
	}

}

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

task SpellDrawTask
{
wait(5);
if(!IsReplay){return;}
let SpellCheck=0;
let SpellNum=[];
loop
{
	SpellCheck=length(GetCommonDataDefault("SpellDraw",[]));
	if(SpellCheck>0)
	{
		loop
		{
			SpellNum=GetCommonDataDefault("SpellDraw",[]);
	
			SpellDisplay(SpellNum[0],SpellNum[1]);

			loop(2)
			{
				SpellNum=erase(SpellNum, 0);
			}
			if(length(SpellNum)==0)
			{
				SetCommonData("SpellDraw",[]);
				break;
			}
			else
			{
				SetCommonData("SpellDraw",SpellNum);
			}
		}
	}
yield;
}
}

task CheckBMEBN
{
let ItemCheck=0;
let XY=[];
loop
{
	ItemCheck=length(GetCommonDataDefault("BurstModeErazeBulletNum",[]));
	if(ItemCheck>0)
	{
		loop
		{
			XY=GetCommonDataDefault("BurstModeErazeBulletNum",[]);

			BurstModeErazeBulletNum+=XY[0];
	
			loop(1)
			{
				XY=erase(XY, 0);
			}
			if(length(XY)==0)
			{
				SetCommonData("BurstModeErazeBulletNum",[]);
				break;
			}
			else
			{
				SetCommonData("BurstModeErazeBulletNum",XY);
			}
		}
	}
yield;
}
}
/*
task INEffect
{
yield;
if(LightMode_PlayerIntervalEffect==1){return;}
loop
{
if(GetTimeOfPlayerInvincibility!=0)
{
	StarLaser;
	while(GetTimeOfPlayerInvincibility!=0){yield;}
}
yield;
}
}

task StarLaser
{
	let R=100;

	let Rmax=100;
	let anglePlus=0;
	let ExpandTime=60;
	let Count=0;
	while(GetTimeOfPlayerInvincibility>0)
	{
		if(Count==0)
		{
		DeltaStarLaserEffect(R,anglePlus);
		DeltaStarLaserEffect(R,-anglePlus);
		}
		if(GetTimeOfPlayerInvincibility>ExpandTime && R<Rmax)
		{
			R+=Rmax/ExpandTime;
		}
		if(GetTimeOfPlayerInvincibility<=ExpandTime)
		{
			R-=Rmax/ExpandTime;
		}
		if(OnPlayerMissed){Count=1;}
		else if(Count>0){Count-=1;}
		anglePlus+=2;
		yield;
	}
}

task DeltaStarLaserEffect(R,angle)
{
		let Scale=1.5*R/100;
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgIneDeltaLine);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -55, -66);
		ObjEffect_SetVertexXY(obj, 1,55,  -66);
		ObjEffect_SetVertexXY(obj, 2,55, 33);
		ObjEffect_SetVertexXY(obj, 3,  -55,  33);
		
		ObjEffect_SetVertexUV(obj, 0,  8,  13);
		ObjEffect_SetVertexUV(obj, 1,  118, 13);
		ObjEffect_SetVertexUV(obj, 2, 118, 111);
		ObjEffect_SetVertexUV(obj, 3, 8, 111);

		let Alpha=200;
		if(OnPlayerMissed){Alpha=0;}

		let R=255;let G=255;let B=255;

		alternative(GetPlayerInfo(PLAYER_SPEED_HIGH))
		case(4){R=100;G=100;B=255;}
		case(4/2){R=100;G=100;B=255;}
		case(5/2){R=255;G=100;B=100;}
		case(5){R=255;G=100;B=100;}
		case(5.5){R=255;G=100;B=255;}
		case(5.5/5){R=255;G=100;B=255;}
		case(4.5){R=50;G=205;B=50;}
		case(4.5/2){R=50;G=205;B=50;}

		Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
		Obj_SetAngle(obj,angle);
		ObjEffect_SetAngle(obj,0,0,angle);
		ObjEffect_SetScale(obj,Scale,Scale);

		loop(15)
		{
		ascent(i in 0..4)
		{
			ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
		}
		Alpha-=200/15;
		if(OnPlayerMissed){Alpha=0;}
		yield;
		}
		Obj_Delete(obj);
}
*/
/////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////ステータス表示部//////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
task DifficultDisplay//難易度を表示
{
	alternative(SelectedDifficult)
	case("Moderate")
	{
		ascent(let i in 0..60)
		{
		StatusModerateDisplay(530,20,255*i/60,255,255,255);
		yield;
		}
		loop{
		StatusModerateDisplayLong(530,20,255,255,255,255);
		wait(600);
		}
	}
	case("Extream")
	{
		ascent(let i in 0..60)
		{
		StatusExtreamDisplay(530,20,255*i/60,255,255,255);
		yield;
		}
		loop{
		StatusExtreamDisplayLong(530,20,255,255,255,255);
		wait(600);
		}
	}
	case("Apocalypse")
	{
		ascent(let i in 0..60)
		{
		StatusApocalypseDisplay(530,20,255*i/60,255,255,255);
		yield;
		}
		loop{
		StatusApocalypseDisplayLong(530,20,255,255,255,255);
		wait(600);
		}
	}
	case("Arrange")
	{
		ascent(let i in 0..60)
		{
		StatusArrangeDisplay(530,20,255*i/60,255,255,255);
		yield;
		}
		loop{
		StatusArrangeDisplay(530,20,255,255,255,255);
		yield;
		}
	}
}

task StatusDisplay//Hiscoreから霊点までの文字を表示
{
	let life;
	let bomb;
	let DrawY=60;
	yield;
	loop
	{
		life=GetPlayerLife-1;
		if(life>8)
		{
			life=8;
		}
		bomb=GetPlayerBomb;
		if(bomb>8)
		{
			bomb=8;
		}
		if(OnLifeExtend){life-=1;}
		if(GetCommonDataDefault("OnBombExtend",false)){bomb-=1;}
		if(LightMode_HiscoreDraw==-1)
		{	
			if(StagePractice)
			{
			DrawY=60;
			StatusHighScoreDisplay(530,DrawY,255,255,255,255);
			StatusScoreDisplay(530,DrawY+50,255,255,255,255);
			StatusPlayerDisplay(470-8,DrawY+100,255,255,255,255);
			StatusBombDisplay(470-8,DrawY+130,255,255,255,255);
			}
			else
			{
			DrawY=100;
			StatusHighScoreDisplay(530,DrawY-40,255,255,255,255);
			StatusScoreDisplay(530,DrawY+30,255,255,255,255);
			StatusPlayerDisplay(470-8,DrawY+100,255,255,255,255);
			StatusBombDisplay(470-8,DrawY+130,255,255,255,255);
			}
		}
		else if(LightMode_HiscoreDraw==0)
		{	
			DrawY=60;
			StatusHighScoreDisplay(530,DrawY,255,255,255,255);
			StatusScoreDisplay(530,DrawY+50,255,255,255,255);
			StatusPlayerDisplay(470-8,DrawY+100,255,255,255,255);
			StatusBombDisplay(470-8,DrawY+130,255,255,255,255);
		}
		else if(LightMode_HiscoreDraw==1)
		{	
			DrawY=10;
			StatusScoreDisplay(530,DrawY+50,255,255,255,255);
			StatusPlayerDisplay(470-8,DrawY+100,255,255,255,255);
			StatusBombDisplay(470-8,DrawY+130,255,255,255,255);
		}

	//	if(life>0)
	//	{
			DisPlayPlayerStar(life,105+DrawY);
	//	}
	//	if(bomb>0)
	//	{
			DisPlayBombStar(bomb,135+DrawY);
	//	}
		wait(600);
	}
}

task DisPlayPlayerStar(i,y)//残機を表示
{
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgStatusStar);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
	//	ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -0, -8);
		ObjEffect_SetVertexXY(obj, 1,16*i,  -8);
		ObjEffect_SetVertexXY(obj, 2,16*i, 8);
		ObjEffect_SetVertexXY(obj, 3,  -0,  8);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  16*i, 0);
		ObjEffect_SetVertexUV(obj, 2, 16*i, 16);
		ObjEffect_SetVertexUV(obj, 3, 0, 16);

		ObjEffect_SetVertexColor(obj,0,255,255,200,200);
		ObjEffect_SetVertexColor(obj,1,255,255,200,200);
		ObjEffect_SetVertexColor(obj,2,255,255,200,200);
		ObjEffect_SetVertexColor(obj,3,255,255,200,200);

		ObjEffect_SetLayer(obj,8);
		Obj_SetPosition(obj,GetClipMaxX+96-8,y);

		loop(600)
		{
		ObjEffect_SetVertexXY(obj, 0, -0, -8);
		ObjEffect_SetVertexXY(obj, 1,16*(GetPlayerLife-1),  -8);
		ObjEffect_SetVertexXY(obj, 2,16*(GetPlayerLife-1), 8);
		ObjEffect_SetVertexXY(obj, 3,  -0,  8);
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  16*(GetPlayerLife-1), 0);
		ObjEffect_SetVertexUV(obj, 2, 16*(GetPlayerLife-1), 16);
		ObjEffect_SetVertexUV(obj, 3, 0, 16);
		if(GetPlayerLife==0)
		{
		ObjEffect_SetVertexColor(obj,0,0,255,200,200);
		ObjEffect_SetVertexColor(obj,1,0,255,200,200);
		ObjEffect_SetVertexColor(obj,2,0,255,200,200);
		ObjEffect_SetVertexColor(obj,3,0,255,200,200);
		}
		else
		{
		ObjEffect_SetVertexColor(obj,0,255,255,200,200);
		ObjEffect_SetVertexColor(obj,1,255,255,200,200);
		ObjEffect_SetVertexColor(obj,2,255,255,200,200);
		ObjEffect_SetVertexColor(obj,3,255,255,200,200);
		}
		yield;
		}
		Obj_Delete(obj);
}

task DisPlayBombStar(i,y)//残ボムを表示
{
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgStatusStar);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
	//	ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -0, -8);
		ObjEffect_SetVertexXY(obj, 1,16*i,  -8);
		ObjEffect_SetVertexXY(obj, 2,16*i, 8);
		ObjEffect_SetVertexXY(obj, 3,  -0,  8);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  16*i, 0);
		ObjEffect_SetVertexUV(obj, 2, 16*i, 16);
		ObjEffect_SetVertexUV(obj, 3, 0, 16);

		ObjEffect_SetVertexColor(obj,0,255,200,255,200);
		ObjEffect_SetVertexColor(obj,1,255,200,255,200);
		ObjEffect_SetVertexColor(obj,2,255,200,255,200);
		ObjEffect_SetVertexColor(obj,3,255,200,255,200);

		ObjEffect_SetLayer(obj,8);
		Obj_SetPosition(obj,GetClipMaxX+96-8,y);

		loop(600)
		{
		ObjEffect_SetVertexXY(obj, 0, -0, -8);
		ObjEffect_SetVertexXY(obj, 1,16*(GetPlayerBomb),  -8);
		ObjEffect_SetVertexXY(obj, 2,16*(GetPlayerBomb), 8);
		ObjEffect_SetVertexXY(obj, 3,  -0,  8);
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  16*(GetPlayerBomb), 0);
		ObjEffect_SetVertexUV(obj, 2, 16*(GetPlayerBomb), 16);
		ObjEffect_SetVertexUV(obj, 3, 0, 16);
		yield;
		}
		Obj_Delete(obj);
}

task DisPlayScore//ハイスコアを呼び出し、ハイスコアと現スコアを表示
{
let EachHiScore=0;
let EachHiScore2=0;
let EachHiScore3=0;
let EachHiScore4=0;
let EachHiScore5=0;
let StageHiscore=[0,0,0,0,0];
let StageHiscore2=[0,0,0,0,0];
let StageHiscore3=[0,0,0,0,0];
let StageHiscore4=[0,0,0,0,0];
let StageHiscore5=[0,0,0,0,0];
	alternative(SelectedDifficult)
	case("Moderate")
	{
		alternative(SelectedCharacter)
		case(DefinedPlayer1)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuAEasy[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuAEasy2[0],0);
		}
		case(DefinedPlayer2)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuBEasy[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuBEasy2[0],0);
		}
		case(DefinedPlayer3)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuCEasy[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuCEasy2[0],0);
		}
		case(DefinedPlayer4)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuDEasy[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuDEasy2[0],0);
		}
		case(DefinedPlayer5)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuEEasy[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuEEasy2[0],0);
		}
	}
	case("Extream")
	{
		alternative(SelectedCharacter)
		case(DefinedPlayer1)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuANormal[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuANormal2[0],0);
		}
		case(DefinedPlayer2)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuBNormal[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuBNormal2[0],0);
		}
		case(DefinedPlayer3)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuCNormal[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuCNormal2[0],0);
		}
		case(DefinedPlayer4)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuDNormal[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuDNormal2[0],0);
		}
		case(DefinedPlayer5)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuENormal[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuENormal2[0],0);
		}
	}
	case("Apocalypse")
	{
		alternative(SelectedCharacter)
		case(DefinedPlayer1)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuAHard[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuAHard2[0],0);
		}
		case(DefinedPlayer2)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuBHard[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuBHard2[0],0);
		}
		case(DefinedPlayer3)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuCHard[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuCHard2[0],0);
		}
		case(DefinedPlayer4)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuDHard[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuDHard2[0],0);
		}
		case(DefinedPlayer5)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuEHard[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuEHard2[0],0);
		}
	}
	case("Arrange")
	{
		alternative(SelectedCharacter)
		case(DefinedPlayer1)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuALuna[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuALuna2[0],0);
			EachHiScore3=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuALuna3[0],0);
		}
		case(DefinedPlayer2)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuBLuna[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuBLuna2[0],0);
		}
		case(DefinedPlayer3)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuCLuna[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuCLuna2[0],0);
		}
		case(DefinedPlayer4)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuDLuna[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuDLuna2[0],0);
		}
		case(DefinedPlayer5)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuELuna[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuELuna2[0],0);
		}
	}
//----------------------------------------------------------------------------------------------------------
	if(SelectedDifficult=="Moderate")
	{
		if(SelectedCharacter==DefinedPlayer1)
		{
			ascent(let i in 0..5)
			{
				StageHiscore[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuAEasy[i],0)+0;
				StageHiscore2[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuAEasy2[i],0)+0;
			}
		}
		if(SelectedCharacter==DefinedPlayer2)
		{
			ascent(let i in 0..5)
			{
				StageHiscore[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuBEasy[i],0)+0;
				StageHiscore2[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuBEasy2[i],0)+0;
			}
		}
		if(SelectedCharacter==DefinedPlayer3)
		{
			ascent(let i in 0..5)
			{
				StageHiscore[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuCEasy[i],0)+0;
				StageHiscore2[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuCEasy2[i],0)+0;
			}
		}
		if(SelectedCharacter==DefinedPlayer4)
		{
			ascent(let i in 0..5)
			{
				StageHiscore[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuDEasy[i],0)+0;
				StageHiscore2[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuDEasy2[i],0)+0;
			}
		}
		if(SelectedCharacter==DefinedPlayer5)
		{
			ascent(let i in 0..5)
			{
				StageHiscore[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuEEasy[i],0)+0;
				StageHiscore2[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuEEasy2[i],0)+0;
			}
		}
	}

	if(SelectedDifficult=="Extream")
	{
		if(SelectedCharacter==DefinedPlayer1)
		{
			ascent(let i in 0..5)
			{
				StageHiscore[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuANormal[i],0)+0;
				StageHiscore2[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuANormal2[i],0)+0;
			}
		}
		if(SelectedCharacter==DefinedPlayer2)
		{
			ascent(let i in 0..5)
			{
				StageHiscore[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuBNormal[i],0)+0;
				StageHiscore2[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuBNormal2[i],0)+0;
			}
		}
		if(SelectedCharacter==DefinedPlayer3)
		{
			ascent(let i in 0..5)
			{
				StageHiscore[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuCNormal[i],0)+0;
				StageHiscore2[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuCNormal2[i],0)+0;
			}
		}
		if(SelectedCharacter==DefinedPlayer4)
		{
			ascent(let i in 0..5)
			{
				StageHiscore[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuDNormal[i],0)+0;
				StageHiscore2[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuDNormal2[i],0)+0;
			}
		}
		if(SelectedCharacter==DefinedPlayer5)
		{
			ascent(let i in 0..5)
			{
				StageHiscore[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuENormal[i],0)+0;
				StageHiscore2[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuENormal2[i],0)+0;
			}
		}
	}


	if(SelectedDifficult=="Apocalypse")
	{
		if(SelectedCharacter==DefinedPlayer1)
		{
			ascent(let i in 0..5)
			{
				StageHiscore[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuAHard[i],0)+0;
				StageHiscore2[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuAHard2[i],0)+0;
			}
		}
		if(SelectedCharacter==DefinedPlayer2)
		{
			ascent(let i in 0..5)
			{
				StageHiscore[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuBHard[i],0)+0;
				StageHiscore2[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuBHard2[i],0)+0;
			}
		}
		if(SelectedCharacter==DefinedPlayer3)
		{
			ascent(let i in 0..5)
			{
				StageHiscore[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuCHard[i],0)+0;
				StageHiscore2[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuCHard2[i],0)+0;
			}
		}
		if(SelectedCharacter==DefinedPlayer4)
		{
			ascent(let i in 0..5)
			{
				StageHiscore[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuDHard[i],0)+0;
				StageHiscore2[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuDHard2[i],0)+0;
			}
		}
		if(SelectedCharacter==DefinedPlayer5)
		{
			ascent(let i in 0..5)
			{
				StageHiscore[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuEHard[i],0)+0;
				StageHiscore2[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuEHard2[i],0)+0;
			}
		}
	}


	if(SelectedDifficult=="Arrange")
	{
		if(SelectedCharacter==DefinedPlayer1)
		{
			ascent(let i in 0..5)
			{
				StageHiscore[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuALuna[i],0)+0;
				StageHiscore2[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuALuna2[i],0)+0;
			}
		}
		if(SelectedCharacter==DefinedPlayer2)
		{
			ascent(let i in 0..5)
			{
				StageHiscore[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuBLuna[i],0)+0;
				StageHiscore2[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuBLuna2[i],0)+0;
			}
		}
		if(SelectedCharacter==DefinedPlayer3)
		{
			ascent(let i in 0..5)
			{
				StageHiscore[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuCLuna[i],0)+0;
				StageHiscore2[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuCLuna2[i],0)+0;
			}
		}
		if(SelectedCharacter==DefinedPlayer4)
		{
			ascent(let i in 0..5)
			{
				StageHiscore[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuDLuna[i],0)+0;
				StageHiscore2[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuDLuna2[i],0)+0;
			}
		}
		if(SelectedCharacter==DefinedPlayer5)
		{
			ascent(let i in 0..5)
			{
				StageHiscore[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuELuna[i],0)+0;
				StageHiscore2[i] = GetCommonDataDefaultEx(NsScore,NsStageHiScoreReimuELuna2[i],0)+0;
			}
		}
	}
//--------------------------------------------------------------------------------------------------------
	yield;
CreateScore(EachHiScore,EachHiScore2,EachHiScore3,EachHiScore4,EachHiScore5,StageHiscore,StageHiscore2,StageHiscore3,StageHiscore4,StageHiscore5);

}

function CreateScore(let EachHiScore,let EachHiScore2,let EachHiScore3,let EachHiScore4,EachHiScore5,StageHiscore,StageHiscore2,StageHiscore3,StageHiscore4,StageHiscore5)//GetScore関数から二つにわけた変数に記録し擬似的に桁を増やしている
{
	continucount;
	let PosX=GetClipMaxX+174;
	let PosX2=GetClipMaxX+174-ScoreNumberXpx*6;
	let PosX3=GetClipMaxX+174-ScoreNumberXpx*12;
	let PosX4=GetClipMaxX+174-ScoreNumberXpx*18;
	let PosX5=GetClipMaxX+174-ScoreNumberXpx*24;
	if(SelectedDifficult=="Arrange")
	{
		ScoreNumberXpx=12;
		PosX=GetClipMaxX+174;
		PosX2=GetClipMaxX+174-ScoreNumberXpx*6;
		PosX3=GetClipMaxX+174-ScoreNumberXpx*12;
		PosX4=GetClipMaxX+174-ScoreNumberXpx*18;
		let PosX5=GetClipMaxX+174-ScoreNumberXpx*24;
	}
	let ScoreNumber3digit=0;
	let ScoreNumber4digit=0;
	let ScoreNumber5digit=0;

	let TempStageScore1=0;
	let TempStageScore2=0;

	let PosY=GetClipMinY+67;
	let PosY2=GetClipMinY+117;

	Scorecalculation;

task Scorecalculation
{
loop
{
	TempStageScore2=ScoreNumber2-SubtotalStagescore2;
	if(ScoreNumber1-SubtotalStagescore<0)
	{
		TempStageScore1=1000000+ScoreNumber1-SubtotalStagescore;
		TempStageScore2-=1;
	}
	else
	{
		TempStageScore1=ScoreNumber1-SubtotalStagescore;
	}
	ScoreNumber1+=GetScore;
	AddScore(-GetScore);

	loop(1000)
	{
		if(ScoreNumber1>=1000000)
		{
			ScoreNumber2+=1;
			ScoreNumber1-=1000000;
		}
		else{break;}
	}
	ScoreNumber1=ScoreNumber1%1000000;
/*
	loop(1000)
	{
		if(ScoreNumber2>=1000000)
		{
			ScoreNumber3+=1;
			ScoreNumber2-=1000000;
		}
		else{break;}
	}
	ScoreNumber2=ScoreNumber2%1000000;
*/
yield;
}
}

loop
{


if(StagePractice==false)
{//通しプレイ
	if(LightMode_HiscoreDraw<=0)
	{
		TempDisPlayHiScoreNumber(PosX,GetClipMinY+67);
		TempDisPlayHiScoreNumber2(PosX2,GetClipMinY+67);

		if(LightMode_HiscoreDraw==0)
		{//On
			TempDisPlayScoreNumber(PosX,GetClipMinY+117);
			TempDisPlayScoreNumber2(PosX2,GetClipMinY+117);

		}
		if(LightMode_HiscoreDraw==-1)
		{//Full
		TempDisPlayScoreNumber(PosX,GetClipMinY+137);
		TempDisPlayScoreNumber2(PosX2,GetClipMinY+137);

		}
	}
	else
	{//Off
		TempDisPlayScoreNumber(PosX,GetClipMinY+67);
		TempDisPlayScoreNumber2(PosX2,GetClipMinY+67);

	}

	if(LightMode_HiscoreDraw==-1)
	{
		TempDisPlaySubStageHiScoreNumber(PosX,GetClipMinY+67+20);
		TempDisPlaySubStageHiScoreNumber2(PosX2+24,GetClipMinY+67+20);

		TempDisPlayStageScoreNumber(PosX,GetClipMinY+117+40);
		TempDisPlayStageScoreNumber2(PosX2+24,GetClipMinY+117+40);

	}


}
else
{
	if(LightMode_HiscoreDraw<=0)
	{
		TempDisPlayStageHiScoreNumber(PosX,GetClipMinY+67);
		TempDisPlayStageHiScoreNumber2(PosX2,GetClipMinY+67);

		TempDisPlayScoreNumber(PosX,GetClipMinY+117);
		TempDisPlayScoreNumber2(PosX2,GetClipMinY+117);

	}
	else
	{

		TempDisPlayScoreNumber(PosX,GetClipMinY+67);
		TempDisPlayScoreNumber2(PosX2,GetClipMinY+67);

	}
	}
wait(600);
//yield;
}

function ObjSetNum(num,x,y,scale,Alpha,R,G,B)
{
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgNumber);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -13, -16);
		ObjEffect_SetVertexXY(obj, 1, 13,  -16);
		ObjEffect_SetVertexXY(obj, 2, 13, 16);
		ObjEffect_SetVertexXY(obj, 3,  -13,  16);
		
		ObjEffect_SetVertexUV(obj, 0,  0+40*num,  6);
		ObjEffect_SetVertexUV(obj, 1,  26+40*num, 6);
		ObjEffect_SetVertexUV(obj, 2, 26+40*num,  38);
		ObjEffect_SetVertexUV(obj, 3, 0+40*num, 38);

		ObjEffect_SetVertexColor(obj,0,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj,1,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj,2,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj,3,Alpha,R,G,B);
		
		ObjEffect_SetScale(obj, scale,scale);
		Obj_SetPosition(obj,x,y+5);
		ObjEffect_SetLayer(obj,8);

		return(obj);
}

function LoopObjSetNum(obj,num,Alpha,R,G,B)
{	
		ObjEffect_SetVertexUV(obj, 0,  0+40*num,  6);
		ObjEffect_SetVertexUV(obj, 1,  26+40*num, 6);
		ObjEffect_SetVertexUV(obj, 2, 26+40*num,  38);
		ObjEffect_SetVertexUV(obj, 3, 0+40*num, 38);

		ObjEffect_SetVertexColor(obj,0,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj,1,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj,2,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj,3,Alpha,R,G,B);
}

task TempDisPlaySubStageHiScoreNumber(let x,let y)
{
	ascent(i in 1..7)
	{
	TempDisplaySubStageHiNumLetter(PosX-(i-1)*8,y,i,255,200,200,255);
	}
}

task TempDisplaySubStageHiNumLetter(let x,let y,let digit,Alpha,R,G,B)
{
		let DrawNumber=0;
		let DrawNumber2=0;
		if(StageHiscore2[StageProgress-1]>TempStageScore2)
		{
			DrawNumber=StageHiscore[StageProgress-1];
			DrawNumber2=StageHiscore2[StageProgress-1];
		}
		else if(StageHiscore2[StageProgress-1]==TempStageScore2)
		{
			if(StageHiscore[StageProgress-1]>TempStageScore1)
			{
				DrawNumber=StageHiscore[StageProgress-1];
				DrawNumber2=StageHiscore2[StageProgress-1];
			}
			else
			{
				DrawNumber=TempStageScore1;
				DrawNumber2=TempStageScore2;
			}
		}
		else
		{
			DrawNumber=TempStageScore1;
			DrawNumber2=TempStageScore2;
		}

		let CheckNum=DrawNumber;
		if(DrawNumber2!=0){CheckNum+=1000000;}
		let num=trunc(DrawNumber%(10^digit)/(10^(digit-1)));
		if(CheckNum<10^(digit-1) && digit!=1){Alpha=0;}

		let scale=0.4;

		let obj0=ObjSetNum(num,x,y,scale,Alpha,R,G,B);

		loop(600)
		{
		if(StageHiscore2[StageProgress-1]>TempStageScore2)
		{
			DrawNumber=StageHiscore[StageProgress-1];
			DrawNumber2=StageHiscore2[StageProgress-1];
		}
		else if(StageHiscore2[StageProgress-1]==TempStageScore2)
		{
			if(StageHiscore[StageProgress-1]>TempStageScore1)
			{
				DrawNumber=StageHiscore[StageProgress-1];
				DrawNumber2=StageHiscore2[StageProgress-1];
			}
			else
			{
				DrawNumber=TempStageScore1;
				DrawNumber2=TempStageScore2;
			}
		}
		else
		{
			DrawNumber=TempStageScore1;
			DrawNumber2=TempStageScore2;
		}
		CheckNum=DrawNumber;
		if(DrawNumber2!=0){CheckNum+=1000000;}
		num=trunc(DrawNumber%(10^digit)/(10^(digit-1)));
		if(CheckNum<10^(digit-1) && digit!=1){Alpha=0;}
		else{Alpha=255;}

		LoopObjSetNum(obj0,num,Alpha,R,G,B);

		yield;
		}
		Obj_Delete(obj0);
}

task TempDisPlaySubStageHiScoreNumber2(let x,let y)
{
	ascent(i in 1..7)
	{
	TempDisplaySubStageHiNum2Letter(x-(i-1)*8,y,i,255,255,200,200);
	}
}

task TempDisplaySubStageHiNum2Letter(let x,let y,let digit,Alpha,R,G,B)
{
		let DrawNumber2=0;
		if(StageHiscore2[StageProgress-1]>TempStageScore2)
		{
			DrawNumber2=StageHiscore2[StageProgress-1];
		}
		else if(StageHiscore2[StageProgress-1]==TempStageScore2)
		{
			if(StageHiscore[StageProgress-1]>TempStageScore1)
			{
				DrawNumber2=StageHiscore2[StageProgress-1];
			}
			else
			{
				DrawNumber2=TempStageScore2;
			}
		}
		else
		{
			DrawNumber2=TempStageScore2;
		}

		let CheckNum=DrawNumber2;
		let num=trunc(DrawNumber2%(10^digit)/(10^(digit-1)));
		if(CheckNum<10^(digit-1) && digit!=1){Alpha=0;}

		let scale=0.4;

		let obj0=ObjSetNum(num,x,y,scale,Alpha,R,G,B);

		loop(600)
		{
		if(StageHiscore2[StageProgress-1]>TempStageScore2)
		{
			DrawNumber2=StageHiscore2[StageProgress-1];
		}
		else if(StageHiscore2[StageProgress-1]==TempStageScore2)
		{
			if(StageHiscore[StageProgress-1]>TempStageScore1)
			{
				DrawNumber2=StageHiscore2[StageProgress-1];
			}
			else
			{
				DrawNumber2=TempStageScore2;
			}
		}
		else
		{
			DrawNumber2=TempStageScore2;
		}
		CheckNum=DrawNumber2;
		num=trunc(DrawNumber2%(10^digit)/(10^(digit-1)));
		if(CheckNum<10^(digit-1) && digit!=1){Alpha=0;}
		else{Alpha=255;}

		LoopObjSetNum(obj0,num,Alpha,R,G,B);

		yield;
		}
		Obj_Delete(obj0);
}
///////////////

////////////////////
task TempDisPlayHiScoreNumber(let x,let y)
{
	ascent(i in 1..7)
	{
	TempDisplayHiNumLetter(x-(i-1)*ScoreNumberXpx,y,i,255,200,200,255);
	}
}

task TempDisplayHiNumLetter(let x,let y,let digit,Alpha,R,G,B)
{
		let DrawNumber=0;
		let DrawNumber2=0;
		if(EachHiScore2>ScoreNumber2)
		{
			DrawNumber=EachHiScore;
			DrawNumber2=EachHiScore2;
		}
		else if(EachHiScore2==ScoreNumber2)
		{
			if(EachHiScore>ScoreNumber1)
			{
				DrawNumber=EachHiScore;
				DrawNumber2=EachHiScore2;
			}
			else
			{
				DrawNumber=ScoreNumber1;
				DrawNumber2=ScoreNumber2;
			}
		}
		else
		{
			DrawNumber=ScoreNumber1;
			DrawNumber2=ScoreNumber2;
		}

		let CheckNum=DrawNumber;
		if(DrawNumber2!=0){CheckNum+=1000000;}
		let num=trunc(DrawNumber%(10^digit)/(10^(digit-1)));
		if(CheckNum<10^(digit-1) && digit!=1){Alpha=0;}

		let scale=0.6;

		let obj0=ObjSetNum(num,x,y,scale,Alpha,R,G,B);

		loop(600)
		{
		if(EachHiScore2>ScoreNumber2)
		{
			DrawNumber=EachHiScore;
			DrawNumber2=EachHiScore2;
		}
		else if(EachHiScore2==ScoreNumber2)
		{
			if(EachHiScore>ScoreNumber1)
			{
				DrawNumber=EachHiScore;
				DrawNumber2=EachHiScore2;
			}
			else
			{
				DrawNumber=ScoreNumber1;
				DrawNumber2=ScoreNumber2;
			}
		}
		else
		{
			DrawNumber=ScoreNumber1;
			DrawNumber2=ScoreNumber2;
		}
		CheckNum=DrawNumber;
		if(DrawNumber2!=0){CheckNum+=1000000;}
		num=trunc(DrawNumber%(10^digit)/(10^(digit-1)));
		if(CheckNum<10^(digit-1) && digit!=1){Alpha=0;}
		else{Alpha=255;}

		LoopObjSetNum(obj0,num,Alpha,R,G,B);

		yield;
		}
		Obj_Delete(obj0);
}

task TempDisPlayHiScoreNumber2(let x,let y)
{
	ascent(i in 1..7)
	{
	TempDisplayHiNum2Letter(x-(i-1)*ScoreNumberXpx,y,i,255,255,200,200);
	}
}

task TempDisplayHiNum2Letter(let x,let y,let digit,Alpha,R,G,B)
{
		let DrawNumber2=0;
		if(EachHiScore2>ScoreNumber2)
		{
			DrawNumber2=EachHiScore2;
		}
		else if(EachHiScore2==ScoreNumber2)
		{
			if(EachHiScore>ScoreNumber1)
			{
				DrawNumber2=EachHiScore2;
			}
			else
			{
				DrawNumber2=ScoreNumber2;
			}
		}
		else
		{
			DrawNumber2=ScoreNumber2;
		}

		let CheckNum=DrawNumber2;
		let num=trunc(DrawNumber2%(10^digit)/(10^(digit-1)));
		if(CheckNum<10^(digit-1) && digit!=1){Alpha=0;}

		let scale=0.6;

		let obj0=ObjSetNum(num,x,y,scale,Alpha,R,G,B);

		loop(600)
		{
		if(EachHiScore2>ScoreNumber2)
		{
			DrawNumber2=EachHiScore2;
		}
		else if(EachHiScore2==ScoreNumber2)
		{
			if(EachHiScore>ScoreNumber1)
			{
				DrawNumber2=EachHiScore2;
			}
			else
			{
				DrawNumber2=ScoreNumber2;
			}
		}
		else
		{
			DrawNumber2=ScoreNumber2;
		}
		CheckNum=DrawNumber2;
		num=trunc(DrawNumber2%(10^digit)/(10^(digit-1)));
		if(CheckNum<10^(digit-1) && digit!=1){Alpha=0;}
		else{Alpha=255;}
		LoopObjSetNum(obj0,num,Alpha,R,G,B);

		yield;
		}
		Obj_Delete(obj0);
}
///////////////

//////////////
task TempDisPlayStageHiScoreNumber(let x,let y)
{
	ascent(i in 1..7)
	{
	TempDisplayStageHiNumLetter(x-(i-1)*ScoreNumberXpx,y,i,255,200,200,255);
	}
}

task TempDisplayStageHiNumLetter(let x,let y,let digit,Alpha,R,G,B)
{
		let DrawNumber=0;
		let DrawNumber2=0;
		if(StageHiscore2[StageProgress-1]>ScoreNumber2)
		{
			DrawNumber=StageHiscore[StageProgress-1];
			DrawNumber2=StageHiscore2[StageProgress-1];
		}
		else if(StageHiscore2[StageProgress-1]==ScoreNumber2)
		{
			if(StageHiscore[StageProgress-1]>ScoreNumber1)
			{
				DrawNumber=StageHiscore[StageProgress-1];
				DrawNumber2=StageHiscore2[StageProgress-1];
			}
			else
			{
				DrawNumber=ScoreNumber1;
				DrawNumber2=ScoreNumber2;
			}
		}
		else
		{
			DrawNumber=ScoreNumber1;
			DrawNumber2=ScoreNumber2;
		}
		let CheckNum=DrawNumber;
		if(DrawNumber2!=0){CheckNum+=1000000;}
		let num=trunc(DrawNumber%(10^digit)/(10^(digit-1)));
		if(CheckNum<10^(digit-1) && digit!=1){Alpha=0;}

		let scale=0.6;

		let obj0=ObjSetNum(num,x,y,scale,Alpha,R,G,B);

		loop(600)
		{
		if(StageHiscore2[StageProgress-1]>ScoreNumber2)
		{
			DrawNumber=StageHiscore[StageProgress-1];
			DrawNumber2=StageHiscore2[StageProgress-1];
		}
		else if(StageHiscore2[StageProgress-1]==ScoreNumber2)
		{
			if(StageHiscore[StageProgress-1]>ScoreNumber1)
			{
				DrawNumber=StageHiscore[StageProgress-1];
				DrawNumber2=StageHiscore2[StageProgress-1];
			}
			else
			{
				DrawNumber=ScoreNumber1;
				DrawNumber2=ScoreNumber2;
			}
		}
		else
		{
			DrawNumber=ScoreNumber1;
			DrawNumber2=ScoreNumber2;
		}
		CheckNum=DrawNumber;
		if(DrawNumber2!=0){CheckNum+=1000000;}
		num=trunc(DrawNumber%(10^digit)/(10^(digit-1)));
		if(CheckNum<10^(digit-1) && digit!=1){Alpha=0;}
		else{Alpha=255;}
		LoopObjSetNum(obj0,num,Alpha,R,G,B);

		yield;
		}
		Obj_Delete(obj0);
}

task TempDisPlayStageHiScoreNumber2(let x,let y)
{
	ascent(i in 1..7)
	{
	TempDisplayStageHiNum2Letter(x-(i-1)*ScoreNumberXpx,y,i,255,255,200,200);
	}
	ascent(i in 7..8)
	{
	TempDisplayStageHiNum2Letter(x-(i-1)*ScoreNumberXpx,y,i,255,255,255,200);
	}
}

task TempDisplayStageHiNum2Letter(let x,let y,let digit,Alpha,R,G,B)
{
		let DrawNumber2=0;
		if(StageHiscore2[StageProgress-1]>ScoreNumber2)
		{
			DrawNumber2=StageHiscore2[StageProgress-1];
		}
		else if(StageHiscore2[StageProgress-1]==ScoreNumber2)
		{
			if(StageHiscore[StageProgress-1]>ScoreNumber1)
			{
				DrawNumber2=StageHiscore2[StageProgress-1];
			}
			else
			{
				DrawNumber2=ScoreNumber2;
			}
		}
		else
		{
			DrawNumber2=ScoreNumber2;
		}
		let CheckNum=DrawNumber2;
		let num=trunc(DrawNumber2%(10^digit)/(10^(digit-1)));
		if(CheckNum<10^(digit-1) && digit!=1){Alpha=0;}

		let scale=0.6;

		let obj0=ObjSetNum(num,x,y,scale,Alpha,R,G,B);

		loop(600)
		{
		if(StageHiscore2[StageProgress-1]>ScoreNumber2)
		{
			DrawNumber2=StageHiscore2[StageProgress-1];
		}
		else if(StageHiscore2[StageProgress-1]==ScoreNumber2)
		{
			if(StageHiscore[StageProgress-1]>ScoreNumber1)
			{
				DrawNumber2=StageHiscore2[StageProgress-1];
			}
			else
			{
				DrawNumber2=ScoreNumber2;
			}
		}
		else
		{
			DrawNumber2=ScoreNumber2;
		}
		CheckNum=DrawNumber2;
		num=trunc(DrawNumber2%(10^digit)/(10^(digit-1)));
		if(CheckNum<10^(digit-1) && digit!=1){Alpha=0;}
		else{Alpha=255;}
		LoopObjSetNum(obj0,num,Alpha,R,G,B);

		yield;
		}
		Obj_Delete(obj0);
}
///////////////

task TempDisPlayStageScoreNumber(let x,let y)
{
	ascent(i in 1..7)
	{
	TempDisplayStageScoreNumLetter(x-(i-1)*8,y,i,255,200,200,255);
	}
}

task TempDisplayStageScoreNumLetter(let x,let y,let digit,Alpha,R,G,B)
{
		let CheckNum=TempStageScore1;
		if(TempStageScore2!=0){CheckNum+=1000000;}
		let num=trunc(TempStageScore1%(10^digit)/(10^(digit-1)));
		if(CheckNum<10^(digit-1) && digit!=1){Alpha=0;}

		let scale=0.4;
		let obj0=ObjSetNum(num,x,y,scale,Alpha,R,G,B);

		loop(600)
		{
		CheckNum=TempStageScore1;
		if(TempStageScore2!=0){CheckNum+=1000000;}
		num=trunc(TempStageScore1%(10^digit)/(10^(digit-1)));
		if(CheckNum<10^(digit-1) && digit!=1){Alpha=0;}
		else{Alpha=255;}

		LoopObjSetNum(obj0,num,Alpha,R,G,B);

		yield;
		}
		Obj_Delete(obj0);
}


task TempDisPlayStageScoreNumber2(let x,let y)
{
	ascent(i in 1..7)
	{
	TempDisplayStageScoreNum2Letter(x-(i-1)*8,y,i,255,255,200,200);
	}
	ascent(i in 7..8)
	{
	TempDisplayStageScoreNum2Letter(x-(i-1)*8,y,i,255,255,255,200);
	}
}

task TempDisplayStageScoreNum2Letter(let x,let y,let digit,Alpha,R,G,B)
{
		let CheckNum=TempStageScore2;
		let num=trunc(TempStageScore2%(10^digit)/(10^(digit-1)));
		if(CheckNum<10^(digit-1)){Alpha=0;}

		let scale=0.4;
		let obj0=ObjSetNum(num,x,y,scale,Alpha,R,G,B);

		loop(600)
		{
		CheckNum=TempStageScore2;
		num=trunc(TempStageScore2%(10^digit)/(10^(digit-1)));
		if(CheckNum<10^(digit-1)){Alpha=0;}
		else{Alpha=255;}

		LoopObjSetNum(obj0,num,Alpha,R,G,B);

		yield;
		}
		Obj_Delete(obj0);
}

task TempDisPlayScoreNumber(let x,let y)
{
	ascent(i in 1..7)
	{
	TempDisplayNumLetter(x-(i-1)*ScoreNumberXpx,y,i,255,200,200,255);
	}
}

task TempDisplayNumLetter(let x,let y,let digit,Alpha,R,G,B)
{
		let CheckNum=ScoreNumber1;
		if(ScoreNumber2!=0){CheckNum+=1000000;}
		let num=trunc(ScoreNumber1%(10^digit)/(10^(digit-1)));
		if(CheckNum<10^(digit-1) && digit!=1){Alpha=0;}

		let scale=0.6;
		let obj0=ObjSetNum(num,x,y,scale,Alpha,R,G,B);

		loop(600)
		{
		CheckNum=ScoreNumber1;
		if(ScoreNumber2!=0){CheckNum+=1000000;}
		num=trunc(ScoreNumber1%(10^digit)/(10^(digit-1)));
		if(CheckNum<10^(digit-1) && digit!=1){Alpha=0;}
		else{Alpha=255;}

		LoopObjSetNum(obj0,num,Alpha,R,G,B);

		yield;
		}
		Obj_Delete(obj0);
}


task TempDisPlayScoreNumber2(let x,let y)
{
	ascent(i in 1..7)
	{
	TempDisplayNum2Letter(x-(i-1)*ScoreNumberXpx,y,i,255,255,200,200);
	}
	ascent(i in 7..8)
	{
	TempDisplayNum2Letter(x-(i-1)*ScoreNumberXpx,y,i,255,255,255,200);
	}
}

task TempDisplayNum2Letter(let x,let y,let digit,Alpha,R,G,B)
{
		let CheckNum=ScoreNumber2;
		let num=trunc(ScoreNumber2%(10^digit)/(10^(digit-1)));
		if(CheckNum<10^(digit-1)){Alpha=0;}

		let scale=0.6;
		let obj0=ObjSetNum(num,x,y,scale,Alpha,R,G,B);

		loop(600)
		{
		CheckNum=ScoreNumber2;
		num=trunc(ScoreNumber2%(10^digit)/(10^(digit-1)));
		if(CheckNum<10^(digit-1)){Alpha=0;}
		else{Alpha=255;}

		LoopObjSetNum(obj0,num,Alpha,R,G,B);

		yield;
		}
		Obj_Delete(obj0);
}

}

task continucount//コンテしたらスコアを0にする
{
	let StageContinueCount=GetCommonDataDefaultEx(NsScore,NsContinueCount,0);
	let ContinueNum=GetAllowedContinueCount;
	while(ContinueNum==GetAllowedContinueCount)
	{
		yield;
	}
	if(GetCommonDataDefault("TrueBossFlag",false)==false)
	{
	StageContinueCount+=1;
	SetCommonDataEx(NsScore,NsContinueCount,StageContinueCount);
	ScoreNumber2=0;
	ScoreNumber1=0;
	continucount;
	}
}



