void CInterfaceUnit::OnLoop()
{
    CInterface::OnLoop();

	CleanUpTargetSurf();
    CleanUpHealthBar();

    UpdateUnit();

	UpdateTarget();

    UpdateHealth();
}
Exemple #2
0
void Update()
{
	// Calculate delta time
	clock_t clockNow = clock();
	clock_t deltaClock = clockNow - clockLastFrame;
	float deltaTime = float(deltaClock) / CLOCKS_PER_SEC;
	clockLastFrame = clockNow;


	// Calculate FPS
	framesCounter++;
	framesTimeCounter += deltaTime;
	if( framesTimeCounter >= 1.0 )
	{
		framesTimeCounter -= 1.0;
		fps = framesCounter;
		framesCounter = 0;
	}


	// Hero control
	if( IsKeyDown(VK_UP) )
		unitsData[heroIndex].yOrder = UnitOrder_Backward;
	else
		unitsData[heroIndex].yOrder = UnitOrder_None;


	if( IsKeyDown(VK_LEFT) )
		unitsData[heroIndex].xOrder = UnitOrder_Backward;
	else
	{
		if( IsKeyDown(VK_RIGHT) )
			unitsData[heroIndex].xOrder = UnitOrder_Forward;
		else
			unitsData[heroIndex].xOrder = UnitOrder_None;
	}


	// Update all units
	for( int u = 0; u < unitsCount; u++ )
		UpdateUnit( &unitsData[u], deltaTime );

	// Update AI
	UpdateAI();

	// Hero dead
	if( unitsData[heroIndex].health <= 0 )
		Initialize();
}
//=================================================================================================
void CreateCharacterPanel::Update(float dt)
{
	RenderUnit();
	UpdateUnit(dt);

	// obracanie
	if(PointInRect(GUI.cursor_pos, INT2(pos.x+228,pos.y+94), INT2(128,256)) && Key.Focus() && focus)
	{
		if(Key.Down(VK_LBUTTON))
			unit->rot = clip(unit->rot - float(GUI.cursor_pos.x - pos.x - 228 - 64)/16*dt);
		//dist = clamp(dist + GUI.mouse_wheel, -3.f, -1.f);
	}

	if(mode == PickClass)
	{
		for(int i=0; i<5; ++i)
		{
			bts[i].mouse_focus = focus;
			bts[i].Update(dt);
		}
	}
	else
	{
		for(int i=0; i<2; ++i)
		{
			bts2[i].mouse_focus = focus;
			bts2[i].Update(dt);
		}

		if(!game->IsOnline())
		{
			checkbox.mouse_focus = focus;
			checkbox.Update(dt);
		}

		for(int i=0; i<5; ++i)
		{
			slider[i].mouse_focus = focus;
			slider[i].Update(dt);
		}
	}

	if(focus && Key.Focus() && Key.PressedRelease(VK_ESCAPE))
		Event((GuiEvent)IdCancel);
}
bool CInterfaceUnit::OnLoad()
{
    if(CInterface::OnLoad() == false) 
        return false;

    if((Surf_UnitStatus = CSurface::OnLoad("./interface/interface_unitinfo_status.png")) == NULL) 
        return false;

    UpdateUnit();

    if(pUnit)
    {
        std::string name = pUnit->GetName();

        Surf_UnitName = CSurface::RenderText(name);

        /*Surf_UnitImage = CPlayer::Player.pPlayerCharacter->GetImage();*/
    }

    return true;
}