Esempio n. 1
0
 void OnGrab(UBasketball ball)
 {
     if (ball.m_owner != m_player)
     {
         timerRebound.stop = true;
     }
 }
Esempio n. 2
0
 private void OnGrab(UBasketball ball)
 {
     if (shooting)
     {
         int score = currBall.m_special ? specialBallScore : normalBallScore;
         refreshOnReboundOver = true;
         if (ball.m_owner == mainRole)
         {
             ++myCombo;
             float bonusRatio = GameSystem.Instance.GameModeConfig.GetComboBonus(GetMatchType(), myCombo);
             if (myCombo > 1)
             {
                 ShowCombo(myCombo);
                 ShowComboBonus(bonusRatio);
             }
             m_homeScore += (int)(score * (1 + bonusRatio));
             mainRole.mStatistics.success_rebound_times = (uint)m_homeScore;
             uiMatch.leftScore = m_homeScore;
             npcCombo          = 0;
         }
         else if (ball.m_owner == npc)
         {
             ++npcCombo;
             float bonusRatio = GameSystem.Instance.GameModeConfig.GetComboBonus(GetMatchType(), npcCombo);
             m_awayScore += (int)(score * (1 + bonusRatio));
             npc.mStatistics.success_rebound_times = (uint)m_awayScore;
             uiMatch.rightScore = m_awayScore;
             myCombo            = 0;
             HideCombo();
             HideComboBonus();
         }
     }
 }
Esempio n. 3
0
    protected void _OnCounterDoneImp()
    {
        UBasketball ball = m_match.mCurScene.mBall;

        ball.initVel     = IM.Vector3.up * INIT_VEl;
        ball.m_fTime     = IM.Number.zero;
        ball.m_ballState = BallState.eRebound;

        foreach (Player player in GameSystem.Instance.mClient.mPlayerManager)
        {
            player.m_enableAction   = true;
            player.m_enableMovement = true;
            if (player.m_aiMgr != null && player.m_inputDispatcher == null)
            {
                player.m_aiMgr.m_enable = Debugger.Instance.m_bEnableAI;
            }
        }

        counterDone = true;
        if (onCounterDone != null)
        {
            onCounterDone();
        }

        m_match.m_gameMatchCountStop = false;
    }
Esempio n. 4
0
    override public void OnEnter(PlayerState lastState)
    {
        if (withBall)
        {
            GameObject goBall = GameObject.Instantiate(ResourceLoadManager.Instance.LoadPrefab("Prefab/DynObject/basketBall")) as GameObject;
            m_tmpBall = goBall.GetComponent <UBasketball>();
            if (m_tmpBall == null)
            {
                m_tmpBall = goBall.AddComponent <UBasketball>();
            }

            m_player.GrabBall(m_tmpBall);
        }

        m_player.mSparkEffect.EnableSpark(false);

        m_curAction = pose;
        if (string.IsNullOrEmpty(m_curAction))
        {
            m_stateMachine.SetState(State.eStand);
        }
        else
        {
            m_player.animMgr.Play(m_curAction, false);
        }
    }
Esempio n. 5
0
    public override void GameUpdate(IM.Number deltaTime)
    {
        base.GameUpdate(deltaTime);
        _RefreshAOD();

        UBasketball ball = mCurScene.mBall;

        if (m_uiMatch != null)
        {
            if (ball.m_owner == null)
            {
                m_uiMatch.leftBall.SetActive(false);
                m_uiMatch.rightBall.SetActive(false);
            }
            else if (ball.m_owner.m_team == mainRole.m_team)
            {
                m_uiMatch.leftBall.SetActive(true);
                m_uiMatch.rightBall.SetActive(false);
            }
            else
            {
                m_uiMatch.leftBall.SetActive(false);
                m_uiMatch.rightBall.SetActive(true);
            }
        }

        if (enableGuide)
        {
            funcUpdate.Call(new object[] { guide, (float)deltaTime });
        }
    }
Esempio n. 6
0
 virtual protected void _OnTimeUp()
 {
     if (m_match.m_bTimeUp)
     {
         bool finalHitOver = true;
         foreach (UBasketball b in m_finalHitBalls)
         {
             if (b.m_ballState == BallState.eUseBall_Shoot || b.m_ballState == BallState.eRebound)
             {
                 finalHitOver = false;
                 break;
             }
         }
         if (finalHitOver)
         {
             m_stateMachine.SetState(MatchState.State.eOver);
         }
     }
     else if (m_match.m_b24TimeUp)
     {
         UBasketball ball = m_match.mCurScene.mBall;
         if (ball.m_ballState == BallState.eUseBall || ball.m_ballState == BallState.eLoseBall)
         {
             m_stateMachine.SetState(MatchState.State.eFoul);
         }
     }
 }
Esempio n. 7
0
    void OnEnable()
    {
        instance = this;

        if (Selection.activeGameObject == null)
        {
            return;
        }
        mBall = Selection.activeGameObject.GetComponent <UBasketball>();
        if (mBall == null)
        {
            EditorUtility.DisplayDialog("ShootSolutionEditor", "请选择篮球", "ok");
        }

        GameObject goBasket = GameObject.FindGameObjectWithTag("basketStand");

        if (goBasket == null)
        {
            EditorUtility.DisplayDialog("ShootSolutionEditor", "请先创建篮板", "ok");
        }
        mBasket = goBasket.GetComponent <UBasket>();

        mDistanceCount = GameSystem.Instance.shootSolutionManager.m_DistanceList.Count;
        mAngleCount    = GameSystem.Instance.shootSolutionManager.m_AngleList.Count;
    }
Esempio n. 8
0
    void HandleOutSync(Pack pack)
    {
        NotifyOutSync outSync = Serializer.Deserialize <NotifyOutSync>(new MemoryStream(pack.buffer));
        int           turnID  = (int)outSync.frameNum;

        Debug.LogError("Turn out sync, ID: " + turnID + " " + (turnID - 1) * TurnController.GAME_UPDATE_PER_TURN);
        PlayerManager pm       = GameSystem.Instance.mClient.mPlayerManager;
        GameMatch     match    = GameSystem.Instance.mClient.mCurMatch;
        CheckFrame    turnData = match.turnManager.GetTurnCheckData(turnID);

        if (turnData != null)
        {
            foreach (RoleKeyState playerData in turnData.roleDatas)
            {
                Player player = pm.GetPlayerByRoomId(playerData.index);
                Debug.LogError(string.Format("{0} P:{1} Pos:({2},{3},{4}) Angle:{5} State:{6}",
                                             player.m_team.m_side, player.m_id,
                                             playerData.position.x, playerData.position.y, playerData.position.z,
                                             playerData.hori_angle, (PlayerState.State)playerData.state));
            }
            foreach (BallKeyState ballData in turnData.ballDatas)
            {
                UBasketball ball = match.mCurScene.balls.Find(b => b.m_id == ballData.index);
                Debug.LogError(string.Format("Ball:{0} Pos:({1},{2},{3}) State:{4}",
                                             ball.m_id, ballData.position.x, ballData.position.y, ballData.position.z,
                                             (BallState)ball.m_ballState));
            }
        }
    }
 private void OnGrab(UBasketball ball)
 {
     if (_step == Step.SwitchRole && ball.m_owner == npc1)
     {
         StartCoroutine(Step_CheckBall());
     }
 }
    protected override void OnMatchSetted()
    {
        base.OnMatchSetted();

        ball = match.mCurScene.mBall;

        for (int i = 0; i < playerList.Count; ++i)
        {
            Player player = playerList[i];
            player.operMode = Player.OperMode.AI;
            (player.m_aiMgr as AISystem_PractiseGuide).index = i;
            player.operMode = Player.OperMode.None;
            if (player.m_AOD == null)
            {
                player.m_AOD = new AOD(player);
            }
            player.m_StateMachine.onStateChanged += OnPlayerStateChanged;
        }

        Animator animator = match.m_uiController.GetComponent <Animator>();

        Object.Destroy(animator);

        match.turnManager.onNewTurn += OnNewTurn;
    }
Esempio n. 11
0
    private UBasketball SelectTargetBall()
    {
        UBasketball target = null;
        List <KeyValuePair <UBasketball, IM.Number> > list = AIUtils.SortBallListByDistance(match.mCurScene.balls, m_player.position);

        if (list.Count > 0)
        {
            target = list[0].Key;
            if (match.level != GameMatch.Level.Easy)
            {
                //Is this ball catchable.
                if (!match.mainRole.m_bWithBall)
                {
                    if (!CanArriveBeforePlayer(target.position))
                    {
                        List <KeyValuePair <UBasketball, IM.Number> > listRival = AIUtils.SortBallListByDistance(match.mCurScene.balls, match.mainRole.position);
                        if (listRival[0].Key == target)
                        {
                            if (list.Count > 1)
                            {
                                //Select second nearest ball.
                                target = list[1].Key;
                            }
                        }
                    }
                }
            }
        }
        return(target);
    }
Esempio n. 12
0
    public override void Update(IM.Number fDeltaTime)
    {
        if (targetBall != null)
        {
            m_moveTarget = targetBall.position;
        }

        base.Update(fDeltaTime);

        if (match.mCurScene.balls.Count == 0 || match.m_stateMachine.m_curState.m_eState != MatchState.State.ePlaying)
        {
            m_player.moveDirection = IM.Vector3.zero;
        }

        if (targetBall == null)
        {
            targetBall = SelectTargetBall();
        }
        else
        {
            if (targetBall.m_owner != null && targetBall.m_owner != m_player)
            {
                targetBall             = null;
                m_player.moveDirection = IM.Vector3.zero;
                //m_moveTarget = m_player.position;
            }
        }

        if (m_player.m_bWithBall)
        {
            OnGrab(m_player.m_ball);
        }
    }
Esempio n. 13
0
    static bool InFrontOfBallOwner(Player player, UBasketball ball, IM.Number distThreshold)
    {
        if (ball.m_owner == null)
        {
            return(false);
        }

        //distance
        IM.Number dist = GameUtils.HorizonalDistance(player.position, ball.position);
        if (dist > distThreshold)
        {
            Debug.Log("Steal distance: " + dist + " greater than " + distThreshold);
            return(false);
        }

        //is in front of target
        IM.Vector3 dir = player.position - ball.m_owner.position;
        dir.Normalize();
        IM.Number angle = IM.Vector3.Angle(ball.m_owner.forward, dir);
        if (angle > new IM.Number(90))
        {
            Debug.Log("Steal angle " + angle);
            return(false);
        }

        return(true);
    }
 private void OnGoal(UBasket basket, UBasketball ball)
 {
     if (step == Step.Play && jumpedInRightArea)
     {
         Step_Praise();
     }
 }
 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;
     }
 }
Esempio n. 16
0
    public override void OnEnter(MatchState lastState)
    {
        base.OnEnter(lastState);
        Debug.Log("PVP Begin");

        if (m_match.m_bOverTime && m_match.m_uiMatch == null)
        {
            m_match.m_gameMathCountEnable = false;
            m_match.CreateUI();
        }

        if (m_match.m_config.type == GameMatch.Type.ePVP_1PLUS)
        {
            GameMatch_PVP match_pvp = m_match as GameMatch_PVP;
            UBasketball   ball      = m_match.mCurScene.mBall;
            Player        ballOwner = ball.m_owner;
            if (ballOwner != null)
            {
                match_pvp.SwitchMainrole(ballOwner.m_defenseTarget);
                match_pvp.SwitchMainrole(ballOwner);
                m_match.m_cam.Positioning(true);
            }
        }

        foreach (Player player in GameSystem.Instance.mClient.mPlayerManager)
        {
            player.m_InfoVisualizer.SetActive(true);
        }
        Color yellow = new Color(1f, 252f / 255, 10f / 255, 1);

        m_match.mainRole.ShowIndicator(yellow, true);
    }
 private void OnGrab(UBasketball ball)
 {
     if (step == Step.Play && !jumpedInRightArea)
     {
         Step_Retutor();
     }
 }
Esempio n. 18
0
    public void OnDunk(UBasketball ball, bool bGoal)
    {
        GetComponent <Animation>().Stop();
        GetComponent <Animation>().Play("grabDunk");

        m_state = bGoal ? BasketState.eDunkGoal : BasketState.eDunkNoGoal;
        _UpdateEffect();

        if (GameSystem.Instance.mClient.mInputManager.isNGDS)
        {
            //设置马达震动
            GameSystem.Instance.mClient.mInputManager.sendShock = true;
        }

        if (bGoal)
        {
            if (onGoal != null)
            {
                onGoal(this, ball);
            }
        }
        else
        {
            if (onNoGoal != null)
            {
                onNoGoal(this, ball);
            }
            PlaySoundManager.Instance.PlaySound(MatchSoundEvent.DunkNoGoal);
        }
    }
Esempio n. 19
0
 void OnCatchBall(UBasketball ball)
 {
     if (ball.m_owner.m_team == mainRole.m_team)
     {
         ShowGuide("SwitchMainRole");
     }
 }
Esempio n. 20
0
 private void OnDunk(UBasketball ball, bool goal)
 {
     if (goal)
     {
         OnGoal(ball);
     }
 }
    protected override void _OnCounterDone()
    {
        base._OnCounterDone();

        if (m_match.m_config.type == GameMatch.Type.ePVP_1PLUS)
        {
            GameMatch_PVP match_pvp = m_match as GameMatch_PVP;
            UBasketball   ball      = m_match.mCurScene.mBall;
            Player        ballOwner = ball.m_owner;
            if (ballOwner != null)
            {
                match_pvp.SwitchMainrole(ballOwner.m_defenseTarget);
                match_pvp.SwitchMainrole(ballOwner);
                m_match.m_cam.Positioning(true);
            }
        }

        foreach (Player player in GameSystem.Instance.mClient.mPlayerManager)
        {
            player.m_InfoVisualizer.SetActive(true);
        }
        Color yellow = new Color(1f, 252f / 255, 10f / 255, 1);

        m_match.mainRole.ShowIndicator(yellow, true);

        m_match.AssumeDefenseTarget();
    }
 private void OnGrab(UBasketball ball)
 {
     //block grab ball
     if (mainRole.m_StateMachine.m_curState.m_eState == PlayerState.State.eBlock)
     {
         OnHitGround(ball);
     }
 }
 private void OnHitGround(UBasketball ball)
 {
     if (timerRefresh == null)
     {
         timerRefresh = new GameUtils.Timer(npcAttackInterval, OnRefresh);
     }
     timerRefresh.stop = false;
 }
Esempio n. 24
0
    private void OnCreateNewBall(ConveyorBall conveyorBall)
    {
        conveyorBall.onReachExit += OnBallReachExit;
        UBasketball ball = CreateBall();

        conveyorBall.GetComponent <UISprite>().spriteName = ball.m_special ? conveyorBall.specialBallSprite : conveyorBall.normalBallSprite;
        ballQ.Enqueue(ball);
    }
Esempio n. 25
0
    private void OnShoot(UBasketball ball)
    {
        //if (ball != targetBall)
        //	Debug.LogError("Not target ball.");

        ball.onShoot -= OnShoot;
        targetBall    = null;
    }
Esempio n. 26
0
 private void OnShootOver(UBasketball ball)
 {
     if (!blocked && _curr_obj_index != EXERCISE_OBJ_INDEX)
     {
         FinishObjective(false);
     }
     Reset();
 }
Esempio n. 27
0
 private void OnGrab(UBasketball ball)
 {
     m_system.SetTransaction(AIState.Type.eGrabZone_Positioning);
     if (targetBall == m_ball)
     {
         targetBall = null;
     }
 }
 private void OnRebound(UBasketball ball)
 {
     if (ball.m_actor == attacker)
     {
         ball_rebounding = true;
         match.HighlightButton(0, !_free_mode);
     }
 }
 private void OnCatch(UBasketball ball)
 {
     ValidateCondition(PractiseStepCondition.CatchBall, (param) =>
     {
         int index = (int)(param[0]);
         return(ball.m_owner == GetPlayer(index));
     });
 }
 public override void OnExit()
 {
     Debug.Log(Time.frameCount + " Exit PlayerState_Pickup.");
     base.OnExit();
     m_animType     = fogs.proto.msg.AnimType.B_TYPE_0;
     m_ballToPickup = null;
     m_bSuccess     = false;
 }