private void AITurn() { if (first) { first = false; Debug.Log(String.Format("White Chess Down:{0},{1},{2}", 7, 7, 0)); boardData[7, 7] = (GameObject)Instantiate(whiteChessPrefab, new Vector3(7, 0, 7), Quaternion.identity); ChessAI.board[7, 7] = 2; end = ChessAI.CheckWinner(7, 7, 2); Debug.Log(end); role = 1; return; } int[] maxPoint = ChessAI.NextMove(role); Debug.Log(String.Format("White Chess Down:{0},{1},{2}", maxPoint[0], maxPoint[1], maxPoint[2])); boardData[maxPoint[0], maxPoint[1]] = (GameObject)Instantiate(whiteChessPrefab, new Vector3(maxPoint[0], 0, maxPoint[1]), Quaternion.identity); ChessAI.board[maxPoint[0], maxPoint[1]] = 2; end = ChessAI.CheckWinner(maxPoint[0], maxPoint[1], 2); Debug.Log(end); role = 1; }
private void DrawPrefab() { first = false; if (clone != null && selectionX == lastSelectionX && selectionY == lastSelectionY && Input.GetMouseButtonDown(0) && boardData[selectionX, selectionY] == null) { Debug.Log(String.Format("Black Chess Down:{0},{1}", selectionX, selectionY)); boardData[selectionX, selectionY] = (GameObject)Instantiate(blackChessPrefab, new Vector3(selectionX, 0, selectionY), Quaternion.identity); ChessAI.board[selectionX, selectionY] = 1; end = ChessAI.CheckWinner(selectionX, selectionY, 1); Debug.Log(end); role = 2; } if (clone != null && (selectionX != lastSelectionX || selectionY != lastSelectionY)) { Destroy(clone); } if (clone == null && selectionX >= 0 && selectionX < 15 && selectionY >= 0 && selectionY < 15 && boardData[selectionX, selectionY] == null) { clone = (GameObject)Instantiate(blackChessPrefab, new Vector3(selectionX, 0, selectionY), Quaternion.identity); lastSelectionX = selectionX; lastSelectionY = selectionY; } }