public override void OnKeyBoardMessage(KeyBoardMessage msg) { switch (msg.type) { case InputMsgType.InputMsgType_KeyDown: { switch (msg.kcode) { case KeyCode.W: m_bMoveForward = true; break; case KeyCode.S: m_bMoveBack = true; break; case KeyCode.A: m_bMoveLeft = true; break; case KeyCode.D: m_bMoveRight = true; break; default: break; } } break; case InputMsgType.InputMsgType_KeyUp: { switch (msg.kcode) { case KeyCode.W: m_bMoveForward = false; break; case KeyCode.S: m_bMoveBack = false; break; case KeyCode.A: m_bMoveLeft = false; break; case KeyCode.D: m_bMoveRight = false; break; default: break; } } break; default: break; } }
void ProcessKeyBoard(IInputMessageHandler handler) { if (handler == null) { return; } KeyCode code = KeyCode.None; KeyBoardMessage keyboardMsg = new KeyBoardMessage(); if (Input.GetKeyDown(KeyCode.W)) { code = KeyCode.W; keyboardMsg.kcode = code; keyboardMsg.type = InputMsgType.InputMsgType_KeyDown; handler.OnKeyMessage(keyboardMsg); } if (Input.GetKeyDown(KeyCode.S)) { code = KeyCode.S; keyboardMsg.kcode = code; keyboardMsg.type = InputMsgType.InputMsgType_KeyDown; handler.OnKeyMessage(keyboardMsg); } if (Input.GetKeyDown(KeyCode.A)) { code = KeyCode.A; keyboardMsg.kcode = code; keyboardMsg.type = InputMsgType.InputMsgType_KeyDown; handler.OnKeyMessage(keyboardMsg); } if (Input.GetKeyDown(KeyCode.D)) { code = KeyCode.D; keyboardMsg.kcode = code; keyboardMsg.type = InputMsgType.InputMsgType_KeyDown; handler.OnKeyMessage(keyboardMsg); } if (Input.GetKeyUp(KeyCode.W)) { code = KeyCode.W; keyboardMsg.kcode = code; keyboardMsg.type = InputMsgType.InputMsgType_KeyUp; handler.OnKeyMessage(keyboardMsg); } if (Input.GetKeyUp(KeyCode.S)) { code = KeyCode.S; keyboardMsg.kcode = code; keyboardMsg.type = InputMsgType.InputMsgType_KeyUp; handler.OnKeyMessage(keyboardMsg); } if (Input.GetKeyUp(KeyCode.A)) { code = KeyCode.A; keyboardMsg.kcode = code; keyboardMsg.type = InputMsgType.InputMsgType_KeyUp; handler.OnKeyMessage(keyboardMsg); } if (Input.GetKeyUp(KeyCode.D)) { code = KeyCode.D; keyboardMsg.kcode = code; keyboardMsg.type = InputMsgType.InputMsgType_KeyUp; handler.OnKeyMessage(keyboardMsg); } }
public virtual void OnKeyMessage(KeyBoardMessage msg) { }
public override void OnKeyMessage(KeyBoardMessage msg) { base.OnKeyMessage(msg); GlobalClient.Instance.cameraController.cameraMode.OnKeyBoardMessage(msg); }