示例#1
0
文件: Main.cpp 项目: dring1/COMP2404
int main()
{
	Controller *master = new Controller();
	cout << master->getList()->getSize()<<endl;
	for(int i = 0;i<50;i++){
		master->generate();
	}
	Node<Warrior> *temp = master->getList()->getFront();
	while(temp!=0)
	{
		Soldier *s = dynamic_cast<Soldier*>(temp->getData());
		if(s!=0) cout<<"Soldier!"<< s->getStrength()<<endl;
		Timmy *t = dynamic_cast<Timmy*>(temp->getData());
		if(t!=0) cout<<"Timmy"<< t->getStrength()<<endl;
		Pirate *p = dynamic_cast<Pirate*>(temp->getData());
		if(p!=0) cout<<"Pirate!"<< p->getStrength()<<endl;
		King *k = dynamic_cast<King*>(temp->getData());
		if(k!=0) cout<<"King!"<< k->getStrength()<<endl;
		Harold *h = dynamic_cast<Harold*>(temp->getData());
		if(h!=0) cout<<"Harold!"<< h->getStrength() <<endl;
		temp = temp->getNext();
	}
	cout << master->getList()->getSize()<<endl;
	

	return 0;

}
示例#2
0
/**
 * Update soldier stats when
 * the soldier changes.
 */
void SoldierInfoState::init()
{
	Soldier *s = _base->getSoldiers()->at(_soldier);
	_edtSoldier->setText(s->getName());

	SurfaceSet *texture = _game->getResourcePack()->getSurfaceSet("BASEBITS.PCK");
	texture->getFrame(s->getRankSprite())->setX(0);
	texture->getFrame(s->getRankSprite())->setY(0);
	texture->getFrame(s->getRankSprite())->blit(_rank);

	std::wstringstream ss;
	ss << s->getTimeUnits();
	_numTimeUnits->setText(ss.str());
	_barTimeUnits->setMax(s->getTimeUnits());
	_barTimeUnits->setValue(s->getTimeUnits());

	std::wstringstream ss2;
	ss2 << s->getStamina();
	_numStamina->setText(ss2.str());
	_barStamina->setMax(s->getStamina());
	_barStamina->setValue(s->getStamina());

	std::wstringstream ss3;
	ss3 << s->getHealth();
	_numHealth->setText(ss3.str());
	_barHealth->setMax(s->getHealth());
	_barHealth->setValue(s->getHealth());

	std::wstringstream ss4;
	ss4 << s->getBravery();
	_numBravery->setText(ss4.str());
	_barBravery->setMax(s->getBravery());
	_barBravery->setValue(s->getBravery());

	std::wstringstream ss5;
	ss5 << s->getReactions();
	_numReactions->setText(ss5.str());
	_barReactions->setMax(s->getReactions());
	_barReactions->setValue(s->getReactions());

	std::wstringstream ss6;
	ss6 << s->getFiringAccuracy();
	_numFiring->setText(ss6.str());
	_barFiring->setMax(s->getFiringAccuracy());
	_barFiring->setValue(s->getFiringAccuracy());

	std::wstringstream ss7;
	ss7 << s->getThrowingAccuracy();
	_numThrowing->setText(ss7.str());
	_barThrowing->setMax(s->getThrowingAccuracy());
	_barThrowing->setValue(s->getThrowingAccuracy());

	std::wstringstream ss8;
	ss8 << s->getStrength();
	_numStrength->setText(ss8.str());
	_barStrength->setMax(s->getStrength());
	_barStrength->setValue(s->getStrength());

	_txtArmor->setText(_game->getLanguage()->getString("STR_NONE_UC"));

	std::wstringstream ss9;
	ss9 << _game->getLanguage()->getString("STR_RANK_") << L'\x01' << _game->getLanguage()->getString(s->getRankString());
	_txtRank->setText(ss9.str());

	std::wstringstream ss10;
	ss10 << _game->getLanguage()->getString("STR_MISSIONS") << L'\x01' << s->getMissions();
	_txtMissions->setText(ss10.str());

	std::wstringstream ss11;
	ss11 << _game->getLanguage()->getString("STR_KILLS") << L'\x01' << s->getKills();
	_txtKills->setText(ss11.str());

	std::wstringstream ss12;
	ss12 << _game->getLanguage()->getString("STR_CRAFT_") << L'\x01';
	if (s->getCraft() == 0)
		ss12 << _game->getLanguage()->getString("STR_NONE");
	else
		ss12 << s->getCraft()->getName(_game->getLanguage());
	_txtCraft->setText(ss12.str());
}