예제 #1
0
    public override void GameUpdate(IM.Number deltaTime)
    {
        base.GameUpdate(deltaTime);

        if (m_stateMachine.m_curState != null && m_stateMachine.m_curState.m_eState == MatchState.State.ePlaying)
        {
            timerSwitchRole.Update(deltaTime);
        }
        if (timerOver != null)
        {
            timerOver.Update(deltaTime);
        }
        if (timerSwitchRoleDelay != null)
        {
            timerSwitchRoleDelay.Update(deltaTime);
        }
        if (timerBoard != null)
        {
            gameMatchTime = timerSwitchRole.Remaining();
        }

        if (switchRoleOnShootOver && mCurScene.mBall.m_ballState == BallState.eLoseBall)
        {
            SwitchRole();
            timerSwitchRole.SetTimer(OFFENSE_TIME_LIMIT);
            timerSwitchRole.stop  = false;
            switchRoleOnShootOver = false;
        }
    }
예제 #2
0
 private void RefreshBalls()
 {
     for (uint i = 0; i < refresh_infos[refreshTimeNum].normal; ++i)
     {
         UBasketball ball    = mCurScene.CreateBall();
         IM.Vector3  tempPos = GenerateIn3PTPosition();
         tempPos.y = ball.m_ballRadius;
         ball.SetInitPos(tempPos);
         ball.m_ballState = BallState.eLoseBall;
     }
     for (uint i = 0; i < refresh_infos[refreshTimeNum].special; ++i)
     {
         UBasketball ball    = mCurScene.CreateBall();
         IM.Vector3  tempPos = GenerateIn3PTPosition();
         tempPos.y = ball.m_ballRadius;
         ball.SetInitPos(tempPos);
         ball.m_special   = true;
         ball.onGrab     += OnGrab;
         ball.m_ballState = BallState.eLoseBall;
     }
     ++refreshTimeNum;
     if (refreshTimeNum < 3)
     {
         timer.SetTimer(refresh_infos[refreshTimeNum].interval);
         timer.stop = false;
     }
     else
     {
         timer.stop = true;
     }
 }
    override public void OnEnter(AIState lastState)
    {
        behaviour = (m_match as GameMatch_Practise).practise_behaviour as PractiseBehaviourPass;

        IM.Number idleTime = IM.Random.Range(IM.Number.zero, IM.Number.one);
        m_timer.SetTimer(idleTime);
        m_timer.stop = false;

        m_player.moveDirection = IM.Vector3.zero;
    }
예제 #4
0
    void OnRebound(UBasketball ball)
    {
        ShootSolution.SShootCurve curve = ball.CompleteLastCurve();
        IM.Number ballMaxHeight         = curve.GetHighestPosition().y;
        //Debug.Log("Ball max height: " + ballMaxHeight);
        IM.Number npcReboundBallHeight = AIUtils.GetNPCReboundBallHeight(npcReboundAttr.maxHeight, playerReboundAttr.maxHeight, ballMaxHeight,
                                                                         match.npcHeightScale, match.playerHeightScale, match.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 - reboundActionTime;
        if (reboundDelayTime < IM.Number.zero)
        {
            reboundDelayTime = IM.Number.zero;
        }

        if (timerRebound == null)
        {
            timerRebound = new GameUtils.Timer(reboundDelayTime, DoRebound);
        }
        timerRebound.SetTimer(reboundDelayTime);
        timerRebound.stop = false;
    }
예제 #5
0
    protected override void OnTick()
    {
        if (match.curPoint == null)
        {
            return;
        }
        if (match.curPoint != null && match.m_stateMachine.m_curState.m_eState == MatchState.State.ePlaying)
        {
            if (targetPoint != match.curPoint)
            {
                targetPoint = match.curPoint;
                timerTracePoint.SetTimer(match.TRACE_POINT_DELAY);
                timerTracePoint.stop = false;
            }
        }
        else
        {
            m_player.moveDirection = IM.Vector3.zero;
        }

        if (m_player.m_bWithBall)
        {
            if (match.level == GameMatch.Level.Easy)
            {
                m_system.SetTransaction(AIState.Type.eGrabPoint_Shoot);
            }
            else if (!CanArriveBeforePlayer(match.curPointPosition))
            {
                if (match.level != GameMatch.Level.Hard)
                {
                    m_system.SetTransaction(AIState.Type.eGrabPoint_Shoot);
                }
                else
                {
                    AIUtils.PositionAndShoot(AIState.Type.eGrabPoint_Positioning, AIState.Type.eGrabPoint_Shoot, match, m_player);
                }
            }
        }
    }
    private void OnGrab(UBasketball ball)
    {
        if (m_stateMachine.m_curState != null && m_stateMachine.m_curState.m_eState == MatchState.State.ePlaying)
        {
            BeginPos beginPos = GameSystem.Instance.MatchPointsConfig.BeginPos;
            if (mainRole.m_team.m_role == MatchRole.eOffense)
            {
                if (ball.m_owner != mainRole)                   //球被对方抢了
                {
                    mainRole.m_inputDispatcher.m_enable = false;
                    //mainRole.m_aiMgr = mainRolePositioningAISystem;
                    if (mainRole.m_aiAssist != null)
                    {
                        mainRole.m_aiAssist.Disable();
                    }
                    mainRoleAIState.moveTarget = beginPos.defenses_transform[0].position;
                    //npc.m_aiMgr = npcPositioningAISystem;
                    npcAIState.moveTarget = beginPos.offenses_transform[0].position;
                    m_inPositioning       = true;
                    m_ruler.SwitchRole();
                    m_needSwitchRole = false;

                    mainRoleAIState.arrived = false;
                    npcAIState.arrived      = false;

                    ShowAnimTip("gameInterface_text_ChangeBall");
                    timerReset.SetTimer(new IM.Number(6));
                    timerReset.stop = false;
                }
                else if (m_criticalShoot)                       //球被自己抢了,但已经是绝杀球
                {
                    m_stateMachine.SetState(MatchState.State.eFoul);
                }
            }
            else if (mainRole.m_team.m_role == MatchRole.eDefense)
            {
                if (ball.m_owner == mainRole)                 //球被对方抢了
                {
                    mainRole.m_inputDispatcher.m_enable = false;
                    //mainRole.m_aiMgr = mainRolePositioningAISystem;
                    if (mainRole.m_aiAssist != null)
                    {
                        mainRole.m_aiAssist.Disable();
                    }
                    mainRoleAIState.moveTarget = beginPos.offenses_transform[0].position;
                    //npc.m_aiMgr = npcPositioningAISystem;
                    npcAIState.moveTarget = beginPos.defenses_transform[0].position;
                    m_inPositioning       = true;
                    m_ruler.SwitchRole();
                    m_needSwitchRole = false;

                    mainRoleAIState.arrived = false;
                    npcAIState.arrived      = false;

                    ShowAnimTip("gameInterface_text_ChangeBall");
                    timerReset.SetTimer(new IM.Number(6));
                    timerReset.stop = false;
                }
                else if (m_criticalShoot)                       //球被自己抢了,但已经是绝杀球
                {
                    m_stateMachine.SetState(MatchState.State.eFoul);
                }
            }
        }
    }
예제 #7
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);
        }
    }