52 lines
1.5 KiB
C#
52 lines
1.5 KiB
C#
using UnityEngine;
|
|
using Random = UnityEngine.Random;
|
|
|
|
public class tetrominoSpawnManager : MonoBehaviour
|
|
{
|
|
public Vector3 spawnPoint;
|
|
public GameObject tetrominoSquare;
|
|
public GameObject tetrominoLine;
|
|
public GameObject tetrominoL;
|
|
public GameObject tetrominoR;
|
|
public GameObject tetrominoS;
|
|
public GameObject tetrominoT;
|
|
public GameObject tetrominoZ;
|
|
|
|
private int nextTetromino = 0;
|
|
private GameObject nextTetrominoObject;
|
|
|
|
public void spawnTetromino()
|
|
{
|
|
nextTetromino = Random.Range(1, 7);
|
|
switch (nextTetromino)
|
|
{
|
|
case 0: //Square
|
|
nextTetrominoObject = tetrominoSquare;
|
|
break;
|
|
case 1: //Line
|
|
nextTetrominoObject = tetrominoLine;
|
|
break;
|
|
case 2: //T-piece
|
|
nextTetrominoObject = tetrominoT;
|
|
break;
|
|
case 3: //L-piece
|
|
nextTetrominoObject = tetrominoL;
|
|
break;
|
|
case 4: //R-piece
|
|
nextTetrominoObject = tetrominoR;
|
|
break;
|
|
case 5: //S-piece
|
|
nextTetrominoObject = tetrominoS;
|
|
break;
|
|
case 6: //Z-piece
|
|
nextTetrominoObject = tetrominoZ;
|
|
break;
|
|
default: //if it's not a piece I have a prefab for yet, default to square
|
|
nextTetrominoObject = tetrominoSquare;
|
|
break;
|
|
}
|
|
|
|
Instantiate(nextTetrominoObject, spawnPoint, Quaternion.identity);
|
|
|
|
}
|
|
}
|