Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IEnumerator PerformActionOnInput(Dictionary<string, Action> inputActions)
- {
- bool pressed = false;
- while (!pressed)
- {
- foreach (string k in inputActions.Keys)
- {
- if (Input.GetButtonDown(k))
- {
- inputActions[k].Invoke();
- pressed = true;
- break;
- }
- }
- yield return null;
- }
- }
- public void Move()
- {
- if(!selected)
- return;
- var actions = new Dictionary<string, Action>()
- {
- {
- "Fire1", () =>
- {
- Debug.Log("Moving: " + selected.name);
- var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
- RaycastHit hit;
- if (Physics.Raycast(ray, out hit, float.MaxValue, moveMask))
- {
- selected.Move(hit.point);
- }
- }
- },
- {
- "Fire2", () => { return; }
- }
- };
- StartCoroutine(PerformActionOnInput(actions));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement