using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DummyCubeSpawn : MonoBehaviour
{
    float timeUntil_difficulty = 0.1f;
    public float difficulty = 0.015f;

    bool gameOver;
    float gameTime;
    float timeUntilNextCube;

    StillHaveCubes cubecount;

    // Start is called before the first frame update
    void Start()
    {
        gameOver = false;
        cubecount = (StillHaveCubes)FindObjectOfType(typeof(StillHaveCubes));
        gameTime = 0;
        SpawnACube();
        timeUntilNextCube = 5;
    }

    // Update is called once per frame
    void Update()
    {
        timeUntilNextCube -= Time.deltaTime;

        if (timeUntilNextCube < 0)
        {
            SpawnACube();
            timeUntilNextCube = 4.5f + Random.value;
        }
    }

    void SpawnACube()
    {
        if (gameOver) return;
        Instantiate(Resources.Load("Cube"), new Vector3(Random.Range(-3.5f, 3.5f), 15, Random.Range(-3.5f, 3.5f)), Quaternion.identity);
    }

    public virtual void OnTriggerEnter(Collider other)
    {
        Destroy(other.gameObject);
    }
}