#include "MainState.h"

MainState::MainState(GameWindow *win) : GameState(win, L"game")
{
}

MainState::~MainState(void)
{
}

void MainState::Initial()
{
	m_daram = new Daram(this);
	m_bullets = new BulletManager(this);
	m_time.Create(GetWindow()->GetGraphics(), L"µ¸¿ò", 12);
	m_timer.SetDelayValue(1000);
	m_elapsedTime = 0;
}

void MainState::Update(float dt)
{
	m_timer.Update(dt);
	if(m_timer.CheckDelay())
	{
		m_elapsedTime += 1;
		m_timer.ResetElapsedValue();
	}

	m_daram->Update(dt);
	m_bullets->Update(dt);
	if(m_bullets->Intersects(m_daram))
	{
		GetWindow()->GetStateManager().OutroState();
	}
}

void MainState::Draw(float dt)
{
	m_daram->Draw(dt);
	m_bullets->Draw(dt);

	wchar_t t[20] = {0,};
	wsprintf(t, L"½Ã°£ : %d", m_elapsedTime);
	m_time.Draw(0, 0, t);
}

void MainState::Destroy()
{
	m_time.Destroy();
	SAFE_DELETE(m_bullets);
	SAFE_DELETE(m_daram);
}