本文整理汇总了C++中Heroes::GetKingdom方法的典型用法代码示例。如果您正苦于以下问题:C++ Heroes::GetKingdom方法的具体用法?C++ Heroes::GetKingdom怎么用?C++ Heroes::GetKingdom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Heroes
的用法示例。
在下文中一共展示了Heroes::GetKingdom方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ActionSpellIdentifyHero
bool ActionSpellIdentifyHero(Heroes & hero)
{
hero.GetKingdom().SetModes(Kingdom::IDENTIFYHERO);
Message("", _("Enemy heroes are now fully identifiable."), Font::BIG, Dialog::OK);
return true;
}
示例2: ActionSpellTownGate
bool ActionSpellTownGate(Heroes & hero)
{
const Kingdom & kingdom = hero.GetKingdom();
const KingdomCastles & castles = kingdom.GetCastles();
KingdomCastles::const_iterator it;
const Castle* castle = NULL;
const s32 center = hero.GetIndex();
s32 min = -1;
// find the nearest castle
for(it = castles.begin(); it != castles.end(); ++it) if(*it && !(*it)->GetHeroes().Guest())
{
const u16 min2 = Maps::GetApproximateDistance(center, (*it)->GetIndex());
if(0 > min || min2 < min)
{
min = min2;
castle = *it;
}
}
Interface::Basic & I = Interface::Basic::Get();
Cursor & cursor = Cursor::Get();
// center hero
cursor.Hide();
I.gameArea.SetCenter(hero.GetCenter());
GameFocus::SetRedraw();
I.Redraw();
if(!castle)
{
Dialog::Message("", _("No avaialble town. Spell Failed!!!"), Font::BIG, Dialog::OK);
return false;
}
return HeroesTownGate(hero, castle);
}
示例3: ArmyJoinWithCost
int Dialog::ArmyJoinWithCost(const Troop & troop, u32 join, u32 gold, Heroes & hero)
{
Display & display = Display::Get();
const Settings & conf = Settings::Get();
// cursor
Cursor & cursor = Cursor::Get();
int oldthemes = cursor.Themes();
cursor.Hide();
cursor.SetThemes(cursor.POINTER);
std::string message;
if(troop.GetCount() == 1)
message = _("The creature is swayed by your diplomatic tongue, and offers to join your army for the sum of %{gold} gold.\nDo you accept?");
else
{
message = _("The creatures are swayed by your diplomatic\ntongue, and make you an offer:\n \n");
if(join != troop.GetCount())
message += _("%{offer} of the %{total} %{monster} will join your army, and the rest will leave you alone, for the sum of %{gold} gold.\nDo you accept?");
else
message += _("All %{offer} of the %{monster} will join your army for the sum of %{gold} gold.\nDo you accept?");
}
StringReplace(message, "%{offer}", join);
StringReplace(message, "%{total}", troop.GetCount());
StringReplace(message, "%{monster}", StringLower(troop.GetPluralName(join)));
StringReplace(message, "%{gold}", gold);
TextBox textbox(message, Font::BIG, BOXAREA_WIDTH);
const int buttons = Dialog::YES | Dialog::NO;
const Sprite & sprite = AGG::GetICN(ICN::RESOURCE, 6);
int posy = 0;
Text text;
message = _("(Rate: %{percent})");
StringReplace(message, "%{percent}", troop.GetMonster().GetCost().gold * join * 100 / gold);
text.Set(message, Font::BIG);
FrameBox box(10 + textbox.h() + 10 + text.h() + 40 + sprite.h() + 10, buttons);
const Rect & pos = box.GetArea();
posy = pos.y + 10;
textbox.Blit(pos.x, posy);
posy += textbox.h() + 10;
text.Blit(pos.x + (pos.w - text.w()) / 2, posy);
posy += text.h() + 40;
sprite.Blit(pos.x + (pos.w - sprite.w()) / 2, posy);
TextSprite tsTotal(GetString(gold) + " " + "(" + "total: " + GetString(world.GetKingdom(hero.GetColor()).GetFunds().Get(Resource::GOLD)) + ")", Font::SMALL,
pos.x + (pos.w - text.w()) / 2, posy + sprite.h() + 5);
tsTotal.Show();
ButtonGroups btnGroups(pos, buttons);
Button btnMarket(pos.x + pos.w / 2 - 60 - 36, posy, (conf.ExtGameEvilInterface() ? ICN::ADVEBTNS : ICN::ADVBTNS), 4, 5);
Button btnHeroes(pos.x + pos.w / 2 + 60, posy, (conf.ExtGameEvilInterface() ? ICN::ADVEBTNS : ICN::ADVBTNS), 0, 1);
const Kingdom & kingdom = hero.GetKingdom();
if(! kingdom.AllowPayment(payment_t(Resource::GOLD, gold)))
btnGroups.DisableButton1(true);
TextSprite tsEnough;
if(kingdom.GetCountMarketplace())
{
if(kingdom.AllowPayment(payment_t(Resource::GOLD, gold)))
btnMarket.SetDisable(true);
else
{
std::string msg = _("Not enough gold (%{gold})");
StringReplace(msg, "%{gold}", gold - kingdom.GetFunds().Get(Resource::GOLD));
tsEnough.SetText(msg, Font::YELLOW_SMALL);
tsEnough.SetPos(btnMarket.x - 25, btnMarket.y - 17);
tsEnough.Show();
btnMarket.Draw();
}
}
if(hero.GetArmy().GetCount() < hero.GetArmy().Size() || hero.GetArmy().HasMonster(troop))
btnHeroes.SetDisable(true);
else
{
TextBox textbox2(_("Not room in\nthe garrison"), Font::SMALL, 100);
textbox2.Blit(btnHeroes.x - 35, btnHeroes.y - 30);
btnHeroes.Draw();
btnGroups.DisableButton1(true);
}
btnGroups.Draw();
cursor.Show();
display.Flip();
LocalEvent & le = LocalEvent::Get();
// message loop
//.........这里部分代码省略.........
示例4: ActionSpellTownPortal
bool ActionSpellTownPortal(Heroes & hero)
{
const Kingdom & kingdom = hero.GetKingdom();
std::vector<s32> castles;
Display & display = Display::Get();
Cursor & cursor = Cursor::Get();
LocalEvent & le = LocalEvent::Get();
cursor.Hide();
cursor.SetThemes(cursor.POINTER);
for(KingdomCastles::const_iterator it = kingdom.GetCastles().begin(); it != kingdom.GetCastles().end(); ++it)
if(*it && !(*it)->GetHeroes().Guest()) castles.push_back((**it).GetIndex());
if(castles.empty())
{
Dialog::Message("", _("No avaialble town. Spell Failed!!!"), Font::BIG, Dialog::OK);
return false;
}
const u16 window_w = 280;
const u16 window_h = 200;
Dialog::FrameBorder* frameborder = new Dialog::FrameBorder();
frameborder->SetPosition((display.w() - window_w) / 2 - BORDERWIDTH, (display.h() - window_h) / 2 - BORDERWIDTH, window_w, window_h);
frameborder->Redraw();
const Rect & area = frameborder->GetArea();
const Sprite & background = AGG::GetICN(ICN::STONEBAK, 0);
background.Blit(Rect(0, 0, window_w, window_h), area);
u16 result = Dialog::ZERO;
CastleIndexListBox listbox(area, result);
listbox.RedrawBackground(area);
listbox.SetScrollButtonUp(ICN::LISTBOX, 3, 4, Point(area.x + 256, area.y + 55));
listbox.SetScrollButtonDn(ICN::LISTBOX, 5, 6, Point(area.x + 256, area.y + 145));
listbox.SetScrollSplitter(AGG::GetICN(ICN::LISTBOX, 10), Rect(area.x + 261, area.y + 78, 14, 64));
listbox.SetAreaMaxItems(5);
listbox.SetAreaItems(Rect(area.x + 10, area.y + 60, 250, 100));
listbox.SetListContent(castles);
listbox.Redraw();
ButtonGroups btnGroups(area, Dialog::OK|Dialog::CANCEL);
btnGroups.Draw();
cursor.Show();
display.Flip();
while(result == Dialog::ZERO && le.HandleEvents())
{
result = btnGroups.QueueEventProcessing();
listbox.QueueEventProcessing();
if(!cursor.isVisible())
{
listbox.Redraw();
cursor.Show();
display.Flip();
}
}
delete frameborder;
// store
if(result == Dialog::OK)
return HeroesTownGate(hero, world.GetCastle(listbox.GetCurrent()));
return false;
}