-
Notifications
You must be signed in to change notification settings - Fork 0
/
InputManager.cs
39 lines (36 loc) · 1.04 KB
/
InputManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Collections.Generic;
public enum InputAction
{
None,
MovePlayerLeft,
MovePlayerRight,
MovePlayerUp,
MovePlayerDown,
SpeedUp,
SlowDown,
EatGlob,
Exit
}
public static class InputManager
{
private static readonly Dictionary<ConsoleKey, InputAction> Actions = new Dictionary<ConsoleKey, InputAction>()
{
{ConsoleKey.LeftArrow , InputAction.MovePlayerLeft},
{ConsoleKey.RightArrow , InputAction.MovePlayerRight},
{ConsoleKey.UpArrow , InputAction.MovePlayerUp},
{ConsoleKey.DownArrow , InputAction.MovePlayerDown},
{ConsoleKey.OemPlus , InputAction.SpeedUp},
{ConsoleKey.Oem4 , InputAction.SlowDown},
{ConsoleKey.Spacebar , InputAction.EatGlob},
{ConsoleKey.Escape , InputAction.Exit}
};
public static InputAction GetInputAction(ConsoleKeyInfo consoleKeyInfo)
{
if(Actions.ContainsKey(consoleKeyInfo.Key))
{
return Actions[consoleKeyInfo.Key];
}
return InputAction.None;
}
}