コード例 #1
0
    public void StartGame(int inChoice)
    {
        switch (inChoice)
        {
        case 0:
            if (mRedPlayerFinished != 4)
            {
                mRollingDice[0].SetActive(true);
                mRollingDice[1].SetActive(false);
                mRollingDice[2].SetActive(false);
                mRollingDice[3].SetActive(false);
                mArrows[0].SetActive(true);
                mArrows[1].SetActive(false);
                mArrows[2].SetActive(false);
                mArrows[3].SetActive(false);
                if (mRedSixCount == 4)
                {
                    mCanRollSix = true;
                }

                mRedToken.OrderInLayer(3);
                mNumberOfSix = 0;
                mCanClick    = true;
                mPlayerIndex++;
                mLastToken  = false;
                mDiceRolled = false;
                mRedToken.CanMove();
            }
            else
            {
                mPlayerIndex++;
                StartGame(mPlayingTokens[mPlayerIndex]);
            }
            break;

        case 1:
            if (mBluePlayerFinished != 4)
            {
                mRollingDice[0].SetActive(false);
                mRollingDice[1].SetActive(true);
                mRollingDice[2].SetActive(false);
                mRollingDice[3].SetActive(false);
                mArrows[0].SetActive(false);
                mArrows[1].SetActive(true);
                mArrows[2].SetActive(false);
                mArrows[3].SetActive(false);
                if (mBlueSixCount == 4)
                {
                    mCanRollSix = true;
                }

                mBlueToken.OrderInLayer(3);
                mNumberOfSix = 0;
                mCanClick    = true;
                mPlayerIndex++;
                mLastToken  = false;
                mDiceRolled = false;
                mBlueToken.CanMove();
            }
            else
            {
                mPlayerIndex++;
                StartGame(mPlayingTokens[mPlayerIndex]);
            }
            break;

        case 2:
            if (mYellowPlayerFinished != 4)
            {
                mRollingDice[0].SetActive(false);
                mRollingDice[1].SetActive(false);
                mRollingDice[2].SetActive(true);
                mRollingDice[3].SetActive(false);
                mArrows[0].SetActive(false);
                mArrows[1].SetActive(false);
                mArrows[2].SetActive(true);
                mArrows[3].SetActive(false);
                if (mYellowSixCount == 4)
                {
                    mCanRollSix = true;
                }

                mYellowToken.OrderInLayer(3);
                mNumberOfSix = 0;
                mCanClick    = true;
                mPlayerIndex++;
                mLastToken  = false;
                mDiceRolled = false;
                mYellowToken.CanMove();
            }
            else
            {
                mPlayerIndex++;
                StartGame(mPlayingTokens[mPlayerIndex]);
            }
            break;

        case 3:
            if (mGreenPlayerFinished != 4)
            {
                mRollingDice[0].SetActive(false);
                mRollingDice[1].SetActive(false);
                mRollingDice[2].SetActive(false);
                mRollingDice[3].SetActive(true);
                mArrows[0].SetActive(false);
                mArrows[1].SetActive(false);
                mArrows[2].SetActive(false);
                mArrows[3].SetActive(true);
                if (mGreenSixCount == 4)
                {
                    mCanRollSix = true;
                }

                mYellowToken.OrderInLayer(3);
                mNumberOfSix = 0;
                mCanClick    = true;
                mPlayerIndex++;
                mLastToken  = false;
                mDiceRolled = false;
                mGreenToken.CanMove();
            }
            else
            {
                mPlayerIndex++;
                StartGame(mPlayingTokens[mPlayerIndex]);
            }
            break;
        }
    }
コード例 #2
0
    //Function to move the token step by step based on the number appeared on the dice.
    IEnumerator IMoveToken()
    {
        yield return(new WaitForSeconds(.25f));

        mNumberGot = GameManagerScript.mGameManager.mNumberGot;
        if (mNumberGot == 6 && mIsReadyToMove == false)
        {
            //This is condition to move the token from Initial position to the first position.
            //mMoveToFirstPosition = true;
            transform.DOMove(mPath[1].transform.position, 1f).SetEase(Ease.InOutQuad).OnComplete(ShakeToken);
            GameManagerScript.mGameManager.mRedPlayerOut++;
            GameManagerScript.mGameManager.mTokenClicked = false;
            mStartingPosition = true;
            mNumberGot        = 2;
            mPositionMoved    = 2;
            mFlag             = 1;
            mIsReadyToMove    = true;
            mAnotherChance    = true;
            mTokenMoved       = false;
            mTokenOut         = true;
        }
        else if (mIsReadyToMove && mNumberGot <= 6 && GameManagerScript.mGameManager.mRolledDice.CompareTag("Red"))
        {
            //Checking whether number appeared on the dice is less than the number of steps remaining.
            //If not shift the turn to the next player.
            mChildObject.SetActive(false);
            mMoveToFirstPosition = false;
            if (mNumberGot <= mNumberOfStepsRemaining)
            {
                GameManagerScript.mGameManager.mCanClick = false;
                for (int i = mNumberOfStepsMoved; i < (mNumberGot + mNumberOfStepsMoved); i++)
                {
                    transform.DOMove(mPath[i].transform.position, .1f).SetEase(Ease.InOutQuad);
                    SoundManagerScript.PlaySound("Move");
                    GameManagerScript.mGameManager.mTokenMoving = true;
                    mRedTokenMoving = true;
                    yield return(new WaitForSeconds(.25f));

                    mLastPosition  += 1;
                    mPositionMoved += 1;
                    mTokenPosition  = i;
                }
                mRedTokenMoving = false;
                GameManagerScript.mGameManager.mTokenMoving = false;
                if (mTokenPosition != 57 && mNumberGot == 6)
                {
                    //This is a condition to check whether a player got 6.
                    //If so he will get another chance to roll the dice.
                    mAnotherChance = true;
                    GameManagerScript.mGameManager.mCanClick = true;
                    mRedCanMove = true;
                    mTokenMoved = false;
                }
                else if (mTokenPosition == 57)
                {
                    gameObject.transform.localScale = new Vector2(0.1f, 0.1f);
                    gameObject.transform.position   = new Vector2(gameObject.transform.position.x - mFinalPosition[mRedToken.mFinalPositionIndex], gameObject.transform.position.y);
                    mRedToken.OrderInLayer(1);
                    SoundManagerScript.PlaySound("Home");
                    GameManagerScript.mGameManager.mRedPlayerFinished++;
                    GameManagerScript.mGameManager.mRedPlayerOut--;
                    mAnotherChance  = true;
                    mRedCanMove     = false;
                    mPlayerFinished = true;
                    mRedToken.mFinalPositionIndex++;
                }
                else
                {
                    mAnotherChance = false;
                    mRedCanMove    = false;
                    mTokenMoved    = true;
                }
                mNumberOfStepsMoved += mNumberGot;
            }
        }
        mNumberOfStepsRemaining = mPath.Length - mPositionMoved;
        StartCoroutine(IShiftPlayer());
        AllPlayerFinished();
        mRedToken.OrderInLayer(2);
        if (mMoveToken != null)
        {
            StopCoroutine(mMoveToken);
        }
    }