//测试DPad的输入,并转换成合适的键值传递 private void TestDPadWord() { Vector2 axis = GetDPadAxis(); if (axis != Vector2.zero) { EInputWord lastWord = GetDPadWord(m_LastDPadAxis); EInputWord word = GetDPadWord(axis); if (lastWord != word) { if (lastWord != EInputWord.NONE) { m_InputSystem.OnInput(lastWord, false); m_KeyStates[(int)lastWord] = false; } m_InputSystem.OnInput(word, true); m_KeyStates[(int)word] = true; } } else if (m_LastDPadAxis != Vector2.zero) { EInputWord lastWord = GetDPadWord(m_LastDPadAxis); if (lastWord != EInputWord.NONE) { m_InputSystem.OnInput(lastWord, false); m_KeyStates[(int)lastWord] = false; } } m_LastDPadAxis = axis; }
private void HandleMultipleWordDown(EInputWord word) { if (m_PressingWord1 == EInputWord.NONE) { m_PressingWord1 = word; } else if (m_PressingWord2 == EInputWord.NONE) { m_PressingWord2 = word; } else if (m_PressingWord1 != word) { m_PressingWord1 = word; } else if (m_PressingWord2 != word) { m_PressingWord2 = word; } if (m_PressMovingWordTime == 0.0f) { m_PressMovingWordTime = Time.time; } UpdateCursor(true); Debug.Log(string.Format("down current input word:{0} word1:{1} word2:{2}", word, m_PressingWord1, m_PressingWord2)); }
//测试扳机键的输入 private void TestTrigger(EInputWord trigger) { float value = 0; float lastValue = 0; if (trigger == EInputWord.LT) { value = UnityEngine.Input.GetAxis(InputConst.XBOX_KEYWORD_LT) != 0 ? 1 : 0; lastValue = m_LastLTrigger; m_LastLTrigger = value; } else if (trigger == EInputWord.RT) { value = UnityEngine.Input.GetAxis(InputConst.XBOX_KEYWORD_RT) != 0 ? 1 : 0; lastValue = m_LastRTrigger; m_LastRTrigger = value; } if (value > 0) { if (lastValue == 0) { m_InputSystem.OnInput(trigger, true); } m_KeyStates[(int)trigger] = true; } else if (lastValue > 0) { m_InputSystem.OnInput(trigger, false); m_KeyStates[(int)trigger] = false; } }
private void MouseTest(int mouseKey, EInputWord word) { if (UnityEngine.Input.GetMouseButtonDown(mouseKey)) { m_InputSystem.OnInput(word, true); } if (UnityEngine.Input.GetMouseButtonUp(mouseKey)) { m_InputSystem.OnInput(word, false); } }
private void KeyTest(KeyCode keyCode, EInputWord word) { if (UnityEngine.Input.GetKeyDown(keyCode)) { m_InputSystem.OnInput(word, true); } if (UnityEngine.Input.GetKeyUp(keyCode)) { m_InputSystem.OnInput(word, false); } }
public void OnInput(EInputWord word, bool down) { inputMsg.Word = word; inputMsg.IsDown = down; foreach (InputEvent del in m_InputEvent) { if (del.Delegate(inputMsg)) { break; } } }
//测试功能键的输入 private void TestFunctionKeyWord(string button, EInputWord word) { if (UnityEngine.Input.GetButtonDown(button)) { m_InputSystem.OnInput(word, true); m_KeyStates[(int)word] = true; } else if (UnityEngine.Input.GetButtonUp(button)) { m_InputSystem.OnInput(word, false); m_KeyStates[(int)word] = false; } }
public bool GetInput(EInputWord word) { bool active = false; for (int i = 0; i < m_InputDevices.Count; ++i) { if ((active = m_InputDevices[i].GetInput(word))) { return(active); } } return(active); }
private void HandleMultipleWordUp(EInputWord word) { if (m_PressingWord1 == word) { m_PressingWord1 = EInputWord.NONE; } if (m_PressingWord2 == word) { m_PressingWord2 = EInputWord.NONE; } if (m_PressingWord1 == m_PressingWord2 && m_PressingWord1 == EInputWord.NONE) { m_PressMovingWordTime = 0.0f; } Debug.Log(string.Format("up current input word:{0} word1:{1} word2:{2}", word, m_PressingWord1, m_PressingWord2)); }
// 根据输入得到方向 public static Direction GetDirectionByInputWord(EInputWord word) { switch (word) { case EInputWord.DPAD_UP: return(Direction.North); case EInputWord.DPAD_DOWN: return(Direction.South); case EInputWord.DPAD_LEFT: return(Direction.West); case EInputWord.DPAD_RIGHT: return(Direction.East); } return(Direction.Center); }
public override bool GetInput(EInputWord input) { return(m_KeyStates[(int)input]); }
public static bool IsAttackWord(EInputWord word) { return(word == EInputWord.LB || word == EInputWord.RB || word == EInputWord.RT || word == EInputWord.LT); }
public abstract bool GetInput(EInputWord input);
// 根据输入得到整形向量 public static IPoint GetPointByInputWord(EInputWord word, int step) { return(GetPointByDir(GetDirectionByInputWord(word), step)); }
public override bool GetInput(EInputWord input) { return(false); }