//	PickupFreeze.cpp - Freeze Pickup.
//  ----------------------------------------------------------------------------
//	This file is part of 'GameTemplate', template code for a game.
//	Copyright (C) 2011  Niall Moody
//	
//	This program is free software: you can redistribute it and/or modify
//	it under the terms of the GNU General Public License as published by
//	the Free Software Foundation, either version 3 of the License, or
//	(at your option) any later version.
//
//	This program is distributed in the hope that it will be useful,
//	but WITHOUT ANY WARRANTY; without even the implied warranty of
//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//	GNU General Public License for more details.
//
//	You should have received a copy of the GNU General Public License
//	along with this program.  If not, see <http://www.gnu.org/licenses/>.
//	----------------------------------------------------------------------------

#include "drawing/Drawer.h"
#include "PickupFreeze.h"
#include "DebugHeaders.h"
#include "GameCounter.h"
#include "../Tone.h"

#include <sstream>

using namespace std;

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
PickupFreeze::PickupFreeze():
Pickup(L"Freeze")
{

}

//------------------------------------------------------------------------------
PickupFreeze::~PickupFreeze()
{

}

//------------------------------------------------------------------------------
shared_ptr<OverrideBehaviour> PickupFreeze::getBehaviour() const
{
	return shared_ptr<OverrideBehaviour>(NiallNew BehaviourFreeze(L"pickup-freeze"));
}

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
BehaviourFreeze::BehaviourFreeze(const wstring& icon):
OverrideBehaviour(icon),
pickupIcon(icon),
counter(30.0f*10.0f)
{

}

//------------------------------------------------------------------------------
BehaviourFreeze::~BehaviourFreeze()
{

}

//------------------------------------------------------------------------------
bool BehaviourFreeze::moveTone(Tone& tone,
							   std::vector<TonePtr>& allTones,
							   float globalSpeed)
{
	bool retval = false;

	counter -= 1.0f;
	if(counter <= 0.0f)
		retval = true;

	return retval;
}

//------------------------------------------------------------------------------
void BehaviourFreeze::drawExtraInformation(DrawerPtr& d,
										   float timestepInterp,
										   const Tone& tone)
{
	wstringstream tempstr;

	//Draw the icon.
	d->drawImage(pickupIcon, tone.position-64);

	//Draw the countdown.
	tempstr << (int)(counter/30)+1;
	d->drawText(tempstr.str(),
				L"Font1",
				TwoFloats(tone.position.x-32.0f, tone.position.y-34),
				64.0f,
				TextLayout::Centre,
				1.33f,
				ThreeFloats(0.5f));
}
