private const float TILE_SIZE = 1.0f;
private const float TILE_OFFSET = 0.5f;
private int selectionX = -1;
private int selectionY = -1;
private void Update(){
PapanCatur ();
UpdateSelection ();
}
private void UpdateSelection ()
{
if (!Camera.main)
return;
RaycastHit hit;
if (Physics.Raycast (Camera.main.ScreenPointToRay (Input.mousePosition), out hit, 25.0f, LayerMask.GetMask ("ChekersPlane"))) {
selectionX = (int)hit.point.x;
selectionY = (int)hit.point.z;
} else {
selectionX = -1;
selectionY = -1;
}
}
private void PapanCatur(){
Vector3 widthLine = Vector3.right * 8;
Vector3 heightline = Vector3.forward * 8;
for(int i = 0; i<=8; i++){
//debug.drawline cant display in game unity
Vector3 start = Vector3.forward * i;
Debug.DrawLine (start, start + widthLine,Color.yellow,0.0f, true);
for (int j = 0; j <= 8; j++) {
start = Vector3.right * j;
Debug.DrawLine (start, start + heightline,Color.yellow,0.0f,true);
}
}
//draw the selection
if (selectionX >= 0 && selectionY >= 0) {
Debug.DrawLine (
Vector3.forward * selectionY + Vector3.right * selectionX,
Vector3.forward * (selectionY + 1) + Vector3.right * (selectionX + 1));
Debug.DrawLine (
Vector3.forward * (selectionY + 1 ) +Vector3.right * selectionX,
Vector3.forward * selectionY + Vector3.right * (selectionX + 1));
}
}
}