Exemple #1
0
    public void Update(float deltaTime)
    {
        Player defenseTarget = match.mainRole.m_defenseTarget;

        if (defenseTarget != null && defenseTarget.m_bWithBall &&
            defenseTarget.m_AOD.GetStateByPos(match.mainRole.position) == AOD.Zone.eInvalid)
        {
            if (!revisingDefense)
            {
                ShowTip(CommonFunction.GetConstString("MATCH_GUIDE_ReviseDefense"));
                revisingDefense = true;
            }
        }
        else
        {
            revisingDefense = false;
        }

        PlayerState curState = match.mainRole.m_StateMachine.m_curState;

        if (lastMainRoleState != PlayerState.State.eRebound && curState.m_eState == PlayerState.State.eRebound)
        {
            IM.Number curDist = GameUtils.HorizonalDistance(match.mainRole.position, match.mCurScene.mBall.position);
            if (curDist > match.mainRole.m_fReboundDist)
            {
                ShowTip(CommonFunction.GetConstString("MATCH_GUIDE_ReviseDistance"));
            }
            else if (!(curState as PlayerState_Rebound).m_success)
            {
                ShowTip(CommonFunction.GetConstString("MATCH_GUIDE_ReviseRebound"));
            }
        }
        else if (lastMainRoleState != PlayerState.State.eSteal && curState.m_eState == PlayerState.State.eSteal)
        {
            if (defenseTarget.m_AOD.GetStateByPos(match.mainRole.position) == AOD.Zone.eInvalid)
            {
                ShowTip(CommonFunction.GetConstString("MATCH_GUIDE_ReviseDistance"));
            }
        }
        else if (lastMainRoleState != PlayerState.State.eBlock && curState.m_eState == PlayerState.State.eBlock)
        {
            IM.Number curDist = GameUtils.HorizonalDistance(match.mainRole.position, match.mCurScene.mBall.position);
            if (curDist < IM.Number.one || curDist > new IM.Number(5))
            {
                ShowTip(CommonFunction.GetConstString("MATCH_GUIDE_ReviseDistance"));
            }
            else if (!match.mainRole.m_defenseTarget.m_blockable.blockable)
            {
                ShowTip(CommonFunction.GetConstString("MATCH_GUIDE_ReviseBlockTimming"));
            }
        }
        else if (lastMainRoleState != PlayerState.State.eBodyThrowCatch && curState.m_eState == PlayerState.State.eBodyThrowCatch)
        {
            IM.Number maxDist = PlayerState_BodyThrowCatch.GetMaxDistance(match.mainRole);
            IM.Number curDist = GameUtils.HorizonalDistance(match.mainRole.position, match.mCurScene.mBall.position);
            if (curDist > maxDist)
            {
                ShowTip(CommonFunction.GetConstString("MATCH_GUIDE_ReviseDistance"));
            }
        }

        lastMainRoleState = curState.m_eState;
    }
    public override void GameUpdate(IM.Number deltaTime)
    {
        base.GameUpdate(deltaTime);

        if (m_stateMachine.m_curState.m_eState != MatchState.State.eOpening && m_stateMachine.m_curState.m_eState != MatchState.State.eOverTime)
        {
            curTipCD -= (float)deltaTime;
            if (timer != null)
            {
                timer.Update(deltaTime);
            }
        }

        if (m_stateMachine.m_curState.m_eState != MatchState.State.ePlaying)
        {
            return;
        }

        matchReviseTip.Update((float)deltaTime);

        if (mainRole.m_StateMachine.m_curState.m_eState == PlayerState.State.eHold && mainRole.m_bMovedWithBall)
        {
            ShowGuide("HoldLock");
        }

        if (!(mainRole.m_StateMachine.m_curState is PlayerState_Skill) &&
            !m_ruler.m_bToCheckBall &&
            mainRole.m_bWithBall && mainRole.m_bOnGround)
        {
            bool isMainRoleDefended = mainRole.IsDefended();
            if (isMainRoleDefended)
            {
                if (mainRole.m_position == PositionType.PT_C || mainRole.m_position == PositionType.PT_PF)
                {
                    //if (completedGuide.Contains("Clutch") && !clutchGuiding)
                    ShowGuide("CrossOver", 4);
                    //else
                    //{
                    //	ShowGuide("Clutch", 5);
                    //	clutchGuiding = true;
                    //}
                }
                else
                {
                    ShowGuide("CrossOver", 4);
                }
            }
            else
            {
                ShowGuide("Undefended", 1);
            }
        }
        else
        {
            clutchGuiding = false;
        }

        if (mCurScene.mBall.m_ballState == BallState.eLoseBall &&
            mainRole.m_bOnGround &&
            (mainRole.m_position == PositionType.PT_PG || mainRole.m_position == PositionType.PT_SG))
        {
            IM.Number catchDistance = PlayerState_BodyThrowCatch.GetMaxDistance(mainRole);
            IM.Number curDistance   = GameUtils.HorizonalDistance(mainRole.position, mCurScene.mBall.position);
            if (curDistance <= catchDistance)
            {
                ShowGuide("BodyThrowCatch", 1);
            }
        }

        if (mainRole.m_defenseTarget.m_bWithBall &&
            mainRole.m_defenseTarget.m_AOD.GetStateByPos(mainRole.position) != AOD.Zone.eInvalid)
        {
            if (GameSystem.Instance.StealConfig.GetRatio(mainRole.m_defenseTarget.m_StateMachine.m_curState.m_eState) > IM.Number.zero)
            {
                ShowGuide("Steal", 4);
            }
            else if (AIUtils.CanBlock(mainRole, mainRole.m_defenseTarget, IM.Number.zero, IM.Number.zero, mCurScene.mBasket.m_vShootTarget))
            {
                if (mainRole.m_defenseTarget.m_StateMachine.m_curState.m_eState != PlayerState.State.ePrepareToShoot)
                {
                    ShowGuide("Block", 1);
                }
            }
        }

        if (mCurScene.mBall.m_ballState == BallState.eRebound)
        {
            IM.Number fDistPlayer2Ball = GameUtils.HorizonalDistance(mainRole.position, mCurScene.mBall.position);
            if (fDistPlayer2Ball <= mainRole.m_fReboundDist)
            {
                IM.Number  minHeight      = new IM.Number(1, 6);
                IM.Number  maxHeight      = mainRole.m_finalAttrs["rebound_height"] * new IM.Number(0, 13) + new IM.Number(3);
                IM.Number  ball_height    = mCurScene.mBall.position.y;
                bool       inReboundRange = minHeight < ball_height && ball_height < maxHeight;
                IM.Vector3 velocity       = mCurScene.mBall.curVel;
                if (velocity.y < IM.Number.zero && inReboundRange)
                {
                    ShowGuide("Rebound", 1);
                }
            }
        }
    }
Exemple #3
0
    /**追球*/
    public static bool ShouldTraceBall(UBasketball ball, Player player)
    {
        GameMatch match = GameSystem.Instance.mClient.mCurMatch;

        if (match.m_stateMachine.m_curState.m_eState == MatchState.State.eTipOff)
        {
            if (player.m_team.GetMember(0) != player)
            {
                return(false);
            }
        }

        IM.Vector3 targetPos;
        if (ball.m_ballState == BallState.eRebound)
        {
            targetPos   = ball.position;
            targetPos.y = IM.Number.zero;
        }
        else if (ball.m_ballState == BallState.eLoseBall)
        {
            targetPos   = ball.position;
            targetPos.y = IM.Number.zero;

            Player    nearestPlayer = null;
            IM.Number minTime       = IM.Number.max;
            foreach (Player mate in player.m_team.members)
            {
                IM.Number dist = GameUtils.HorizonalDistance(mate.position, targetPos);
                if (mate.m_position == PositionType.PT_PG || mate.m_position == PositionType.PT_SG)
                {
                    dist -= PlayerState_BodyThrowCatch.GetMaxDistance(mate);
                }
                IM.Number speed = mate.mMovements[(int)PlayerMovement.Type.eRunWithoutBall].mAttr.m_curSpeed;
                IM.Number time  = dist / speed;
                if (time < minTime)
                {
                    minTime       = time;
                    nearestPlayer = mate;
                }
            }
            return(player == nearestPlayer);
        }
        else if (ball.m_ballState == BallState.eUseBall_Shoot && ball.m_owner == null)
        {
            targetPos   = match.mCurScene.mBasket.m_vShootTarget;
            targetPos.y = IM.Number.zero;
        }
        else
        {
            return(false);
        }

        int playerPriority = priority[(int)player.m_position];

        IM.Number distPlayer = GameUtils.HorizonalDistance(targetPos, player.position);
        foreach (Player mate in player.m_team.members)
        {
            if (mate != player)
            {
                int       matePriority = priority[(int)mate.m_position];
                IM.Number distMate     = GameUtils.HorizonalDistance(targetPos, mate.position);
                if (matePriority >= playerPriority && (distPlayer - distMate) > IM.Number.half)
                {
                    return(false);
                }
            }
        }
        return(true);
    }
Exemple #4
0
    override public void Update(IM.Number fDeltaTime)
    {
        base.Update(fDeltaTime);

        if (m_player.CanRebound(m_ball) && (timerRebound == null || timerRebound.stop))
        {
            //Debug.Log("Rebound info of " + m_player.m_name);
            ReboundAttrConfig.ReboundAttr attr = GameSystem.Instance.ReboundAttrConfigData.GetReboundAttr(m_player.m_position);
            if (attr == null)
            {
                Debug.LogError("Rebound height config error.");
            }

            ShootSolution.SShootCurve curve = m_ball.CompleteLastCurve();
            IM.Number ballHeight            = m_ball.position.y;
            ballHeight *= (IM.Number.one - m_system.AI.devBallHeight);
            if (ballHeight >= attr.minHeight)
            {
                //Debug.Log("Rebound max height: " + attr.maxHeight +" Ball height: " + ballHeight + " Rebound height scale: " + attr.reboundHeightScale + " Ball height scale: " + attr.ballHeightScale);
                IM.Number npcReboundBallHeight = AIUtils.GetNPCReboundBallHeight(attr.maxHeight, ballHeight, attr.reboundHeightScale, attr.ballHeightScale);
                //Debug.Log("NPC rebound ball height: " + npcReboundBallHeight);
                IM.Number time1, time2;
                curve.GetTimeByHeight(npcReboundBallHeight, out time1, out time2);
                IM.Number ballFlyTime = time2;
                //Debug.Log("Ball fly time: " + ballFlyTime);
                if (ballFlyTime < -new IM.Number(0, 1))
                {
                    Debug.LogError("Ball fly time error.");
                }

                SkillInstance basicRebound  = m_player.m_skillSystem.GetBasicSkillsByCommand(Command.Rebound)[0];
                string        basicActionId = basicRebound.skill.actions[0].action_id;
                IM.Number     frameRate     = m_player.animMgr.GetFrameRate(basicActionId);
                Dictionary <string, PlayerAnimAttribute.AnimAttr> rebounds = m_player.m_animAttributes.m_rebound;
                int       reboundKey        = rebounds[m_player.animMgr.GetOriginName(basicActionId)].GetKeyFrame("OnRebound").frame;
                IM.Number reboundActionTime = reboundKey / frameRate;

                IM.Number reboundDelayTime = ballFlyTime - m_ball.m_fTime - reboundActionTime;
                //Debug.Log("Rebound delay time: " + reboundDelayTime);
                if (reboundDelayTime < IM.Number.zero)
                {
                    reboundDelayTime = IM.Number.zero;
                }
                timerRebound.SetTimer(reboundDelayTime);
                timerRebound.stop = false;

                return;
            }
        }

        if (m_ball.m_owner != null)
        {
            m_system.SetTransaction(AIState.Type.eIdle);
        }
        else
        {
            IM.Vector3 vMoveTarget = m_ball.position;
            if (m_ball.m_ballState == BallState.eUseBall_Shoot)
            {
                vMoveTarget = m_match.mCurScene.mBasket.m_vShootTarget;
            }
            vMoveTarget.y       = IM.Number.zero;
            m_moveTarget        = vMoveTarget;
            m_player.m_moveType = fogs.proto.msg.MoveType.eMT_Rush;

            if (m_ball.m_ballState == BallState.eLoseBall &&
                (m_player.m_position == PositionType.PT_PG || m_player.m_position == PositionType.PT_SG))
            {
                IM.Vector3 ballPos    = m_ball.position;
                IM.Number  distToBall = GameUtils.HorizonalDistance(ballPos, m_player.position);
                if (distToBall < PlayerState_BodyThrowCatch.GetMaxDistance(m_player) && ballPos.y <= IM.Number.one)
                {
                    m_system.SetTransaction(AIState.Type.eBodyThrowCatch);
                }
            }
        }

        if (timerRebound != null)
        {
            timerRebound.Update(fDeltaTime);
        }
    }