Esempio n. 1
0
    void _UpdateValidCommand(GameMatch match)
    {
        validCmdList.Clear();

        if (player == null)
        {
            return;
        }

        bool        bOffense    = (player.m_team.m_role == GameMatch.MatchRole.eOffense);
        UBasketball ball        = match.mCurScene.mBall;
        UBasket     basket      = match.mCurScene.mBasket;
        bool        hasTeamMate = player.m_team.GetMemberCount() > 1;

        if (bOffense)
        {
            if (player.m_bWithBall)
            {
                if (hasTeamMate && match.IsCommandValid(Command.Pass))
                {
                    validCmdList.Add(Command.Pass);
                }
                if (match.IsCommandValid(Command.Shoot))
                {
                    validCmdList.Add(Command.Shoot);
                }
                if (player.m_position == PositionType.PT_C || player.m_position == PositionType.PT_PF)
                {
                    if (match.IsCommandValid(Command.BackToBack))
                    {
                        validCmdList.Add(Command.BackToBack);
                    }
                }
                else
                {
                    if (match.IsCommandValid(Command.CrossOver))
                    {
                        validCmdList.Add(Command.CrossOver);
                    }
                }
            }
            else
            {
                if (ball != null)
                {
                    if (ball.m_owner != null || ball.m_ballState == BallState.eUseBall_Pass)
                    {
                        if (match.IsCommandValid(Command.RequireBall))
                        {
                            validCmdList.Add(Command.RequireBall);
                        }
                    }

                    if (ball.m_owner != null && ball.m_ballState != BallState.eUseBall_Pass)
                    {
                        if (match.IsCommandValid(Command.PickAndRoll))
                        {
                            validCmdList.Add(Command.PickAndRoll);
                        }
                    }
                }
                if (match.IsCommandValid(Command.CutIn))
                {
                    validCmdList.Add(Command.CutIn);
                }
            }
            if (ball == null || (ball.m_ballState != BallState.eLoseBall && ball.m_ballState != BallState.eRebound))
            {
                if (match.IsCommandValid(Command.Rush))
                {
                    validCmdList.Add(Command.Rush);
                }
            }
        }
        //defense
        else
        {
            if (ball != null)
            {
                if (ball.m_ballState == BallState.eUseBall ||
                    ball.m_ballState == BallState.eUseBall_Pass ||
                    ball.m_ballState == BallState.eUseBall_Shoot)
                {
                    if (match.IsCommandValid(Command.Rush) && match.GetMatchType() == GameMatch.Type.ePVP_3On3)
                    {
                        validCmdList.Add(Command.Rush);
                    }
                    if (match.IsCommandValid(Command.Defense))
                    {
                        validCmdList.Add(Command.Defense);
                    }
                }

                if (ball != null && ball.m_owner != null && match.IsCommandValid(Command.Steal) || (ball.m_ballState == BallState.eUseBall_Pass))
                {
                    validCmdList.Add(Command.Steal);
                }

                if (ball != null && (ball.m_ballState == BallState.eUseBall || ball.m_ballState == BallState.eUseBall_Shoot))
                {
                    if (match.IsCommandValid(Command.Block))
                    {
                        validCmdList.Add(Command.Block);
                    }
                }
            }
            if (hasTeamMate && match.IsCommandValid(Command.Switch))
            {
                validCmdList.Add(Command.Switch);
            }
        }
        if (ball != null && ball.m_ballState == BallState.eLoseBall)
        {
            if (match.GetMatchType() == GameMatch.Type.ePVP_3On3)
            {
                if (match.IsCommandValid(Command.Rush))
                {
                    validCmdList.Add(Command.Rush);
                }
            }
            else
            {
                if (match.IsCommandValid(Command.TraceBall))
                {
                    validCmdList.Add(Command.TraceBall);
                }
            }

            if (hasTeamMate && match.IsCommandValid(Command.Switch))
            {
                validCmdList.Add(Command.Switch);
            }

            if (player.m_position == PositionType.PT_SG || player.m_position == PositionType.PT_PG)
            {
                if (match.IsCommandValid(Command.BodyThrowCatch))
                {
                    validCmdList.Add(Command.BodyThrowCatch);
                }
            }
        }
        if (ball != null &&
            (ball.m_ballState == BallState.eLoseBall ||
             ball.m_ballState == BallState.eRebound ||
             ball.m_ballState == BallState.eNone))
        {
            if (hasTeamMate && match.IsCommandValid(Command.Switch))
            {
                validCmdList.Add(Command.Switch);
            }
        }

        MatchState curMatchState = match.m_stateMachine.m_curState;

        if (!player.m_bWithBall &&
            (ball != null && ball.m_ballState == BallState.eRebound ||
             (curMatchState != null && curMatchState.m_eState == MatchState.State.eTipOff)))
        {
            if (match.IsCommandValid(Command.Rebound))
            {
                validCmdList.Add(Command.Rebound);
            }
            //float fDist = GameUtils.HorizonalDistance(player.position, basket.m_vShootTarget).ToUnity();
            //if( fDist < 3.0f )
            //	m_validCmdList.Add(Command.JockeyForPosition);
        }

        if (match.m_uiController != null)
        {
            match.m_uiController.UpdateBtnCmd();
        }
    }