#include "Data/Levels/Common/Tutorial/Scripts/DialogsFades.bhass"
#include "Data/Levels/Common/Tutorial/Scripts/PatchFades.bhass"
#include "Data/Levels/Common/Tutorial/Scripts/SkinFades.bhass"
#include "Data/Levels/Common/Tutorial/Scripts/Utilities.bhass"

CTutorial@ pTutorial;
CLocalizer@ pLocalizer;
CGameText@ pText;
CFloat2 vLeftPosition;
CFloat2 vRightPosition;
CGameSkin@ pMarvin;
CGameSkin@ pBarney;
CGameSkin@ pHeather;
CGameText@ pLeftNameBlack;
CGameText@ pRightNameBlack;
CGameText@ pLeftNameWhite;
CGameText@ pRightNameWhite;
uint64 musicID;

//------------------------------------------------ Init/Release ---------------------------------------------------
void InitTutorial()
{
    @pTutorial = GetGame().GetCurrentLevel().GetTutorial();
    @pLocalizer = GetGame().GetLocalizer();
    @pText = pTutorial.GetGameText("Text");
    vLeftPosition.x = -350.0f;
    vLeftPosition.y = 250.0f;
    vRightPosition.x = 350.0f;
    vRightPosition.y = 250.0f;
	@pLeftNameBlack = pTutorial.GetGameText("LeftNameBlack");
    @pRightNameBlack = pTutorial.GetGameText("RightNameBlack");
	@pLeftNameWhite = pTutorial.GetGameText("LeftNameWhite");
    @pRightNameWhite = pTutorial.GetGameText("RightNameWhite");
    @pMarvin = cast<CGameSkin>(pTutorial.GetGameObject("Marvin"));
    @pBarney = cast<CGameSkin>(pTutorial.GetGameObject("Barney"));
	@pHeather = cast<CGameSkin>(pTutorial.GetGameObject("Heather"));
	ChangeSkinAnimation(pHeather, "Data/Levels/Chars/Heather/Poses/A_HeatherWorriedRight.ahsanimation");
	ChangeSkinAnimation(pMarvin, "Data/Levels/Chars/Marvin/Poses/A_MarvinRobotRight.ahsanimation");
	ChangeSkinAnimation(pBarney, "Data/Levels/Chars/Barney/Poses/A_BarneyNormalLeft.ahsanimation");
	musicID = PlayMusic("Data/Musics/Stress.ogg", true);
}

void ReleaseTutorial()
{
	StopMusic(musicID, 0.5f);
}

//------------------------------------------------ Fade Chars ---------------------------------------------------
void FadeInBarneyLeftMarvinRightEnter()	
{	
	pBarney.SetPosition(vLeftPosition);
	pMarvin.SetPosition(vRightPosition);
	FadeInSkinEnter(pBarney);
	FadeInSkinEnter(pMarvin);
}	
void FadeInBarneyLeftMarvinRightUpdate(float _Delta)	
{	
	FadeInSkinUpdate(pBarney);
	FadeInSkinUpdate(pMarvin);
}	

void FadeOutMarvinRightEnter()	
{	
	pMarvin.SetPosition(vRightPosition);
	FadeOutSkinEnter(pMarvin);
}	
void FadeOutMarvinUpdate()	
{	
	FadeOutSkinUpdate(pMarvin);
}	

void FadeInHeatherRightEnter()	
{	
	pHeather.SetPosition(vRightPosition);
	FadeInSkinEnter(pHeather);
}	
void FadeInHeatherUpdate()	
{	
	FadeInSkinUpdate(pHeather);
}	


//------------------------------------------------ Script Functions ---------------------------------------------------
void HideText()
{
    pText.SetText("");
}

void EnterSaucer_6_100()
{
	pText.SetVisible(true);
	ChangeSkinAnimation(pBarney, "Data/Levels/Chars/Barney/Poses/A_BarneyNormalLeft.ahsanimation");
	ChangeSkinAnimation(pMarvin, "Data/Levels/Chars/Marvin/Poses/A_MarvinRobotRight.ahsanimation");
	pLeftNameBlack.SetVisible(true);
	pLeftNameWhite.SetVisible(true);
	pLeftNameBlack.SetText(GetGame().GetLocalizer().LocalizeText("BARNEY_NAMETAG"));
	pLeftNameWhite.SetText(GetGame().GetLocalizer().LocalizeText("BARNEY_NAMETAG"));
		pRightNameBlack.SetVisible(true);
	pRightNameWhite.SetVisible(true);
	pRightNameBlack.SetText(GetGame().GetLocalizer().LocalizeText("MRV42-MK-I_NAMETAG"));
	pRightNameWhite.SetText(GetGame().GetLocalizer().LocalizeText("MRV42-MK-I_NAMETAG"));

	pText.SetText(pLocalizer.LocalizeText("SAUCER_6_100"));
}

void ExitSaucer_6_100()
{
	pText.SetText("");
}

void EnterSaucer_6_200()
{
	pText.SetText(pLocalizer.LocalizeText("SAUCER_6_200"));
}

void ExitSaucer_6_200()
{
	pText.SetText("");
}

void EnterSaucer_6_300()
{
	pRightNameBlack.SetText("");
	pRightNameWhite.SetText("");
pText.SetText(pLocalizer.LocalizeText("SAUCER_6_300"));
}

void ExitSaucer_6_300()
{
	pText.SetText("");
}

void EnterSaucer_6_400()
{
	ChangeSkinAnimation(pBarney, "Data/Levels/Chars/Barney/Poses/A_BarneyNormalLeft.ahsanimation");
	ChangeSkinAnimation(pHeather, "Data/Levels/Chars/Heather/Poses/A_HeatherWorriedRight.ahsanimation");
	pHeather.SetVisible(true);
	pHeather.SetPosition(vRightPosition);
	pLeftNameBlack.SetVisible(true);
	pLeftNameWhite.SetVisible(true);
	pLeftNameBlack.SetText(GetGame().GetLocalizer().LocalizeText("BARNEY_NAMETAG"));
	pLeftNameWhite.SetText(GetGame().GetLocalizer().LocalizeText("BARNEY_NAMETAG"));
		pRightNameBlack.SetVisible(true);
	pRightNameWhite.SetVisible(true);
	pRightNameBlack.SetText(GetGame().GetLocalizer().LocalizeText("HEATHER_NAMETAG"));
	pRightNameWhite.SetText(GetGame().GetLocalizer().LocalizeText("HEATHER_NAMETAG"));

	pText.SetText(pLocalizer.LocalizeText("SAUCER_6_400"));
}

void ExitSaucer_6_400()
{
	pText.SetText("");
}

void EnterSaucer_6_500()
{
	ChangeSkinAnimation(pBarney, "Data/Levels/Chars/Barney/Poses/A_BarneyNormalLeft.ahsanimation");
	pLeftNameBlack.SetVisible(true);
	pLeftNameWhite.SetVisible(true);
	pLeftNameBlack.SetText(GetGame().GetLocalizer().LocalizeText("BARNEY_NAMETAG"));
	pLeftNameWhite.SetText(GetGame().GetLocalizer().LocalizeText("BARNEY_NAMETAG"));

	pText.SetText(pLocalizer.LocalizeText("SAUCER_6_500"));
}

void ExitSaucer_6_500()
{
	pText.SetText("");
}

void EnterSaucer_6_600()
{
	pText.SetText(pLocalizer.LocalizeText("SAUCER_6_600"));
}

void ExitSaucer_6_600()
{
	pText.SetText("");
}

void EnterSaucer_6_700()
{
	ChangeSkinAnimation(pBarney, "Data/Levels/Chars/Barney/Poses/A_BarneyNormalLeft.ahsanimation");
	pLeftNameBlack.SetVisible(true);
	pLeftNameWhite.SetVisible(true);
	pLeftNameBlack.SetText(GetGame().GetLocalizer().LocalizeText("BARNEY_NAMETAG"));
	pLeftNameWhite.SetText(GetGame().GetLocalizer().LocalizeText("BARNEY_NAMETAG"));

	pText.SetText(pLocalizer.LocalizeText("SAUCER_6_700"));
}


void EnterSaucer_6_800()
{
	pText.SetText(pLocalizer.LocalizeText("SAUCER_6_800"));
}

void ExitSaucer_6_800()
{
	pText.SetText("");
}

void EnterSaucer_6_900()
{
	pText.SetText(pLocalizer.LocalizeText("SAUCER_6_900"));
}


void EnterSaucer_6_1000()
{
	ChangeSkinAnimation(pHeather, "Data/Levels/Chars/Heather/Poses/A_HeatherCuteRight.ahsanimation");
	pText.SetText(pLocalizer.LocalizeText("SAUCER_6_1000"));
}

void ExitSaucer_6_1000()
{
	pText.SetText("");
}
