本文整理汇总了C++中Heroes类的典型用法代码示例。如果您正苦于以下问题:C++ Heroes类的具体用法?C++ Heroes怎么用?C++ Heroes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Heroes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SpriteFlag
Sprite SpriteFlag(const Heroes & hero, int index, bool reflect, bool rotate)
{
int icn_flag = ICN::UNKNOWN;
int index_sprite = 0;
switch(hero.GetColor())
{
case Color::BLUE: icn_flag = hero.isShipMaster() ? ICN::B_BFLG32 : ICN::B_FLAG32; break;
case Color::GREEN: icn_flag = hero.isShipMaster() ? ICN::G_BFLG32 : ICN::G_FLAG32; break;
case Color::RED: icn_flag = hero.isShipMaster() ? ICN::R_BFLG32 : ICN::R_FLAG32; break;
case Color::YELLOW: icn_flag = hero.isShipMaster() ? ICN::Y_BFLG32 : ICN::Y_FLAG32; break;
case Color::ORANGE: icn_flag = hero.isShipMaster() ? ICN::O_BFLG32 : ICN::O_FLAG32; break;
case Color::PURPLE: icn_flag = hero.isShipMaster() ? ICN::P_BFLG32 : ICN::P_FLAG32; break;
default: DEBUG(DBG_GAME, DBG_WARN, "unknown color"); break;
}
if(rotate) index_sprite = 45;
else
switch(hero.GetDirection())
{
case Direction::TOP: index_sprite = 0; break;
case Direction::TOP_RIGHT: index_sprite = 9; break;
case Direction::RIGHT: index_sprite = 18; break;
case Direction::BOTTOM_RIGHT: index_sprite = 27; break;
case Direction::BOTTOM: index_sprite = 36; break;
case Direction::BOTTOM_LEFT: index_sprite = 27; break;
case Direction::LEFT: index_sprite = 18; break;
case Direction::TOP_LEFT: index_sprite = 9; break;
default: DEBUG(DBG_GAME, DBG_WARN, "unknown direction"); break;
}
return AGG::GetICN(icn_flag, index_sprite + (index % 9), reflect);
}
示例2: while
void AI::HeroesTurn(Heroes & hero)
{
Interface::StatusWindow *status = Interface::NoGUI() ? NULL : &Interface::StatusWindow::Get();
hero.ResetModes(HEROES_MOVED);
while(AI::HeroesCanMove(hero))
{
// turn indicator
if(status) status->RedrawTurnProgress(3);
if(status) status->RedrawTurnProgress(4);
// get task for heroes
AI::HeroesGetTask(hero);
// turn indicator
if(status) status->RedrawTurnProgress(5);
if(status) status->RedrawTurnProgress(6);
// heroes AI turn
AI::HeroesMove(hero);
hero.SetModes(HEROES_MOVED);
// turn indicator
if(status) status->RedrawTurnProgress(7);
if(status) status->RedrawTurnProgress(8);
}
DEBUG(DBG_AI, DBG_TRACE, hero.GetName() << ", end");
}
示例3: GetFocusHeroes
void Interface::Basic::EventDefaultAction(void)
{
Heroes* hero = GetFocusHeroes();
if(hero)
{
const Maps::Tiles & tile = world.GetTiles(hero->GetIndex());
// 1. action object
if(MP2::isActionObject(hero->GetMapsObject(), hero->isShipMaster()) &&
(! MP2::isMoveObject(hero->GetMapsObject()) || hero->CanMove()))
{
hero->Action(hero->GetIndex());
if(MP2::OBJ_STONELIGHTS == tile.GetObject(false) || MP2::OBJ_WHIRLPOOL == tile.GetObject(false))
SetRedraw(REDRAW_HEROES);
SetRedraw(REDRAW_GAMEAREA);
}
else
// 2. continue
if(hero->GetPath().isValid())
hero->SetMove(true);
else
// 3. hero dialog
Game::OpenHeroesDialog(*hero);
}
else
// 4. town dialog
if(GetFocusCastle())
{
Game::OpenCastleDialog(*GetFocusCastle());
}
}
示例4: GetRandomHeroesPosition
s32 GetRandomHeroesPosition(Heroes & hero, u32 scoute)
{
Maps::Indexes v = Maps::GetAroundIndexes(hero.GetIndex(), scoute, true);
Maps::Indexes res;
v.resize(std::distance(v.begin(),
std::remove_if(v.begin(), v.end(), std::ptr_fun(&Maps::TileIsUnderProtection))));
#if defined(ANDROID)
const MapsIndexes::const_reverse_iterator crend = v.rend();
for(MapsIndexes::const_reverse_iterator
it = v.rbegin(); it != crend && res.size() < 4; ++it)
#else
for(MapsIndexes::const_reverse_iterator
it = v.rbegin(); it != v.rend() && res.size() < 4; ++it)
#endif
{
if(world.GetTiles(*it).isPassable(&hero, Direction::CENTER, true) &&
hero.GetPath().Calculate(*it))
res.push_back(*it);
}
const s32 result = res.size() ? *Rand::Get(res) : -1;
if(0 <= result)
{
DEBUG(DBG_AI, DBG_INFO, Color::String(hero.GetColor()) <<
", hero: " << hero.GetName() << ", added task: " << result);
}
return result;
}
示例5: DEBUG
void AI::HeroesTurn(Heroes & hero)
{
DEBUG(DBG_AI, DBG_TRACE, hero.GetName() << ", start: " <<
(hero.Modes(Heroes::SHIPMASTER) ? "SHIPMASTER," : "") <<
(hero.Modes(AI::HEROES_SCOUTER) ? "SCOUTER," : "") <<
(hero.Modes(AI::HEROES_HUNTER) ? "HUNTER," : "") <<
(hero.Modes(Heroes::PATROL) ? "PATROL," : "") <<
(hero.Modes(AI::HEROES_WAITING) ? "WAITING," : "") <<
(hero.Modes(AI::HEROES_STUPID) ? "STUPID" : ""));
Interface::StatusWindow & status = Interface::Basic::Get().GetStatusWindow();
while(hero.MayStillMove() &&
!hero.Modes(AI::HEROES_WAITING|AI::HEROES_STUPID))
{
// turn indicator
status.RedrawTurnProgress(3);
// get task for heroes
AI::HeroesGetTask(hero);
// turn indicator
status.RedrawTurnProgress(5);
// heroes AI turn
AI::HeroesMove(hero);
// turn indicator
status.RedrawTurnProgress(7);
}
DEBUG(DBG_AI, DBG_TRACE, hero.GetName() << ", end");
}
示例6: ActionSpellSetGuardian
bool ActionSpellSetGuardian(Heroes & hero, const Spell & spell, u8 id)
{
Maps::Tiles & tile = world.GetTiles(hero.GetIndex());
if(MP2::OBJ_MINES != tile.GetObject(false))
{
Dialog::Message("", _("You must be standing on the entrance to a mine (sawmills and alchemists don't count) to cast this spell."), Font::BIG, Dialog::OK);
return false;
}
const u16 count = hero.GetPower() * spell.ExtraValue();
if(count)
{
Maps::TilesAddon* addon = tile.FindObject(MP2::OBJ_MINES);
if(addon)
addon->tmp = spell();
if(spell == Spell::HAUNT)
{
world.CaptureObject(tile.GetIndex(), Color::UNUSED);
tile.SetObject(MP2::OBJ_ABANDONEDMINE);
}
Army::Troop troop = world.GetCapturedObject(tile.GetIndex()).GetTroop();
troop.Set(Monster(spell), count);
}
return false;
}
示例7: Init
void Init(Heroes* ptr)
{
hero = ptr;
Clear();
armyBar = new ArmyBar(&hero->GetArmy(), true, false);
armyBar->SetBackground(41, 53, 0x82);
armyBar->SetColRows(5, 1);
armyBar->SetHSpace(-1);
artifactsBar = new ArtifactsBar(hero, true, false);
artifactsBar->SetColRows(7, 2);
artifactsBar->SetHSpace(1);
artifactsBar->SetVSpace(8);
artifactsBar->SetContent(hero->GetBagArtifacts());
secskillsBar = new SecondarySkillsBar();
secskillsBar->SetColRows(4, 2);
secskillsBar->SetHSpace(-1);
secskillsBar->SetVSpace(8);
secskillsBar->SetContent(hero->GetSecondarySkills());
primskillsBar = new PrimarySkillsBar(ptr, true);
primskillsBar->SetColRows(4, 1);
primskillsBar->SetHSpace(2);
primskillsBar->SetTextOff(20, -13);
}
示例8: ActionSpellSummonBoat
bool ActionSpellSummonBoat(Heroes & hero)
{
u8 chance = 0;
switch(hero.GetLevelSkill(Skill::Secondary::WISDOM))
{
case Skill::Level::BASIC:
chance = 50;
break;
case Skill::Level::ADVANCED:
chance = 75;
break;
case Skill::Level::EXPERT:
chance = 100;
break;
default:
chance = 30;
break;
}
const s32 center = hero.GetIndex();
// find water
s32 dst_water = -1;
const MapsIndexes & v = Maps::ScanAroundObject(center, MP2::OBJ_ZERO);
for(MapsIndexes::const_iterator
it = v.begin(); it != v.end(); ++it)
{
if(world.GetTiles(*it).isWater()) {
dst_water = *it;
break;
}
}
const MapsIndexes & boats = Maps::GetObjectPositions(center, MP2::OBJ_BOAT, false);
if(boats.empty())
{
DEBUG(DBG_GAME, DBG_WARN, "free boat: " << "not found");
}
else
{
const s32 & src = boats.front();
if(Rand::Get(1, 100) <= chance &&
Maps::isValidAbsIndex(src) && Maps::isValidAbsIndex(dst_water))
{
world.GetTiles(src).SetObject(MP2::OBJ_ZERO);
world.GetTiles(dst_water).SetObject(MP2::OBJ_BOAT);
}
else
DialogSpellFailed(Spell::SUMMONBOAT);
}
return true;
}
示例9: ApplyPlayWithStartingHero
void Kingdom::ApplyPlayWithStartingHero(void)
{
if(isPlay() && castles.size())
{
// get first castle
Castle* first = castles.GetFirstCastle();
if(NULL == first) first = castles.front();
// check manual set hero (castle position + point(0, 1))?
const Point & cp = (first)->GetCenter();
Heroes* hero = world.GetTiles(cp.x, cp.y + 1).GetHeroes();
// and move manual set hero to castle
if(hero && hero->GetColor() == GetColor())
{
bool patrol = hero->Modes(Heroes::PATROL);
hero->SetFreeman(0);
hero->Recruit(*first);
if(patrol)
{
hero->SetModes(Heroes::PATROL);
hero->SetCenterPatrol(cp);
}
}
else
if(Settings::Get().GameStartWithHeroes())
{
Heroes* hero = world.GetFreemanHeroes(first->GetRace());
if(hero && AllowRecruitHero(false, 0)) hero->Recruit(*first);
}
}
}
示例10: AIHeroesPriorityObject
// get priority object for AI independent of distance (1 day)
bool AIHeroesPriorityObject(const Heroes & hero, s32 index)
{
Maps::Tiles & tile = world.GetTiles(index);
if(MP2::OBJ_CASTLE == tile.GetObject())
{
const Castle* castle = world.GetCastle(Maps::GetPoint(index));
if(castle)
{
if(hero.GetColor() == castle->GetColor())
{
// maybe need join army
return hero.Modes(AI::HEROES_HUNTER) &&
castle->GetArmy().isValid() &&
! hero.isVisited(world.GetTiles(castle->GetIndex()));
}
else
if(! hero.isFriends(castle->GetColor()))
return AI::HeroesValidObject(hero, index);
}
}
else
if(MP2::OBJ_HEROES == tile.GetObject())
{
// kill enemy hero
const Heroes* hero2 = tile.GetHeroes();
return hero2 &&
! hero.isFriends(hero2->GetColor()) &&
AI::HeroesValidObject(hero, index);
}
switch(tile.GetObject())
{
case MP2::OBJ_MONSTER:
case MP2::OBJ_SAWMILL:
case MP2::OBJ_MINES:
case MP2::OBJ_ALCHEMYLAB:
case MP2::OBJ_ARTIFACT:
case MP2::OBJ_RESOURCE:
case MP2::OBJ_CAMPFIRE:
case MP2::OBJ_TREASURECHEST:
return AI::HeroesValidObject(hero, index);
default: break;
}
return false;
}
示例11: ActionSpellIdentifyHero
bool ActionSpellIdentifyHero(Heroes & hero)
{
world.GetKingdom(hero.GetColor()).SetModes(Kingdom::IDENTIFYHERO);
Message("", _("Enemy heroes are now fully identifiable."), Font::BIG, Dialog::OK);
return true;
}
示例12: isNeedStayFrontObject
bool isNeedStayFrontObject(const Heroes & hero, const Maps::Tiles & next)
{
if(next.GetObject() == MP2::OBJ_CASTLE)
{
const Castle* castle = world.GetCastle(next.GetCenter());
return (castle &&
! hero.isFriends(castle->GetColor()));
}
else
// to coast action
if(hero.isShipMaster() &&
next.GetObject() == MP2::OBJ_COAST)
return true;
return MP2::isNeedStayFront(next.GetObject());
}
示例13: HeroesTownGate
bool HeroesTownGate(Heroes & hero, const Castle* castle)
{
if(castle)
{
Interface::Basic & I = Interface::Basic::Get();
const s32 src = hero.GetIndex();
const s32 dst = castle->GetIndex();
if(!Maps::isValidAbsIndex(src) || !Maps::isValidAbsIndex(dst))
return false;
AGG::PlaySound(M82::KILLFADE);
hero.GetPath().Hide();
hero.FadeOut();
Cursor::Get().Hide();
hero.Move2Dest(dst);
I.gameArea.SetCenter(hero.GetCenter());
GameFocus::SetRedraw();
I.Redraw();
AGG::PlaySound(M82::KILLFADE);
hero.GetPath().Hide();
hero.FadeIn();
// educate spells
if(! Settings::Get().ExtHeroLearnSpellsWithDay()) castle->MageGuildEducateHero(hero);
return true;
}
return false;
}
示例14: HeroesActionNewPosition
void AI::HeroesActionNewPosition(Heroes & hero)
{
AIHero & ai_hero = AIHeroes::Get(hero);
//AIKingdom & ai_kingdom = AIKingdoms::Get(hero.GetColor());
Queue & task = ai_hero.sheduled_visit;
const u8 objs[] = { MP2::OBJ_ARTIFACT, MP2::OBJ_RESOURCE, MP2::OBJ_CAMPFIRE, MP2::OBJ_TREASURECHEST, 0 };
Maps::Indexes pickups = Maps::ScanAroundObjects(hero.GetIndex(), objs);
if(pickups.size() && hero.GetPath().isValid() &&
pickups.end() == std::find(pickups.begin(), pickups.end(), hero.GetPath().GetDestinationIndex()))
hero.GetPath().Reset();
for(MapsIndexes::const_iterator
it = pickups.begin(); it != pickups.end(); ++it)
if(*it != hero.GetPath().GetDestinationIndex())
task.push_front(*it);
}
示例15: PassableToTile
bool PassableToTile(const Heroes & hero, const Maps::Tiles & toTile, int direct, s32 dst)
{
// check end point
if(toTile.GetIndex() == dst)
{
// fix toTilePassable with action object
if(MP2::isPickupObject(toTile.GetObject()))
return true;
// check direct to object
if(MP2::isActionObject(toTile.GetObject(false), hero.isShipMaster()))
return Direction::Reflect(direct) & toTile.GetPassable();
if(MP2::OBJ_HEROES == toTile.GetObject())
return toTile.isPassable(NULL, Direction::Reflect(direct), (hero.isControlAI() ? AI::HeroesSkipFog() : false));
}
// check to tile direct
if(! toTile.isPassable(&hero, Direction::Reflect(direct), (hero.isControlAI() ? AI::HeroesSkipFog() : false)))
return false;
if(toTile.GetIndex() != dst)
{
if(MP2::isPickupObject(toTile.GetObject()) ||
MP2::isActionObject(toTile.GetObject(false), hero.isShipMaster()))
return false;
// check hero/monster on route
switch(toTile.GetObject())
{
case MP2::OBJ_HEROES:
case MP2::OBJ_MONSTER:
return false;
default: break;
}
// check monster protection
if(CheckMonsterProtectionAndNotDst(toTile.GetIndex(), dst))
return false;
}
return true;
}