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


C++ CGroup::isMicroing方法代码示例

本文整理汇总了C++中CGroup::isMicroing方法的典型用法代码示例。如果您正苦于以下问题:C++ CGroup::isMicroing方法的具体用法?C++ CGroup::isMicroing怎么用?C++ CGroup::isMicroing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CGroup的用法示例。


在下文中一共展示了CGroup::isMicroing方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onUpdate

void AttackTask::onUpdate() {
	CGroup *group = firstGroup();

	if (group->isMicroing() && group->isIdle()) {
		targetAlt = -1; // for sure
		group->micro(false);
	}

	if (isMoving) {
		/* Keep tracking the target */
		pos = ai->cbc->GetUnitPos(target);

		float3 gpos = group->pos();
		float dist = gpos.distance2D(pos);
		float range = group->getRange();

		/* See if we can attack our target already */
		if (dist <= range) {
			bool canAttack = true;

			/*
			// for ground units prevent shooting across hill...
			if ((group->cats&AIR).none()) {
				// FIXME: improve
				dist = ai->pathfinder->getPathLength(*group, pos);
				canAttack = (dist <= range * 1.1f);
			}
			*/

			if (canAttack) {
				if ((group->cats&BUILDER).any())
					group->reclaim(target);
				else
					group->attack(target);
				isMoving = false;
				ai->pathfinder->remove(*group);
				group->micro(true);
			}
		}
	}

	/* See if we can attack a target we found on our path */
	if (!(group->isMicroing() || urgent())) {
		if ((group->cats&BUILDER).any())
			resourceScan(); // builders should not be too aggressive
		else
			enemyScan(targetAlt);
	}
}
开发者ID:Error323,项目名称:E323AI,代码行数:49,代码来源:Attack.cpp

示例2: onUpdate

void AssistTask::onUpdate() {
    CGroup *group = firstGroup();

    if (group->isMicroing() && group->isIdle()) {
        targetAlt = -1; // for sure
        group->micro(false);
    }

    if (!assisting) {
        if (isMoving) {
            /* Keep tracking the target */
            pos = assist->pos;

            float3 gpos = group->pos();
            float dist = gpos.distance2D(pos);
            float range = group->getRange();

            if (dist <= range) {
                bool canAssist = true;
                /*
                // for ground units prevent assisting across hill...
                if ((group->cats&AIR).none()) {
                	dist = ai->pathfinder->getPathLength(*group, pos);
                	canAssist = (dist <= range * 1.1f);
                }
                */
                if (canAssist) {
                    isMoving = false;
                    ai->pathfinder->remove(*group);
                }
            }
        }

        if (!isMoving) {
            group->assist(*assist);
            group->micro(true);
            assisting = true;
        }
    }

    if (!group->isMicroing()) {
        if ((group->cats&BUILDER).any())
            resourceScan(); // builders should not be too aggressive
        else if ((group->cats&AIR).none()) {
            enemyScan(targetAlt);
        }
    }
}
开发者ID:hoijui,项目名称:E323AI,代码行数:48,代码来源:Assist.cpp

示例3: onUpdate

void MergeTask::onUpdate() {
	/* See which groups can be merged already */
	std::list<CGroup*>::iterator it;
	for (it = groups.begin(); it != groups.end(); ++it) {
		CGroup *g = *it;
		
		if (g->isMicroing())
			continue;
		
		if (pos.distance2D(g->pos()) < range) {
			mergable[g->key] = g;
			g->micro(true);
		}
	}
	
	/* We have at least two groups, now we can merge */
	if (mergable.size() >= 2) {
		std::vector<int> keys;
		std::map<int, CGroup*>::iterator it;
		
		// get keys because while merging "mergable" is reducing...
		for (it = mergable.begin(); it != mergable.end(); ++it) {
			keys.push_back(it->first);
		}
		
		for (int i = 0; i < keys.size(); i++) {
			int key = keys[i];
			if (key != masterGroup->key) {
				CGroup *g = mergable[key];
				LOG_II("MergeTask::update merging " << (*g) << " with " << (*masterGroup))
				// NOTE: group being merged is automatically removed
				masterGroup->merge(*g);
			}
		}
		
		assert(mergable.size() == 1);
		mergable.clear();
		masterGroup->micro(false);
	}

	// if only one (or none) group remains, merging is no longer possible,
	// remove the task, unreg groups...
	if (groups.size() <= 1)
		ATask::remove();
}
开发者ID:hoijui,项目名称:E323AI,代码行数:45,代码来源:Merge.cpp


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