@ -943,19 +943,42 @@ void Player::SetVelocity(vf2d vel){
}
}
void Player : : SetAnimationBasedOnTargetingDirection ( float targetDirection ) {
void Player : : SetAnimationBasedOnTargetingDirection ( float targetDirection ) {
if ( GetClass ( ) = = Class : : RANGER ) {
auto FacingEast = [ & ] ( ) { return targetDirection < = PI / 4 & & targetDirection > - PI / 4 ; } ;
if ( targetDirection < = PI / 4 & & targetDirection > - PI / 4 ) {
auto FacingWest = [ & ] ( ) { return targetDirection > = 3 * PI / 4 | | targetDirection < - 3 * PI / 4 ; } ;
UpdateAnimation ( " RANGER_SHOOT_E " ) ;
auto FacingSouth = [ & ] ( ) { return targetDirection < = 3 * PI / 4 & & targetDirection > PI / 4 ; } ;
auto FacingNorth = [ & ] ( ) { return targetDirection > = - 3 * PI / 4 & & targetDirection < - PI / 4 ; } ;
switch ( GetClass ( ) ) {
case Class : : WARRIOR :
case Class : : THIEF : {
if ( FacingNorth ( ) ) {
UpdateAnimation ( " WARRIOR_SWINGSWORD_N " ) ;
} else
} else
if ( targetDirection > = 3 * PI / 4 | | targetDirection < - 3 * PI / 4 ) {
if ( FacingSouth ( ) ) {
UpdateAnimation ( " RANGER_SHOOT_W " ) ;
UpdateAnimation ( " WARRIOR_SWINGSWORD_S " ) ;
} else
} else
if ( targetDirection < = 3 * PI / 4 & & targetDirection > PI / 4 ) {
if ( FacingWest ( ) ) {
UpdateAnimation ( " RANGER_SHOOT_S " ) ;
UpdateAnimation ( " WARRIOR_SWINGSWORD_W " ) ;
} else
} else
if ( targetDirection > = - 3 * PI / 4 & & targetDirection < - PI / 4 ) {
if ( FacingEast ( ) ) {
UpdateAnimation ( " WARRIOR_SWINGSWORD_E " ) ;
}
} break ;
case Class : : RANGER :
case Class : : TRAPPER : {
if ( FacingNorth ( ) ) {
UpdateAnimation ( " RANGER_SHOOT_N " ) ;
UpdateAnimation ( " RANGER_SHOOT_N " ) ;
} else
if ( FacingSouth ( ) ) {
UpdateAnimation ( " RANGER_SHOOT_S " ) ;
} else
if ( FacingWest ( ) ) {
UpdateAnimation ( " RANGER_SHOOT_W " ) ;
} else
if ( FacingEast ( ) ) {
UpdateAnimation ( " RANGER_SHOOT_E " ) ;
}
}
} break ;
}
}
}
}