Can someone fix this cript?

can someone fix this script :

using UnityEngine;
using System.Collections;

public class GameManager : MonoBehaviour {

	public GameObject CubeDark;
	public GameObject CubeLight;
	public GameObject[] PiecesGO = new GameObject[6];
	public int gameState = 0;			// In this state, the code is waiting for : 0 = Piece selection, 1 = Piece animation, 2 = Player2/AI movement
	//private int activePlayer = 0;		// 0 = Player1, 1 = Player2, 2 = AI, to be used later
	private GameObject SelectedPiece;	// Selected Piece
	private int _boardHeight = -1;
	private int _pieceHeight =  0;
	private static int _boardSize = 7;
	private int[,] _boardPieces = new int[_boardSize,_boardSize];

	// Initialize the board area
	void Start()
	{
		CreateBoard();
		AddPieces();
	}
	
	// Create the board by placing cubes
	void CreateBoard()
	{
		
		
		for(int i = 0; i < _boardSize; i++)
		{
			for(int j = 0; j < _boardSize; j++)
			{
				if((i+j)%2 == 0)
				{
					Object.Instantiate(CubeDark,new Vector3(i,_boardHeight,j), Quaternion.identity);	
				}
				else
				{
					Object.Instantiate(CubeLight,new Vector3(i,_boardHeight,j), Quaternion.identity);
				}
			}
		}
	}

	// Add all pieces are their respective position
	void AddPieces()
	{
		int _linePosY;
		int _piecePlayer;
		
		// Create all pawn at once
		for(int i = 0; i < _boardSize; i++)
		
		// Create Down pieces
		_linePosY = 0;
		_piecePlayer = 1;
		CreatePiece("Pawn"  , 0, _linePosY, _piecePlayer);
		CreatePiece("Pawn", 1, _linePosY, _piecePlayer);
		CreatePiece("Pawn", 5, _linePosY, _piecePlayer);
		CreatePiece("Pawn" , 6, _linePosY, _piecePlayer);
		
		// Create Up pieces
		_linePosY = 6;
		_piecePlayer = -1;
		CreatePiece("Pawn"  , 0, _linePosY, _piecePlayer);
		CreatePiece("Pawn", 1, _linePosY, _piecePlayer);
		CreatePiece("Pawn", 5, _linePosY, _piecePlayer);
		CreatePiece("Pawn" , 5, _linePosY, _piecePlayer);

		// Creat Second Line Pieces
		_linePosY = 1;
		_piecePlayer = 1;
		CreatePiece("Pawn"  , 0, _linePosY, _piecePlayer);
		CreatePiece("Pawn", 6, _linePosY, _piecePlayer);

		// Creat Second Line Pieces
		_linePosY = 5;
		_piecePlayer = 1;
		CreatePiece("Pawn"  , 0, _linePosY, _piecePlayer);
		CreatePiece("Pawn", 6, _linePosY, _piecePlayer);
	}
	
	// Spawn a piece on the board
	void CreatePiece(string _pieceName, int _posX, int _posY, int _playerTag)
	{
				GameObject _PieceToCreate = null;
				int _pieceIndex = 0;
				//Select the right prefab to instantiate
				switch (_pieceName) 
		{
				case "Pawn": 
						_pieceIndex = 1;
						break;
				}
				_PieceToCreate = PiecesGO [_pieceIndex - 1];
				// Instantiate the piece as a GameObject to be able to modify it after
				_PieceToCreate = Object.Instantiate (_PieceToCreate, new Vector3 (_posX, _pieceHeight, _posY), Quaternion.identity) as GameObject;
				_PieceToCreate.name = _pieceName;
		}
	//Update SlectedPiece with the GameObject inputted to this function
	public void SelectPiece(GameObject _PieceToSelect)
	{
		// Unselect the piece if it was already selected
		if(_PieceToSelect  == SelectedPiece)
		{
			SelectedPiece.renderer.material.color = Color.white;
			SelectedPiece = null;
			ChangeState (0);
		}
		else
		{
			// Change color of the selected piece to make it apparent. Put it back to white when the piece is unselected
			if(SelectedPiece)
			{
				SelectedPiece.renderer.material.color = Color.white;
			}
			SelectedPiece = _PieceToSelect;
			SelectedPiece.renderer.material.color = Color.blue;
			ChangeState (1);
		}
	}
	
	// Move the SelectedPiece to the inputted coords
	public void MovePiece(Vector2 _coordToMove)
	{
		bool validMovementBool = false;
		Vector2 _coordPiece = new Vector2(SelectedPiece.transform.position.x, SelectedPiece.transform.position.z);
		
		// Don't move if the user clicked on its own cube or if there is a piece on the cube
		if((_coordToMove.x != _coordPiece.x || _coordToMove.y != _coordPiece.y) || _boardPieces[(int)_coordToMove.x,(int)_coordToMove.y] != 0)
		{
			validMovementBool	= TestMovement (SelectedPiece, _coordToMove);
		}
		
		if(validMovementBool)
		{
			_boardPieces[(int)_coordToMove.x, (int)_coordToMove.y] = _boardPieces[(int)_coordPiece.x, (int)_coordPiece.y];
			_boardPieces[(int)_coordPiece.x , (int)_coordPiece.y ] = 0;
			
			SelectedPiece.transform.position = new Vector3(_coordToMove.x, _pieceHeight, _coordToMove.y);		// Move the piece
			SelectedPiece.renderer.material.color = Color.white;	// Change it's color back
			SelectedPiece = null;									// Unselect the Piece
		}
	}

	// Test if the piece can do the player's movement
	bool TestMovement(GameObject _SelectedPiece, Vector2 _coordToMove)
	{
		bool _movementLegalBool = false;
		bool _collisionDetectBool = false;
		Vector2 _coordPiece = new Vector2(_SelectedPiece.transform.localPosition.x, _SelectedPiece.transform.localPosition.z);
		
		int _deltaX = (int)(_coordToMove.x - _coordPiece.x);
		int _deltaY = (int)(_coordToMove.y - _coordPiece.y);
		int activePlayerPawnPostion = 1;
		//Debug.Log("Piece (" + _coordPiece.x + "," + _coordPiece.x + ") - Move (" + _coordToMove.x + "," + _coordToMove.y + ")");
		//Debug.Log("Delta (" + _deltaX + "," + _deltaY + ")");
		// Use the name of the _SelectedPiece GameObject to find the piece used
		switch (_SelectedPiece.name)
		{

		case "Pawn":
			// Rook can move horizontally or vertically
			if((_deltaX != 0 && _deltaY == 0) || (_deltaX == 0 && _deltaY != 0)) 
			{
				_movementLegalBool = true;
			}
			break;
			
		default:
			_movementLegalBool = false;
			break;
		}
		
		// If the movement is legal, detect collision with piece in the way. Don't do it with knight since they can pass over pieces.
		if(_movementLegalBool && SelectedPiece.name != "Knight")
		{
			_collisionDetectBool = TestCollision (_coordPiece, _coordToMove);
		}
		
		return (_movementLegalBool && !_collisionDetectBool);
	}

	// Test if a unit is in the path of the tested movement
	bool TestCollision(Vector2 _coordInitial,Vector2 _coordFinal)
	{
		bool CollisionBool = false;
		int _deltaX = (int)(_coordFinal.x - _coordInitial.x);
		int _deltaY = (int)(_coordFinal.y - _coordInitial.y);
		int _incX = 0; // Direction of the incrementation in X
		int _incY = 0; // Direction of the incrementation in Y
		int i;
		int j;
		
		// Calculate the increment if _deltaX/Y is different from 0 to avoid division by 0
		if(_deltaX != 0)
		{
			_incX = (_deltaX/Mathf.Abs(_deltaX));
		}
		if(_deltaY != 0)
		{
			_incY = (_deltaY/Mathf.Abs(_deltaY));
		}
		
		i = (int)_coordInitial.x + _incX;
		j = (int)_coordInitial.y + _incY;
		
		while(new Vector2(i, j) != _coordFinal)
		{
			
			if(_boardPieces[i,j] != 0)
			{
				CollisionBool = true;
				break;
			}
			
			i += _incX;
			j += _incY;
		}
		Debug.Log (CollisionBool);
		return CollisionBool;
	}
	// Change the state of the game
	public void ChangeState(int _newState)
	{
		gameState = _newState;
		Debug.Log ("GameState = " + _newState);
	}
}

i only edit it not make it… but i get it not working, the error is :
Assets/Script/GameManager.cs(57,42): error CS0165: Use of unassigned local variable `_linePosY’
i don’t know how to fix it
should i attach my project?

thanks before

You need to add a { after the for, and a } at the end of the function. Right now, _linePosY is inside inside the loop.