/* * compute for the winner * */ public int getWinner() { int player1C = 0, player2C = 0; int player1T1 = 0, player1T2 = 0; int player2T1 = 0, player2T2 = 0; //count all 3x3 diamond first for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { if (hasThreeThreeDiamond(1, i, j)) { player1T1++; } if (hasThreeThreeDiamond(2, i, j)) { player2T1++; } } } UIManagerScript.Instance.numPlayer1Triangle1 = player1T1; //UIManagerScript.Instance.numPlayer1Triangle2 = player1T2; UIManagerScript.Instance.numPlayer2Triangle1 = player2T1; //UIManagerScript.Instance.numPlayer2Triangle2 = player2T2; player1C = player1T1 * GameManagerScript.Instance.score2x3Triangle + player1T2 * GameManagerScript.Instance.score2x2Triangle; player2C = player2T1 * GameManagerScript.Instance.score2x3Triangle + player2T2 * GameManagerScript.Instance.score2x2Triangle; UIManagerScript.Instance.player1Count = player1C; UIManagerScript.Instance.player2Count = player2C; if (player1C > player2C) { GameManagerScript.AddScore(GameManagerScript.PLAYER_RED); } else if (player1C < player2C) { GameManagerScript.AddScore(GameManagerScript.PLAYER_BLUE); } GameManagerScript.AddGame(); return((player1C > player2C) ? 1 : (player1C < player2C) ? 2 : 0); }