示例#1
0
const GBColor GBSensorShot::Color() const {
	float fraction = 1.0 - (float)age / Lifetime();
	switch ( seen ) {
		case ocRobot: return GBColor(0.4f, 0.8f, 1) * fraction;
		case ocFood: return GBColor(0.5f, 1, 0.5f) * fraction;
		case ocShot: return GBColor(1, 1, 0.5f) * fraction;
	}
	return GBColor(fraction);
}
bool ChallengeManager::Match( const Challenge& challenge, Challenge::Duration* ping )
{
	Cleanup();

	auto it = std::find_if( challenges.begin(), challenges.end(),
		[&challenge]( const Challenge& ch ) {
			return ch.Matches( challenge );
	} );

	if ( it != challenges.end() )
	{
		if ( ping )
		{
			*ping = it->Lifetime();
		}
		challenges.erase( it );
		return true;
	}

	return false;
}
示例#3
0
GBObjectClass GBSensorShot::Class() const {
	if ( age >= Lifetime() )
		return ocDead;
	else
		return ocSensorShot;
}