void SpawnShape()
{
// int shape = Random.Range(0, 6); //Rand shape
int shape = shapeQueue.Dequeue();
shapeQueue.Enqueue(Random.Range(0, 6));
int height = (int)transform.position.y + QPreview.GetLength(1) - 4;
int xPos = (int)transform.position.x + QPreview.GetLength(0) / 2 - 1;
//Create pivot
pivot = new GameObject("RotateAround"); //Pivot of shape
if (shape == 0)
{ //S Shape
SetCubePositions(new Vector3(xPos, height + 1, 0),
new Vector3(xPos, height, 0),
new Vector3(xPos - 1, height, 0),
new Vector3(xPos, height + 1, 0),
new Vector3(xPos + 1, height + 1, 0));
}
else if (shape == 1)
{ //I Shape
SetCubePositions(new Vector3(xPos + 0.5f, height + 1.5f, 0),
new Vector3(xPos, height, 0),
new Vector3(xPos, height + 1, 0),
new Vector3(xPos, height + 2, 0),
new Vector3(xPos, height + 3, 0));
}
else if (shape == 2)
{ //O Shape
SetCubePositions(new Vector3(xPos + 0.5f, height + 0.5f, 0),
new Vector3(xPos, height, 0),
new Vector3(xPos + 1, height, 0),
new Vector3(xPos, height + 1, 0),
new Vector3(xPos + 1, height + 1, 0));
}
else if (shape == 3)
{ //J Shape
SetCubePositions(new Vector3(xPos, height + 1, 0),
new Vector3(xPos, height, 0),
new Vector3(xPos + 1, height, 0),
new Vector3(xPos, height + 1, 0),
new Vector3(xPos, height + 2, 0));
}
else if (shape == 4)
{ //T Shape
SetCubePositions(new Vector3(xPos, height, 0),
new Vector3(xPos, height, 0),
new Vector3(xPos - 1, height, 0),
new Vector3(xPos + 1, height, 0),
new Vector3(xPos, height + 1, 0));
}
else if (shape == 5)
{ //L Shape
SetCubePositions(new Vector3(xPos, height + 1, 0),
new Vector3(xPos, height, 0),
new Vector3(xPos - 1, height, 0),
new Vector3(xPos, height + 1, 0),
new Vector3(xPos, height + 2, 0));
}
else if (shape == 6)
{ //Z Shape
SetCubePositions(new Vector3(xPos, height + 1, 0),
new Vector3(xPos, height, 0),
new Vector3(xPos + 1, height, 0),
new Vector3(xPos, height + 1, 0),
new Vector3(xPos - 1, height + 1, 0));
}
else
{
Debug.Log("Illegal shape code: " + shape);
}
}