Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        boardManager  = GameObject.FindGameObjectWithTag("GameController").GetComponent <BoardManager>();
        hexController = GameObject.FindGameObjectWithTag("GameController").GetComponent <HexController>();
        whoseTurn     = BoardManager.UnitColor.White;
        phase         = Phase.FirstPlacement;
        eligibleColor = "WhitePiece";
        selectionMode = true;

        //Initialize GUI display
        DisableButtons();
        UpdateStatus("White's Turn");

        if (PhotonNetwork.isMasterClient)   //Master client is white and takes the first turn
        {
            myTurn = true;
        }
        else
        {
            myTurn = false;
        }
    }
Esempio n. 2
0
    public void NetworkSyncNextTurn()
    {
        if (!PhotonNetwork.offlineMode) //For offline mode leave my turn as true always
        {
            if (myTurn)
                myTurn = false;

            else
            {
                myTurn = true;
                startOfTurn = true;
            }
        }

        else //If in offline mode
        {
            startOfTurn = true;
        }

        dragMode = false;
        selectionMode = true;

        boardManager.lastPieceMoved = null; //Clear the last piece moved variable

        //hexController.ClearHighlights();    //Clear all highlights

        CheckVictoryConditions();

        if (!gameover)
        {

            if (phase == Phase.FirstPlacement || phase == Phase.SecondPlacement)
            {
                phase++;
            }

            if (whoseTurn == BoardManager.UnitColor.White)
            {
                whoseTurn = BoardManager.UnitColor.Black;
                eligibleColor = "BlackPiece";
                UpdateStatus("Black's Turn");
            }
            else
            {
                whoseTurn = BoardManager.UnitColor.White;
                eligibleColor = "WhitePiece";
                UpdateStatus("White's Turn");
                turnNumber++;
            }

            //If it's the fourth turn and the queen has not been placed
            if (turnNumber == 4 && !boardManager.HasQueenBeenPlaced(whoseTurn))
            {
                onlyQueen = true;
                Debug.Log("Queen must be placed this turn");
            }
            else
                onlyQueen = false;

            //Until the queen has been placed, no moves are allowed, only new placements
            if (turnNumber <= 4 && !boardManager.HasQueenBeenPlaced(whoseTurn))
            {
                onlyPlacementAllowed = true;
                Debug.Log("No moves allowed until queen has been placed");
            }
            else
                onlyPlacementAllowed = false;

            boardManager.DetermineMoveablePieces(whoseTurn);

            DisableButtons();
        }
    }
Esempio n. 3
0
    // Use this for initialization
    void Start()
    {
        boardManager = GameObject.FindGameObjectWithTag("GameController").GetComponent<BoardManager>();
        hexController = GameObject.FindGameObjectWithTag("GameController").GetComponent<HexController>();
        whoseTurn = BoardManager.UnitColor.White;
        phase = Phase.FirstPlacement;
        eligibleColor = "WhitePiece";
        selectionMode = true;

        //Initialize GUI display
        DisableButtons();
        UpdateStatus("White's Turn");

        if (PhotonNetwork.isMasterClient)   //Master client is white and takes the first turn
        {
            myTurn = true;
        }
        else
            myTurn = false;
    }
Esempio n. 4
0
    public void NetworkSyncNextTurn()
    {
        if (!PhotonNetwork.offlineMode) //For offline mode leave my turn as true always
        {
            if (myTurn)
            {
                myTurn = false;
            }

            else
            {
                myTurn      = true;
                startOfTurn = true;
            }
        }

        else //If in offline mode
        {
            startOfTurn = true;
        }

        dragMode      = false;
        selectionMode = true;

        boardManager.lastPieceMoved = null; //Clear the last piece moved variable

        //hexController.ClearHighlights();    //Clear all highlights

        CheckVictoryConditions();

        if (!gameover)
        {
            if (phase == Phase.FirstPlacement || phase == Phase.SecondPlacement)
            {
                phase++;
            }

            if (whoseTurn == BoardManager.UnitColor.White)
            {
                whoseTurn     = BoardManager.UnitColor.Black;
                eligibleColor = "BlackPiece";
                UpdateStatus("Black's Turn");
            }
            else
            {
                whoseTurn     = BoardManager.UnitColor.White;
                eligibleColor = "WhitePiece";
                UpdateStatus("White's Turn");
                turnNumber++;
            }

            //If it's the fourth turn and the queen has not been placed
            if (turnNumber == 4 && !boardManager.HasQueenBeenPlaced(whoseTurn))
            {
                onlyQueen = true;
                Debug.Log("Queen must be placed this turn");
            }
            else
            {
                onlyQueen = false;
            }

            //Until the queen has been placed, no moves are allowed, only new placements
            if (turnNumber <= 4 && !boardManager.HasQueenBeenPlaced(whoseTurn))
            {
                onlyPlacementAllowed = true;
                Debug.Log("No moves allowed until queen has been placed");
            }
            else
            {
                onlyPlacementAllowed = false;
            }

            boardManager.DetermineMoveablePieces(whoseTurn);

            DisableButtons();
        }
    }