Ejemplo n.º 1
0
        void checkDoneRolling()
        {
            bool doneRolling = true;

            for (int i = 0; i < m_balls.Length; i++)
            {
                if (m_balls[i] && (m_balls[i].isDoneRolling() == false &&
                                   m_balls[i].gameObject.activeInHierarchy))
                {
                    doneRolling = false;
                }
            }
            if (doneRolling)
            {
                Debug.Log("doneRolling!");
                float waitTime = 0;
                bool  fouls    = handleFouls();
                //clear the wall hit.
                if (fouls)
                {
                    PoolKit.BaseGameManager.foul("");
                    waitTime = 2f;
                }


                PoolKit.BaseGameManager.ballStopped();
                m_state = State.DONE_ROLLING;


                //change turn!
                if (m_ballsPocketed == 0 || m_whiteEnteredPocket || m_foul)
                {
                    if (m_players.Length > 1)
                    {
                        m_playerTurn ^= 1;

                        m_currentPlayer = m_players[m_playerTurn];
                    }

                    StartCoroutine(changeTurn(waitTime));
                }
                else
                {
                    StartCoroutine(changeTurn(waitTime));
                }
                m_ballsPocketed = 0;
                m_turnCounter++;
            }
        }
Ejemplo n.º 2
0
        public virtual void changeTurnRPC(bool foul, int turn)
        {
            m_foul          = foul;
            m_playerTurn    = turn;
            m_currentPlayer = m_players[m_playerTurn];

            m_currentPlayer.foul = m_foul;

            Vector3 oldBallPos    = Vector3.zero;
            bool    hasOldBallpos = false;

            if (m_whiteBall != null)
            {
                hasOldBallpos = true;
                oldBallPos    = m_whiteBall.transform.position;
                Debug.Log("disable whiteBall" + m_whiteBall.name);
                m_whiteBall.gameObject.SetActive(false);
            }

            m_whiteBall = m_currentPlayer.getWhiteBall();
            if (m_whiteBall)
            {
                m_whiteBall.gameObject.SetActive(true);
                if (hasOldBallpos)
                {
                    m_whiteBall.transform.position = oldBallPos;
                }
                Debug.Log("enable whiteBall" + m_whiteBall.name);

                m_whiteBall.clear();
                m_whiteBall.setPoolCue(m_currentPlayer.getCue());

                m_whiteBall.foul = m_foul;
            }

            PoolKit.BaseGameManager.showTitleCard(m_players[m_playerTurn].playerName + " turn!");

            PoolKit.BaseGameManager.playersTurn(m_playerTurn);
        }