Exemplo n.º 1
0
    /// <summary>
    /// Sets a peice on the space.
    /// </summary>
    /// <param name="peice">The peice prefab to be set.</param>
    /// <param name="space">The space where the peice will be set.</param>
    /// <returns>The set peice.</returns>
    public GameObject SetPiece(GameObject peice, ISpace space)
    {
        GameObject pieceGo = null;

        try {
            pieceGo = Instantiate(peice, space.GetWorldCoords(),
                                  Quaternion.Euler(0, 0, 0));
            var piece = pieceGo.GetComponent <IPiece>();

            if (pieceLayout[space.X, space.Y].StartsWith("W"))
            {
                piece.Team     = "W";
                piece.Rotation = Rotation.South;
            }
            else
            {
                piece.Team     = "B";
                piece.Rotation = Rotation.North;
            }

            piece.Initialise(space);
            //piece.MoveableSpaces = piece.MovementRules.GetLegalMoves(Board, piece);
        } catch (Exception e) {
            Debug.LogError("Error setting piece at " + space.X + ", " + space.Y);
        }

        return(pieceGo);
    }
Exemplo n.º 2
0
    private GameObject SetPiece(ISpace space)
    {
        GameObject pieceGo = null;

        try {
            pieceGo = Instantiate(pieceDictionary[pieceLayout[space.X, space.Y]], space.GetWorldCoords(),
                                  Quaternion.Euler(0, 0, 0));
            var piece = pieceGo.GetComponent <IPiece>();
            piece.Initialise(space);
            piece.MoveableSpaces = piece.MovementRules.GetLegalMoves(board, piece);
            piece.Rotation       = (space.Y % 2 == 0)? Rotation.West : Rotation.East;
        } catch {
            Debug.Log("Did not find any piece at " + space.X + ", " + space.Y);
        }

        return(pieceGo);
    }