public void ReadInput() { float hori = Input.GetAxis("Horizontal"); float vert = Input.GetAxis("Vertical"); Direction dir = ConvertToDirection(hori, vert); Command cmd = Command.None; if (Input.GetKey(KeyCode.J)) { cmd = Command.Action1; } else if (Input.GetKey(KeyCode.K)) { cmd = Command.Action2; } else if (Input.GetKey(KeyCode.L)) { cmd = Command.Action3; } if (curCmd != cmd || curDir != dir) { //Logger.Log("SendInput " + dir + " " + cmd); GameMsgSender.SendInput(dir, cmd); } curCmd = cmd; curDir = dir; }
public void Update(GameMatch match) { if (!enabled) { _UpdateValidCommand(match); return; } _UpdateValidCommand(match); InputDirection dir = ConvertToDirection(GameSystem.Instance.mClient.mInputManager.mHVDirection); Command cmd = Command.None; if (match.m_uiController == null) { return; } if (GameSystem.Instance.mClient.mInputManager.m_CmdBtn1Click && match.m_uiController.m_btns[0].cmd != Command.None) { cmd = match.m_uiController.m_btns[0].cmd; } else if (GameSystem.Instance.mClient.mInputManager.m_CmdBtn2Click && match.m_uiController.m_btns[1].cmd != Command.None) { cmd = match.m_uiController.m_btns[1].cmd; } else if (GameSystem.Instance.mClient.mInputManager.m_CmdBtn3Click && match.m_uiController.m_btns[2].cmd != Command.None) { cmd = match.m_uiController.m_btns[2].cmd; } else if (GameSystem.Instance.mClient.mInputManager.m_CmdBtn4Click && match.m_uiController.m_btns[3].cmd != Command.None) { cmd = match.m_uiController.m_btns[3].cmd; } if (curCmd != cmd || curDir != dir) { GameMsgSender.SendInput(dir, cmd); } curCmd = cmd; curDir = dir; }