当前位置: 首页>>代码示例>>C++>>正文


C++ CUnit::IsAliveOnMap方法代码示例

本文整理汇总了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);
		}
	}
}
开发者ID:landswellsong,项目名称:Stratagus,代码行数:37,代码来源:player.cpp

示例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);
	}
}
开发者ID:stefanhendriks,项目名称:stratagus,代码行数:8,代码来源:missile.cpp

示例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;
}
开发者ID:wangtianhang,项目名称:stratagus,代码行数:24,代码来源:script_unit.cpp


注:本文中的CUnit::IsAliveOnMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。