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


C++ Ufo::getVisibility方法代码示例

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


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

示例1: detect

/**
 * Returns if a certain target is covered by the base's
 * radar range, taking in account the range and chance.
 * @param target Pointer to target to compare.
 * @return 0 - not detected, 1 - detected by conventional radar, 2 - detected by hyper-wave decoder.
 */
int Base::detect(Target *target) const
{
	int chance = 0;
	double distance = getDistance(target) * 60.0 * (180.0 / M_PI);
	for (std::vector<BaseFacility*>::const_iterator i = _facilities.begin(); i != _facilities.end(); ++i)
	{
		if ((*i)->getRules()->getRadarRange() >= distance && (*i)->getBuildTime() == 0)
		{
			if ((*i)->getRules()->isHyperwave())
			{
				return 2;
			}
			chance += (*i)->getRules()->getRadarChance();
		}
	}
	if (chance == 0) return 0;

	Ufo *u = dynamic_cast<Ufo*>(target);
	if (u != 0)
	{
		chance = chance * (100 + u->getVisibility()) / 100;
	}

	return RNG::percent(chance)? 1 : 0;
}
开发者ID:Scarberian,项目名称:OpenXcom,代码行数:31,代码来源:Base.cpp

示例2: detect

/**
 * Returns if a certain target is detected by the craft's
 * radar, taking in account the range and chance.
 * @param target Pointer to target to compare.
 * @return True if it's detected, False otherwise.
 */
bool Craft::detect(Target *target) const
{
	if (_rules->getRadarRange() == 0 || !insideRadarRange(target))
		return false;

	// backward compatibility with vanilla
	if (_rules->getRadarChance() == 100)
		return true;

	Ufo *u = dynamic_cast<Ufo*>(target);
	int chance = _rules->getRadarChance() * (100 + u->getVisibility()) / 100;
	return RNG::percent(chance);
}
开发者ID:BHSDuncan,项目名称:OpenXcom,代码行数:19,代码来源:Craft.cpp


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