#pragma strict

var rowIDs : int[];
var gridSizeX : float = 2.0f;

function SetInitialValues(end : int) {
	var count : int = end - 8;

	for (var i=0; i < 7; i++) {
		rowIDs[i] = count;
		count++; 	
	}
}

function ShiftLeft() {
	var elementOne = rowIDs[0];
	for (var i=0; i < 6; i++) {
		rowIDs[i] = rowIDs[i+1];
	}
	rowIDs[rowIDs.Length-1] = elementOne;
	UpdateBlocks();
}

function ShiftRight() {
	var elementLast = rowIDs[rowIDs.Length-1];
	for (var i = 5; i >= 0; i=i-1) {
		rowIDs[i+1] = rowIDs[i];
	}
	rowIDs[0] = elementLast;
	UpdateBlocks();
}

function UpdateBlocks() {
	var x : float = GameObject.Find("LevelBase").transform.position.x;

	var thisblock : int;
	for (var i = 0; i < rowIDs.Length; i++) {
		thisblock = rowIDs[i] + 1;
		GameObject.Find("tile"+thisblock).transform.position.x = x;
		x = x + gridSizeX;
	}
}