public void Update(IM.Number deltaTime) { if (!m_enable) { m_player.moveDirection = IM.Vector3.zero; return; } if (m_player == null) { return; } //刷新扩展加速状态 if (m_player.m_StateMachine.m_curState.m_eState != PlayerState.State.eRush) { rushExtRemain = IM.Number.zero; } if (rushExtRemain <= IM.Number.zero) { rushExtending = false; } rushExtRemain -= deltaTime; if (bufferedCommand != Command.None) { bufferedTime -= deltaTime; //Debug.Log("Cur buffer time:" + bufferedTime); if (bufferedTime < IM.Number.zero) { // Debug.Log("Clear buffer command for time out."); bufferedCommand = Command.None; } } //松开加速键后,进入扩展加速状态 if (_prevCmd == Command.Rush && cmd != Command.Rush) { if (m_player.m_StateMachine.m_curState.m_eState == PlayerState.State.eRush) { rushExtRemain = RUSH_EXTENSION_TIME; rushExtending = true; } } _UpdateInputDirection(dir, cmd); //投篮力度条控制 if (_prevCmd == Command.Shoot && cmd != Command.Shoot) { if (m_player.shootStrength != null && m_player.m_StateMachine.m_curState.m_eState == PlayerState.State.eShoot) { m_player.shootStrength.Stop(); } } //自动盯防接管 if (m_player.m_team.m_role == GameMatch.MatchRole.eDefense && _autoDefTakeOver.InTakeOver && m_match.mCurScene.mBall.m_ballState != BallState.eLoseBall) { //&& !curMatch.m_ruler.m_bToCheckBall) CommandToAction(Command.Defense); } //盯防命令启动自动盯防 if (cmd == Command.Defense) { if (!_autoDefTakeOver.InTakeOver) { _autoDefTakeOver.Enabled = true; } m_player.m_dir = -1; } //命令转化为技能 if (cmd != Command.None) { CommandToAction(cmd); } //如果没有命令执行 if (cmd == Command.None) { //方向操作取消技能 PlayerState skillState = m_player.m_StateMachine.m_curState; if (!(skillState is PlayerState_Skill)) { CommandToAction(Command.None); } if (skillState.m_lstActionId.Count != 0 && skillState is PlayerState_Skill) { if (dir != InputDirection.Null && dir != InputDirection.None) { CommandToAction(Command.None); } } else if (bufferedCommand != Command.None) //执行缓存命令 { //Debug.Log("Cast buffered command:" + bufferedCommand); CommandToAction(bufferedCommand); } } if (m_match.m_stateMachine.m_curState != null && m_match.m_stateMachine.m_curState.m_eState == MatchState.State.ePlaying) { //AI 接管玩家操作 if (m_match.EnableTakeOver()) { bool uncontrol = (dir == InputDirection.None && cmd != Command.None); if (uncontrol) { if (m_match.mCurScene.mBall.m_ballState != BallState.eUseBall_Pass || m_match.mCurScene.mBall.m_catcher != m_player) { uncontrolTime = uncontrolTime + deltaTime; } } else { uncontrolTime = IM.Number.zero; } if (!inTakeOver && uncontrol) { if (uncontrolTime > MAX_UNCONTROL_TIME) { inTakeOver = true; Debug.Log("InputDispatcher, Take over."); if (m_player.m_aiMgr != null && m_player.m_aiMgr.m_enable != Debugger.Instance.m_bEnableAI) { m_player.m_aiMgr.m_enable = Debugger.Instance.m_bEnableAI; } } } else if (inTakeOver && !uncontrol) { inTakeOver = false; Debug.Log("InputDispatcher, Resume."); if (m_player.m_aiMgr != null && m_player.m_aiMgr.m_enable) { m_player.m_aiMgr.m_enable = false; } } else if (inTakeOver && Debugger.Instance.m_bEnableAI && !m_player.m_aiMgr.m_enable) { if (m_player.m_aiMgr != null && m_player.m_aiMgr.m_enable != Debugger.Instance.m_bEnableAI) { m_player.m_aiMgr.m_enable = Debugger.Instance.m_bEnableAI; } } } else { inTakeOver = false; } } else { uncontrolTime = IM.Number.zero; inTakeOver = false; } //操作关闭AI if (disableAIOnAction) { if (m_player.m_team.m_role == GameMatch.MatchRole.eDefense) { if (m_player.m_aiMgr != null) { ignoreDirTime += deltaTime; bool disable = false; if (ignoreDirTime > MAX_IGNORE_DIR_TIME) { disable = (dir != InputDirection.None || curCommand == Command.Defense || curCommand == Command.Steal || curCommand == Command.Block); } else { disable = (curCommand == Command.Defense || curCommand == Command.Steal || curCommand == Command.Block); } if (disable) { if (m_player.m_aiMgr != null && m_player.m_aiMgr.m_enable) { m_player.m_aiMgr.m_enable = false; } disableAIOnAction = false; } else { m_player.m_dir = -1; } } } else if (!inTakeOver) { if (m_player.m_aiMgr != null && m_player.m_aiMgr.m_enable) { m_player.m_aiMgr.m_enable = false; } } } if (dir != InputDirection.None) { _autoDefTakeOver.SetControlled(); } //if (m_player.m_dir == -1) // m_player.m_moveType = MoveType.eMT_Stand; //自动盯防接管 if (m_player.m_team.m_role == GameMatch.MatchRole.eDefense) { _autoDefTakeOver.Update(deltaTime); } _prevDir = dir; _prevCmd = cmd; }