Beispiel #1
0
    private void WinGame(int player, BoardController.WinObj winObj)
    {
        int        length      = winObj.chainlenght;
        int        repetitions = winObj.mclRepeticions;
        Vector2Int dir         = winObj.dir;

        numTurns++;         //Add turn for cheess like back and fowards, since `PlaceActualObject()` didn't get to change turn
        hasWon = true;
        if (player == 0)
        {
            for (int i = 0; i < numPlayers; i++)               //Check if draw
            {
                championScores[i] += 0.5f;
            }
            print("Draw. boooo");
        }
        else             //Win actual game
        {
            championScores[player] += 1;
            print($"{objDict[player]} wins with {repetitions} chains of {length} \nHe has {championScores[player]} points");
            canPlace = false;
            turn     = 0;

            //Display line
        }
    }
Beispiel #2
0
    public void PlaceActualObject(int col, int turn)
    {
        int row = boardController.ApplyGravity(col).x;

        BoardController.WinObj winObj = boardController.PlaceObject(col, turn);
        int[] status = winObj.status();

        UpdateBoard();

        history.Add(col);

        if (status[0] >= 4)
        {
            WinGame(turn, winObj);
        }
        else           //Check if whole board is full, then if truthy win with player = 0 to indicate draw
        {
            int caca = 1;
            for (int i = 0; i < boardSize.y; i++)
            {
                caca *= boardController.board[3, i];
            }

            if (caca != 0)
            {
                WinGame(0, winObj);
            }
            else
            {
                ChangeTurn();
            }
        }
    }