Skip to content

Commit

Permalink
とりあえず後手番でもAIとさせるようになった?(成と持ち駒は正しく動かない)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrwaaa committed Feb 17, 2024
1 parent 0e6473d commit 93712e1
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions Assets/Scripts/GameSceneScreen/GameSceneController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,28 @@ private async UniTask InitBoard(string boardJsonPath = "", BoardType boardType =
Debug.Log(boardData);
foreach (var data in boardData.boardData)
{
var piece = Instantiate(piecePrefab, cells[data.y, data.x].transform);
piece.GetComponent<Image>().sprite = Resources.Load<Sprite>("ShogiUI/Piece/" + data.pieceType);
piece.GetComponent<Piece>().pieceType = PieceData.StrToPieceType(data.pieceType);
var cellX = isAIFirst ? 8 - data.x : data.x;
var cellY = isAIFirst ? 8 - data.y : data.y;
var piece = Instantiate(piecePrefab, cells[cellY, cellX].transform);
if(isAIFirst)
{
// AIが先手の場合、blackpieceとwhitepieceの配置を逆にする
piece.GetComponent<Piece>().piecePotition = new PieceData.PiecePotition(8 - data.x, 8 - data.y);
}
{
var pieceType = "";
if (data.pieceType.Contains("white"))
{
pieceType = data.pieceType.Replace("white", "black");
} else
{
pieceType = data.pieceType.Replace("black", "white");
}
piece.GetComponent<Image>().sprite = Resources.Load<Sprite>("ShogiUI/Piece/" + pieceType);
}
else
{
piece.GetComponent<Piece>().piecePotition = new PieceData.PiecePotition(data.x, data.y);
{
piece.GetComponent<Image>().sprite = Resources.Load<Sprite>("ShogiUI/Piece/" + data.pieceType);
}
piece.GetComponent<Piece>().pieceType = PieceData.StrToPieceType(data.pieceType);
piece.GetComponent<Piece>().piecePotition = new PieceData.PiecePotition(cellX, cellY);


piece.GetComponent<Piece>().OnClickAction += UniTask.UnityAction(async () =>
{
Expand Down Expand Up @@ -483,15 +493,13 @@ private async UniTask GetAIAction()
Debug.Log("fromX:" + fromX + " fromY:" + fromY + " toX:" + toX + " toY:" + toY);
isPieceSelected = true;

/*
if(isAIFirst)
{
fromX = 8 - fromX;
fromY = 8 - fromY;
toX = 8 - toX;
toY = 8 - toY;
}
*/

// 駒を打つ場合
if (move.IsDrop())
Expand Down

0 comments on commit 93712e1

Please sign in to comment.