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


C++ Boss::getHealthPercent方法代码示例

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


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

示例1: drawBlobHealthShieldInfo

void drawBlobHealthShieldInfo()
{
	float healthPercent;
	float healthBar, shieldBar, oxygenBar;
	int fade;
	int y, bossX;
	String s;
	GLColor c;
	Texture *t;
	
	static GLColor darkRed = GLColor::red.darker();
	static GLColor darkYellow = GLColor::yellow.darker();
	static GLColor darkCyan = GLColor::cyan.darker();
	static GLColor darkGreen = GLColor::green.darker();
	
	y = 20;
	
	bool flashBar = ((((int)graphics->getAnimTimer()) % 100) < 50);
	bool showDanger;
	
	for (Unit *unit = (Unit*)entityManager->blobList.getFirstElement() ; unit != NULL ; unit = (Unit*)unit->next)
	{
		if ((unit->health <= -100) || (unit->definition->type == BLOB_MIA) || (!unit->showHealthData))
		{
			continue;
		}
		
		switch (unit->definition->type)
		{
			case BLOB_MIA:
			case BLOB_ASSIMILATING:
			case BLOB_SOLDIER:
				continue;
				break;
					
			default:
				break;
		}
		
		showDanger = false;
		
		fade = 35;
		
		if (unit->maxShield > 0)
		{
			fade = 40;
		}
		
		if (unit->oxygen < MAX_OXYGEN_IND)
		{
			fade = 45;
		}
		
		graphics->fade(0.5, 30, y - 5, 210, fade);
		
		s.setText("str_%s", unit->getName());
		
		if ((t = textureManager->getTexture(s.getText())) == NULL)
		{
			t = graphics->getGLString("%s", unit->getName());
			textureManager->addTexture(s.getText(), t);
		}
		
		glColor3f(1.0, 1.0, 1.0);
		graphics->blit(t, 35, y, false);
		
		healthPercent = unit->getHealthPercent();
		
		healthBar = 200;
		shieldBar = 200;
		oxygenBar = 200;
		
		healthBar /= unit->maxHealth;
		shieldBar /= unit->maxShield;
		oxygenBar /= MAX_OXYGEN;
		
		healthBar *= unit->health;
		shieldBar *= unit->shield;
		oxygenBar *= unit->oxygen;
		
		y += 16;
		
		if (healthPercent >= 75)
		{
			c = darkGreen;
		}
		else if (healthPercent >= 25)
		{
			c = darkYellow;
		}
		else
		{
			c = darkRed;
		}
		
		graphics->drawRect(35, y, 200, 8, c, true);
		
		if (unit == player)
		{
			glColor4f(1.0, 1.0, 1.0, (!game->autoLockTarget) ? 1.0 : 0.15);
//.........这里部分代码省略.........
开发者ID:lumidify,项目名称:blobandconquer,代码行数:101,代码来源:controlPanel.cpp


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