本文整理汇总了C++中MapPoint::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ MapPoint::isValid方法的具体用法?C++ MapPoint::isValid怎么用?C++ MapPoint::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapPoint
的用法示例。
在下文中一共展示了MapPoint::isValid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MoveToMapPt
void GameWorldView::MoveToMapPt(const MapPoint pt)
{
if(!pt.isValid())
return;
lastOffset = offset;
Point<int> nodePos = GetWorld().GetNodePos(pt);
MoveTo(nodePos - DrawPoint(GetSize() / 2), true);
}
示例2:
BOOST_FIXTURE_TEST_CASE(HQPlacement, WorldFixtureEmpty1P)
{
GamePlayer& player = world.GetPlayer(0);
BOOST_REQUIRE(player.isUsed());
const MapPoint hqPos = player.GetHQPos();
BOOST_REQUIRE(hqPos.isValid());
BOOST_REQUIRE_EQUAL(world.GetNO(player.GetHQPos())->GetGOT(), GOT_NOB_HQ);
// Check ownership of points
std::vector<MapPoint> ownerPts = world.GetPointsInRadius(hqPos, HQ_RADIUS);
BOOST_FOREACH(MapPoint pt, ownerPts)
{
// This should be ensured by `GetPointsInRadius`
BOOST_REQUIRE_LE(world.CalcDistance(pt, hqPos), HQ_RADIUS);
// We must own this point
BOOST_REQUIRE_EQUAL(world.GetNode(pt).owner, 1);
// Points at radius are border nodes, others player territory
if(world.CalcDistance(pt, hqPos) == HQ_RADIUS)
BOOST_REQUIRE(world.IsBorderNode(pt, 1));
else
BOOST_REQUIRE(world.IsPlayerTerritory(pt));
}
示例3: MissAttackingWalk
void nofAttacker::MissAttackingWalk()
{
// Ist evtl. unser Heimatgebäude zerstört?
if(!building)
{
// Dann dem Ziel Bescheid sagen, falls es existiert (evtl. wurdes zufällig zur selben Zeit zerstört)
InformTargetsAboutCancelling();
// Ggf. Schiff Bescheid sagen (Schiffs-Angreifer)
if(ship_obj_id)
CancelAtShip();
// Rumirren
state = STATE_FIGUREWORK;
StartWandering();
Wander();
return;
}
// Gibts das Ziel überhaupt noch?
if(!attacked_goal)
{
ReturnHomeMissionAttacking();
return;
}
/*// Is it still a hostile destination?
// (Could be captured in the meantime)
if(!players->getElement(player)->IsPlayerAttackable(attacked_goal->GetPlayer()))
{
ReturnHomeMissionAttacking();
return;
}*/
// Eine Position rund um das Militärgebäude suchen
MapPoint goal = attacked_goal->FindAnAttackerPlace(radius, this);
// Keinen Platz mehr gefunden?
if(!goal.isValid())
{
// Dann nach Haus gehen
ReturnHomeMissionAttacking();
return;
}
// Sind wir evtl schon da?
if(pos == goal)
{
ReachedDestination();
return;
}
// Find all sorts of enemies (attackers, aggressive defenders..) nearby
if(FindEnemiesNearby())
// Enemy found -> abort, because nofActiveSoldier handles all things now
return;
// Haben wir noch keinen Feind?
// Könnte mir noch ein neuer Verteidiger entgegenlaufen?
TryToOrderAggressiveDefender();
// Ansonsten Weg zum Ziel suchen
unsigned char dir = gwg->FindHumanPath(pos, goal, MAX_ATTACKING_RUN_DISTANCE, true);
// Keiner gefunden? Nach Hause gehen
if(dir == 0xff)
{
ReturnHomeMissionAttacking();
return;
}
// Start walking
StartWalking(Direction(dir));
}