//#TouhouDanmakufu[Single]
#ScriptVersion[3]
#System["./default_system/Default_System.txt"]
#Title["Nonspell 1"]
#Text["First Nonspell of Mirai"]

#include "./img/All_Star_Shots/AllStarShot_Const.txt"
#include "./Sounds.txt"
#include "./Functions.txt"
#include "./Animation.txt"
#include "./Effects.txt"
#include "./Marisa.txt"
#include "./FeeDesFlammes.txt"

let bossObj;
let sceneObj = GetEnemyBossSceneObjectID;
let IMG_BACKGROUND=GetCurrentScriptDirectory~"./img/mask_ball.png";


@Initialize
{
	bossObj = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjMove_SetX(bossObj, GetCommonData("bossX", -32));
	ObjMove_SetY(bossObj, GetCommonData("bossY", -32));
	ObjEnemy_Regist(bossObj);
	
	DeleteShotAll(TYPE_ALL, TYPE_IMMEDIATE);
	SetCommonData("animStyle", "idle");
	
	ReverseEffect;
	renderBoss666;
	TFinalize;
	bulle;
	texte1;
	texte2;
	texte3;
}

@Event
{
	alternative (GetEventType())
	case (EV_REQUEST_LIFE) {
		SetScriptResult(1);
	}
}

@MainLoop
{
	SetCommonData("bossX", ObjMove_GetX(bossObj));
	SetCommonData("bossY", ObjMove_GetY(bossObj));
	yield;
}

function ObjPrim_SetDestCenter(obj,x1,y1,x2,y2)
{
    //指定域の画像の中心をobjの中心に設定する(よく使うタイプ)
    ObjPrim_SetVertexPosition(obj, 0, -(x2-x1)/2, -(y2-y1)/2, -0);
    ObjPrim_SetVertexPosition(obj, 1, (x2-x1)/2, -(y2-y1)/2, -0);
    ObjPrim_SetVertexPosition(obj, 2, (x2-x1)/2, (y2-y1)/2, 0);
    ObjPrim_SetVertexPosition(obj, 3, -(x2-x1)/2, (y2-y1)/2, 0);
    ObjPrim_SetVertexUVT(obj, 0, x1, y1);
    ObjPrim_SetVertexUVT(obj, 1, x2, y1);
    ObjPrim_SetVertexUVT(obj, 2, x2, y2);
    ObjPrim_SetVertexUVT(obj, 3, x1, y2);
}

task ReverseEffect
		{
			let obj = ObjPrim_Create(OBJ_PRIMITIVE_2D);
			ObjPrim_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
			ObjRender_SetBlendType(obj, BLEND_INV_DESTRGB);
			ObjPrim_SetVertexCount(obj, 4);
			Obj_SetRenderPriorityI(obj,78);
			ObjRender_SetAngleZ(obj,0);
			ObjPrim_SetDestCenter(obj,0,0,640,640);
			ObjRender_SetPosition(obj,320,240,0);
			let Alpha=0;
			let Scale=0;
			let ScalePlus=0;
			let ScalePlusSpeed=0.0125/8*1.33;
		}


task bulle {
	SetForbidPlayerShot(true);
	SetForbidPlayerSpell(true);
	test(1);
	wait(60);
		ObjMove_SetDestAtFrame(bossObj, getCenterX, 90, 1);
		FeeDesFlammesOmbreNoir;		
		DialogueBubbleEnnemi(180,90,178,0.5,3,"CONTROL",0);
		DialogueBubbleEnnemi(180,90,178,0.6,5,"CONTROL",0);
		DialogueBubbleEnnemi(180,90,178,0.6,5,"CONTROL",0);
		DialogueBubbleEnnemi(180,90,178,0.6,5,"CONTROL",0);
		DialogueBubbleEnnemi(180,90,178,0.5,3,"CONTROL",0);
		DialogueBubbleEnnemi(180,90,178,0.6,5,"CONTROL",0);
		DialogueBubbleEnnemi(180,90,178,0.6,5,"CONTROL",0);
		DialogueBubbleEnnemi(180,90,178,0.6,5,"CONTROL",0);
		SetForbidPlayerShot(false);
		SetForbidPlayerSpell(false);
		ObjEnemy_AddLife(bossObj, -1);
}

task texte1 {
	wait(60);
		DialogueText(90,158,"CONTROL",0,21,"... oh ?");
		wait(5);
		DialogueText(72,146,"CONTROL",0,21,"J'ai interrompus");
		wait(5);
		DialogueText(72,146,"CONTROL",0,21,"Pardon, je ne voulais pas");
		wait(5);
		DialogueText(72,146,"CONTROL",0,21,"Je vois, elle lui");
		wait(5);
		DialogueText(90,158,"CONTROL",0,21,"J'arrangerais ca");
		wait(5);
		DialogueText(72,146,"CONTROL",0,21,"Tu est courageux");
		wait(5);
		DialogueText(72,146,"CONTROL",0,21,"Profite de cette demo");
		wait(5);
		DialogueText(72,146,"CONTROL",0,21,"Il ce pourrait que nous nous");
}

task texte2 {
	wait(60);
		DialogueText(72,166,"CONTROL",0,21,"");
		wait(5);
		DialogueText(72,166,"CONTROL",0,21,"quelque chose ?");
		wait(5);
		DialogueText(72,166,"CONTROL",0,21,"intervenir maintenant");
		wait(5);
		DialogueText(72,166,"CONTROL",0,21,"restait 2 SpellCards");
		wait(5);
		DialogueText(72,166,"CONTROL",0,21,"");
		wait(5);
		DialogueText(72,166,"CONTROL",0,21,"n'es-ce pas ?");
		wait(5);
		DialogueText(72,166,"CONTROL",0,21,"pour t'entrainer");
		wait(5);
		DialogueText(72,166,"CONTROL",0,21,"rencontrerions plus tard");
}

task texte3 {
	wait(60);
		DialogueText(72,175,"CONTROL",0,21,"");
		wait(5);
		DialogueText(72,165,"CONTROL",0,21,"");
}

task TFinalize
{
	while (ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0) {yield;}
	wait(5);
	SetCommonData("bossX", ObjMove_GetX(bossObj));
	SetCommonData("bossY", ObjMove_GetY(bossObj));
	Obj_Delete(bossObj);
	DeleteShotAll(TYPE_ALL, TYPE_ITEM);
	SetAutoDeleteObject(true);
	CloseScript(GetOwnScriptID());
	return;
}



