#include "CS_CurlyAir.h"
#include "CS_Curly.h"
const int CS_CurlySTATENAME_AIR = GetNextEntityStateID();
CS_CurlyAir::CS_CurlyAir()
{
	stateID = CS_CurlySTATENAME_AIR;
}

void CS_CurlyAir::SetAir(int index)
{
	auto we = e.lock();
	if (!we)
		return;
	//ÉèÖÃ¶¯»­
	const wchar_t* jump = L"";
	if (we->ud == -1)
		jump = we->lr == 0 ? L"mc_curly_jump_lu" : L"mc_curly_jump_ru";
	else if (we->ud == 0)
		jump = we->lr == 0 ? L"mc_curly_jump_l" : L"mc_curly_jump_r";
	else if (we->ud == 1)
		jump = we->lr == 0 ? L"mc_curly_jump_ld" : L"mc_curly_jump_rd";
	we->ani.sprite_index = jump;
	we->ani.image_index = index;
}

void CS_CurlyAir::State()
{
	auto we = e.lock();
	if (!we)
		return;

	auto mychar = std::static_pointer_cast<CS_Curly>(we);
	if (mychar->fishState)
	{
		const wchar_t* move = L"";
		if (we->ud == -1)
			move = we->lr == 0 ? L"mc_curlyfish_swim_lu" : L"mc_curlyfish_swim_ru";
		else if (we->ud == 0)
			move = we->lr == 0 ? L"mc_curlyfish_swim_l" : L"mc_curlyfish_swim_r";
		else if (we->ud == 1)
			move = we->lr == 0 ? L"mc_curlyfish_swim_ld" : L"mc_curlyfish_swim_rd";
		we->ani.sprite_index = move;
	}
	else
	{
		if (we->vy < 0)
			SetAir(0);
		else
			SetAir(1);
	}
}

void CS_CurlyAir::ChangeStateMsg(int stateID)
{
	if (stateID == GetStateID())
		enable = true;
	else
		enable = false;
}
