#include "PeSplash.h"
#include "PeSpray.h"
PeSplash::PeSplash()
{
	type = 3;
	//贴图
	ani.png = L"water";
	ani.sprite_index = L"splash";
}

void PeSplash::Step()
{
	//产生小水花
	if (bSetSpray1)
	{
		gameFunc->PlaySound(L"Splash");
		bSetSpray1 = false;
		int num = Random(10, 20);
		for (auto i = 0; i < num; i++)
		{
			auto e = std::make_shared<PeSpray>();
			e->x = x;
			e->y = y;
			e->color = color;
			gameFunc->SetEntity(shared_from_this(), e);
		}
	}
	//在第14帧产生小水花
	if (bSetSpray2 && ani.image_index == 14)
	{
		bSetSpray2 = false;
		int num = Random(3, 5);
		for (auto i = 0; i < num; i++)
		{
			auto e = std::make_shared<PeSpray>();
			e->x = x;
			e->y = y;
			e->color = color;
			gameFunc->SetEntity(shared_from_this(), e);
		}
	}
	//消失
	if (ani.image_index >= 27)
		Destroy();
}

std::shared_ptr<Entity> CreatePeSplash()
{
	return std::make_shared<PeSplash>();
}
