Exemple #1
0
void Gui::MinToTray(const HWND hWnd) 
{
	if (DoAnimation() && ::IsWindowVisible(hWnd)) 
	{
		RECT rcFrom = { 0 }, rcTo = { 0 };
	
		::GetWindowRect(hWnd, &rcFrom);
		GetTrayWndRect(rcTo);
		
		::DrawAnimatedRects(hWnd, IDANI_CAPTION, &rcFrom, &rcTo);
	}
	
	::ShowWindow(hWnd, SW_HIDE);
}
Exemple #2
0
void Gui::RestoreFromTray(const HWND hWnd, BOOL bForceMax) 
{
	if (DoAnimation()) 
	{
		RECT rcFrom = { 0 }, rcTo = { 0 };

		GetTrayWndRect(rcFrom);
		::GetWindowRect(hWnd, &rcTo);
		
		::DrawAnimatedRects(hWnd, IDANI_CAPTION, &rcFrom, &rcTo);
	}
	
	BOOL bZoomed = (IsZoomed(hWnd) || bForceMax);

	::ShowWindow(hWnd, bZoomed ? SW_SHOWMAXIMIZED : SW_RESTORE);
	::SetActiveWindow(hWnd);
	::SetForegroundWindow(hWnd);
}
Exemple #3
0
/*!****************************************************************************
 @Function		RenderScene
 @Return		bool		true if no error occured
 @Description	Main rendering loop function of the program. The shell will
				call this function every frame.
				eglSwapBuffers() will be performed by PVRShell automatically.
				PVRShell will also manage important OS events.
				Will also manage relevent OS events. The user has access to
				these events through an abstraction layer provided by PVRShell.
******************************************************************************/
bool OGLESFur::RenderScene()
{
	// Reset the states that print3D changes
	glDisable(GL_CULL_FACE);
	glEnable(GL_FOG);
	glEnable(GL_LIGHT0);
	glEnable(GL_LIGHTING);
	glEnable(GL_DEPTH_TEST);

	//	User input
	bool bNewPage = false;

	if(PVRShellIsKeyPressed(PVRShellKeyNameSELECT))
		m_bPause = !m_bPause;

	if(PVRShellIsKeyPressed(PVRShellKeyNameLEFT))
	{
		if(--m_i32WndPage < 0)
			m_i32WndPage = 5;

		bNewPage = true;
	}

	if(PVRShellIsKeyPressed(PVRShellKeyNameRIGHT))
	{
		if(++m_i32WndPage > 5)
			m_i32WndPage = 0;

		bNewPage = true;
	}

	if(bNewPage)
	{
		switch(m_i32WndPage)
		{
			case 0:
				m_bViewMode = false;
				m_i32FurShellNo = 7;
				break;
			case 1:
				m_bViewMode = true;
				m_i32FurShellNo = 0;
				break;
			case 2:
				m_bViewMode = true;
				m_i32FurShellNo = 1;
				break;
			case 3:
				m_bViewMode = true;
				m_i32FurShellNo = 2;
				break;
			case 4:
				m_bViewMode = true;
				m_i32FurShellNo = 7;
				break;
			case 5:
				m_bViewMode = false;
				m_i32FurShellNo = 7;
				break;
		}

		// Since the number of fur shells has changed, update them
		UpdateFurShells();
	}

	// Clear
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Animation
	DoAnimation();

	// View matrix
	glMatrixMode(GL_MODELVIEW);
	glLoadMatrixf(m_mView.f);

	// Enable the vertex and normal arrays
	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_NORMAL_ARRAY);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);

	// Begin Scene
	if(!m_bViewMode)
		DrawEnvironment();

	// Draw the Duck
	DrawDuck();

	// Display Paused if the app is paused
	if(m_bPause)
		m_Print3D.Print3D(78.0f, 2.0f, 1.0f, PVRTRGBA(255,255,255,255), "Paused");

	// Disable the normals before our drawing of the print3D content
	glDisableClientState(GL_NORMAL_ARRAY);
	
	char szDesc[256];
	snprintf(szDesc, 256, "Displaying %d shells", m_i32FurShellNo);

	// Display the IMG logo
	m_Print3D.DisplayDefaultTitle("Fur", szDesc, ePVRTPrint3DSDKLogo);
	m_Print3D.Flush();
	return true;
}
void Player::UpdateMe()
{
	float angle = atan2(m_dashDirection.z, m_dashDirection.x);
	DirectX::XMFLOAT3 position = DirectX::XMFLOAT3(m_position.x, 2.0f, m_position.z);
	m_trail->Update(position, angle);

	//Required for ambient 3D sounds
	if (m_sound != nullptr){
		m_sound->UpdateAmbientSound(m_position.x, m_position.y, m_position.z);
	}

	if (m_updateVisibility)
	{
		m_updateVisibility = false;
		GraphicsEngine::UpdateVisibilityPolygon(Point(m_position.x, m_position.z), (float)GLOBAL::GetInstance().GetDeltaTime());
	}

	// Check values from server
	if (Network::GetInstance()->IsConnected())
	{
		SetHealth(Network::GetInstance()->GetMyPlayer().currentHP);
		SetMaxHealth(Network::GetInstance()->GetMyPlayer().maxHP);
		SetIsAlive(Network::GetInstance()->GetMyPlayer().isAlive);
		SetTeam(Network::GetInstance()->GetMyPlayer().team);
		SetGuID(Network::GetInstance()->GetMyPlayer().guid);
		//SetPosition(DirectX::XMFLOAT3(Network::GetInstance()->GetMyPlayer().x, Network::GetInstance()->GetMyPlayer().y, Network::GetInstance()->GetMyPlayer().z));
	}

	float directionAngle = DirectX::XMVector3AngleBetweenVectors(DirectX::XMLoadFloat3(&m_attackDir), DirectX::XMLoadFloat3(&m_direction)).m128_f32[0];

	if (directionAngle > (3.14f * 0.625f))
	{
		m_speed = m_originalSpeed * 0.85f;
	}
	else
	{
		SetSpeed(m_originalSpeed);
	}
	
	for (unsigned int i = 0; i < m_stickyTrapList.size(); i++)
	{		
		if (Collisions::SphereSphereCollision(m_playerSphere, m_stickyTrapList[i]->GetStickyTrapSphere()))
		{
			SetSpeed(m_speed * STICKY_TRAP_SLOW_PRECENTAGE);
			break;
		}
	}


	UpdateBlood();

	// Don't update player if he is dead
	if (!m_isAlive || Network::GetInstance()->GetMatchOver())
	{
		m_ability = m_noAbility;
		// Animation None ?
		UpdateAbilities();
		UpdateAbilityBar();
		AnimatedObject::ChangeAnimationState(AnimationState::None);
		if (m_sound != nullptr && m_soundEmitter != nullptr){
			m_sound->StopAmbientSound(m_soundEmitter);
		}

		return;
	}

	// Check for dash
	if (Network::GetInstance()->HaveDashed())
	{		
		// Calc distance
		float dx = Network::GetInstance()->GetDashLocation().x - m_position.x;
		float dz = Network::GetInstance()->GetDashLocation().z - m_position.z;
		m_dashDistanceLeft = sqrt(dx * dx + dz * dz);

		// Calc dir
		DirectX::XMVECTOR tempVector = DirectX::XMLoadFloat3(&DirectX::XMFLOAT3(dx, 0, dz));
		tempVector = DirectX::XMVector3Normalize(tempVector);
		DirectX::XMStoreFloat3(&m_dashDirection, tempVector);

		m_isDashing = true;

		m_trail->StartEmiting();
	}

	// Dash movement
	if (m_isDashing)
	{
		float distance = DASH_SPEED * m_speed * (float)GLOBAL::GetInstance().GetDeltaTime();

		Sphere playerSphere = m_playerSphere;
		playerSphere.m_position.x += m_dashDistanceLeft * m_dashDirection.x;
		playerSphere.m_position.z += m_dashDistanceLeft * m_dashDirection.z;		

		if (!CollisionManager::GetInstance()->CheckCollisionWithAllStaticObjects(playerSphere))
		{
			if (distance >= m_dashDistanceLeft)
			{
				m_position.x += m_dashDistanceLeft * m_dashDirection.x;
				m_position.z += m_dashDistanceLeft * m_dashDirection.z;
				m_dashDistanceLeft = 0.0f;
				m_isDashing = false;

				Network::GetInstance()->SendAnimationState(AnimationState::None);

				m_trail->StopEmiting();
			}
			else
			{
				m_position.x += (DASH_SPEED * m_speed * (float)GLOBAL::GetInstance().GetDeltaTime()) * m_dashDirection.x;
				m_position.z += (DASH_SPEED * m_speed * (float)GLOBAL::GetInstance().GetDeltaTime()) * m_dashDirection.z;
				m_dashDistanceLeft -= distance;
			}

			// If we dashed, update shadow shapes.
			GraphicsEngine::UpdateVisibilityPolygon(Point(m_position.x, m_position.z), (float)GLOBAL::GetInstance().GetDeltaTime());
			// Force network to send pos
			Network::GetInstance()->SendLatestPos();
		}

		else
		{
			m_isDashing = false;

			Network::GetInstance()->SendAnimationState(AnimationState::None);

			m_trail->StopEmiting();
		}

		SendPosition(m_position);
	}

	// Move.
	if ((CalculateDirection() || Network::GetInstance()->ConnectedNow()) && !m_isDashing)
	{
		SetCalculatePlayerPosition();

		// If we moved, update shadow shapes.

		GraphicsEngine::UpdateVisibilityPolygon(Point(m_position.x, m_position.z), (float)GLOBAL::GetInstance().GetDeltaTime());

		//Update sound (walking)
	
		m_sound->StartAmbientSound(m_soundEmitter);
		m_soundEmitter->m_pos.x = position.x;
		m_soundEmitter->m_pos.y = position.y;
		m_soundEmitter->m_pos.z = position.z;
	}
	else{
		m_sound->StopAmbientSound(m_soundEmitter);
	}
	m_playerSphere.m_position = m_position;
	
	// Check if the player have made an invalid move
	if (Network::GetInstance()->MadeInvalidMove())
	{
		PlayerNet myPlayer = Network::GetInstance()->GetMyPlayer();
		SendPosition(DirectX::XMFLOAT3(myPlayer.x, myPlayer.y, myPlayer.z));
		Network::GetInstance()->UpdatedMoveFromInvalidMove();

		m_updateVisibility = true;
	}

	// Check if the player need to respawn
	if (Network::GetInstance()->HasRespawned())
	{
		PlayerNet myPlayer = Network::GetInstance()->GetMyPlayer();
		SendPosition(DirectX::XMFLOAT3(myPlayer.x, myPlayer.y, myPlayer.z));
		Network::GetInstance()->SetHaveRespawned();

		m_updateVisibility = true;
	}

	if (Settings::GetInstance()->m_apeToggle)
	{
		if (InputManager::GetInstance()->IsKeyClicked(VkKeyScan(VK_SPACE)))
		{
			m_onPressed = !m_onPressed;
			GLOBAL::GetInstance().APE_ON = !m_onPressed;
		}
	}
	else
	{
		if (InputManager::GetInstance()->IsKeyPressed(VkKeyScan(VK_SPACE)))
		{
			if (Settings::GetInstance()->m_apeEnabled)
			{
				m_onPressed = false;
				GLOBAL::GetInstance().APE_ON = true;
			}
			else
			{
				m_onPressed = true;
				GLOBAL::GetInstance().APE_ON = false;
			}
		}
		else
		{
			if (Settings::GetInstance()->m_apeEnabled)
			{
				m_onPressed = true;
				GLOBAL::GetInstance().APE_ON = false;
			}
			else
			{
				m_onPressed = false;
				GLOBAL::GetInstance().APE_ON = true;
			}
		}
	}

	m_ability = m_noAbility;
	CheckForSpecialAttack();
	if (m_onPressed)
	{
		// Range attack
		if (InputManager::GetInstance()->IsRightMousePressed())
		{
			// Check cd so m_ability does not get set if u have cooldown preventing other abilities to be casted.
			if (m_rangeAttack->GetStacks() > 0 || m_rangeAttack->GetStacks() == -1)
			{
				m_ability = m_rangeAttack;
			}
			else
			{
				StillCDText();
			}
		}
		// Melee attack
		if (InputManager::GetInstance()->IsLeftMousePressed())
		{
			if ((float)m_meleeAttack->GetCooldown() <= 0.0f)
			{
				m_ability = m_meleeAttack;
			}
			else
			{
				StillCDText();
			}
		}
	}
	else
	{		
		// Range attack
		if (InputManager::GetInstance()->IsRightMouseClicked())
		{
			// Check cd so m_ability does not get set if u have cooldown preventing other abilities to be casted.
			if (m_rangeAttack->GetStacks() > 0 || m_rangeAttack->GetStacks() == -1)
			{
				m_ability = m_rangeAttack;
			}
			else
			{
				StillCDText();
			}
		}
		// Melee attack
		if (InputManager::GetInstance()->IsLeftMouseClicked())
		{
			if ((float)m_meleeAttack->GetCooldown() <= 0.0f)
			{
				m_ability = m_meleeAttack;
			}
			else
			{
				StillCDText();
			}
		}
	}

	// Count down cooldowns
	UpdateAbilities();
	throwDistance = CollisionManager::GetInstance()->CalculateMouseDistanceFromPlayer(m_position);
	if (m_ability != m_noAbility && m_globalCooldown <= 0.0f)
	{
		if (m_ability->Execute(throwDistance))
		{
			// Play ability animation if we did any
			DoAnimation();

			// Set global cooldown
			m_globalCooldown = m_maxGlobalCooldown;
		}
	}

	DealtDamageStruct temp = Network::GetInstance()->GetDealtDamage();
	m_floatingText->SetDealtDamageText(temp.m_position ,temp.m_damage);
	UpdateAbilityBar();

}