Esempio n. 1
0
void Hero::onWalkAttack(){
    if (!m_moveable){
        return;
    }
    Role::onWalkAttack();
    CheckAttack(0);
}
Esempio n. 2
0
void Player::Update(float dt) {
	
	m_Aim = glm::vec2(g_Mouse.Position().x, g_Mouse.Position().y) / glm::vec2(1280, 720);
	m_Aim = m_Aim * 2.0f - 1.0f;
	m_Rotation = (atan2f(m_Aim.y, m_Aim.x) + 3.14f * 0.5f) * 180.0f / 3.14f; //adjust for sprite
	sf::Keyboard kb;
	m_Direction = glm::vec2(0);
	if (kb.isKeyPressed(sf::Keyboard::W)){
		m_Direction += glm::vec2(0, -1);
	}
	if (kb.isKeyPressed(sf::Keyboard::S)){
		m_Direction += glm::vec2(0, 1);
	}
	if (kb.isKeyPressed(sf::Keyboard::D)){
		m_Direction += glm::vec2(1, 0);
	}
	if (kb.isKeyPressed(sf::Keyboard::A)){
		m_Direction += glm::vec2(-1, 0);
	}

	if (m_PounceTimer > 0.0f) {
		m_Direction = m_PounceDirection;
	}
	if (!m_Mauling){
		m_Position += m_Direction * m_MovementSpeed * dt;
	}
	g_Camera.SetPosition(m_Position);

	if (m_Direction == glm::vec2(0, 0)){
		m_Walking = false;
	}else{
		m_Walking = true;
	}

	if (m_Walking && !m_Mauling && !m_Pouncing){
		m_AnimationTimer += dt * 10.0f;
		int frame = (int)m_AnimationTimer;
		m_Sprite.setTextureRect(sf::IntRect(120 * (m_WalkAnimation[frame % 6]), 0, 120, 450));
	}
	else if (m_Pouncing){
		m_AnimationTimer += dt * 20.0f;
		int frame = (int)m_AnimationTimer;
		m_Sprite.setTextureRect(sf::IntRect(120 * (m_PouncingAnimation[frame % 3]), 900, 120, 450));
	}
	else if (!m_Walking&& !m_Mauling && !m_Pouncing){
		m_Sprite.setTextureRect(sf::IntRect(120 * (0), 0, 120, 450));
	}
	CheckAttack(dt);
	GameObject::Update(dt); //will update the sprite
}
Esempio n. 3
0
float CheckAnyAttack()
{
	if ( !enemy_vis )
		return false;

	if ( streq( self->s.v.classname, "monster_dog" ) )
		return DogCheckAttack ();
	if ( streq( self->s.v.classname, "monster_army" ) )
		return SoldierCheckAttack ();
	if ( streq( self->s.v.classname, "monster_ogre" ) )
		return OgreCheckAttack ();
	if ( streq( self->s.v.classname, "monster_shambler" ) )
		return ShamCheckAttack ();
	if ( streq( self->s.v.classname, "monster_demon1" ) )
		return DemonCheckAttack ();
	if ( streq( self->s.v.classname, "monster_wizard" ) )
		return WizardCheckAttack ();

	return CheckAttack ();
}
Esempio n. 4
0
void CMeleeWeapon::Think( void )
{
	idMoveable::Think();

	// Move the custom clipmodel around to match the weapon
	if( m_WeapClip )
	{
		idMat3 CMaxis;

		if( m_bClipAxAlign )
			CMaxis = GetPhysics()->GetAxis();
		else
			CMaxis = mat3_identity;

		// option to maintain pitch relative to world
		// (only implemented for parries for now)
		if( m_bClipYawOnly )
		{
			idAngles tempAng = CMaxis.ToAngles();
			// idAngles pitchAng;
			// pitchAng.Zero();
			// pitchAng.pitch = m_ClipPitchAngle;
			tempAng.pitch = 0;
			tempAng.roll = 0;
			CMaxis = tempAng.ToMat3();
			// CMaxis = pitchAng.ToMat3() * CMaxis;
			// CMaxis = mat3_identity;
		}

		// Is id = 0 correct here, or will that cause problems with
		// the other clipmodel, which is also zero?
		
		if( m_bParrying )
		{
			idClipModel *pClip;
			if( m_WeapClip )
			{
				// m_WeapClip->Link( gameLocal.clip, this, 0, GetPhysics()->GetOrigin() + m_ClipOffset, CMaxis * m_ClipRotation );
				m_WeapClip->Link( gameLocal.clip, this, 0, GetPhysics()->GetOrigin() + m_ClipOffset, m_ClipRotation * CMaxis  );
				pClip = m_WeapClip;
			}
			else
				pClip = GetPhysics()->GetClipModel();
			
			// Debug display of the parry clipmodel
			if( m_bParrying && cv_melee_debug.GetBool())
			{
				collisionModelManager->DrawModel
					(
						pClip->Handle(), GetPhysics()->GetOrigin() + m_ClipOffset, m_ClipRotation * CMaxis,
						gameLocal.GetLocalPlayer()->GetEyePosition(), idMath::INFINITY 
					);
			}
		}
	}

	// Run the checks for an attack, handle what happens when something is hit
	// TODO: Time interleave this test?
	if( m_bAttacking )
	{
		CheckAttack( m_OldOrigin, m_OldAxis );

		m_OldOrigin = GetPhysics()->GetOrigin() + m_ClipOffset;
		m_OldAxis = GetPhysics()->GetAxis() * m_ClipRotation;
	}
}
Esempio n. 5
0
void Hero::onJumpAttack(){
    Role::onJumpAttack();
    m_velocity.x = 0;
    CheckAttack(0);
}