예제 #1
0
    private void SwitchRole()
    {
        foreach (Player player in players)
        {
            player.m_enableAction         = false;
            player.m_enableMovement       = false;
            player.m_enablePickupDetector = false;
        }

        if (timerSwitchRoleDelay == null)
        {
            timerSwitchRoleDelay = new GameUtils.Timer(IM.Number.one, () =>
            {
                timerSwitchRoleDelay.stop = true;
                HideAnimTip("gameInterface_text_ChangeBall");

                Player attacker = orderedPlayers[0];
                orderedPlayers.RemoveAt(0);
                orderedPlayers.Add(attacker);

                AllocatePlayers();
                m_stateMachine.SetState(MatchState.State.eBegin);
            });
        }

        timerSwitchRoleDelay.stop = false;

        ShowAnimTip("gameInterface_text_ChangeBall");
    }
예제 #2
0
 public AI_PractiseRebound_Positioning(AISystem owner)
     : base(owner)
 {
     m_eType    = AIState.Type.ePractiseRebound_Positioning;
     timer      = new GameUtils.Timer(new IM.Number(0, 100), OnTimer);
     timer.stop = true;
 }
예제 #3
0
    public override void GameUpdate(IM.Number deltaTime)
    {
        base.GameUpdate(deltaTime);

        if (m_bTimeUp)
        {
            npc.m_aiMgr.m_enable = false;
        }

        if (m_stateMachine.m_curState != null && m_stateMachine.m_curState.m_eState == MatchState.State.ePlaying && refreshTimeNum == 0)
        {
            timer = new GameUtils.Timer(refresh_infos[0].interval, RefreshBalls);
        }

        //If there is no ball in the scene, or the only ball is hold by main player.
        //TODO 针对PVP修改
        if ((mCurScene.balls.Count == 0 || (mCurScene.balls.Count == 1 && mainRole.m_bWithBall)) &&
            refreshTimeNum == refresh_infos.Count)
        {
            refreshTimeNum = 0;
            RefreshBalls();
        }

        if (timer != null)
        {
            timer.Update(deltaTime);
        }
    }
예제 #4
0
 public AI_TraceBall(AISystem owner)
     : base(owner)
 {
     m_eType           = AIState.Type.eTraceBall;
     timerRebound      = new GameUtils.Timer(IM.Number.one, OnTimerRebound, 1);
     timerRebound.stop = true;
 }
 public MatchStateShowSkillGuide(MatchStateMachine owner)
     : base(owner)
 {
     m_eState   = MatchState.State.eShowSkillGuide;
     timer      = new GameUtils.Timer(new IM.Number(3), OnTimer);
     timer.stop = true;
 }
 private void OnHitGround(UBasketball ball)
 {
     if (timerRefresh == null)
     {
         timerRefresh = new GameUtils.Timer(npcAttackInterval, OnRefresh);
     }
     timerRefresh.stop = false;
 }
예제 #7
0
 public AI_GrabPoint_TracePoint(AISystem owner)
     : base(owner)
 {
     m_eType = Type.eGrabPoint_TracePoint;
     match   = m_match as GameMatch_GrabPoint;
     if (match != null)
     {
         timerTracePoint      = new GameUtils.Timer(match.TRACE_POINT_DELAY, TracePoint);
         timerTracePoint.stop = true;
     }
 }
예제 #8
0
    public PlayerState_PickAndRoll(PlayerStateMachine owner, GameMatch match) : base(owner, match)
    {
        m_eState      = State.ePickAndRoll;
        m_bPersistent = true;

        m_validStateTransactions.Add(Command.PickAndRoll);

        m_mapAnimType[AnimType.N_TYPE_0] = "pickandrollR";
        m_mapAnimType[AnimType.N_TYPE_1] = "pickandrollL";

        prNoMove = new GameUtils.Timer(IM.Number.two, OnEnableMovement, 0);
    }
예제 #9
0
    public GameMatch_Ultimate21(Config config)
        : base(config)
    {
        string[] tokens = gameMode.additionalInfo.Split('&');
        OFFENSE_TIME_LIMIT = IM.Number.Parse(tokens[0]);
        WIN_SCORE          = int.Parse(tokens[1]);

        timerSwitchRole      = new GameUtils.Timer(OFFENSE_TIME_LIMIT, OnTimerSwitchRole);
        timerSwitchRole.stop = true;

        GameSystem.Instance.mNetworkManager.ConnectToGS(config.type, "", 1);
    }
    override public void OnEnter(MatchState lastState)
    {
        base.OnEnter(lastState);

        InputReader.Instance.enabled = false;
        NGUITools.SetActive(match.slotMachine.gameObject, true);
        NGUITools.BringForward(match.slotMachine.gameObject);
        match.slotMachine.onCreateItem += OnCreateSlotMachineItem;
        match.slotMachine.onEnd        += OnSlotMachineEnd;

        timerBegin      = new GameUtils.Timer(IM.Number.one, BeginSlotMachine);
        timerBegin.stop = false;
    }
예제 #11
0
    public AIState(AISystem owner)
    {
        m_system    = owner;
        m_player    = owner.m_player;
        m_match     = owner.m_curMatch;
        m_basket    = m_match.mCurScene.mBasket;
        m_timerTick = new GameUtils.Timer(m_system.AI.delay, OnTick);

        if (m_player == null)
        {
            Debug.LogError("AIState: player can not be null.");
        }
    }
    private void OnSlotMachineEnd(GameObject selectedItem)
    {
        for (int i = 0; i < 4; ++i)
        {
            if (selectedItem == items[i])
            {
                selectedItemIndex = i % 2;
                break;
            }
        }

        timerEnd      = new GameUtils.Timer(new IM.Number(1, 500), BeginMatch);
        timerEnd.stop = false;
    }
예제 #13
0
 public void SetAssist(Player assistor, Player assistee)
 {
     //Scheduler.Instance.AddTimer( m_fAssistTime, false, OnAssistTimeUp );
     if (timer == null)
     {
         timer = new GameUtils.Timer(m_fAssistTime, OnAssistTimeUp);
     }
     else
     {
         timer.Reset();
     }
     m_assistor = assistor;
     m_assistee = assistee;
 }
예제 #14
0
    private void OnGoal(UBasketball ball)
    {
        bool matchOver = false;

        int score = ball.m_pt;

        for (int i = 0; i < 3; ++i)
        {
            if (players[i] == ball.m_actor)
            {
                scores[i]  += score;
                m_homeScore = scores[0];
                m_awayScore = scores[1] > scores[2] ? scores[1] : scores[2];
                UISprite tensDigit  = scoreBoards[i].transform.FindChild("Tens").GetComponent <UISprite>();
                UISprite unitsDigit = scoreBoards[i].transform.FindChild("Units").GetComponent <UISprite>();
                tensDigit.spriteName  = "gameInterface_figure_black" + (scores[i] / 10).ToString();
                unitsDigit.spriteName = "gameInterface_figure_black" + (scores[i] % 10).ToString();
                timerSwitchRole.SetTimer(OFFENSE_TIME_LIMIT);
                if (scores[i] >= WIN_SCORE)
                {
                    matchOver = true;
                }
                break;
            }
        }

        if (matchOver)
        {
            foreach (Player player in players)
            {
                player.m_alwaysForbiddenPickup = true;
            }
            if (timerOver == null)
            {
                timerOver = new GameUtils.Timer(IM.Number.two, () => { m_stateMachine.SetState(MatchState.State.eOver); }, 1);
            }
            timerOver.stop    = true;
            ball.onHitGround += (GameObject) => { timerOver.stop = false; };
        }
        else
        {
            foreach (Player player in players)
            {
                player.m_alwaysForbiddenPickup = true;
            }
            ball.onHitGround += OnHitGround;
        }
    }
예제 #15
0
    public GameMatch_PVP(Config config)
        : base(config)
    {
        GameSystem.Instance.mNetworkManager.onServerConnected += OnGameServerConn;

        GameSystem.Instance.mNetworkManager.ConnectToGS(config.type, config.ip, config.port);

        NetworkManager mgr = GameSystem.Instance.mNetworkManager;

        mgr.m_gameMsgHandler.RegisterHandler(MsgID.EnterGameSrvRespID, OnEnterGameSrv);         //进入游戏服务器
        mgr.m_gameMsgHandler.RegisterHandler(MsgID.EnterGameRespID, OnEnterGame);               //加入玩家
        mgr.m_gameMsgHandler.RegisterHandler(MsgID.InstructionBroadcastID, HandleBroadcast);

        mgr.m_gameConn.m_profiler.BeginRecordDataUsage();

        m_overTimer      = new GameUtils.Timer(new IM.Number(3), _HandleGameOver, 1);
        m_overTimer.stop = true;
    }
예제 #16
0
    override public void OnEnter(MatchState lastState)
    {
        base.OnEnter(lastState);

        foreach (Player player in GameSystem.Instance.mClient.mPlayerManager)
        {
            player.m_enableAction         = false;
            player.m_enableMovement       = false;
            player.m_enablePickupDetector = false;
            player.Hide();
        }

        InputReader.Instance.enabled = false;
        NGUITools.SetActive(match.slotMachine.gameObject, true);
        NGUITools.BringForward(match.slotMachine.gameObject);
        match.slotMachine.onCreateItem += OnCreateSlotMachineItem;
        match.slotMachine.onEnd        += OnSlotMachineEnd;

        timerBegin      = new GameUtils.Timer(IM.Number.one, BeginSlotMachine);
        timerBegin.stop = false;
    }
예제 #17
0
    override public void OnEnter(MatchState lastState)
    {
        foreach (Player player in GameSystem.Instance.mClient.mPlayerManager)
        {
            player.moveDirection     = IM.Vector3.zero;
            player.m_toSkillInstance = null;
            player.m_bToCatch        = false;
            player.m_bOnGround       = true;
            player.m_passTarget      = null;
            player.DropBall(m_match.mCurScene.mBall);
        }

        m_match.m_bOverTime = true;

        m_goDrawGameMsg = UIManager.Instance.CreateUI("msg/Msg_DrawGame");
        m_goDrawGameMsg.SetActive(false);

        _OnPlayTrack();

        _timer = new GameUtils.Timer(DURATION, OnOverTimeFinish);
    }
예제 #18
0
    protected override void _OnLoadingCompleteImp()
    {
        base._OnLoadingCompleteImp();
        m_stateMachine.m_matchStateListeners.Add(this);

        mCurScene.mBall.onCatch = OnCatchBall;

        matchReviseTip = new MatchReviseTip(this);

        timer = new GameUtils.Timer(IM.Number.half, () => { ShowGuide("Intro"); }, 1);

        //load tip resource
        guideTip = UIManager.Instance.CreateUI("GuideTip").AddMissingComponent <GuideTip>();
        guideTip.GetComponent <UIPanel>().depth = 1000;
        guideTip.transform.localPosition        = new Vector3(79, 230, 0);
        guideTip.instructorVisible  = true;
        guideTip.instructor         = "effects_guide";
        guideTip.instructorPos      = new Vector3(-444, -18, 0);
        guideTip.onFirstButtonClick = OnTipClick;
        guideTip.Hide();
    }
예제 #19
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;
    }
예제 #20
0
    protected override void CreateCustomGUI()
    {
        GameObject prefab = ResourceLoadManager.Instance.LoadPrefab("Prefab/GUI/UIMatchReboundStorm") as GameObject;

        uiMatch = CommonFunction.InstantiateObject(prefab, UIManager.Instance.m_uiRootBasePanel.transform).GetComponent <UIMatchReboundStorm>();
        uiMatch.timerBoard.isChronograph = true;
        gameMatchTime = new IM.Number((int)gameMode.time);
        uiMatch.timerBoard.UpdateTime((float)gameMatchTime);
        if (m_gameMathCountEnable)
        {
            if (m_gameMathCountTimer == null)
            {
                m_gameMathCountTimer = new GameUtils.Timer(gameMatchTime, () => { m_stateMachine.SetState(MatchState.State.eOver);
                                                                                  NGUITools.SetActive(uiMatch.transform.FindChild("ButtonBack").gameObject, false);
                                                                                  uiMatch.timerBoard.UpdateTime(0f); });
            }
            else
            {
                m_gameMathCountTimer.SetTimer(gameMatchTime);
            }
        }
        m_gameMatchCountStop = true;
    }
    protected override void CreateCustomGUI()
    {
        GameObject prefab = ResourceLoadManager.Instance.LoadPrefab("Prefab/GUI/UIMatchBlockStorm") as GameObject;

        uiMatch          = CommonFunction.InstantiateObject(prefab, UIManager.Instance.m_uiRootBasePanel.transform).GetComponent <UIMatchBlockStorm>();
        uiMatch.maxScore = oneStarScore;
        gameMatchTime    = new IM.Number((int)gameMode.time);
        uiMatch.timerBoard.isChronograph = true;
        uiMatch.timerBoard.SetVisible(m_gameMathCountEnable);
        uiMatch.timerBoard.UpdateTime((float)gameMatchTime);
        m_gameMatchCountStop = true;
        if (m_gameMathCountEnable)
        {
            if (m_gameMathCountTimer == null)
            {
                m_gameMathCountTimer = new GameUtils.Timer(gameMatchTime, () => { m_stateMachine.SetState(MatchState.State.eOver);
                                                                                  uiMatch.timerBoard.UpdateTime(0f); });
            }
            else
            {
                m_gameMathCountTimer.SetTimer(gameMatchTime);
            }
        }
    }
예제 #22
0
    public GameMatch_BullFight(Config config)
        : base(config)
    {
        if (gameMode != null)
        {
            string[] tokens = gameMode.additionalInfo.Split('&');

            OFFENSE_TIME_LIMIT = IM.Number.Parse(tokens[0]);
            WIN_SCORE          = int.Parse(tokens[1]);
        }
        else
        {
            OFFENSE_TIME_LIMIT = new IM.Number(14);
            WIN_SCORE          = 5;
        }


        timerReset      = new GameUtils.Timer(IM.Number.two, Reset);
        timerReset.stop = true;
        timerOver       = new GameUtils.Timer(IM.Number.two, Over);
        timerOver.stop  = true;

        GameSystem.Instance.mNetworkManager.ConnectToGS(config.type, "", 1);
    }
    override public void OnEnter(MatchState lastState)
    {
        base.OnEnter(lastState);

        if (m_match.m_bOverTime)
        {
            m_match.m_gameMathCountEnable = false;
        }

        m_match.CreateUI();

        m_match.ResetPlayerPos();
        m_match.m_cam.Positioning(true);
        m_match.m_cam.m_PositionImmediately = false;
        foreach (Player player in GameSystem.Instance.mClient.mPlayerManager)
        {
            player.m_enableAction         = false;
            player.m_enableMovement       = false;
            player.m_enablePickupDetector = false;
            player.Show(true);
        }

        m_match.m_cam.m_moveSpeed = m_match.m_cam.m_CloseUpRestoreSpeed;

        m_match.m_cam.m_Zoom.SetZoom(m_match.mainRole.gameObject.transform, ZoomType.ePlayerCloseUp);

        if (m_match.m_uiMatch != null)
        {
            m_match.m_gameMatchCountStop = true;
            m_match.m_count24TimeStop    = true;
        }

        Team oppoTeam = m_match.mainRole.m_team.m_side == Team.Side.eAway ? m_match.m_homeTeam : m_match.m_awayTeam;

        foreach (Player member in oppoTeam.members)
        {
            if (member.model != null)
            {
                member.model.EnableGrey();
            }
        }

        Color yellow = new Color(1f, 252f / 255, 10f / 255, 1);

        m_match.mainRole.ShowIndicator(yellow, true);

        //if (m_match.m_mainRole.m_inputDispatcher == null && m_match.GetMatchType() != GameMatch.Type.e3AIOn3AI )
        //	m_match.m_mainRole.m_inputDispatcher = new InputDispatcher (m_match, m_match.m_mainRole);

        //reset position
        if (m_match.m_needTipOff)
        {
            TipOffPos tipOffPos = GameSystem.Instance.MatchPointsConfig.TipOffPos;
            int       homeCnt   = m_match.m_homeTeam.GetMemberCount();
            for (int idx = 0; idx != homeCnt; idx++)
            {
                IM.Transform trOffensePos = tipOffPos.offenses_transform[idx];
                IM.Transform trDefensePos = tipOffPos.defenses_transform[idx];
                Player       homePlayer   = m_match.m_homeTeam.members[idx];
                if (homePlayer != null)
                {
                    homePlayer.position = trOffensePos.position;
                    homePlayer.rotation = trOffensePos.rotation;
                }
                Player awayPlayer = m_match.m_awayTeam.members[idx];
                if (awayPlayer != null)
                {
                    awayPlayer.position = trDefensePos.position;
                    awayPlayer.rotation = trDefensePos.rotation;
                }
            }
            m_match.m_needTipOff = false;
        }

        if (m_match.m_bOverTime)
        {
            timer2 = new GameUtils.Timer(BEGIN_WAIT_TIME, () => m_stateMachine.SetState(State.eTipOff), 1);
        }
        else
        {
            timer1 = new GameUtils.Timer4View((float)BEGIN_WAIT_TIME, GameMsgSender.SendGameBegin, 1);
        }
    }
예제 #24
0
 public AI_PickAndRoll(AISystem owner)
     : base(owner)
 {
     m_eType = AIState.Type.ePickAndRoll;
     timer   = new GameUtils.Timer(new IM.Number(0, 300), OnTimer);
 }
예제 #25
0
    override public void OnEnter(MatchState lastState)
    {
        if (m_match.m_needTipOff)
        {
            TipOffPos tipOffPos = GameSystem.Instance.MatchPointsConfig.TipOffPos;
            int       homeCnt   = m_match.m_homeTeam.GetMemberCount();
            for (int idx = 0; idx != homeCnt; idx++)
            {
                IM.Transform trOffensePos = tipOffPos.offenses_transform[idx];
                IM.Transform trDefensePos = tipOffPos.defenses_transform[idx];
                Player       homePlayer   = m_match.m_homeTeam.members[idx];
                if (homePlayer != null)
                {
                    homePlayer.position = trOffensePos.position;
                    homePlayer.rotation = trOffensePos.rotation;
                }
                Player awayPlayer = m_match.m_awayTeam.members[idx];
                if (awayPlayer != null)
                {
                    awayPlayer.position = trDefensePos.position;
                    awayPlayer.rotation = trDefensePos.rotation;
                }
            }
            m_match.m_needTipOff = false;
        }

        if (m_match.m_cam != null)
        {
            m_match.m_cam.m_Zoom.ReleaseZoom();
        }

        foreach (Player player in GameSystem.Instance.mClient.mPlayerManager)
        {
            player.m_enableAction   = false;
            player.m_enableMovement = false;
            player.m_bMovedWithBall = false;

            if (player.m_catchHelper != null)
            {
                player.m_catchHelper.enabled = true;
            }

            if (player.m_pickupDetector != null)
            {
                player.m_enablePickupDetector = true;
            }

            if (player.m_AOD != null)
            {
                player.m_AOD.visible = false;
            }

            player.m_toSkillInstance = null;
            player.m_stamina.ResetStamina();

            player.m_StateMachine.SetState(PlayerState.State.eStand);
        }

        if (m_goBeginUI == null)
        {
            m_goBeginUI = GameSystem.Instance.mClient.mUIManager.CreateUI("UIBeginCounter");
        }
        if (m_goBeginUI == null)
        {
            Debug.Log("Error -- can not find ui resource " + "UIBeginCounter");
            return;
        }
        Animation anim = m_goBeginUI.GetComponentInChildren <Animation>();

        anim.Stop();
        anim.Play("counter");

        UBasketball ball = m_match.mCurScene.mBall;

        if (ball != null && ball.m_owner != null && m_match.m_uiMatch != null && m_match.EnableCounter24())
        {
            m_match.m_uiMatch.ShowCounter(true, ball.m_owner.m_team.m_side == Team.Side.eHome);
            m_match.m_count24TimeStop = true;
        }

        ball.Reset();
        IM.Number x1 = m_match.m_homeTeam.members[0].position.x;
        IM.Number x2 = m_match.m_awayTeam.members[0].position.x;
        IM.Number z  = m_match.m_homeTeam.members[0].position.z;
        ball.SetInitPos(new IM.Vector3((x1 + x2) * IM.Number.half, fBallInitHeight, z));
        ball.m_ballState = BallState.eNone;

        if (m_match.m_uiMatch != null && m_match.EnableCounter24())
        {
            m_match.m_uiMatch.ShowCounter(true, true);

            m_match.m_gameMatchCountStop = true;
            m_match.m_count24TimeStop    = true;
        }

        if (m_match.EnableEnhanceAttr())
        {
            m_match.EnhanceAttr();
        }

        mTimer      = new GameUtils.Timer(new IM.Number(3), _OnCounterDone, 1);
        mTimerSound = new GameUtils.Timer(new IM.Number(3), PlaySound, 1);

        m_match.m_homeTeam.m_role         = GameMatch.MatchRole.eNone;
        m_match.m_awayTeam.m_role         = GameMatch.MatchRole.eNone;
        m_match.m_ruler.m_toCheckBallTeam = null;
    }
예제 #26
0
 public NetworkProfiler(NetworkConn server)
 {
     m_server    = server;
     m_timer     = new GameUtils.Timer(1f, _OnTimer);
     m_dataUsage = 0;
 }
 public AI_PractisePass_Idle(AISystem owner)
     : base(owner)
 {
     m_eType = AIState.Type.ePractisePass_Idle;
     m_timer = new GameUtils.Timer(IM.Number.one, _OnTimer);
 }
예제 #28
0
 public void ResetAssist()
 {
     timer      = null;
     m_assistor = null;
     m_assistee = null;
 }