#include "CS_PeFireworks.h"
#include "CS_PeFireworksBomb.h"
CS_PeFireworks::CS_PeFireworks()
{
	type = 3;
	shoot_counter_max = Random(240, 300);//随机发射时间间隔
	shoot_counter = Random(0, 240);
}

void CS_PeFireworks::Step()
{
	if (shoot_counter > 0)
	{
		shoot_counter--;
		if (shoot_counter == 0)
		{
			shoot_counter = shoot_counter_max;
			//随机发射调度
			float radian = (270 + Random(-5, 5)) * deg2rad;
			float dirX = cosf(radian);
			float dirY = sinf(radian);
			SetCS_PeFireworksBomb(shared_from_this(), x, y, dirX, dirY);
		}
	}
}

std::shared_ptr<Entity> CreateCS_PeFireworks()
{
	return std::make_shared<CS_PeFireworks>();
}
