The key concept here is, using the delegation, you'e just pointing to a method which accepts an input parameter, so it won't work like what you've written in your code, the parameter should be passed during invocation! So as a workaround you can write st. like this:
internal class Input : IInput
{
private readonly IDictionary<Keys, Tuple<Action<Directions>, Directions>> keyBindings;
public void BindKey( Keys key, Tuple<Action<Directions>, Directions> action)
{
keyBindings.Add( key, action );
}
public void Process()
{
// update keyboard state...
foreach ( var binding in keyBindings )
{
if ( keyboard.IsKeyDown( binding.Key )
{
binding.Value.Item1(binding.Value.Item2);
}
}
}
}
Use input.BindKey
like this:
input.BindKey(Keys.W, Tuple.Create<Action<Directions>, Directions>(Move, Directions.Up));
EDIT:
You can even do that with you original Input
class and instead of pointing to the Move
method, you can create a delegate to do it for you (s.t like @Magus said in the comments) like this:
input.BindKey(Keys.W, () => Move(Directions.Up));
this way, during the invocation, this delate will be invoked and in turn as you can see it invokes the Move
method with required parameter.