2021-11-01 01:54:04 -06:00
|
|
|
using UnityEngine;
|
|
|
|
|
2022-10-07 14:54:24 -06:00
|
|
|
public class StartTrigger : MonoBehaviour
|
2021-11-01 01:54:04 -06:00
|
|
|
{
|
2022-10-07 14:54:24 -06:00
|
|
|
private TetrominoSpawnManager tetrominoSpawnManager;
|
2022-10-07 13:18:54 -06:00
|
|
|
private bool gameStarted;
|
2021-11-01 01:54:04 -06:00
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start()
|
|
|
|
{
|
2022-10-07 14:54:24 -06:00
|
|
|
tetrominoSpawnManager = FindObjectOfType<TetrominoSpawnManager>();
|
2021-11-01 01:54:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
private void OnTriggerEnter2D(Collider2D other)
|
|
|
|
{
|
2021-11-01 23:55:30 -06:00
|
|
|
if (other.gameObject.tag == "Player" && !gameStarted)
|
2021-11-01 01:54:04 -06:00
|
|
|
{
|
2021-11-01 23:55:30 -06:00
|
|
|
GetComponent<AudioSource>().Play();
|
2022-10-07 14:54:24 -06:00
|
|
|
tetrominoSpawnManager.spawnTetromino();
|
2021-11-01 23:55:30 -06:00
|
|
|
gameStarted = true;
|
2022-10-07 13:18:54 -06:00
|
|
|
gameObject.SetActive(false);
|
2021-11-01 01:54:04 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|