2021-10-07 13:56:22 -06:00
|
|
|
using System;
|
2021-10-01 15:30:01 -06:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
2021-10-07 13:56:22 -06:00
|
|
|
using Random = UnityEngine.Random;
|
2021-10-01 15:30:01 -06:00
|
|
|
|
|
|
|
public class tetrisManager : MonoBehaviour
|
|
|
|
{
|
|
|
|
public Vector3 spawnPoint;
|
|
|
|
public GameObject tetrominoSquare;
|
2021-10-07 13:56:22 -06:00
|
|
|
public GameObject tetrominoLine;
|
|
|
|
public GameObject tetrominoL;
|
|
|
|
public GameObject tetrominoR;
|
|
|
|
public GameObject tetrominoS;
|
|
|
|
public GameObject tetrominoT;
|
|
|
|
|
|
|
|
private int nextTetromino = 0;
|
2021-10-01 15:30:01 -06:00
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start()
|
|
|
|
{
|
2021-10-07 13:56:22 -06:00
|
|
|
|
2021-10-01 15:30:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
void Update()
|
|
|
|
{
|
2021-10-07 13:56:22 -06:00
|
|
|
//DEBUG: Spawn a new tetromino on click.
|
2021-10-01 15:30:01 -06:00
|
|
|
if (Input.GetMouseButtonDown(0))
|
|
|
|
{
|
|
|
|
spawnTetromino();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void spawnTetromino()
|
|
|
|
{
|
2021-10-07 13:56:22 -06:00
|
|
|
nextTetromino = Random.Range(1, 6);
|
|
|
|
switch (nextTetromino)
|
|
|
|
{
|
|
|
|
case 0: //Square
|
|
|
|
Instantiate(tetrominoSquare, spawnPoint, Quaternion.identity);
|
|
|
|
break;
|
|
|
|
case 1: //Line
|
|
|
|
Instantiate(tetrominoLine, spawnPoint, Quaternion.identity);
|
|
|
|
break;
|
|
|
|
case 2: //T-piece
|
|
|
|
Instantiate(tetrominoT, spawnPoint, Quaternion.identity);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Instantiate(tetrominoSquare, spawnPoint, Quaternion.identity);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-10-01 15:30:01 -06:00
|
|
|
}
|
|
|
|
}
|