private void UpdateTimer(Keys key, Buttons button, float directionX, float directionY, float elapsedTime, ButtonDown downAction, ButtonUp upAction, ButtonPressed pressAction, ref float downTimer, ref float upTimer)
{
if (IsKeyDown(key) || currentGamePadState.IsButtonDown(button))
{
if(downAction != null && downTimer == 0)
downAction.Invoke(directionX, directionY, upTimer, PlayerIndex);
downTimer += elapsedTime;
upTimer = 0;
}
else if (IsKeyUp(key) || currentGamePadState.IsButtonUp(button))
{
//Check if it was a press of key
if(this.oldKeyboardState.IsKeyDown(key) || oldGamePadState.IsButtonDown(button)){
if (pressAction != null)
pressAction.Invoke(PlayerIndex);
if (upAction != null)
upAction.Invoke(downTimer, PlayerIndex);
}
upTimer += elapsedTime;
downTimer = 0;
}
}