本文整理汇总了C++中CUnit::IsVisible方法的典型用法代码示例。如果您正苦于以下问题:C++ CUnit::IsVisible方法的具体用法?C++ CUnit::IsVisible怎么用?C++ CUnit::IsVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUnit
的用法示例。
在下文中一共展示了CUnit::IsVisible方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SyncRand
/* virtual */ void CAnimation_RandomSound::Action(CUnit &unit, int &/*move*/, int /*scale*/) const
{
Assert(unit.Anim.Anim == this);
if (unit.IsVisible(*ThisPlayer) || ReplayRevealMap) {
const size_t index = SyncRand() % this->sounds.size();
PlayUnitSound(unit, this->sounds[index].Sound);
}
}
示例2: DrawInformations
/**
** Draw additional informations of a unit.
**
** @param unit Unit pointer of drawn unit.
** @param type Unit-type pointer.
** @param screenPos screen pixel (top left) position of unit.
**
** @todo FIXME: The different styles should become a function call.
*/
static void DrawInformations(const CUnit &unit, const CUnitType &type, const PixelPos &screenPos)
{
#if 0 && DEBUG // This is for showing vis counts and refs.
char buf[10];
sprintf(buf, "%d%c%c%d", unit.VisCount[ThisPlayer->Index],
unit.Seen.ByPlayer & (1 << ThisPlayer->Index) ? 'Y' : 'N',
unit.Seen.Destroyed & (1 << ThisPlayer->Index) ? 'Y' : 'N',
unit.Refs);
CLabel(GetSmallFont()).Draw(screenPos.x + 10, screenPos.y + 10, buf);
#endif
const CUnitStats &stats = *unit.Stats;
// For debug draw sight, react and attack range!
if (IsOnlySelected(unit)) {
const PixelPos center(screenPos + type.GetPixelSize() / 2);
if (Preference.ShowSightRange) {
const int value = stats.Variables[SIGHTRANGE_INDEX].Max;
const int radius = value * PixelTileSize.x + (type.TileWidth - 1) * PixelTileSize.x / 2;
if (value) {
// Radius -1 so you can see all ranges
Video.DrawCircleClip(ColorGreen, center.x, center.y, radius - 1);
}
}
if (type.CanAttack) {
if (Preference.ShowReactionRange) {
const int value = (unit.Player->Type == PlayerPerson) ? type.ReactRangePerson : type.ReactRangeComputer;
const int radius = value * PixelTileSize.x + (type.TileWidth - 1) * PixelTileSize.x / 2;
if (value) {
Video.DrawCircleClip(ColorBlue, center.x, center.y, radius);
}
}
if (Preference.ShowAttackRange) {
const int value = stats.Variables[ATTACKRANGE_INDEX].Max;
const int radius = value * PixelTileSize.x + (type.TileWidth - 1) * PixelTileSize.x / 2;
if (value) {
// Radius +1 so you can see all ranges
Video.DrawCircleClip(ColorGreen, center.x, center.y, radius - 1);
}
}
}
}
// FIXME: johns: ugly check here, should be removed!
if (unit.CurrentAction() != UnitActionDie && (unit.IsVisible(*ThisPlayer) || ReplayRevealMap)) {
DrawDecoration(unit, type, screenPos);
}
}