mirror of
https://github.com/p08dev/Tetrys.git
synced 2026-06-19 13:13:50 +02:00
Added Tetris functionality
This commit is contained in:
25
Assets/Scripts/Spawner.cs
Normal file
25
Assets/Scripts/Spawner.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Spawner : MonoBehaviour
|
||||
{
|
||||
// Array of groups
|
||||
public GameObject[] groups;
|
||||
|
||||
// Constructor (called when game starts)
|
||||
void Start()
|
||||
{
|
||||
// Spawn initial group
|
||||
spawnNext();
|
||||
}
|
||||
|
||||
public void spawnNext()
|
||||
{
|
||||
// Generates random index
|
||||
int i = Random.Range(0, groups.Length);
|
||||
// Spawn group at current spawner position
|
||||
Instantiate(groups[i], transform.position, Quaternion.identity);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user