示例#1
0
    public override void OnEnter(AIState lastState)
    {
        base.OnEnter(lastState);

        npcReboundAttr = GameSystem.Instance.ReboundAttrConfigData.GetReboundAttr(m_player.m_position);
        if (npcReboundAttr == null)
        {
            Debug.LogError("Rebound height config error.");
        }
        //TODO Õë¶ÔPVPÐÞ¸Ä
        playerReboundAttr = GameSystem.Instance.ReboundAttrConfigData.GetReboundAttr(match.mainRole.m_position);
        if (playerReboundAttr == null)
        {
            Debug.LogError("Rebound height config error.");
        }
    }
示例#2
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);
        }
    }