// variables used for testing //public int addPieces; //public bool colsTested = false; //public int[] colsToTest = {5}; // Use this for initialization void Start() { var difficulty = PreGameSettings.getDifficulty(); board = new BoardControl(6, 4, FieldPrefab, white, black); currentPlayer = new AiControl(difficulty, board, "white"); waitingPlayer = new HumanPlayerControl(board, "player1", "black"); }
//Invoked when a submit button is clicked. public void UpdateDifficultySetting(float val) { Debug.Log(val); PreGameSettings.setDifficulty((int)val); }
// Update is called once per frame void Update() { if (!gameOver) { turnPlayed = currentPlayer.PlayTurn(); if (turnPlayed) { if (checkWin(currentPlayer.GetColor())) { Debug.Log("------------------------------------------------" + currentPlayer.GetColor() + " wins"); if (currentPlayer.IsAi()) { GameOverState.gameResult = "The AI level " + PreGameSettings.getDifficulty() + " won"; aiWon = true; } else { GameOverState.gameResult = "Congratulations " + currentPlayer.GetName() + " you beat AI level " + PreGameSettings.getDifficulty(); aiWon = false; } gameOver = true; } else { turnNumber++; togglePlayer(); if (turnNumber >= HorizontalSize * VerticalSize) { GameOverState.gameResult = ""; gameOver = true; } } } } else { //SceneManager.LoadScene(0); // show win, loss, draw and ask to play again.. } //if (currentPlayer.Equals("white")) //{ // int lastCol = PlayTurn(); // if (checkWin(lastCol)) // { // Debug.Log("------------------------------------------------" + currentPlayer + " wins"); // } // else // { // currentPlayer = "black"; // } //} //else //{ // int lastCol = PlayTurn(); // if (checkWin(lastCol)) // { // Debug.Log("------------------------------------------------" + currentPlayer + " wins"); // } // currentPlayer = "white"; //} }