本文整理汇总了C++中CUnit::IsAliveOnMap方法的典型用法代码示例。如果您正苦于以下问题:C++ CUnit::IsAliveOnMap方法的具体用法?C++ CUnit::IsAliveOnMap怎么用?C++ CUnit::IsAliveOnMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUnit
的用法示例。
在下文中一共展示了CUnit::IsAliveOnMap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PlayersEachCycle
/**
** Handle AI of all players each game cycle.
*/
void PlayersEachCycle()
{
for (int player = 0; player < NumPlayers; ++player) {
CPlayer *p = &Players[player];
if (p->AutoAttackTargets.size() > 0) {
CUnitCache &autoatacktargets = p->AutoAttackTargets;
/* both loops can not be connected !!!! */
for (unsigned int i = 0; i < autoatacktargets.size();) {
CUnit *aatarget = autoatacktargets[i];
if (!aatarget->IsAliveOnMap() ||
Map.Field(aatarget->Offset)->Guard[player] == 0) {
autoatacktargets.Units.erase(autoatacktargets.Units.begin() + i);
aatarget->RefsDecrease();
continue;
}
++i;
}
if (autoatacktargets.size() > 0) {
for (int j = 0; j < p->TotalNumUnits; ++j) {
CUnit &guard = *p->Units[j];
bool stand_ground = guard.CurrentAction() == UnitActionStandGround;
if (guard.Type->CanAttack &&
(stand_ground || guard.IsIdle()) &&
!guard.IsUnusable()) {
AutoAttack(guard, autoatacktargets, stand_ground);
}
}
}
}
if (p->AiEnabled) {
AiEachCycle(p);
}
}
}
示例2: MissileHandlePierce
void MissileHandlePierce(Missile &missile, const Vec2i &pos)
{
CUnit *unit = UnitOnMapTile(pos, -1);
if (unit && unit->IsAliveOnMap()
&& (missile.Type->FriendlyFire || unit->IsEnemy(*missile.SourceUnit->Player))) {
missile.MissileHit(unit);
}
}
示例3: CclSetTeleportDestination
/**
** Set teleport deastination for teleporter unit
**
** @param l Lua state.
*/
static int CclSetTeleportDestination(lua_State *l)
{
LuaCheckArgs(l, 2);
lua_pushvalue(l, 1);
CUnit *unit = CclGetUnit(l);
lua_pop(l, 1);
if (unit->Type->Teleporter == false) {
LuaError(l, "Unit not a teleporter");
}
lua_pushvalue(l, 2);
CUnit *dest = CclGetUnit(l);
lua_pop(l, 1);
if (dest->IsAliveOnMap()) {
unit->Goal = dest;
}
return 0;
}