#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;
CGameSkin@ pSkybird;
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"));
    @pHeather = cast<CGameSkin>(pTutorial.GetGameObject("Heather"));
	@pSkybird = cast<CGameSkin>(pTutorial.GetGameObject("Skybird"));
    ChangeSkinAnimation(pMarvin, "Data/Levels/Chars/Marvin/Poses/A_MarvinBlaseLeft.ahsanimation");
    ChangeSkinAnimation(pHeather, "Data/Levels/Chars/Heather/Poses/A_HeatherNormalLeft.ahsanimation");
	ChangeSkinAnimation(pSkybird, "Data/Levels/Chars/Skybird/Poses/A_SkybirdNormalRight.ahsanimation");
	musicID = PlayMusic("Data/Musics/Upgrade.ogg", true);
}

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

//------------------------------------------------ Fade Chars ---------------------------------------------------
void FadeInMarvinLeftSkybirdRightEnter()
{
    pMarvin.SetPosition(vLeftPosition);
	pSkybird.SetPosition(vRightPosition);
    FadeInSkinEnter(pMarvin);
	FadeInSkinEnter(pSkybird);
}

void FadeInMarvinLeftSkybirdRightUpdate()
{
    FadeInSkinUpdate(pMarvin);
	FadeInSkinUpdate(pSkybird);
}

void FadeInHeatherLeftEnter()
{
    pHeather.SetPosition(vLeftPosition);
    FadeInSkinEnter(pHeather);
}

void FadeInHeatherUpdate()
{
    FadeInSkinUpdate(pHeather);
}

void FadeInSkybirdRightEnter()
{
    pSkybird.SetPosition(vRightPosition);
    FadeInSkinEnter(pSkybird);
}

void FadeInSkybirdUpdate()
{
    FadeInSkinUpdate(pSkybird);
}

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

void EnterSky_3_100()
{
	pText.SetVisible(true);
	ChangeSkinAnimation(pMarvin, "Data/Levels/Chars/Marvin/Poses/A_MarvinBlaseLeft.ahsanimation");
	ChangeSkinAnimation(pSkybird, "Data/Levels/Chars/Skybird/Poses/A_SkybirdNormalRight.ahsanimation");
	pLeftNameBlack.SetVisible(true);
	pLeftNameWhite.SetVisible(true);
	pLeftNameBlack.SetText(GetGame().GetLocalizer().LocalizeText("MARVIN_NAMETAG"));
	pLeftNameWhite.SetText(GetGame().GetLocalizer().LocalizeText("MARVIN_NAMETAG"));
		pRightNameBlack.SetVisible(true);
	pRightNameWhite.SetVisible(true);
	pRightNameBlack.SetText(GetGame().GetLocalizer().LocalizeText("UNKNOWN_NAMETAG"));
	pRightNameWhite.SetText(GetGame().GetLocalizer().LocalizeText("UNKNOWN_NAMETAG"));

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


void EnterSky_3_200()
{
	ChangeSkinAnimation(pHeather, "Data/Levels/Chars/Heather/Poses/A_HeatherCuteLeft.ahsanimation");
	pMarvin.SetVisible(false);
	pHeather.SetVisible(true);
	pHeather.SetPosition(vLeftPosition);
	pLeftNameBlack.SetVisible(true);
	pLeftNameWhite.SetVisible(true);
	pLeftNameBlack.SetText(GetGame().GetLocalizer().LocalizeText("HEATHER_NAMETAG"));
	pLeftNameWhite.SetText(GetGame().GetLocalizer().LocalizeText("HEATHER_NAMETAG"));

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

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

void EnterSky_3_300()
{
	ChangeSkinAnimation(pHeather, "Data/Levels/Chars/Heather/Poses/A_HeatherNormalLeft.ahsanimation");
	pText.SetText(pLocalizer.LocalizeText("SKY_3_300"));
}

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

void EnterSky_3_400()
{
	pText.SetText(pLocalizer.LocalizeText("SKY_3_400"));
}

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

void EnterSky_3_500()
{
	pText.SetText(pLocalizer.LocalizeText("SKY_3_500"));
}

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

void EnterSky_3_600()
{
	pText.SetText(pLocalizer.LocalizeText("SKY_3_600"));
}

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

void EnterSky_3_700()
{
	pText.SetText(pLocalizer.LocalizeText("SKY_3_700"));
}

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

void EnterSky_3_800()
{
	ChangeSkinAnimation(pHeather, "Data/Levels/Chars/Heather/Poses/A_HeatherCuteLeft.ahsanimation");
	pText.SetText(pLocalizer.LocalizeText("SKY_3_800"));
}

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

void EnterSky_3_900()
{
	pText.SetText(pLocalizer.LocalizeText("SKY_3_900"));
}

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