#東方弾幕風[Stage]
#Title[これが本体]
#Text[東方二次創作弾幕シューティングの予定だったんだけどなぁ]
#Image[]
#BackGround[Default]
#Player[script\script_Player\PlayerScript.txt]
#ScriptVersion[2]

script_stage_main{//
#include_function "script\Script-Main\NumberData.txt"
#include_function "script\Script-Main\TitleData.txt"
#include_function "script\Script-Main\SystemData.txt"
#include_function "script\Script-Stage1\Stage1-Lord.txt"
#include_function "script\Script-Stage1\Stage1-Back.txt"
#include_function "script\Script-Stage2\Stage2-Lord.txt"
#include_function "script\Script-Stage2\Stage2-Back.txt"
let Title=true;//タイトル画面の場合はtrue　ゲーム中ならfalse
let Command1=1;//メインタイトルカーソル
let Command2=1;//難易度選択カーソル
let Command3=1;//キャラ選択カーソル
let Command4=1;//オプションカーソル
let Scene=1;//現在シーン(1.メインメニュー　2.難易度選択　3.キャラ選択　4.オプション　5.EX難易度選択　6.EXキャラ選択　7.本編)
let MainTime=0;
let RankTime=0;
let PlayerTime=0;
let Cx=GetCenterX;
let Cy=GetCenterY;
let Score=12345678;
let Frame1=0;
let Frame2=0;
let Frame3=0;
let Frame4=0;
let Frame5=0;
let Life=0;
let StageNo=0;
let OK1=0;
let OK2=0;
let OK3=0;
let OK4=0;
let OK5=0;
let OK6=0;
let OK7=0;
SetCommonData("1END",false);
SetCommonData("2END",false);
SetCommonData("3END",false);
let Enemyimg="script\img-System\EnemySet.png";
SetCommonData("Rank","E");
SetCommonData("Player","NoPlayer");
SetCommonData("Power",1);
SetCommonData("OKShot",false);
SetCommonData("Grudge",223);//ゲージ
SetCommonData("SamonPoint",false);//敵撃破時true起動でポイントアイテム投下
SetCommonData("SamonPower",false);//敵撃破時true起動でパワーアイテム投下
SetCommonData("SamonBigPower",false);//敵撃破時true起動で大パワーアイテム投下
SetCommonData("EnemyVanish",false);//敵撃破時true起動で敵撃破エフェクト表示
task StageTask{//ステージタスク
function Wait(let frame){loop(frame){yield};}
function WaitForZeroEnemy{while(GetEnemyNum != 0){yield;}}	
Wait(1);
PlayMusic("script\BGM\No.01.mp3");
TitleBack;
Wait(20);
TitleReimu;
Wait(25);
TitleName;
Wait(30);
TitleCommand1;
TitleCommand2;
TitleCommand3;
TitleCommand4;
RankCommand1;
RankCommand2;
RankCommand3;
RankCommand4;
CharacterCommand2;
CharacterCommand;
GrudgeGauge;
StgFrame;
ScoreNum1;
ScoreNum2;
ScoreNum3;
ScoreNum4;
ScoreNum5;
ScoreNum6;
ScoreNum7;
ScoreNum8;
ScoreNum9;
loop{//ループ開始
if(Title==true){//現在タイトル画面の場合
yield;

if(Scene==1){//現在のシーンはメインメニューか？
RankTime=0;
MainTime++;
PlayerTime=0;
if(MainTime>5){
if(GetKeyState(VK_DOWN)==KEY_PUSH){//下キーを軽く押しているか？
if(Command1==1){//ゲームスタートを選んでいるか？
PlaySE("script\SE\Select.wav");
Command1=2;//エキストラへコマンド移動
MainTime=0;
}else//ゲームスタート終わり
if(Command1==2){//エキストラスタートを選んでいるか？
PlaySE("script\SE\Select.wav");
Command1=3;//オプションへコマンド移動
MainTime=0;
}else//エキストラスタート終わり
if(Command1==3){//オプションを選んでいるか？
PlaySE("script\SE\Select.wav");
Command1=4;//Quitへコマンド移動
MainTime=0;
}//オプション終わり
}//下キー軽く処理終了
if(GetKeyState(VK_UP)==KEY_PUSH){//上キーを軽く押しているか？
if(Command1==2){//エキストラスタートを選んでいるか？
PlaySE("script\SE\Select.wav");
Command1=1;//ゲームスタートへコマンド移動
MainTime=0;
}else//エキストラスタート終わり
if(Command1==3){//オプションを選んでいるか？
PlaySE("script\SE\Select.wav");
Command1=2;//エキストラスタートへコマンド移動
MainTime=0;
}else//オプション終わり
if(Command1==4){//Quitを選んでいるか？
PlaySE("script\SE\Select.wav");
Command1=3;//オプションへコマンド移動
MainTime=0;
}//Quit終わり
}//上キー軽く処理終了
if(GetKeyState(VK_SHOT)==KEY_PUSH){//決定キーを軽く押しているか？
if(Command1==1){//ゲームスタートを選んでいるか？
PlaySE("script\SE\Ok.wav");
Command2=2;//次の難易度選択をノーマルに設定
Scene=2;//シーンを難易度選択に
MainTime=0;
}else//ゲームスタート終わり
if(Command1==2){//エキストラスタートを選んでいるか？
PlaySE("script\SE\Ok.wav");
Command1=2;//エキストラスタートへコマンド移動
MainTime=0;
}else//エキストラスタート終わり
if(Command1==3){//オプションを選んでいるか？
PlaySE("script\SE\Ok.wav");
Command1=3;//オプションへコマンド移動
MainTime=0;
}else//オプション終わり
if(Command1==4){//Quitを選んでいるか？
PlaySE("script\SE\Ok.wav");
ClearStage;//ゲームの強制終了
Command1=4;//オプションへコマンド移動
MainTime=0;
}
}//決定キー軽く処理終了
}
}//メインメニュー処理終わり




if(Scene==2){//現在のシーンは難易度選択か？
RankTime++;
MainTime=0;
PlayerTime=0;
if(RankTime>5){
if(GetKeyState(VK_DOWN)==KEY_PUSH){//下キーを軽く押しているか？
	
if(Command2==1){//イージーを選んでいるか？
PlaySE("script\SE\Select.wav");
Command2=2;//コマンド移動
RankTime=0;
}else//イージー終わり
if(Command2==2){//ノーマルを選んでいるか？
PlaySE("script\SE\Select.wav");
Command2=3;//コマンド移動
RankTime=0;
}else//ノーマル終わり
if(Command2==3){//ハードを選んでいるか？
PlaySE("script\SE\Select.wav");
Command2=4;//コマンド移動
RankTime=0;
}
}//下キー軽く処理終了

if(GetKeyState(VK_UP)==KEY_PUSH){//上キーを軽く押しているか？
if(Command2==2){//ノーマルを選んでいるか？
PlaySE("script\SE\Select.wav");
Command2=1;//コマンド移動
RankTime=0;
}else//ノーマル終わり
if(Command2==3){//ハードを選んでいるか？
PlaySE("script\SE\Select.wav");
Command2=2;//コマンド移動
RankTime=0;
}else//ハード終わり
if(Command2==4){//ルナを選んでいるか？
PlaySE("script\SE\Select.wav");
Command2=3;//コマンド移動
RankTime=0;
}//ルナ終わり
}//上キー軽く処理終了
if(GetKeyState(VK_SHOT)==KEY_PUSH){//決定キーを軽く押しているか？
if(Command2==1){//イージーを選んでいるか？
PlaySE("script\SE\Ok.wav");
SetCommonData("Rank","E");//難易度をイージーに
Scene=3;//シーンをキャラ選択に
Command3=1;
}else//イージー終わり
if(Command2==2){//ノーマルを選んでいるか？
PlaySE("script\SE\Ok.wav");
SetCommonData("Rank","N");//難易度をノーマルに
Scene=3;//シーンをキャラ選択に
Command3=1;
}else//ノーマル終わり
if(Command2==3){//ハードを選んでいるか？
PlaySE("script\SE\Ok.wav");
SetCommonData("Rank","H");//難易度をハードに
Scene=3;//シーンをキャラ選択に
Command3=1;
}else//ハード終わり
if(Command2==4){//ルナを選んでいるか？
PlaySE("script\SE\Ok.wav");
SetCommonData("Rank","L");//難易度をルナティックに
Scene=3;//シーンをキャラ選択に
Command3=1;
}
}//決定キー軽く処理終了
if(GetKeyState(VK_BOMB)==KEY_PUSH){//キャンセルキーを軽く押しているか？
if(Command2==1){//イージーを選んでいるか？
PlaySE("script\SE\Cancel.wav");
Scene=1;//シーンをキャラ選択に
Command1=1;//ゲームスタートからコマンド開始
}else//イージー終わり
if(Command2==2){//ノーマルを選んでいるか？
PlaySE("script\SE\Cancel.wav");
Scene=1;//シーンをキャラ選択に
Command1=1;//ゲームスタートからコマンド開始
}else//ノーマル終わり
if(Command2==3){//ハードを選んでいるか？
PlaySE("script\SE\Cancel.wav");
Scene=1;//シーンをキャラ選択に
Command1=1;//ゲームスタートからコマンド開始
}else//ハード終わり
if(Command2==4){//ルナを選んでいるか？
PlaySE("script\SE\Cancel.wav");
Scene=1;//シーンをキャラ選択に
Command1=1;//ゲームスタートからコマンド開始
}
}//キャンセルキー軽く処理終了
}
}//難易度選択処理終わり



if(Scene==3){//現在のシーンはキャラ選択か？
PlayerTime++;
RankTime=0;
MainTime=0;
if(PlayerTime>5){
if(GetKeyState(VK_LEFT)==KEY_PUSH){//左キーを軽く押しているか？
	
if(Command3==1){//霊夢を選んでいるか？
PlaySE("script\SE\Select.wav");
Command3=3;//コマンド移動
}else//霊夢終わり
if(Command3==2){//魔理沙を選んでいるか？
PlaySE("script\SE\Select.wav");
Command3=1;//コマンド移動
PlayerTime=0;
}else//魔理沙終わり
if(Command3==3){//早苗を選んでいるか？
PlaySE("script\SE\Select.wav");
Command3=2;//コマンド移動
PlayerTime=0;
}else{
}
}//左キー軽く処理終了

if(GetKeyState(VK_RIGHT)==KEY_PUSH){//右キーを軽く押しているか？
	
if(Command3==1){//霊夢を選んでいるか？
PlaySE("script\SE\Select.wav");
Command3=2;//コマンド移動
PlayerTime=0;
}else//霊夢終わり
if(Command3==2){//魔理沙を選んでいるか？
PlaySE("script\SE\Select.wav");
Command3=3;//コマンド移動
PlayerTime=0;
}else//ノーマル終わり
if(Command3==3){//咲夜を選んでいるか？
PlaySE("script\SE\Select.wav");
Command3=1;//コマンド移動
PlayerTime=0;
}else{
}
}//右キー軽く処理終了

if(GetKeyState(VK_SHOT)==KEY_PUSH){//決定キーを軽く押しているか？
if(Command3==1){//霊夢を選んでいるか？
PlaySE("script\SE\Ok.wav");
SetCommonData("Player","Reimu");
Scene=7;//ゲームスタート
Title=false;
}else//霊夢終わり
if(Command3==2){//魔理沙を選んでいるか？
PlaySE("script\SE\Buzzer.wav");
}else//ノーマル終わり
if(Command3==3){//咲夜を選んでいるか？
PlaySE("script\SE\Buzzer.wav");
}else{
}
}//決定キー軽く処理終了

if(GetKeyState(VK_BOMB)==KEY_PUSH){//キャンセルキーを軽く押しているか？
if(Command3==1){//霊夢を選んでいるか？
PlaySE("script\SE\Cancel.wav");
Scene=2;//シーンを難易度選択に
}else
if(Command3==2){//魔理沙を選んでいるか？
PlaySE("script\SE\Cancel.wav");
Scene=2;//シーンを難易度選択に
}else
if(Command3==3){//昨夜を選んでいるか？
PlaySE("script\SE\Cancel.wav");
Scene=2;//シーンを難易度選択に
}
}//キャンセルキー軽く処理終了
}
}//キャラ選択処理終わり




}else{//ゲーム中だった場合開始
ScoreLine;
ScoreName;
GrazeLine;
GrazeName;
GrazeNum1;
GrazeNum2;
GrazeNum3;
GrazeNum4;
GMax;
LifeLine;
PlayerLife;
Wait(60);

//タスク管理が面倒になって本体にくっつけました

let ENM11 = "script\Script-Stage1\1面-自機狙い1.txt";
let ENM21 = "script\Script-Stage1\1面-自機狙い2.txt";
let ENM31 = "script\Script-Stage1\1面-扇状弾1.txt";
let ENM41 = "script\Script-Stage1\1面-ランダム拡散.txt";
let ENM51 = "script\Script-Stage1\1面-全方位弾.txt";

StageNo=1;
PlayMusic("script\BGM\No.02.mp3");
CompileEnemyFromFile(ENM11);
CompileEnemyFromFile(ENM21);
CompileEnemyFromFile(ENM31);
CompileEnemyFromFile(ENM41);
CompileEnemyFromFile(ENM51);

Wait(60);
	StageNo=1;
	PlayMusic("script\BGM\No.02.mp3");
	Wait(50);
	CreateEnemyFromFile(ENM11,0,60,0,0,0);
	Wait(50);
	CreateEnemyFromFile(ENM11,0,90,0,0,0);
	Wait(50);
	CreateEnemyFromFile(ENM11,0,120,0,0,0);
	Wait(50);
	CreateEnemyFromFile(ENM11,0,150,0,0,0);
	Wait(50);
	CreateEnemyFromFile(ENM11,0,190,0,0,0);
	Wait(50);
	CreateEnemyFromFile(ENM21,430,60,0,0,0);
	Wait(50);
	CreateEnemyFromFile(ENM21,430,90,0,0,0);
	Wait(50);
	CreateEnemyFromFile(ENM21,430,120,0,0,0);
	Wait(50);
	CreateEnemyFromFile(ENM21,430,150,0,0,0);
	Wait(50);
	CreateEnemyFromFile(ENM21,430,190,0,0,0);
	WaitForZeroEnemy;
	Wait(120);
	StageTitle1;
	Wait(700);
	CreateEnemyFromFile(ENM31,Cx-100,0,0,0,0);
	CreateEnemyFromFile(ENM31,Cx+100,0,0,0,0);
	Wait(150);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(120);
	CreateEnemyFromFile(ENM31,Cx-50,0,0,0,0);
	CreateEnemyFromFile(ENM31,Cx+50,0,0,0,0);
	Wait(150);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	WaitForZeroEnemy;
	Wait(150);
	CreateEnemyFromFile(ENM51,Cx-150,0,0,0,0);
	Wait(60);
	CreateEnemyFromFile(ENM51,Cx+150,0,0,0,0);
	Wait(60);
	CreateEnemyFromFile(ENM11,0,60,0,0,0);
	Wait(50);
	CreateEnemyFromFile(ENM11,0,90,0,0,0);
	Wait(50);
	CreateEnemyFromFile(ENM11,0,120,0,0,0);
	Wait(50);
	CreateEnemyFromFile(ENM11,0,150,0,0,0);
	Wait(50);
	CreateEnemyFromFile(ENM11,0,190,0,0,0);
	Wait(50);
	CreateEnemyFromFile(ENM11,0,220,0,0,0);
	Wait(50);
	CreateEnemyFromFile(ENM11,0,250,0,0,0);
	Wait(50);
	CreateEnemyFromFile(ENM11,0,280,0,0,0);
	Wait(50);
	CreateEnemyFromFile(ENM11,0,310,0,0,0);
	WaitForZeroEnemy;
	Wait(120);
	CreateEnemyFromFile(ENM31,Cx-50,0,0,0,0);
	CreateEnemyFromFile(ENM31,Cx+50,0,0,0,0);
	Wait(150);
	CreateEnemyFromFile(ENM31,Cx-100,0,0,0,0);
	CreateEnemyFromFile(ENM31,Cx+100,0,0,0,0);
	Wait(150);
	CreateEnemyFromFile(ENM31,Cx-150,0,0,0,0);
	CreateEnemyFromFile(ENM31,Cx+150,0,0,0,0);
	WaitForZeroEnemy;
	Wait(150);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	WaitForZeroEnemy;
	Wait(150);
	if(GetCommonData("Rank")=="E"){
	CreateEnemyBossFromFile("script\Script-1Boss\Frolir-MiddleBossE.txt",0,0,0,0,0);
	}else if(GetCommonData("Rank")=="N"){
	CreateEnemyBossFromFile("script\Script-1Boss\Frolir-MiddleBossN.txt",0,0,0,0,0);
	}else if(GetCommonData("Rank")=="H"){
	CreateEnemyBossFromFile("script\Script-1Boss\Frolir-MiddleBossH.txt",0,0,0,0,0);
	}else if(GetCommonData("Rank")=="L"){
	CreateEnemyBossFromFile("script\Script-1Boss\Frolir-MiddleBossL.txt",0,0,0,0,0);
	} 
	WaitForZeroEnemy;
	Wait(120);
	CreateEnemyFromFile(ENM51,Cx-150,0,0,0,0);
	CreateEnemyFromFile(ENM51,Cx+150,0,0,0,0);
	Wait(100);
	CreateEnemyFromFile(ENM31,Cx-50,0,0,0,0);
	CreateEnemyFromFile(ENM31,Cx+50,0,0,0,0);
	Wait(100);
	CreateEnemyFromFile(ENM11,0,60,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM11,0,120,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM11,0,60,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM11,0,120,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM11,0,60,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM11,0,120,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM11,0,60,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM11,0,120,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM11,0,60,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM11,0,120,0,0,0);
	Wait(130);
	CreateEnemyFromFile(ENM51,Cx-150,0,0,0,0);
	CreateEnemyFromFile(ENM51,Cx+150,0,0,0,0);
	Wait(110);
	CreateEnemyFromFile(ENM31,Cx-150,0,0,0,0);
	CreateEnemyFromFile(ENM31,Cx+150,0,0,0,0);
	WaitForZeroEnemy;
	Wait(150);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(140);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(130);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(120);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(110);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(100);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(90);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(80);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(70);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	Wait(60);
	CreateEnemyFromFile(ENM41,rand(Cx-150,Cx+150),0,0,0,0);
	WaitForZeroEnemy;
	Wait(120);
	CreateEnemyFromFile(ENM31,Cx-150,0,0,0,0);
	Wait(90);
	CreateEnemyFromFile(ENM31,Cx+150,0,0,0,0);
	Wait(90);
	CreateEnemyFromFile(ENM31,Cx+100,0,0,0,0);
	Wait(90);
	CreateEnemyFromFile(ENM31,Cx+50,0,0,0,0);
	Wait(90);
	CreateEnemyFromFile(ENM31,Cx-100,0,0,0,0);
	Wait(90);
	CreateEnemyFromFile(ENM31,Cx-50,0,0,0,0);
	WaitForZeroEnemy;
	Wait(160);
	CreateEnemyFromFile(ENM11,0,60,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM21,0,120,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM11,0,60,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM21,0,120,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM11,0,60,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM21,0,120,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM11,0,60,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM21,0,120,0,0,0);
	Wait(35);
	CreateEnemyFromFile(ENM11,0,60,0,0,0);
	Wait(35);
CreateEnemyFromFile(ENM21,0,120,0,0,0);
WaitForZeroEnemy;
ClearByteCodeCache;
Wait(160);
if(GetCommonData("Rank")=="E"){
CreateEnemyBossFromFile("script\Script-1Boss\Frolir-BossE.txt",0,0,0,0,0);
}else if(GetCommonData("Rank")=="N"){
CreateEnemyBossFromFile("script\Script-1Boss\Frolir-BossN.txt",0,0,0,0,0);
}else if(GetCommonData("Rank")=="H"){
CreateEnemyBossFromFile("script\Script-1Boss\Frolir-BossH.txt",0,0,0,0,0);
}else if(GetCommonData("Rank")=="L"){
CreateEnemyBossFromFile("script\Script-1Boss\Frolir-BossL.txt",0,0,0,0,0);
} 
WaitForZeroEnemy;
FadeOutMusic("script\BGM\No.03.mp3",20);
StageEnd;
Wait(60);
StageNo=0;
Wait(220);	
StageNo=2;
Wait(160);
PlayMusic("script\BGM\No.04.mp3");
Wait(300);

if(GetCommonData("Rank")=="E"){
CreateEnemyBossFromFile("script\Script-1Boss\Frolir-BossE.txt",0,0,0,0,0);
}else if(GetCommonData("Rank")=="N"){
CreateEnemyBossFromFile("script\Script-1Boss\Frolir-BossN.txt",0,0,0,0,0);
}else if(GetCommonData("Rank")=="H"){
CreateEnemyBossFromFile("script\Script-1Boss\Frolir-BossH.txt",0,0,0,0,0);
}else if(GetCommonData("Rank")=="L"){
CreateEnemyBossFromFile("script\Script-1Boss\Frolir-BossL.txt",0,0,0,0,0);
} 
WaitForZeroEnemy;
FadeOutMusic("script\BGM\No.03.mp3",20);
StageEnd;
Wait(60);
StageNo=2;
Wait(120);	


ClearStage;


Wait(900000000000000000000);
yield;
}//ゲーム中だった場合終了
ForbidShot(false);//ショット許可命令
ForbidBomb(false);//ボム許可命令
}//ループ終了

}
@DrawTopObject{
if(Title==true){
}else{
Frame1++;

SetCommonData("Grudge",GetCommonData("Grudge")-1);


}
}
@Initialize{
LoadGraphic(Enemyimg);
SetDefaultStatusVisible(false);
StageTask;


}//イニシャライズ終了
	
@MainLoop{
yield;//タスク復帰
if(Title==true){
ForbidShot(true);//ショット命令
ForbidBomb(true);//ボム命令
SetCommonData("OKShot",true);
}else{
Life=GetPlayerLife;
if(GetCommonData("SamonPoint")==true){
loop(4){
ItemPoint;
}
SetCommonData("SamonPoint",false);
}
if(GetCommonData("SamonPower")==true){
loop(4){
ItemPower;
}
SetCommonData("SamonPower",false);
}
if(GetCommonData("EnemyVanish")==true){
Vanish;
SetCommonData("EnemyVanish",false);
}
if(GetCommonData("SamonBigPower")==true){
loop(1){
ItemBigPower;
}
SetCommonData("SamonBigPower",false);
}

}



}
	
@Finalize{//

}//ファイナライズ終了

@BackGround{
yield;
if(StageNo==1){
if(OK1==0){
Stage1LordBack;
OK1=1;
}
}
if(StageNo==2){
if(OK2==0){
Stage2LordBack;
OK2=1;
}
}


}




task StageEnd{
let X=GetCenterX;
let Y=GetCenterY;
let Img1="script\img-System\Clear.png";
let rect01=0;
let rect02=0;
let rect03=384;
let rect04=446;
let Layer=7;
let W=(rect03-rect01)/2;
let H=(rect04-rect02)/2;
let Angle1=0;
let Scale=1;
let Frame1=0;
let Set1=0;
let Set2=0;
let Set3=0;
let Set4=0;
let Set5=0;
let Angle2=rand(0,180)+40;
let Angle3=rand(0,180)+40;
let Alpha=0;
let Obj=Obj_Create(OBJ_EFFECT);
LoadGraphic(Img1);
ObjEffect_SetTexture(Obj,Img1);
ObjEffect_SetRenderState(Obj,ALPHA);
ObjEffect_SetPrimitiveType(Obj, PRIMITIVE_TRIANGLEFAN);
ObjEffect_CreateVertex(Obj,4);
ObjEffect_SetLayer(Obj,Layer);
Obj_SetPosition(Obj,X,Y);
ObjEffect_SetAngle(Obj,0,0,0);
ObjEffect_SetScale(Obj,1.0,1.0);
ObjEffect_SetVertexXY(Obj,0,-W,-H);
ObjEffect_SetVertexXY(Obj,1,W,-H);
ObjEffect_SetVertexXY(Obj,2,W,H);
ObjEffect_SetVertexXY(Obj,3,-W,H);
ObjEffect_SetVertexUV(Obj,0,rect01,rect02);
ObjEffect_SetVertexUV(Obj,1,rect03,rect02);
ObjEffect_SetVertexUV(Obj,2,rect03,rect04);
ObjEffect_SetVertexUV(Obj,3,rect01,rect04);
ObjEffect_SetVertexColor(Obj,0,255,255,255,255);
ObjEffect_SetVertexColor(Obj,1,255,255,255,255);
ObjEffect_SetVertexColor(Obj,2,255,255,255,255);
ObjEffect_SetVertexColor(Obj,3,255,255,255,255);
loop{
Frame1++;
ObjEffect_SetAngle(Obj,Angle1,Angle1,Angle1);
ObjEffect_SetScale(Obj,Scale,Scale);
ObjEffect_SetVertexColor(Obj,0,Alpha,255,255,255);
ObjEffect_SetVertexColor(Obj,1,Alpha,255,255,255);
ObjEffect_SetVertexColor(Obj,2,Alpha,255,255,255);
ObjEffect_SetVertexColor(Obj,3,Alpha,255,255,255);

if(Frame1==220){
Set1=1;
}
if(Frame1==280){
Obj_Delete(Obj);
break;
}
if(Set1==1){
if(Alpha<0){

}else{
Alpha-=5;
}
}else{
if(Alpha>255){

}else{
Alpha+=5;
}
}

yield;	
}
}
task StageTitle2{
let X=GetCenterX-150;
let Y=GetCenterY-100;
let Img1="script\Script-Stage2\StageTitle-2.png";
let rect01=0;
let rect02=0;
let rect03=428;
let rect04=187;
let Layer=7;
let W=(rect03-rect01)/2;
let H=(rect04-rect02)/2;
let Angle1=0;
let Scale=1;
let Frame1=0;
let Set1=0;
let Set2=0;
let Set3=0;
let Set4=0;
let Set5=0;
let Angle2=rand(0,180)+40;
let Angle3=rand(0,180)+40;
let Alpha=0;
let Obj=Obj_Create(OBJ_EFFECT);
LoadGraphic(Img1);
ObjEffect_SetTexture(Obj,Img1);
ObjEffect_SetRenderState(Obj,ALPHA);
ObjEffect_SetPrimitiveType(Obj, PRIMITIVE_TRIANGLEFAN);
ObjEffect_CreateVertex(Obj,4);
ObjEffect_SetLayer(Obj,Layer);
Obj_SetPosition(Obj,X,Y);
ObjEffect_SetAngle(Obj,0,0,0);
ObjEffect_SetScale(Obj,1.0,1.0);
ObjEffect_SetVertexXY(Obj,0,-W,-H);
ObjEffect_SetVertexXY(Obj,1,W,-H);
ObjEffect_SetVertexXY(Obj,2,W,H);
ObjEffect_SetVertexXY(Obj,3,-W,H);
ObjEffect_SetVertexUV(Obj,0,rect01,rect02);
ObjEffect_SetVertexUV(Obj,1,rect03,rect02);
ObjEffect_SetVertexUV(Obj,2,rect03,rect04);
ObjEffect_SetVertexUV(Obj,3,rect01,rect04);
ObjEffect_SetVertexColor(Obj,0,255,255,255,255);
ObjEffect_SetVertexColor(Obj,1,255,255,255,255);
ObjEffect_SetVertexColor(Obj,2,255,255,255,255);
ObjEffect_SetVertexColor(Obj,3,255,255,255,255);
Obj_SetSpeed(Obj,1);
Obj_SetAngle(Obj,0);
loop{
Frame1++;
ObjEffect_SetAngle(Obj,Angle1,Angle1,Angle1);
ObjEffect_SetScale(Obj,Scale,Scale);
ObjEffect_SetVertexColor(Obj,0,Alpha,255,255,255);
ObjEffect_SetVertexColor(Obj,1,Alpha,255,255,255);
ObjEffect_SetVertexColor(Obj,2,Alpha,255,255,255);
ObjEffect_SetVertexColor(Obj,3,Alpha,255,255,255);
if(Frame1==20){
Obj_SetSpeed(Obj,2);
}
if(Frame1==30){
Obj_SetSpeed(Obj,3);
}
if(Frame1==100){
Obj_SetSpeed(Obj,2);
}
if(Frame1==110){
Obj_SetSpeed(Obj,1);
}
if(Frame1==120){
Obj_SetSpeed(Obj,0);
}
if(Frame1==360){
Set1=1;
}
if(Frame1==600){
Obj_Delete(Obj);
break;
}
if(Set1==1){
if(Alpha<0){

}else{
Alpha-=1;
}
}else{
if(Alpha>255){

}else{
Alpha+=5;
}
}

yield;	
}
}
task StageTitle1{
let X=GetCenterX-150;
let Y=GetCenterY-100;
let Img1="script\Script-Stage1\StageTitle-1.png";
let rect01=0;
let rect02=0;
let rect03=428;
let rect04=187;
let Layer=7;
let W=(rect03-rect01)/2;
let H=(rect04-rect02)/2;
let Angle1=0;
let Scale=1;
let Frame1=0;
let Set1=0;
let Set2=0;
let Set3=0;
let Set4=0;
let Set5=0;
let Angle2=rand(0,180)+40;
let Angle3=rand(0,180)+40;
let Alpha=0;
let Obj=Obj_Create(OBJ_EFFECT);
LoadGraphic(Img1);
ObjEffect_SetTexture(Obj,Img1);
ObjEffect_SetRenderState(Obj,ALPHA);
ObjEffect_SetPrimitiveType(Obj, PRIMITIVE_TRIANGLEFAN);
ObjEffect_CreateVertex(Obj,4);
ObjEffect_SetLayer(Obj,Layer);
Obj_SetPosition(Obj,X,Y);
ObjEffect_SetAngle(Obj,0,0,0);
ObjEffect_SetScale(Obj,1.0,1.0);
ObjEffect_SetVertexXY(Obj,0,-W,-H);
ObjEffect_SetVertexXY(Obj,1,W,-H);
ObjEffect_SetVertexXY(Obj,2,W,H);
ObjEffect_SetVertexXY(Obj,3,-W,H);
ObjEffect_SetVertexUV(Obj,0,rect01,rect02);
ObjEffect_SetVertexUV(Obj,1,rect03,rect02);
ObjEffect_SetVertexUV(Obj,2,rect03,rect04);
ObjEffect_SetVertexUV(Obj,3,rect01,rect04);
ObjEffect_SetVertexColor(Obj,0,255,255,255,255);
ObjEffect_SetVertexColor(Obj,1,255,255,255,255);
ObjEffect_SetVertexColor(Obj,2,255,255,255,255);
ObjEffect_SetVertexColor(Obj,3,255,255,255,255);
Obj_SetSpeed(Obj,1);
Obj_SetAngle(Obj,0);
loop{
Frame1++;
ObjEffect_SetAngle(Obj,Angle1,Angle1,Angle1);
ObjEffect_SetScale(Obj,Scale,Scale);
ObjEffect_SetVertexColor(Obj,0,Alpha,255,255,255);
ObjEffect_SetVertexColor(Obj,1,Alpha,255,255,255);
ObjEffect_SetVertexColor(Obj,2,Alpha,255,255,255);
ObjEffect_SetVertexColor(Obj,3,Alpha,255,255,255);
if(Frame1==20){
Obj_SetSpeed(Obj,2);
}
if(Frame1==30){
Obj_SetSpeed(Obj,3);
}
if(Frame1==100){
Obj_SetSpeed(Obj,2);
}
if(Frame1==110){
Obj_SetSpeed(Obj,1);
}
if(Frame1==120){
Obj_SetSpeed(Obj,0);
}
if(Frame1==360){
Set1=1;
}
if(Frame1==600){
Obj_Delete(Obj);
break;
}
if(Set1==1){
if(Alpha<0){

}else{
Alpha-=1;
}
}else{
if(Alpha>255){

}else{
Alpha+=5;
}
}

yield;	
}
}
task PlayerLife{
let X=Cx+315;let Y=Cy-80;
let img1="script\img-System\Life-0.png";
let img2="script\img-System\Life-1.png";
let img3="script\img-System\Life-2.png";
let img4="script\img-System\Life-3.png";
let img5="script\img-System\Life-4.png";
let img6="script\img-System\Life-5.png";
let img7="script\img-System\Life-6.png";
let img8="script\img-System\Life-7.png";
let img9="script\img-System\Life-8.png";
let rect01=0;let rect02=0;let rect03=0;let rect04=0;
let Layer=8;let alpha=255;let W=(rect03-rect01)/2;
let H=(rect04-rect02)/2;let frame=0;
let obj = Obj_Create(OBJ_EFFECT);
LoadGraphic(img1);LoadGraphic(img2);LoadGraphic(img3);LoadGraphic(img4);
LoadGraphic(img5);LoadGraphic(img6);LoadGraphic(img7);LoadGraphic(img8);LoadGraphic(img9);
ObjEffect_SetTexture(obj,img1);
ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
ObjEffect_CreateVertex(obj, 4);
ObjEffect_SetLayer(obj,Layer);
Obj_SetPosition(obj,X,Y);
ObjEffect_SetAngle(obj,0,0,0);
ObjEffect_SetScale(obj,1,1);
ObjEffect_SetVertexXY(obj, 0,-W,-H);
ObjEffect_SetVertexXY(obj, 1, W,-H);
ObjEffect_SetVertexXY(obj, 2, W, H);
ObjEffect_SetVertexXY(obj, 3,-W, H);
ObjEffect_SetVertexUV(obj, 0, rect01, rect02);
ObjEffect_SetVertexUV(obj, 1, rect03, rect02);
ObjEffect_SetVertexUV(obj, 2, rect03, rect04);
ObjEffect_SetVertexUV(obj, 3, rect01, rect04);
ObjEffect_SetVertexColor(obj, 0, 255, 255, 255, alpha);
ObjEffect_SetVertexColor(obj, 1, 255, 255, 255, alpha);
ObjEffect_SetVertexColor(obj, 2, 255, 255, 255, alpha);
ObjEffect_SetVertexColor(obj, 3, 255, 255, 255, alpha);
ObjEffect_SetRenderState(obj,ALPHA);
loop{
if(Title==false){
let rect01=0;let rect02=0;let rect03=211;let rect04=36;	
W=(rect03-rect01)/2;H=(rect04-rect02)/2;
ObjEffect_SetVertexXY(obj, 0,-W,-H);ObjEffect_SetVertexXY(obj, 1, W,-H);ObjEffect_SetVertexXY(obj, 2, W, H);
ObjEffect_SetVertexXY(obj, 3,-W, H);ObjEffect_SetVertexUV(obj, 0, rect01, rect02);ObjEffect_SetVertexUV(obj, 1, rect03, rect02);
ObjEffect_SetVertexUV(obj, 2, rect03, rect04);ObjEffect_SetVertexUV(obj, 3, rect01, rect04);

if(Life==1){
ObjEffect_SetTexture(obj,img1);
}
if(Life==2){
ObjEffect_SetTexture(obj,img2);
}
if(Life==3){
ObjEffect_SetTexture(obj,img3);
}
if(Life==4){
ObjEffect_SetTexture(obj,img4);
}
if(Life==5){
ObjEffect_SetTexture(obj,img5);
}
if(Life==6){
ObjEffect_SetTexture(obj,img6);
}
if(Life==7){
ObjEffect_SetTexture(obj,img7);
}
if(Life==8){
ObjEffect_SetTexture(obj,img8);
}
if(Life==9){
ObjEffect_SetTexture(obj,img9);
}
}
yield;
}
}
task GMax{
let X=Cx+303;let Y=Cy-104;
let img1="script\img-System\FrameData.png";
let rect01=0;let rect02=0;let rect03=0;let rect04=0;
let Layer=8;let alpha=255;let W=(rect03-rect01)/2;
let H=(rect04-rect02)/2;let frame=0;
let obj = Obj_Create(OBJ_EFFECT);
LoadGraphic(img1);
ObjEffect_SetTexture(obj,img1);
ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
ObjEffect_CreateVertex(obj, 4);
ObjEffect_SetLayer(obj,Layer);
Obj_SetPosition(obj,X,Y);
ObjEffect_SetAngle(obj,0,0,0);
ObjEffect_SetScale(obj,1,1);
ObjEffect_SetVertexXY(obj, 0,-W,-H);
ObjEffect_SetVertexXY(obj, 1, W,-H);
ObjEffect_SetVertexXY(obj, 2, W, H);
ObjEffect_SetVertexXY(obj, 3,-W, H);
ObjEffect_SetVertexUV(obj, 0, rect01, rect02);
ObjEffect_SetVertexUV(obj, 1, rect03, rect02);
ObjEffect_SetVertexUV(obj, 2, rect03, rect04);
ObjEffect_SetVertexUV(obj, 3, rect01, rect04);
ObjEffect_SetVertexColor(obj, 0, 255, 255, 255, alpha);
ObjEffect_SetVertexColor(obj, 1, 255, 255, 255, alpha);
ObjEffect_SetVertexColor(obj, 2, 255, 255, 255, alpha);
ObjEffect_SetVertexColor(obj, 3, 255, 255, 255, alpha);
ObjEffect_SetRenderState(obj,ALPHA);
loop{
if(GetCommonData("Grudge")==0){
let rect01=16;let rect02=144;let rect03=207;let rect04=159;	
W=(rect03-rect01)/2;H=(rect04-rect02)/2;
ObjEffect_SetVertexXY(obj, 0,-W,-H);ObjEffect_SetVertexXY(obj, 1, W,-H);ObjEffect_SetVertexXY(obj, 2, W, H);
ObjEffect_SetVertexXY(obj, 3,-W, H);ObjEffect_SetVertexUV(obj, 0, rect01, rect02);ObjEffect_SetVertexUV(obj, 1, rect03, rect02);
ObjEffect_SetVertexUV(obj, 2, rect03, rect04);ObjEffect_SetVertexUV(obj, 3, rect01, rect04);
}else{
let rect01=0;let rect02=0;let rect03=0;let rect04=0;	
W=(rect03-rect01)/2;H=(rect04-rect02)/2;
ObjEffect_SetVertexXY(obj, 0,-W,-H);ObjEffect_SetVertexXY(obj, 1, W,-H);ObjEffect_SetVertexXY(obj, 2, W, H);
ObjEffect_SetVertexXY(obj, 3,-W, H);ObjEffect_SetVertexUV(obj, 0, rect01, rect02);ObjEffect_SetVertexUV(obj, 1, rect03, rect02);
ObjEffect_SetVertexUV(obj, 2, rect03, rect04);ObjEffect_SetVertexUV(obj, 3, rect01, rect04);
}
yield;
}
}
task GrudgeGauge{
let X=Cx+303;let Y=Cy-104;
let img1="script\img-System\FrameData.png";
let rect01=0;let rect02=0;let rect03=0;let rect04=0;
let Layer=8;let alpha=255;let W=(rect03-rect01)/2;
let H=(rect04-rect02)/2;let frame=0;
let Gage=223;
let obj = Obj_Create(OBJ_EFFECT);
LoadGraphic(img1);
ObjEffect_SetTexture(obj,img1);
ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
ObjEffect_CreateVertex(obj, 4);
ObjEffect_SetLayer(obj,Layer);
Obj_SetPosition(obj,X,Y);
ObjEffect_SetAngle(obj,0,0,0);
ObjEffect_SetScale(obj,1,1);
ObjEffect_SetVertexXY(obj, 0,-W,-H);
ObjEffect_SetVertexXY(obj, 1, W,-H);
ObjEffect_SetVertexXY(obj, 2, W, H);
ObjEffect_SetVertexXY(obj, 3,-W, H);
ObjEffect_SetVertexUV(obj, 0, rect01, rect02);
ObjEffect_SetVertexUV(obj, 1, rect03, rect02);
ObjEffect_SetVertexUV(obj, 2, rect03, rect04);
ObjEffect_SetVertexUV(obj, 3, rect01, rect04);
ObjEffect_SetVertexColor(obj, 0, 255, 255, 255, alpha);
ObjEffect_SetVertexColor(obj, 1, 255, 255, 255, alpha);
ObjEffect_SetVertexColor(obj, 2, 255, 255, 255, alpha);
ObjEffect_SetVertexColor(obj, 3, 255, 255, 255, alpha);
ObjEffect_SetRenderState(obj,ALPHA);
loop{
Obj_SetPosition(obj,X+Gage,Y);
Gage=GetCommonData("Grudge");
if(Title==false){
let rect01=0;let rect02=128;let rect03=223;let rect04=144;	
W=(rect03-rect01)/2;H=(rect04-rect02)/2;
ObjEffect_SetVertexXY(obj, 0,-W,-H);ObjEffect_SetVertexXY(obj, 1, W,-H);ObjEffect_SetVertexXY(obj, 2, W, H);
ObjEffect_SetVertexXY(obj, 3,-W, H);ObjEffect_SetVertexUV(obj, 0, rect01, rect02);ObjEffect_SetVertexUV(obj, 1, rect03, rect02);
ObjEffect_SetVertexUV(obj, 2, rect03, rect04);ObjEffect_SetVertexUV(obj, 3, rect01, rect04);
}
if(GetCommonData("Grudge")<0){
SetCommonData("Grudge",0);
}else{
}
if(GetCommonData("Grudge")>223){
SetCommonData("Grudge",223);
}else{
}
yield;
}
}
task StgFrame{
let X=Cx+125;let Y=Cy;
let img1="script\img-System\StgFrame.png";
let rect01=0;let rect02=0;let rect03=0;let rect04=0;
let Layer=8;let alpha=255;let W=(rect03-rect01)/2;
let H=(rect04-rect02)/2;let frame=0;
let frame1=0;
let obj = Obj_Create(OBJ_EFFECT);
LoadGraphic(img1);
ObjEffect_SetTexture(obj,img1);
ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
ObjEffect_CreateVertex(obj, 4);
ObjEffect_SetLayer(obj,Layer);
Obj_SetPosition(obj,X,Y);
ObjEffect_SetAngle(obj,0,0,0);
ObjEffect_SetScale(obj,1,1);
ObjEffect_SetVertexXY(obj, 0,-W,-H);
ObjEffect_SetVertexXY(obj, 1, W,-H);
ObjEffect_SetVertexXY(obj, 2, W, H);
ObjEffect_SetVertexXY(obj, 3,-W, H);
ObjEffect_SetVertexUV(obj, 0, rect01, rect02);
ObjEffect_SetVertexUV(obj, 1, rect03, rect02);
ObjEffect_SetVertexUV(obj, 2, rect03, rect04);
ObjEffect_SetVertexUV(obj, 3, rect01, rect04);
ObjEffect_SetVertexColor(obj, 0, 255, 255, 255, alpha);
ObjEffect_SetVertexColor(obj, 1, 255, 255, 255, alpha);
ObjEffect_SetVertexColor(obj, 2, 255, 255, 255, alpha);
ObjEffect_SetVertexColor(obj, 3, 255, 255, 255, alpha);
ObjEffect_SetRenderState(obj,ALPHA);
loop{
if(Title==false){
let rect01=0;let rect02=0;let rect03=700;let rect04=480;	
W=(rect03-rect01)/2;H=(rect04-rect02)/2;
ObjEffect_SetVertexXY(obj, 0,-W,-H);ObjEffect_SetVertexXY(obj, 1, W,-H);ObjEffect_SetVertexXY(obj, 2, W, H);
ObjEffect_SetVertexXY(obj, 3,-W, H);ObjEffect_SetVertexUV(obj, 0, rect01, rect02);ObjEffect_SetVertexUV(obj, 1, rect03, rect02);
ObjEffect_SetVertexUV(obj, 2, rect03, rect04);ObjEffect_SetVertexUV(obj, 3, rect01, rect04);
}
yield;
}
}





}//メインスクリプト終了
