Exemplo n.º 1
0
		/*=============================================================================
        -- Draws the actor.
        =============================================================================*/
        void Actor::Draw(int sx, int sy, Window *window)
        {
			Entity::Draw(sx, sy, window);

            GetAnimationManager().lock()->GetActiveAnimation().lock()->SetWindow(window);	//TODO why are you setting the window every draw call?
			GetAnimationManager().lock()->GetActiveAnimation().lock()->Draw(sx, sy);
        }
Exemplo n.º 2
0
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Summary: The function that HURTS the player! His health goes down and then it checks
		 if he's still alive. If so, starts the death process; if not, does got damaged
		 stuff.
Parameters:
[in] _damage - the amount of damage to receive.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void CPlayer::TakeDamage( int _damage )
{
	// if he's currently not invulnerable.
	if( GetInvulnerableTime() <= 0.0f )
	{
		if( this->GetHealth() > 0 )
		{
			this->SetHealth( this->GetHealth() - _damage );
			if( this->GetHealth() < 0 )
				this->SetHealth( 0 );
//			AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_DX_2D_UNDERATTACK);
			//HAX
			//AUTH: Ryan
			//Desc: feedback for player hurt, replace with animation / effect later
			//Date: ????
			m_Hurt = true;
			GetAnimationManager()->SwitchAnimation(CAssetManager::GetInstance()->GetAnimation(ET_PLAYER, PL_HURT), 0.2f);
			//this->GetRenderNode().hTextureDiffuse = CAssetManager::GetInstance()->GetSmallEnemyData(RED).m_DiffuseHandle;
		}
		else if( this->GetHealth() <= 0 )
			GetAnimationManager()->SwitchAnimation(CAssetManager::GetInstance()->GetAnimation(ET_PLAYER, PL_DEATH), 0.1f);
		
		std::cout << "Player Health: " << this->GetHealth() << "/" << MAX_HP_PLAYER << std::endl;

		// TODO:: Animations
		if( this->GetHealth() != 0 )
		{
			// TODO:: Play damage sound
			// TODO:: Play damage animation
			// TODO:: Use damage effect
		}
		else
		{
			// TODO:: Play death sound
			// TODO:: Play Death animation
			// TODO:: Use Death effect
			// TODO:: Activate GAME OVER process.
			if( GetLives() > 1 )
			{
				m_DeathTimer = (float)(CAssetManager::GetInstance()->GetAnimation(ET_PLAYER, PL_DEATH)->GetDuration() - 0.6f);
				//CMessageSystem::GetInstance()->SendMessage(new CCreateVFXMessage(GEO_EMITTER_BLOOD_POOL,this,0.0f,0.0f,0.0f));
			}
			else
				m_DeathTimer = (float)(CAssetManager::GetInstance()->GetAnimation(ET_PLAYER, PL_LOSE)->GetDuration() - 0.6f);

			std::cout << "PLAYER DYING!" << std::endl;
//			AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_DX_3D_DEATH);
		}

		this->SetInvulnerableTime(1.0f);
	}
}
Exemplo n.º 3
0
AnimationPlayerCollection*
AnimationPlayer::GetCollection() const
{
  css::CommonAnimationManager* manager = GetAnimationManager();
  if (!manager) {
    return nullptr;
  }
  MOZ_ASSERT(mSource, "A player with an animation manager must have a source");

  Element* targetElement;
  nsCSSPseudoElements::Type targetPseudoType;
  mSource->GetTarget(targetElement, targetPseudoType);
  MOZ_ASSERT(targetElement,
             "A player with an animation manager must have a target");

  return manager->GetAnimationPlayers(targetElement, targetPseudoType, false);
}
Exemplo n.º 4
0
AnimationCollection*
Animation::GetCollection() const
{
  css::CommonAnimationManager* manager = GetAnimationManager();
  if (!manager) {
    return nullptr;
  }
  MOZ_ASSERT(mEffect,
             "An animation with an animation manager must have an effect");

  Element* targetElement;
  nsCSSPseudoElements::Type targetPseudoType;
  mEffect->GetTarget(targetElement, targetPseudoType);
  MOZ_ASSERT(targetElement,
             "An animation with an animation manager must have a target");

  return manager->GetAnimations(targetElement, targetPseudoType, false);
}
Exemplo n.º 5
0
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Summary: Updates the medium enemy!
Parameters:
[in] _elapsedTime - the time passed since the last frame.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
bool CMediumEnemy::Update( float _elapsedTime )
{
#if _DEBUG
	if(this->GetIsPaused())
	{
		this->GetAnimationManager()->Update(_elapsedTime, &this->GetRenderNode());
		return true;
	}
#endif

	if(m_SpawnTimer > 0.0f)
		m_SpawnTimer -= _elapsedTime;

	Vec4f white = { 1.0f, 1.0f, 1.0f, 1.0f };
	Vec4f black = { 0.2f, 0.2f, 0.2f, 1.0f };
	// If they are preparing an attack.
	if( this->GetState() == Enemy_Charging )
	{
		if(!m_PowerUp && m_PowerUpTimer <= 0.0f)
		{
			CMessageSystem::GetInstance()->SendMessage(new CCreateVFXMessage(EMITTER_POWERUP,this,0.0f,0.0f,0.0f));
			AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MEDIUM_MORTAR_CHARGE);
//			AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_MEDIUM_MORTAR_CHARGE);
			m_PowerUpTimer = 6.0f;
			m_PowerUp = true;
		}


		static float tell_blink = 0.2f;
		tell_blink += _elapsedTime;
		if(tell_blink >= 0.2f)
		{
			if(this->GetRenderNode().GetColor()[0] == white[0])
				this->GetRenderNode().SetColor(black);
			else
				this->GetRenderNode().SetColor(white);

			tell_blink = 0.0f;
		}
	}
	else if(this->GetRenderNode().GetColor()[0] != white[0])
		this->GetRenderNode().SetColor(white);

	if(m_PowerUp)
	{
		m_PowerUpTimer -= _elapsedTime;

		if(m_PowerUpTimer <= 0.0f)
		{
			m_PowerUp = false;
			//AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::);
		}
	}

	// If they are dying.
	if( this->GetState() == Enemy_Dying )
	{
		// Move the enemy into the planet, so it doesn't
		// pop out of the game.
		if(!GetLaserDeath())
		{
			Vec3f nPos, move;
			glsCopyVector3(move,GetRenderNode().GetUpVector());
			glsScaleVector3(move, 10.5f * _elapsedTime);
			glsAddVectors3(nPos,GetRenderNode().GetPosition(),move);
			GetRenderNode().SetPosition( nPos );
		
			// If death timer has just started:
			if( m_DeathTimer == MEDIUM_ENEMY_TIMER_DEATH )
			{
				CMessageSystem::GetInstance()->SendMessageW(new CCreateVFXMessage(EMITTER_EXPLOSION,this,0.0f,0.0f,0.0f));
			}

			// Decrement the death timer.dd
			m_DeathTimer -= _elapsedTime;

			// Check if the timer is finished.
			// If so... KILL ZE ENEMY!
			if(m_DeathTimer <= 0.0f)
				Kill();

			if(m_HurtTimer > 0.0f)
			{
				this->GetRenderNode().SetColor(white);
				m_HurtTimer = 0.0f;
			}
		}
		else
		{
			GetRenderNode().SetDissolveFactor( GetRenderNode().GetDissolveFactor() - _elapsedTime );
			if(GetRenderNode().GetDissolveFactor() <= 0.0f)
			{
				this->SetIsActive(false);
				this->SetIsAlive(false);
				SetLaserDeath(false);
				//Init();
			}
		}

		return true;
	}

	// Update laser invulnerablity timer
	if( m_LaserTimer > 0.0f )
	{
		m_LaserTimer -= _elapsedTime;
		if( m_LaserTimer < 0.0f )
			m_LaserTimer = 0.0f;
	}

	Vec4f red = {1.0f, 0.0f, 0.0f, 1.0f};
	if( m_HurtTimer > 0.0f )
	{
		GetAnimationManager()->SwitchAnimation(CAssetManager::GetInstance()->GetAnimation(ET_MEDIUMENEMY, MEDIUM_HURT), 0.4f);
		if(this->GetRenderNode().GetColor()[1] == white[1])
			this->GetRenderNode().SetColor(red);

		m_HurtTimer -= _elapsedTime;
		if( m_HurtTimer <= 0.0f )
			this->GetRenderNode().SetColor(white);
	}


	// Orient the movement vector
	glsCopyVector3(m_MoveUp, this->GetRenderNode().GetUpVector());
	glsCrossProduct3( m_MoveForward, m_MoveRight, m_MoveUp );
	glsNormalizeVector3( m_MoveForward );
	glsCrossProduct3( m_MoveRight, m_MoveUp, m_MoveForward );
	glsNormalizeVector3( m_MoveRight );

	UpdateVelocity();
	SwitchAnimation();
	CEnemy::Update(_elapsedTime);

	// Death stuff:
	if(this->GetHealth() <= 0 && this->GetState() != Enemy_Dying)
	{
		this->SetState(Enemy_Dying);
		m_DeathTimer = MEDIUM_ENEMY_TIMER_DEATH;
	}

	return true;
}
Exemplo n.º 6
0
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Summary: Updates the player!
Parameters:
[in] _elapsedTime - the time passed since the last frame.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
bool CPlayer::Update( float _elapsedTime )
{
	static bool once = false;
	// Timer for death animation.
	if( m_DeathTimer > 0.0f )
	{
		m_DeathTimer -= _elapsedTime;
		
		m_StopAnimSwitching = true;
		if( GetLives() <= 1 )
		{
				
			if( !once )
			{
				GetAnimationManager()->SwitchAnimation(CAssetManager::GetInstance()->GetAnimation(ET_PLAYER, PL_LOSE), 0.5f);
				AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::STOP_MX_TRACK_04);
				AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::STOP_MX_TRACK_03);
				AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::STOP_MX_TRACK_02);
				AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::STOP_MX_TRACK_01);
				AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_MX_TRACK_02);
				SetLives(0);
				once = true;
			}
		}
		else
		{
			GetAnimationManager()->SwitchAnimation(CAssetManager::GetInstance()->GetAnimation(ET_PLAYER, PL_DEATH), 0.3f);
		}
			
		if(m_DeathTimer <= 0.0f)
		{
			SetIsDying(true);
			SetKillScreen(true);
			once = false;

			if( GetLives() == 0 )
			{
				m_DeathTimer = 0.0f;
				return true;
			}

			m_ResetWave = true;
			m_DeathTimer = 0.0f;
		}
		GetAnimationManager()->Update(_elapsedTime, &GetRenderNode());
		return true;
	}

	if(this->GetHealth() <= 25)
	{
		m_LowHPTimer += _elapsedTime;
		if(m_LowHPTimer > 1.5f)
		{
			m_LowHPTimer = 0.0f;
//			AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_BEEP);
		}
	}

	if(this->m_HealthPickup >= 0.0f)
	{
		static bool healthpickupcolor = false;
		if(healthpickupcolor)
		{
			//GetRenderNode().hTextureDiffuse = CAssetManager::GetInstance()->GetObjData(ET_PLAYER).m_DiffuseHandle;
			GetRenderNode().SetDiffuseTextureHandle( CAssetManager::GetInstance()->GetObjData(ET_SMALLENEMY).m_DiffuseHandle );
		}
		else
		{
			GetRenderNode().SetDiffuseTextureHandle( CAssetManager::GetInstance()->GetObjData(ET_PLAYER).m_DiffuseHandle );
		}
		m_HealthPickup -= HEALTH_PICKUP_BLINKING_TIME;
		healthpickupcolor = !healthpickupcolor;
	}
	else
	{
		GetRenderNode().SetDiffuseTextureHandle( CAssetManager::GetInstance()->GetObjData(ET_PLAYER).m_DiffuseHandle );
	}

	if( GetIsDying() )
	{
		SetIsDying(false);
		SetKillScreen(false);
		//m_StopAnimSwitching = false;

		Vec3f direction;
		glsLoadVector3(direction, 0.0f, 0.0f, 0.0f);
		glsCopyVector3(*GetPosition(), direction);
		GetRenderNode().SetPosition( direction );

		ResetMatrix();
	}

	//	Vec3f direction;
	//	glsLoadVector3(direction, 0.0f, 0.0f, 0.0f);

	//	// Gets the two distances between the north and south pole (possibly in need of optimizations later).
	//	float SDist = glsGetDistance3(direction, GetRenderNode().m_vPosition);
	//	glsLoadVector3(direction, 0.0f, 150.0f, 0.0f);
	//	float NDist = glsGetDistance3(direction, GetRenderNode().m_vPosition);
	//	// finds the shortest one so it can travel to that one
	//	bool HeadinNorth = NDist < SDist ;

	//	// resets the vector if heading to the south
	//	if(!HeadinNorth)
	//		glsLoadVector3(direction, 0.0f, 0.0f, 0.0f);

	//	// gets the directional vector
	//	glsSubtractVectors3(direction, direction, GetRenderNode().m_vPosition);
	//	glsNormalizeVector3(direction);
	//	glsScaleVector3(direction, 30.0f * _elapsedTime);
	//	
	//	// moves the player by that direction by elapsedTime
	//	glsAddVectors3(GetRenderNode().m_vPosition, GetRenderNode().m_vPosition, direction);

	//	// if the distance is small enough the player stops moving
	//	//glsLoadVector3(direction, 0.0f, 0.0f, 0.0f);
	//	if( (HeadinNorth ? NDist : SDist) <= 0.5f )
	//	{
	//		SetIsDying(false);
	//		m_StopAnimSwitching = false;
	//		ResetMatrix();
	//		GetAnimationManager()->SwitchAnimation(CAssetManager::GetInstance()->GetAnimation(ET_PLAYER, PL_IDLE), 0.01f);
	//	}

	//	// copying the player's new position%
	//	glsCopyVector3(*this->GetPosition(), GetRenderNode().m_vPosition);
	//	
	//	// remaking the player's up vector
	//	Vec3f world = { 0.0f, 75.0f, 0.0f };
	//	glsSubtractVectors3(direction, world, GetRenderNode().m_vPosition);

	//	glsNormalizeVector3(direction);
	//	glsCopyVector3(GetRenderNode().m_vUp, direction);

	//	glsCrossProduct3( this->GetRenderNode().m_vForward, this->GetRenderNode().m_vRight, this->GetRenderNode().m_vUp );
	//	glsNormalizeVector3( this->GetRenderNode().m_vForward );

	//	glsCrossProduct3( this->GetRenderNode().m_vRight, this->GetRenderNode().m_vUp, this->GetRenderNode().m_vForward );
	//	glsNormalizeVector3( this->GetRenderNode().m_vRight );

	//	// returing out so no other calcualtions are done.
	//	GetAnimationManager()->Update(_elapsedTime, &GetRenderNode());
	//	return true;
	//}

	if( m_PullTimer > 0.0f )
		m_PullTimer -= _elapsedTime;
	else if( m_PullTimer < 0.0f )
		m_PullTimer = 0.0f;

	if( m_PushTimer > 0.0f )
		m_PushTimer -= _elapsedTime;
	else if( m_PushTimer < 0.0f )
		m_PushTimer = 0.0f;

	m_Gun.AddTime(_elapsedTime);

	// Orient the movement
	glsCopyVector3(m_MoveUp, this->GetRenderNode().GetUpVector());
	glsCrossProduct3( m_MoveForward, m_MoveRight, m_MoveUp );
	glsNormalizeVector3( m_MoveForward );

	glsCrossProduct3( m_MoveRight, m_MoveUp, m_MoveForward );
	glsNormalizeVector3( m_MoveRight );

	// Update the velocities.
	UpdateVelocity();

	m_PosXOffset += (*this->GetVelocity())[0] * _elapsedTime;
	m_PosYOffset += (*this->GetVelocity())[1] * _elapsedTime;

	// Call parents update
	CLivingEntity::Update(_elapsedTime);

	// Update player specific data.
	// Player position	
	GetRenderNode().SetPosition( ((const float *)(*GetPosition())) );

	if( m_JumpTimer > 0.0f )
	{
		m_JumpTimer -= _elapsedTime;
	}
	else if( m_JumpTimer < 0.0f )
		m_JumpTimer = 0.0f;



	//////////////////////////////////////////////
	// Debug Code
	//////////////////////////////////////////////
	//if( GetAsyncKeyState('P') & 0x01 )
	//{
	//	std::cout << "HUD INFO:\n";
	//	std::cout << "HP : " << this->GetHealth() << '/' << MAX_HP_PLAYER << std::endl;
	//	std::cout << "Lives : " << this->GetLives() << std::endl;
	//	std::cout << "Ammo : " << this->GetGun().GetShotTotal() << std::endl;
	//	std::cout << "Curr Gun : " << this->GetGun().GetConsumed() << std::endl;
	//}

	//HAX
	//AUTH: Ryan
	//Desc: feedback for player hurt, replace with animation / effect later
	//Date: ????
	static float hurtTimer = 0.0f;
	if(m_Hurt)
	{
		GetRenderNode().SetColor(1.0f, 0.2f, 0.2f, 1.0f);
		hurtTimer += _elapsedTime;
		if(hurtTimer >= 0.5f)
		{
			//this->GetRenderNode().hTextureDiffuse = CAssetManager::GetInstance()->GetObjData(ET_PLAYER).m_DiffuseHandle;
			GetRenderNode().SetColor(1.0f, 1.0f, 1.0f, 1.0f);
			hurtTimer = 0.0f;
			m_Hurt = false;
		}
	}

	glsCopyVector3(((Sphere*)this->GetCollisionEntity())->m_Center, this->GetRenderNode().GetPosition());
	return true;
}