#include "CS_CurlyMove.h"
#include "CS_Curly.h"
const int CS_CurlySTATENAME_MOVE = ++entityStateID;
CS_CurlyMove::CS_CurlyMove()
{
	stateID = CS_CurlySTATENAME_MOVE;
}

void CS_CurlyMove::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
	{
		const wchar_t* move = L"";
		if (we->ud == -1)
			move = we->lr == 0 ? L"mc_curly_move_lu" : L"mc_curly_move_ru";
		else
			move = we->lr == 0 ? L"mc_curly_move_l" : L"mc_curly_move_r";
		we->ani.sprite_index = move;
		if ((we->ani.image_index == 1 || we->ani.image_index == 3) && playWalkSound)
		{
			we->gameFunc->PlaySound(L"CS_024_quote_walk");
			playWalkSound = false;
		}
		if (we->ani.image_index == 0 || we->ani.image_index == 2)
			playWalkSound = true;
	}
}

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