How to piece move

Hello, I’m doing a chess-like game and I based this https://www.raywenderlich.com/186631/how-to-make-a-chess-game-with-unity project as a substructure, but I have a problem here, the rook just want to cancel it going back. Can you write how it’s done?another code that only goes left, left and forward will work for me… Thank you.

using System.Collections.Generic;
using UnityEngine;

public class Rook : Piece
{
public override List MoveLocations(Vector2Int gridPoint)
{
List locations = new List();

    foreach (Vector2Int dir in RookDirections)
    {
        for (int i = 1; i < 8; i++)
        {
            Vector2Int nextGridPoint = new Vector2Int(gridPoint.x + i * dir.x, gridPoint.y + i * dir.y);
            locations.Add(nextGridPoint);
            if (GameManager.instance.PieceAtGrid(nextGridPoint))
            {
                break;
            }
        }
    }

    return locations;
}

}

This topic was automatically closed after 166 days. New replies are no longer allowed.