本文整理汇总了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;
}
示例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);
}