本文整理汇总了C++中Country::getUnits方法的典型用法代码示例。如果您正苦于以下问题:C++ Country::getUnits方法的具体用法?C++ Country::getUnits怎么用?C++ Country::getUnits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Country
的用法示例。
在下文中一共展示了Country::getUnits方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void UIManager::draw(sf::RenderWindow* target)
{
sf::Sprite mapSprite;
// this->mapController->update();
sf::Texture tex = this->mapController->getMapTexture();
mapSprite.setTexture(tex);
mapSprite.setPosition(xincrease,yincrease);
target->draw(mapSprite);
//draw the unit counts on the countries
//we know where the origins are for the demo
sf::Text unitCountText;
unitCountText.setFont(this->textFont);
unitCountText.setCharacterSize(34);
unitCountText.setColor(sf::Color(192,186,232));
unitCountText.setStyle(sf::Text::Bold);
//draw unit counts on countries
for (int c = 0; c < this->mapController->map->getContinents().size(); c++) {
Continent* continent = this->mapController->map->getContinents()[c];
for (int cu = 0; cu < continent->countries.size(); cu++) {
Country* country = continent->countries[cu];
int xPos = country->getXPosition() + xincrease + country->getCenterOffsetX();
int yPos = country->getYPosition() + yincrease + country->getCenterOffsetY();
unitCountText.setPosition(xPos, yPos);
std::stringstream ss;
ss << country->getUnits();
unitCountText.setString(ss.str().c_str());
target->draw(unitCountText);
}
}
//draw ui information
for(int i = 0; i < 2; i++) {
sf::Color c = mapController->playerColours[i];
if(turnController->activePlayer != i) {
int sub = 100;
c.r = (c.r-sub < 0) ? 0 : c.r-sub;
c.g = (c.g-sub < 0) ? 0 : c.g-sub;
c.b = (c.b-sub < 0) ? 0 : c.b-sub;
}
unitCountText.setColor(c);
unitCountText.setCharacterSize(46);
int x = (i*(900+xincrease)+xincrease/2-100);
std::stringstream uistring;
uistring << "Player " << i+1;
unitCountText.setString(uistring.str().c_str());
unitCountText.setPosition(x,yincrease);
target->draw(unitCountText);
unitCountText.setCharacterSize(33);
unitCountText.setPosition(x,yincrease+80);
std::stringstream incomestring;
incomestring << "Income: " << shopController->getPlayerIncome(turnController->playerList[i]);
unitCountText.setString(incomestring.str().c_str());
target->draw(unitCountText);
unitCountText.setPosition(x,yincrease+120);
std::stringstream unitstream;
if(turnController->playerList[i]->income == -1) {
if ( turnController->activePlayer != i) {
unitstream << "Stored Units: " << 0;
} else {
unitstream << "Stored Units: " << shopController->getPlayerIncome(turnController->playerList[i]);
}
} else {
unitstream << "Stored Units: " << turnController->playerList[i]->income;
}
unitCountText.setString(unitstream.str().c_str());
target->draw(unitCountText);
}
}