public void InjectKeyDown( SharpInputSystem.KeyEventArgs e )
{
if ( e.Key == SharpInputSystem.KeyCode.Key_Q && ( topAnimID == AnimationID.IdleTop || topAnimID == AnimationID.RunTop ) )
{
// take swords out (or put them back, since it's the same animation but reversed)
SetTopAnimation( AnimationID.DrawSword, true );
timer = 0;
}
else if ( e.Key == SharpInputSystem.KeyCode.Key_E && !swordsDrawn )
{
if ( topAnimID == AnimationID.IdleTop || topAnimID == AnimationID.RunTop )
{
// start dancing
SetBaseAnimation( AnimationID.Dance, true );
SetTopAnimation( AnimationID.None );
// disable hand animation because the dance controls hands
anims[ (int)AnimationID.HandsRelaxed ].IsEnabled = false;
}
else if ( baseAnimID == AnimationID.Dance )
{
// stop dancing
SetBaseAnimation( AnimationID.IdleBase, true );
SetTopAnimation( AnimationID.IdleTop );
// re-enable hand animation
anims[ (int)AnimationID.HandsRelaxed ].IsEnabled = true;
}
}
// keep track of the player's intended direction
else if ( e.Key == SharpInputSystem.KeyCode.Key_W )
keyDirection.z = -1;
else if ( e.Key == SharpInputSystem.KeyCode.Key_A )
keyDirection.x = -1;
else if ( e.Key == SharpInputSystem.KeyCode.Key_S )
keyDirection.z = 1;
else if ( e.Key == SharpInputSystem.KeyCode.Key_D )
keyDirection.x = 1;
else if ( e.Key == SharpInputSystem.KeyCode.Key_SPACE && ( topAnimID == AnimationID.IdleTop || topAnimID == AnimationID.RunTop ) )
{
// jump if on ground
SetBaseAnimation( AnimationID.JumpStart, true );
SetTopAnimation( AnimationID.None );
timer = 0;
}
if ( !keyDirection.IsZeroLength && baseAnimID == AnimationID.IdleBase )
{
// start running if not already moving and the player wants to move
SetBaseAnimation( AnimationID.RunBase, true );
if ( topAnimID == AnimationID.IdleTop )
SetTopAnimation( AnimationID.RunTop, true );
}
}