Пример #1
0
    static int OnSwitch(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        GameMatch_MultiPlayer obj = (GameMatch_MultiPlayer)LuaScriptMgr.GetNetObjectSelf(L, 1, "GameMatch_MultiPlayer");

        Team.Side arg0 = (Team.Side)LuaScriptMgr.GetNetObject(L, 2, typeof(Team.Side));
        obj.OnSwitch(arg0);
        return(0);
    }
Пример #2
0
    public void CommandToAction(Command cmd)
    {
        if (!m_enable)
        {
            return;
        }
        //特殊处理:自动盯防生效时,加速键显示,但无效
        if (m_player.m_team.m_role == GameMatch.MatchRole.eDefense &&
            _autoDefTakeOver.InTakeOver &&
            cmd == Command.Rush)
        {
            return;
        }
        curCommand = cmd;
        //if( !(GameSystem.Instance.mClient.mCurMatch is GameMatch_PVP) )
        {
            if (m_player.m_StateMachine.assistAI != null)
            {
                m_player.m_StateMachine.assistAI.curCommand = cmd;
            }
        }
        //buffer command
        PlayerState curState = m_player.m_StateMachine.m_curState;

        if (curState is PlayerState_Skill)
        {
            Command curCmd = Command.None;
            if (curState.m_curExecSkill != null)
            {
                curCmd = (Command)curState.m_curExecSkill.skill.action_type;
            }
            //Debug.Log("Cur skill type:" + curCmd);
            if (cmd != curCmd)
            {
                if (cmd != bufferedCommand)
                {
                    //Debug.Log("Buffer command:" + cmd);
                    bufferedCommand = cmd;
                    bufferedTime    = COMMAND_BUFFER_TIME;
                }
            }
            else
            {
                if (cmd == bufferedCommand)
                {
                    //Debug.Log("Clear buffer command for casted.");
                    bufferedCommand = Command.None;
                }
            }
        }

        /*
         * if (cmd == Command.Boxout)
         * {
         *      m_player.m_StateMachine.SetState(PlayerState.State.eBoxout);
         *      return;
         * }
         */
        if (cmd == Command.Switch)
        {
            GameMatch_MultiPlayer match = m_match as GameMatch_MultiPlayer;
            if (match != null)
            {
                match.OnSwitch(m_player.m_team.m_side);
            }
        }
        //for prepare shoot
        if (cmd == Command.Shoot && curState.m_eState == PlayerState.State.ePrepareToShoot)
        {
            //m_player.m_bToShoot = true;
            PlayerState_PrepareToShoot prepareShoot = m_player.m_StateMachine.GetState(PlayerState.State.ePrepareToShoot) as PlayerState_PrepareToShoot;
            m_player.m_toSkillInstance = prepareShoot.mCachedShootSkill;
            return;
        }

        if (cmd == Command.Pass)
        {
            if (m_player.m_passTarget == null)
            {
                m_player.m_passTarget = PassHelper.ChoosePassTarget(m_player);
            }
        }

        SkillInstance skill = m_player.m_skillSystem.GetValidSkillInMatch(cmd);

        //Debug.Log( Time.frameCount + "skill: " + (skill != null ? skill.skill.name : "NULL" ));
        if (skill == null)
        {
            //Debug.LogError("Can not get valid skill, check config.");
            return;
        }

        //failed to dunk

        /*
         * if( (Command)skill.skill.action_type == Command.Dunk || (Command)skill.skill.action_type == Command.Layup )
         * {
         *      if( m_player.m_defenseTarget != null )
         *      {
         *              Player nearestValidDefender = null;
         *              float fNearestDist = float.MaxValue;
         *              foreach(Player pl in m_player.m_defenseTarget.m_team)
         *              {
         *                      if( m_player.m_AOD.GetStateByPos(pl.position) != AOD.Zone.eInvalid )
         *                      {
         *                              float fDist = GameUtils.HorizonalDistance(m_player.position, pl.position);
         *                              if( fDist > fNearestDist )
         *                                      continue;
         *                              fNearestDist = fDist;
         *                              nearestValidDefender = pl;
         *                      }
         *              }
         *              if( nearestValidDefender != null )
         *              {
         *                      float fDist = GameUtils.HorizonalDistance(m_player.position, nearestValidDefender.position);
         *                      if( fDist < skill.skill.attrange )
         *                      {
         *                              //if( !m_player.m_bSimulator )
         *                              //	m_player.m_StateMachine.SetState(PlayerState.State.eLayupFailed);
         *                              if( !m_player.m_bSimulator )
         *                                      ShootHelper.ShootByArea(m_player, GameSystem.Instance.mClient.mCurMatch);
         *                              return;
         *                      }
         *              }
         *      }
         * }
         */

        skill.curInput.inputType = InputDirType.eBasket;
        skill.curInput.cmd       = cmd;
        skill.curInput.moveDir   = m_player.m_inputDispatcher.GetMoveDirection(InputDirType.eBasket);

        /*
         * SkillInput input = skill.curAction.inputs[0];
         * if( (Command)skill.skill.action_type == Command.CrossOver && input.moveDir == EDirection.eNone )
         * {
         *      Player defender = m_player.m_defenseTarget;
         *      if (defender != null)
         *      {
         *              Vector3 dirPlayerToDefenser = (defender.position - m_player.position).normalized;
         *              float angle = Quaternion.FromToRotation(dirPlayerToDefenser, m_player.right).eulerAngles.y;
         *              bool horiCross = (45f < angle && angle < 135f);
         *              bool left = angle < 90f || angle > 270f;
         *              List<SkillInstance> crossSkills = m_player.m_skillSystem.GetSkillList(SkillType.ACTIVE, Command.CrossOver);
         *              SkillInstance inst = AIUtils.ChooseCrossSkill(crossSkills, horiCross, left);
         *              if (m_player.m_stamina.m_curStamina.ToUnity() >= (float)inst.skill.levels[inst.level].stama )
         *                      skill = inst;
         *      }
         * }
         */

        m_player.m_toSkillInstance = skill;
        Debug.Log("skill id: " + m_player.m_toSkillInstance.skill.id);
    }