HKI Core
InputHandlers.cs
Go to the documentation of this file.
1 using UnityEngine;
2 using HKI.Core.Variables;
3 
4 namespace HKI.Core.GameSystems.Input
5 {
9  public interface InputHandler
10  {
11  // Interface functions
16  bool Validate();
17 
21  void Update();
22  }
23 
24  [System.Serializable]
26  {
27  // Public variables
28  [SerializeField] KeyCode KeyCode = KeyCode.A;
29  [SerializeField] Boolean BooleanValue = null;
30 
31  // Interface function
36  public bool Validate()
37  {
38  return BooleanValue != null;
39  }
40 
44  public void Update()
45  {
46  if(UnityEngine.Input.GetKeyDown(KeyCode))
47  BooleanValue.SetValue = !BooleanValue.Value;
48  }
49  }
50 
51  [System.Serializable]
53  {
54  // Public variables
55  [SerializeField] KeyCode KeyCode = KeyCode.A;
56  [SerializeField] Boolean BooleanValue = null;
57 
58  // Interface function
63  public bool Validate()
64  {
65  return BooleanValue != null;
66  }
67 
71  public void Update()
72  {
73  BooleanValue.SetValue = UnityEngine.Input.GetKeyDown(KeyCode);
74  }
75  }
76 
77  [System.Serializable]
79  {
80  // Public variables
81  [SerializeField] KeyCode KeyCode = KeyCode.A;
82  [SerializeField] Boolean BooleanValue = null;
83 
84  // Interface function
89  public bool Validate()
90  {
91  return BooleanValue != null;
92  }
93 
97  public void Update()
98  {
99  BooleanValue.SetValue = UnityEngine.Input.GetKeyUp(KeyCode);
100  }
101  }
102 
103  [System.Serializable]
105  {
106  // Public variables
107  [SerializeField]
108  KeyCode KeyCode = KeyCode.A;
109  [SerializeField]
110  Boolean BooleanValue = null;
111 
112  // Interface function
117  public bool Validate()
118  {
119  return BooleanValue != null;
120  }
121 
125  public void Update()
126  {
127  BooleanValue.SetValue = UnityEngine.Input.GetKey(KeyCode);
128  }
129  }
130 
131  [System.Serializable]
133  {
134  // Public variables
135  [SerializeField] HKI.Core.Variables.Vector2 Position = null;
136 
137  // Interface function
142  public bool Validate()
143  {
144  return Position != null;
145  }
146 
150  public void Update()
151  {
152  Position.SetValue = UnityEngine.Input.mousePosition;
153  }
154  }
155 
156  [System.Serializable]
158  {
159  // Public variables
160  [SerializeField] int MouseButtonId = 0;
161  [SerializeField] Boolean BooleanValue = null;
162 
163  // Interface function
168  public bool Validate()
169  {
170  return BooleanValue != null;
171  }
172 
176  public void Update()
177  {
178  BooleanValue.SetValue = UnityEngine.Input.GetMouseButtonDown(MouseButtonId);
179  }
180  }
181 
182  [System.Serializable]
184  {
185  // Public variables
186  [SerializeField] int MouseButtonId = 0;
187  [SerializeField] Boolean BooleanValue = null;
188 
189  // Interface function
194  public bool Validate()
195  {
196  return BooleanValue != null;
197  }
198 
202  public void Update()
203  {
204  BooleanValue.SetValue = UnityEngine.Input.GetMouseButtonUp(MouseButtonId);
205  }
206  }
207 
208  [System.Serializable]
210  {
211  // Public variables
212  [SerializeField] int MouseButtonId = 0;
213  [SerializeField] Boolean BooleanValue = null;
214 
215  // Interface function
220  public bool Validate()
221  {
222  return BooleanValue != null;
223  }
224 
228  public void Update()
229  {
230  BooleanValue.SetValue = UnityEngine.Input.GetMouseButton(MouseButtonId);
231  }
232  }
233 
234  [System.Serializable]
236  {
237  // Public variables
238  [SerializeField] string AxisName = "";
239  [SerializeField] Float FloatValue = null;
240 
241  // Interface function
246  public bool Validate()
247  {
248  return FloatValue != null;
249  }
250 
254  public void Update()
255  {
256  FloatValue.SetValue = UnityEngine.Input.GetAxis(AxisName);
257  }
258  }
259 
260  [System.Serializable]
262  {
263  // Public variables
264  [SerializeField] string AxisName = "";
265  [SerializeField] Float FloatValue = null;
266 
267  // Interface function
272  public bool Validate()
273  {
274  return FloatValue != null;
275  }
276 
280  public void Update()
281  {
282  FloatValue.SetValue = UnityEngine.Input.GetAxisRaw(AxisName);
283  }
284  }
285 }
void Update()
This function will implement the actual logic of the toogle the value.
bool Validate()
Validation function that check if the handler is setup properly (all parameters are set and not null)...
bool Validate()
Validation function that check if the handler is setup properly (all parameters are set and not null)...
void Update()
This function will implement the actual logic of checking the mouse button.
bool Validate()
Validation function that check if the handler is setup properly (all parameters are set and not null)...
void Update()
This function will implement the actual logic of checking the key up.
Implementation of a float value as a HKIVar via HKIVarGeneric.
Definition: Float.cs:16
Interface for all InputHandler.
Definition: InputHandlers.cs:9
void Update()
This function will implement the actual logic of setting a input axis value.
bool Validate()
Validation function that check if the handler is setup properly (all parameters are set and not null)...
void Update()
This function will implement the actual logic of checking the mouse button down.
Implementation of a boolean value as a HKIVar via HKIVarGeneric.
Definition: Boolean.cs:16
void Update()
This function will implement the actual logic of checking the mouse button up.
void Update()
This function will implement the actual logic of checking the key.
bool Validate()
Validation function that check if the handler is setup properly (all parameters are set and not null)...
bool Validate()
Validation function that check if the handler is setup properly (all parameters are set and not null)...
Implementation of a Vector2 value as a HKIVar via HKIVarGeneric.
Definition: Vector2.cs:14
bool Validate()
Validation function that check if the handler is setup properly (all parameters are set and not null)...
void Update()
This function will implement the actual logic of setting a input axis raw value.
void Update()
This function will implement the actual logic of setting the mouse position.
bool Validate()
Validation function that check if the handler is setup properly (all parameters are set and not null)...
bool Validate()
Validation function that check if the handler is setup properly (all parameters are set and not null)...
void Update()
This function will implement the actual logic of checking the key down.
bool Validate()
Validation function that check if the handler is setup properly (all parameters are set and not null)...